babylon.d.ts 2.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. /**
  1239. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1240. * @param x defines the first coordinates (on X axis)
  1241. * @param y defines the second coordinates (on Y axis)
  1242. * @param z defines the third coordinates (on Z axis)
  1243. */
  1244. constructor(
  1245. /**
  1246. * Defines the first coordinates (on X axis)
  1247. */
  1248. x?: number,
  1249. /**
  1250. * Defines the second coordinates (on Y axis)
  1251. */
  1252. y?: number,
  1253. /**
  1254. * Defines the third coordinates (on Z axis)
  1255. */
  1256. z?: number);
  1257. /**
  1258. * Creates a string representation of the Vector3
  1259. * @returns a string with the Vector3 coordinates.
  1260. */
  1261. toString(): string;
  1262. /**
  1263. * Gets the class name
  1264. * @returns the string "Vector3"
  1265. */
  1266. getClassName(): string;
  1267. /**
  1268. * Creates the Vector3 hash code
  1269. * @returns a number which tends to be unique between Vector3 instances
  1270. */
  1271. getHashCode(): number;
  1272. /**
  1273. * Creates an array containing three elements : the coordinates of the Vector3
  1274. * @returns a new array of numbers
  1275. */
  1276. asArray(): number[];
  1277. /**
  1278. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1279. * @param array defines the destination array
  1280. * @param index defines the offset in the destination array
  1281. * @returns the current Vector3
  1282. */
  1283. toArray(array: FloatArray, index?: number): Vector3;
  1284. /**
  1285. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1286. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1287. */
  1288. toQuaternion(): Quaternion;
  1289. /**
  1290. * Adds the given vector to the current Vector3
  1291. * @param otherVector defines the second operand
  1292. * @returns the current updated Vector3
  1293. */
  1294. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1295. /**
  1296. * Adds the given coordinates to the current Vector3
  1297. * @param x defines the x coordinate of the operand
  1298. * @param y defines the y coordinate of the operand
  1299. * @param z defines the z coordinate of the operand
  1300. * @returns the current updated Vector3
  1301. */
  1302. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1303. /**
  1304. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1305. * @param otherVector defines the second operand
  1306. * @returns the resulting Vector3
  1307. */
  1308. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1309. /**
  1310. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1311. * @param otherVector defines the second operand
  1312. * @param result defines the Vector3 object where to store the result
  1313. * @returns the current Vector3
  1314. */
  1315. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1316. /**
  1317. * Subtract the given vector from the current Vector3
  1318. * @param otherVector defines the second operand
  1319. * @returns the current updated Vector3
  1320. */
  1321. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1322. /**
  1323. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1324. * @param otherVector defines the second operand
  1325. * @returns the resulting Vector3
  1326. */
  1327. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1328. /**
  1329. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1330. * @param otherVector defines the second operand
  1331. * @param result defines the Vector3 object where to store the result
  1332. * @returns the current Vector3
  1333. */
  1334. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1335. /**
  1336. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1337. * @param x defines the x coordinate of the operand
  1338. * @param y defines the y coordinate of the operand
  1339. * @param z defines the z coordinate of the operand
  1340. * @returns the resulting Vector3
  1341. */
  1342. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1343. /**
  1344. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1345. * @param x defines the x coordinate of the operand
  1346. * @param y defines the y coordinate of the operand
  1347. * @param z defines the z coordinate of the operand
  1348. * @param result defines the Vector3 object where to store the result
  1349. * @returns the current Vector3
  1350. */
  1351. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1352. /**
  1353. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1354. * @returns a new Vector3
  1355. */
  1356. negate(): Vector3;
  1357. /**
  1358. * Multiplies the Vector3 coordinates by the float "scale"
  1359. * @param scale defines the multiplier factor
  1360. * @returns the current updated Vector3
  1361. */
  1362. scaleInPlace(scale: number): Vector3;
  1363. /**
  1364. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1365. * @param scale defines the multiplier factor
  1366. * @returns a new Vector3
  1367. */
  1368. scale(scale: number): Vector3;
  1369. /**
  1370. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1371. * @param scale defines the multiplier factor
  1372. * @param result defines the Vector3 object where to store the result
  1373. * @returns the current Vector3
  1374. */
  1375. scaleToRef(scale: number, result: Vector3): Vector3;
  1376. /**
  1377. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1378. * @param scale defines the scale factor
  1379. * @param result defines the Vector3 object where to store the result
  1380. * @returns the unmodified current Vector3
  1381. */
  1382. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1383. /**
  1384. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1385. * @param otherVector defines the second operand
  1386. * @returns true if both vectors are equals
  1387. */
  1388. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1389. /**
  1390. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1391. * @param otherVector defines the second operand
  1392. * @param epsilon defines the minimal distance to define values as equals
  1393. * @returns true if both vectors are distant less than epsilon
  1394. */
  1395. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1396. /**
  1397. * Returns true if the current Vector3 coordinates equals the given floats
  1398. * @param x defines the x coordinate of the operand
  1399. * @param y defines the y coordinate of the operand
  1400. * @param z defines the z coordinate of the operand
  1401. * @returns true if both vectors are equals
  1402. */
  1403. equalsToFloats(x: number, y: number, z: number): boolean;
  1404. /**
  1405. * Multiplies the current Vector3 coordinates by the given ones
  1406. * @param otherVector defines the second operand
  1407. * @returns the current updated Vector3
  1408. */
  1409. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1410. /**
  1411. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1412. * @param otherVector defines the second operand
  1413. * @returns the new Vector3
  1414. */
  1415. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1416. /**
  1417. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1418. * @param otherVector defines the second operand
  1419. * @param result defines the Vector3 object where to store the result
  1420. * @returns the current Vector3
  1421. */
  1422. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1423. /**
  1424. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1425. * @param x defines the x coordinate of the operand
  1426. * @param y defines the y coordinate of the operand
  1427. * @param z defines the z coordinate of the operand
  1428. * @returns the new Vector3
  1429. */
  1430. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1431. /**
  1432. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1433. * @param otherVector defines the second operand
  1434. * @returns the new Vector3
  1435. */
  1436. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1437. /**
  1438. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1439. * @param otherVector defines the second operand
  1440. * @param result defines the Vector3 object where to store the result
  1441. * @returns the current Vector3
  1442. */
  1443. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1444. /**
  1445. * Divides the current Vector3 coordinates by the given ones.
  1446. * @param otherVector defines the second operand
  1447. * @returns the current updated Vector3
  1448. */
  1449. divideInPlace(otherVector: Vector3): Vector3;
  1450. /**
  1451. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1452. * @param other defines the second operand
  1453. * @returns the current updated Vector3
  1454. */
  1455. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1456. /**
  1457. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1458. * @param other defines the second operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1462. /**
  1463. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1464. * @param x defines the x coordinate of the operand
  1465. * @param y defines the y coordinate of the operand
  1466. * @param z defines the z coordinate of the operand
  1467. * @returns the current updated Vector3
  1468. */
  1469. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1470. /**
  1471. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1472. * @param x defines the x coordinate of the operand
  1473. * @param y defines the y coordinate of the operand
  1474. * @param z defines the z coordinate of the operand
  1475. * @returns the current updated Vector3
  1476. */
  1477. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1478. /**
  1479. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1480. * Check if is non uniform within a certain amount of decimal places to account for this
  1481. * @param epsilon the amount the values can differ
  1482. * @returns if the the vector is non uniform to a certain number of decimal places
  1483. */
  1484. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1485. /**
  1486. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1487. */
  1488. readonly isNonUniform: boolean;
  1489. /**
  1490. * Gets a new Vector3 from current Vector3 floored values
  1491. * @returns a new Vector3
  1492. */
  1493. floor(): Vector3;
  1494. /**
  1495. * Gets a new Vector3 from current Vector3 floored values
  1496. * @returns a new Vector3
  1497. */
  1498. fract(): Vector3;
  1499. /**
  1500. * Gets the length of the Vector3
  1501. * @returns the length of the Vecto3
  1502. */
  1503. length(): number;
  1504. /**
  1505. * Gets the squared length of the Vector3
  1506. * @returns squared length of the Vector3
  1507. */
  1508. lengthSquared(): number;
  1509. /**
  1510. * Normalize the current Vector3.
  1511. * Please note that this is an in place operation.
  1512. * @returns the current updated Vector3
  1513. */
  1514. normalize(): Vector3;
  1515. /**
  1516. * Reorders the x y z properties of the vector in place
  1517. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1518. * @returns the current updated vector
  1519. */
  1520. reorderInPlace(order: string): this;
  1521. /**
  1522. * Rotates the vector around 0,0,0 by a quaternion
  1523. * @param quaternion the rotation quaternion
  1524. * @param result vector to store the result
  1525. * @returns the resulting vector
  1526. */
  1527. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1528. /**
  1529. * Rotates a vector around a given point
  1530. * @param quaternion the rotation quaternion
  1531. * @param point the point to rotate around
  1532. * @param result vector to store the result
  1533. * @returns the resulting vector
  1534. */
  1535. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1536. /**
  1537. * Normalize the current Vector3 with the given input length.
  1538. * Please note that this is an in place operation.
  1539. * @param len the length of the vector
  1540. * @returns the current updated Vector3
  1541. */
  1542. normalizeFromLength(len: number): Vector3;
  1543. /**
  1544. * Normalize the current Vector3 to a new vector
  1545. * @returns the new Vector3
  1546. */
  1547. normalizeToNew(): Vector3;
  1548. /**
  1549. * Normalize the current Vector3 to the reference
  1550. * @param reference define the Vector3 to update
  1551. * @returns the updated Vector3
  1552. */
  1553. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1554. /**
  1555. * Creates a new Vector3 copied from the current Vector3
  1556. * @returns the new Vector3
  1557. */
  1558. clone(): Vector3;
  1559. /**
  1560. * Copies the given vector coordinates to the current Vector3 ones
  1561. * @param source defines the source Vector3
  1562. * @returns the current updated Vector3
  1563. */
  1564. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1565. /**
  1566. * Copies the given floats to the current Vector3 coordinates
  1567. * @param x defines the x coordinate of the operand
  1568. * @param y defines the y coordinate of the operand
  1569. * @param z defines the z coordinate of the operand
  1570. * @returns the current updated Vector3
  1571. */
  1572. copyFromFloats(x: number, y: number, z: number): Vector3;
  1573. /**
  1574. * Copies the given floats to the current Vector3 coordinates
  1575. * @param x defines the x coordinate of the operand
  1576. * @param y defines the y coordinate of the operand
  1577. * @param z defines the z coordinate of the operand
  1578. * @returns the current updated Vector3
  1579. */
  1580. set(x: number, y: number, z: number): Vector3;
  1581. /**
  1582. * Copies the given float to the current Vector3 coordinates
  1583. * @param v defines the x, y and z coordinates of the operand
  1584. * @returns the current updated Vector3
  1585. */
  1586. setAll(v: number): Vector3;
  1587. /**
  1588. * Get the clip factor between two vectors
  1589. * @param vector0 defines the first operand
  1590. * @param vector1 defines the second operand
  1591. * @param axis defines the axis to use
  1592. * @param size defines the size along the axis
  1593. * @returns the clip factor
  1594. */
  1595. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1596. /**
  1597. * Get angle between two vectors
  1598. * @param vector0 angle between vector0 and vector1
  1599. * @param vector1 angle between vector0 and vector1
  1600. * @param normal direction of the normal
  1601. * @return the angle between vector0 and vector1
  1602. */
  1603. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1604. /**
  1605. * Returns a new Vector3 set from the index "offset" of the given array
  1606. * @param array defines the source array
  1607. * @param offset defines the offset in the source array
  1608. * @returns the new Vector3
  1609. */
  1610. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1611. /**
  1612. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1613. * This function is deprecated. Use FromArray instead
  1614. * @param array defines the source array
  1615. * @param offset defines the offset in the source array
  1616. * @returns the new Vector3
  1617. */
  1618. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1619. /**
  1620. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1621. * @param array defines the source array
  1622. * @param offset defines the offset in the source array
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1626. /**
  1627. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1628. * This function is deprecated. Use FromArrayToRef instead.
  1629. * @param array defines the source array
  1630. * @param offset defines the offset in the source array
  1631. * @param result defines the Vector3 where to store the result
  1632. */
  1633. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1634. /**
  1635. * Sets the given vector "result" with the given floats.
  1636. * @param x defines the x coordinate of the source
  1637. * @param y defines the y coordinate of the source
  1638. * @param z defines the z coordinate of the source
  1639. * @param result defines the Vector3 where to store the result
  1640. */
  1641. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1642. /**
  1643. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1644. * @returns a new empty Vector3
  1645. */
  1646. static Zero(): Vector3;
  1647. /**
  1648. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1649. * @returns a new unit Vector3
  1650. */
  1651. static One(): Vector3;
  1652. /**
  1653. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1654. * @returns a new up Vector3
  1655. */
  1656. static Up(): Vector3;
  1657. /**
  1658. * Gets a up Vector3 that must not be updated
  1659. */
  1660. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1661. /**
  1662. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1663. * @returns a new down Vector3
  1664. */
  1665. static Down(): Vector3;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1668. * @returns a new forward Vector3
  1669. */
  1670. static Forward(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Backward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1678. * @returns a new right Vector3
  1679. */
  1680. static Right(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1683. * @returns a new left Vector3
  1684. */
  1685. static Left(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1688. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1689. * @param vector defines the Vector3 to transform
  1690. * @param transformation defines the transformation matrix
  1691. * @returns the transformed Vector3
  1692. */
  1693. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1694. /**
  1695. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1696. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @param result defines the Vector3 where to store the result
  1700. */
  1701. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1702. /**
  1703. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1704. * This method computes tranformed coordinates only, not transformed direction vectors
  1705. * @param x define the x coordinate of the source vector
  1706. * @param y define the y coordinate of the source vector
  1707. * @param z define the z coordinate of the source vector
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param vector defines the Vector3 to transform
  1716. * @param transformation defines the transformation matrix
  1717. * @returns the new Vector3
  1718. */
  1719. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1720. /**
  1721. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1722. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1723. * @param vector defines the Vector3 to transform
  1724. * @param transformation defines the transformation matrix
  1725. * @param result defines the Vector3 where to store the result
  1726. */
  1727. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1728. /**
  1729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1730. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1731. * @param x define the x coordinate of the source vector
  1732. * @param y define the y coordinate of the source vector
  1733. * @param z define the z coordinate of the source vector
  1734. * @param transformation defines the transformation matrix
  1735. * @param result defines the Vector3 where to store the result
  1736. */
  1737. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1738. /**
  1739. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1740. * @param value1 defines the first control point
  1741. * @param value2 defines the second control point
  1742. * @param value3 defines the third control point
  1743. * @param value4 defines the fourth control point
  1744. * @param amount defines the amount on the spline to use
  1745. * @returns the new Vector3
  1746. */
  1747. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1748. /**
  1749. * 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"
  1750. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1751. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1752. * @param value defines the current value
  1753. * @param min defines the lower range value
  1754. * @param max defines the upper range value
  1755. * @returns the new Vector3
  1756. */
  1757. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1758. /**
  1759. * 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"
  1760. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1761. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1762. * @param value defines the current value
  1763. * @param min defines the lower range value
  1764. * @param max defines the upper range value
  1765. * @param result defines the Vector3 where to store the result
  1766. */
  1767. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1768. /**
  1769. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1770. * @param value1 defines the first control point
  1771. * @param tangent1 defines the first tangent vector
  1772. * @param value2 defines the second control point
  1773. * @param tangent2 defines the second tangent vector
  1774. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1775. * @returns the new Vector3
  1776. */
  1777. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1778. /**
  1779. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1780. * @param start defines the start value
  1781. * @param end defines the end value
  1782. * @param amount max defines amount between both (between 0 and 1)
  1783. * @returns the new Vector3
  1784. */
  1785. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1786. /**
  1787. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1788. * @param start defines the start value
  1789. * @param end defines the end value
  1790. * @param amount max defines amount between both (between 0 and 1)
  1791. * @param result defines the Vector3 where to store the result
  1792. */
  1793. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1794. /**
  1795. * Returns the dot product (float) between the vectors "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @returns the dot product
  1799. */
  1800. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1801. /**
  1802. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1803. * The cross product is then orthogonal to both "left" and "right"
  1804. * @param left defines the left operand
  1805. * @param right defines the right operand
  1806. * @returns the cross product
  1807. */
  1808. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1809. /**
  1810. * Sets the given vector "result" with the cross product of "left" and "right"
  1811. * The cross product is then orthogonal to both "left" and "right"
  1812. * @param left defines the left operand
  1813. * @param right defines the right operand
  1814. * @param result defines the Vector3 where to store the result
  1815. */
  1816. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1817. /**
  1818. * Returns a new Vector3 as the normalization of the given vector
  1819. * @param vector defines the Vector3 to normalize
  1820. * @returns the new Vector3
  1821. */
  1822. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1823. /**
  1824. * Sets the given vector "result" with the normalization of the given first vector
  1825. * @param vector defines the Vector3 to normalize
  1826. * @param result defines the Vector3 where to store the result
  1827. */
  1828. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1829. /**
  1830. * Project a Vector3 onto screen space
  1831. * @param vector defines the Vector3 to project
  1832. * @param world defines the world matrix to use
  1833. * @param transform defines the transform (view x projection) matrix to use
  1834. * @param viewport defines the screen viewport to use
  1835. * @returns the new Vector3
  1836. */
  1837. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1838. /** @hidden */
  1839. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1840. /**
  1841. * Unproject from screen space to object space
  1842. * @param source defines the screen space Vector3 to use
  1843. * @param viewportWidth defines the current width of the viewport
  1844. * @param viewportHeight defines the current height of the viewport
  1845. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1846. * @param transform defines the transform (view x projection) matrix to use
  1847. * @returns the new Vector3
  1848. */
  1849. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1850. /**
  1851. * Unproject from screen space to object space
  1852. * @param source defines the screen space Vector3 to use
  1853. * @param viewportWidth defines the current width of the viewport
  1854. * @param viewportHeight defines the current height of the viewport
  1855. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1856. * @param view defines the view matrix to use
  1857. * @param projection defines the projection matrix to use
  1858. * @returns the new Vector3
  1859. */
  1860. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1861. /**
  1862. * Unproject from screen space to object space
  1863. * @param source defines the screen space Vector3 to use
  1864. * @param viewportWidth defines the current width of the viewport
  1865. * @param viewportHeight defines the current height of the viewport
  1866. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1867. * @param view defines the view matrix to use
  1868. * @param projection defines the projection matrix to use
  1869. * @param result defines the Vector3 where to store the result
  1870. */
  1871. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1872. /**
  1873. * Unproject from screen space to object space
  1874. * @param sourceX defines the screen space x coordinate to use
  1875. * @param sourceY defines the screen space y coordinate to use
  1876. * @param sourceZ defines the screen space z coordinate to use
  1877. * @param viewportWidth defines the current width of the viewport
  1878. * @param viewportHeight defines the current height of the viewport
  1879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1880. * @param view defines the view matrix to use
  1881. * @param projection defines the projection matrix to use
  1882. * @param result defines the Vector3 where to store the result
  1883. */
  1884. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1885. /**
  1886. * Gets the minimal coordinate values between two Vector3
  1887. * @param left defines the first operand
  1888. * @param right defines the second operand
  1889. * @returns the new Vector3
  1890. */
  1891. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1892. /**
  1893. * Gets the maximal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Returns the distance between the vectors "value1" and "value2"
  1901. * @param value1 defines the first operand
  1902. * @param value2 defines the second operand
  1903. * @returns the distance
  1904. */
  1905. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1906. /**
  1907. * Returns the squared distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the squared distance
  1911. */
  1912. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns a new Vector3 located at the center between "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the new Vector3
  1918. */
  1919. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1920. /**
  1921. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1922. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1923. * to something in order to rotate it from its local system to the given target system
  1924. * Note: axis1, axis2 and axis3 are normalized during this operation
  1925. * @param axis1 defines the first axis
  1926. * @param axis2 defines the second axis
  1927. * @param axis3 defines the third axis
  1928. * @returns a new Vector3
  1929. */
  1930. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1931. /**
  1932. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1933. * @param axis1 defines the first axis
  1934. * @param axis2 defines the second axis
  1935. * @param axis3 defines the third axis
  1936. * @param ref defines the Vector3 where to store the result
  1937. */
  1938. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1939. }
  1940. /**
  1941. * Vector4 class created for EulerAngle class conversion to Quaternion
  1942. */
  1943. export class Vector4 {
  1944. /** x value of the vector */
  1945. x: number;
  1946. /** y value of the vector */
  1947. y: number;
  1948. /** z value of the vector */
  1949. z: number;
  1950. /** w value of the vector */
  1951. w: number;
  1952. /**
  1953. * Creates a Vector4 object from the given floats.
  1954. * @param x x value of the vector
  1955. * @param y y value of the vector
  1956. * @param z z value of the vector
  1957. * @param w w value of the vector
  1958. */
  1959. constructor(
  1960. /** x value of the vector */
  1961. x: number,
  1962. /** y value of the vector */
  1963. y: number,
  1964. /** z value of the vector */
  1965. z: number,
  1966. /** w value of the vector */
  1967. w: number);
  1968. /**
  1969. * Returns the string with the Vector4 coordinates.
  1970. * @returns a string containing all the vector values
  1971. */
  1972. toString(): string;
  1973. /**
  1974. * Returns the string "Vector4".
  1975. * @returns "Vector4"
  1976. */
  1977. getClassName(): string;
  1978. /**
  1979. * Returns the Vector4 hash code.
  1980. * @returns a unique hash code
  1981. */
  1982. getHashCode(): number;
  1983. /**
  1984. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1985. * @returns the resulting array
  1986. */
  1987. asArray(): number[];
  1988. /**
  1989. * Populates the given array from the given index with the Vector4 coordinates.
  1990. * @param array array to populate
  1991. * @param index index of the array to start at (default: 0)
  1992. * @returns the Vector4.
  1993. */
  1994. toArray(array: FloatArray, index?: number): Vector4;
  1995. /**
  1996. * Adds the given vector to the current Vector4.
  1997. * @param otherVector the vector to add
  1998. * @returns the updated Vector4.
  1999. */
  2000. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2003. * @param otherVector the vector to add
  2004. * @returns the resulting vector
  2005. */
  2006. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2009. * @param otherVector the vector to add
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Subtract in place the given vector from the current Vector4.
  2016. * @param otherVector the vector to subtract
  2017. * @returns the updated Vector4.
  2018. */
  2019. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2020. /**
  2021. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2022. * @param otherVector the vector to add
  2023. * @returns the new vector with the result
  2024. */
  2025. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2026. /**
  2027. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2028. * @param otherVector the vector to subtract
  2029. * @param result the vector to store the result
  2030. * @returns the current Vector4.
  2031. */
  2032. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2033. /**
  2034. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2035. */
  2036. /**
  2037. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2038. * @param x value to subtract
  2039. * @param y value to subtract
  2040. * @param z value to subtract
  2041. * @param w value to subtract
  2042. * @returns new vector containing the result
  2043. */
  2044. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2045. /**
  2046. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2047. * @param x value to subtract
  2048. * @param y value to subtract
  2049. * @param z value to subtract
  2050. * @param w value to subtract
  2051. * @param result the vector to store the result in
  2052. * @returns the current Vector4.
  2053. */
  2054. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2055. /**
  2056. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2057. * @returns a new vector with the negated values
  2058. */
  2059. negate(): Vector4;
  2060. /**
  2061. * Multiplies the current Vector4 coordinates by scale (float).
  2062. * @param scale the number to scale with
  2063. * @returns the updated Vector4.
  2064. */
  2065. scaleInPlace(scale: number): Vector4;
  2066. /**
  2067. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2068. * @param scale the number to scale with
  2069. * @returns a new vector with the result
  2070. */
  2071. scale(scale: number): Vector4;
  2072. /**
  2073. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2074. * @param scale the number to scale with
  2075. * @param result a vector to store the result in
  2076. * @returns the current Vector4.
  2077. */
  2078. scaleToRef(scale: number, result: Vector4): Vector4;
  2079. /**
  2080. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2081. * @param scale defines the scale factor
  2082. * @param result defines the Vector4 object where to store the result
  2083. * @returns the unmodified current Vector4
  2084. */
  2085. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2088. * @param otherVector the vector to compare against
  2089. * @returns true if they are equal
  2090. */
  2091. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2092. /**
  2093. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2094. * @param otherVector vector to compare against
  2095. * @param epsilon (Default: very small number)
  2096. * @returns true if they are equal
  2097. */
  2098. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2099. /**
  2100. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2101. * @param x x value to compare against
  2102. * @param y y value to compare against
  2103. * @param z z value to compare against
  2104. * @param w w value to compare against
  2105. * @returns true if equal
  2106. */
  2107. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2108. /**
  2109. * Multiplies in place the current Vector4 by the given one.
  2110. * @param otherVector vector to multiple with
  2111. * @returns the updated Vector4.
  2112. */
  2113. multiplyInPlace(otherVector: Vector4): Vector4;
  2114. /**
  2115. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2116. * @param otherVector vector to multiple with
  2117. * @returns resulting new vector
  2118. */
  2119. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2120. /**
  2121. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2122. * @param otherVector vector to multiple with
  2123. * @param result vector to store the result
  2124. * @returns the current Vector4.
  2125. */
  2126. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2127. /**
  2128. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2129. * @param x x value multiply with
  2130. * @param y y value multiply with
  2131. * @param z z value multiply with
  2132. * @param w w value multiply with
  2133. * @returns resulting new vector
  2134. */
  2135. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2136. /**
  2137. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2138. * @param otherVector vector to devide with
  2139. * @returns resulting new vector
  2140. */
  2141. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2144. * @param otherVector vector to devide with
  2145. * @param result vector to store the result
  2146. * @returns the current Vector4.
  2147. */
  2148. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2149. /**
  2150. * Divides the current Vector3 coordinates by the given ones.
  2151. * @param otherVector vector to devide with
  2152. * @returns the updated Vector3.
  2153. */
  2154. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2155. /**
  2156. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2157. * @param other defines the second operand
  2158. * @returns the current updated Vector4
  2159. */
  2160. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2161. /**
  2162. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2163. * @param other defines the second operand
  2164. * @returns the current updated Vector4
  2165. */
  2166. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2167. /**
  2168. * Gets a new Vector4 from current Vector4 floored values
  2169. * @returns a new Vector4
  2170. */
  2171. floor(): Vector4;
  2172. /**
  2173. * Gets a new Vector4 from current Vector3 floored values
  2174. * @returns a new Vector4
  2175. */
  2176. fract(): Vector4;
  2177. /**
  2178. * Returns the Vector4 length (float).
  2179. * @returns the length
  2180. */
  2181. length(): number;
  2182. /**
  2183. * Returns the Vector4 squared length (float).
  2184. * @returns the length squared
  2185. */
  2186. lengthSquared(): number;
  2187. /**
  2188. * Normalizes in place the Vector4.
  2189. * @returns the updated Vector4.
  2190. */
  2191. normalize(): Vector4;
  2192. /**
  2193. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2194. * @returns this converted to a new vector3
  2195. */
  2196. toVector3(): Vector3;
  2197. /**
  2198. * Returns a new Vector4 copied from the current one.
  2199. * @returns the new cloned vector
  2200. */
  2201. clone(): Vector4;
  2202. /**
  2203. * Updates the current Vector4 with the given one coordinates.
  2204. * @param source the source vector to copy from
  2205. * @returns the updated Vector4.
  2206. */
  2207. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2208. /**
  2209. * Updates the current Vector4 coordinates with the given floats.
  2210. * @param x float to copy from
  2211. * @param y float to copy from
  2212. * @param z float to copy from
  2213. * @param w float to copy from
  2214. * @returns the updated Vector4.
  2215. */
  2216. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2217. /**
  2218. * Updates the current Vector4 coordinates with the given floats.
  2219. * @param x float to set from
  2220. * @param y float to set from
  2221. * @param z float to set from
  2222. * @param w float to set from
  2223. * @returns the updated Vector4.
  2224. */
  2225. set(x: number, y: number, z: number, w: number): Vector4;
  2226. /**
  2227. * Copies the given float to the current Vector3 coordinates
  2228. * @param v defines the x, y, z and w coordinates of the operand
  2229. * @returns the current updated Vector3
  2230. */
  2231. setAll(v: number): Vector4;
  2232. /**
  2233. * Returns a new Vector4 set from the starting index of the given array.
  2234. * @param array the array to pull values from
  2235. * @param offset the offset into the array to start at
  2236. * @returns the new vector
  2237. */
  2238. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2239. /**
  2240. * Updates the given vector "result" from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @param result the vector to store the result in
  2244. */
  2245. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given Float32Array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" coordinates from the given floats.
  2255. * @param x float to set from
  2256. * @param y float to set from
  2257. * @param z float to set from
  2258. * @param w float to set from
  2259. * @param result the vector to the floats in
  2260. */
  2261. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2262. /**
  2263. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2264. * @returns the new vector
  2265. */
  2266. static Zero(): Vector4;
  2267. /**
  2268. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2269. * @returns the new vector
  2270. */
  2271. static One(): Vector4;
  2272. /**
  2273. * Returns a new normalized Vector4 from the given one.
  2274. * @param vector the vector to normalize
  2275. * @returns the vector
  2276. */
  2277. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2278. /**
  2279. * Updates the given vector "result" from the normalization of the given one.
  2280. * @param vector the vector to normalize
  2281. * @param result the vector to store the result in
  2282. */
  2283. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2284. /**
  2285. * Returns a vector with the minimum values from the left and right vectors
  2286. * @param left left vector to minimize
  2287. * @param right right vector to minimize
  2288. * @returns a new vector with the minimum of the left and right vector values
  2289. */
  2290. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2291. /**
  2292. * Returns a vector with the maximum values from the left and right vectors
  2293. * @param left left vector to maximize
  2294. * @param right right vector to maximize
  2295. * @returns a new vector with the maximum of the left and right vector values
  2296. */
  2297. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns the distance (float) between the vectors "value1" and "value2".
  2300. * @param value1 value to calulate the distance between
  2301. * @param value2 value to calulate the distance between
  2302. * @return the distance between the two vectors
  2303. */
  2304. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2305. /**
  2306. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors squared
  2310. */
  2311. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the center between
  2315. * @param value2 value to calulate the center between
  2316. * @return the center between the two vectors
  2317. */
  2318. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2319. /**
  2320. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param vector the vector to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @returns the new vector
  2325. */
  2326. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2327. /**
  2328. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2329. * This methods computes transformed normalized direction vectors only.
  2330. * @param vector the vector to transform
  2331. * @param transformation the transformation matrix to apply
  2332. * @param result the vector to store the result in
  2333. */
  2334. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2335. /**
  2336. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2337. * This methods computes transformed normalized direction vectors only.
  2338. * @param x value to transform
  2339. * @param y value to transform
  2340. * @param z value to transform
  2341. * @param w value to transform
  2342. * @param transformation the transformation matrix to apply
  2343. * @param result the vector to store the results in
  2344. */
  2345. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2346. /**
  2347. * Creates a new Vector4 from a Vector3
  2348. * @param source defines the source data
  2349. * @param w defines the 4th component (default is 0)
  2350. * @returns a new Vector4
  2351. */
  2352. static FromVector3(source: Vector3, w?: number): Vector4;
  2353. }
  2354. /**
  2355. * Interface for the size containing width and height
  2356. */
  2357. export interface ISize {
  2358. /**
  2359. * Width
  2360. */
  2361. width: number;
  2362. /**
  2363. * Heighht
  2364. */
  2365. height: number;
  2366. }
  2367. /**
  2368. * Size containing widht and height
  2369. */
  2370. export class Size implements ISize {
  2371. /**
  2372. * Width
  2373. */
  2374. width: number;
  2375. /**
  2376. * Height
  2377. */
  2378. height: number;
  2379. /**
  2380. * Creates a Size object from the given width and height (floats).
  2381. * @param width width of the new size
  2382. * @param height height of the new size
  2383. */
  2384. constructor(width: number, height: number);
  2385. /**
  2386. * Returns a string with the Size width and height
  2387. * @returns a string with the Size width and height
  2388. */
  2389. toString(): string;
  2390. /**
  2391. * "Size"
  2392. * @returns the string "Size"
  2393. */
  2394. getClassName(): string;
  2395. /**
  2396. * Returns the Size hash code.
  2397. * @returns a hash code for a unique width and height
  2398. */
  2399. getHashCode(): number;
  2400. /**
  2401. * Updates the current size from the given one.
  2402. * @param src the given size
  2403. */
  2404. copyFrom(src: Size): void;
  2405. /**
  2406. * Updates in place the current Size from the given floats.
  2407. * @param width width of the new size
  2408. * @param height height of the new size
  2409. * @returns the updated Size.
  2410. */
  2411. copyFromFloats(width: number, height: number): Size;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width to set
  2415. * @param height height to set
  2416. * @returns the updated Size.
  2417. */
  2418. set(width: number, height: number): Size;
  2419. /**
  2420. * Multiplies the width and height by numbers
  2421. * @param w factor to multiple the width by
  2422. * @param h factor to multiple the height by
  2423. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2424. */
  2425. multiplyByFloats(w: number, h: number): Size;
  2426. /**
  2427. * Clones the size
  2428. * @returns a new Size copied from the given one.
  2429. */
  2430. clone(): Size;
  2431. /**
  2432. * True if the current Size and the given one width and height are strictly equal.
  2433. * @param other the other size to compare against
  2434. * @returns True if the current Size and the given one width and height are strictly equal.
  2435. */
  2436. equals(other: Size): boolean;
  2437. /**
  2438. * The surface of the Size : width * height (float).
  2439. */
  2440. readonly surface: number;
  2441. /**
  2442. * Create a new size of zero
  2443. * @returns a new Size set to (0.0, 0.0)
  2444. */
  2445. static Zero(): Size;
  2446. /**
  2447. * Sums the width and height of two sizes
  2448. * @param otherSize size to add to this size
  2449. * @returns a new Size set as the addition result of the current Size and the given one.
  2450. */
  2451. add(otherSize: Size): Size;
  2452. /**
  2453. * Subtracts the width and height of two
  2454. * @param otherSize size to subtract to this size
  2455. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2456. */
  2457. subtract(otherSize: Size): Size;
  2458. /**
  2459. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2460. * @param start starting size to lerp between
  2461. * @param end end size to lerp between
  2462. * @param amount amount to lerp between the start and end values
  2463. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2464. */
  2465. static Lerp(start: Size, end: Size, amount: number): Size;
  2466. }
  2467. /**
  2468. * Class used to store quaternion data
  2469. * @see https://en.wikipedia.org/wiki/Quaternion
  2470. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2471. */
  2472. export class Quaternion {
  2473. /** defines the first component (0 by default) */
  2474. x: number;
  2475. /** defines the second component (0 by default) */
  2476. y: number;
  2477. /** defines the third component (0 by default) */
  2478. z: number;
  2479. /** defines the fourth component (1.0 by default) */
  2480. w: number;
  2481. /**
  2482. * Creates a new Quaternion from the given floats
  2483. * @param x defines the first component (0 by default)
  2484. * @param y defines the second component (0 by default)
  2485. * @param z defines the third component (0 by default)
  2486. * @param w defines the fourth component (1.0 by default)
  2487. */
  2488. constructor(
  2489. /** defines the first component (0 by default) */
  2490. x?: number,
  2491. /** defines the second component (0 by default) */
  2492. y?: number,
  2493. /** defines the third component (0 by default) */
  2494. z?: number,
  2495. /** defines the fourth component (1.0 by default) */
  2496. w?: number);
  2497. /**
  2498. * Gets a string representation for the current quaternion
  2499. * @returns a string with the Quaternion coordinates
  2500. */
  2501. toString(): string;
  2502. /**
  2503. * Gets the class name of the quaternion
  2504. * @returns the string "Quaternion"
  2505. */
  2506. getClassName(): string;
  2507. /**
  2508. * Gets a hash code for this quaternion
  2509. * @returns the quaternion hash code
  2510. */
  2511. getHashCode(): number;
  2512. /**
  2513. * Copy the quaternion to an array
  2514. * @returns a new array populated with 4 elements from the quaternion coordinates
  2515. */
  2516. asArray(): number[];
  2517. /**
  2518. * Check if two quaternions are equals
  2519. * @param otherQuaternion defines the second operand
  2520. * @return true if the current quaternion and the given one coordinates are strictly equals
  2521. */
  2522. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2523. /**
  2524. * Clone the current quaternion
  2525. * @returns a new quaternion copied from the current one
  2526. */
  2527. clone(): Quaternion;
  2528. /**
  2529. * Copy a quaternion to the current one
  2530. * @param other defines the other quaternion
  2531. * @returns the updated current quaternion
  2532. */
  2533. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2534. /**
  2535. * Updates the current quaternion with the given float coordinates
  2536. * @param x defines the x coordinate
  2537. * @param y defines the y coordinate
  2538. * @param z defines the z coordinate
  2539. * @param w defines the w coordinate
  2540. * @returns the updated current quaternion
  2541. */
  2542. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2543. /**
  2544. * Updates the current quaternion from the given float coordinates
  2545. * @param x defines the x coordinate
  2546. * @param y defines the y coordinate
  2547. * @param z defines the z coordinate
  2548. * @param w defines the w coordinate
  2549. * @returns the updated current quaternion
  2550. */
  2551. set(x: number, y: number, z: number, w: number): Quaternion;
  2552. /**
  2553. * Adds two quaternions
  2554. * @param other defines the second operand
  2555. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2556. */
  2557. add(other: DeepImmutable<Quaternion>): Quaternion;
  2558. /**
  2559. * Add a quaternion to the current one
  2560. * @param other defines the quaternion to add
  2561. * @returns the current quaternion
  2562. */
  2563. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2564. /**
  2565. * Subtract two quaternions
  2566. * @param other defines the second operand
  2567. * @returns a new quaternion as the subtraction result of the given one from the current one
  2568. */
  2569. subtract(other: Quaternion): Quaternion;
  2570. /**
  2571. * Multiplies the current quaternion by a scale factor
  2572. * @param value defines the scale factor
  2573. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2574. */
  2575. scale(value: number): Quaternion;
  2576. /**
  2577. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2578. * @param scale defines the scale factor
  2579. * @param result defines the Quaternion object where to store the result
  2580. * @returns the unmodified current quaternion
  2581. */
  2582. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2583. /**
  2584. * Multiplies in place the current quaternion by a scale factor
  2585. * @param value defines the scale factor
  2586. * @returns the current modified quaternion
  2587. */
  2588. scaleInPlace(value: number): Quaternion;
  2589. /**
  2590. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2591. * @param scale defines the scale factor
  2592. * @param result defines the Quaternion object where to store the result
  2593. * @returns the unmodified current quaternion
  2594. */
  2595. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2596. /**
  2597. * Multiplies two quaternions
  2598. * @param q1 defines the second operand
  2599. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2600. */
  2601. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2602. /**
  2603. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2604. * @param q1 defines the second operand
  2605. * @param result defines the target quaternion
  2606. * @returns the current quaternion
  2607. */
  2608. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2609. /**
  2610. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @returns the currentupdated quaternion
  2613. */
  2614. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2615. /**
  2616. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2617. * @param ref defines the target quaternion
  2618. * @returns the current quaternion
  2619. */
  2620. conjugateToRef(ref: Quaternion): Quaternion;
  2621. /**
  2622. * Conjugates in place (1-q) the current quaternion
  2623. * @returns the current updated quaternion
  2624. */
  2625. conjugateInPlace(): Quaternion;
  2626. /**
  2627. * Conjugates in place (1-q) the current quaternion
  2628. * @returns a new quaternion
  2629. */
  2630. conjugate(): Quaternion;
  2631. /**
  2632. * Gets length of current quaternion
  2633. * @returns the quaternion length (float)
  2634. */
  2635. length(): number;
  2636. /**
  2637. * Normalize in place the current quaternion
  2638. * @returns the current updated quaternion
  2639. */
  2640. normalize(): Quaternion;
  2641. /**
  2642. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2643. * @param order is a reserved parameter and is ignore for now
  2644. * @returns a new Vector3 containing the Euler angles
  2645. */
  2646. toEulerAngles(order?: string): Vector3;
  2647. /**
  2648. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2649. * @param result defines the vector which will be filled with the Euler angles
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns the current unchanged quaternion
  2652. */
  2653. toEulerAnglesToRef(result: Vector3): Quaternion;
  2654. /**
  2655. * Updates the given rotation matrix with the current quaternion values
  2656. * @param result defines the target matrix
  2657. * @returns the current unchanged quaternion
  2658. */
  2659. toRotationMatrix(result: Matrix): Quaternion;
  2660. /**
  2661. * Updates the current quaternion from the given rotation matrix values
  2662. * @param matrix defines the source matrix
  2663. * @returns the current updated quaternion
  2664. */
  2665. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2666. /**
  2667. * Creates a new quaternion from a rotation matrix
  2668. * @param matrix defines the source matrix
  2669. * @returns a new quaternion created from the given rotation matrix values
  2670. */
  2671. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2672. /**
  2673. * Updates the given quaternion with the given rotation matrix values
  2674. * @param matrix defines the source matrix
  2675. * @param result defines the target quaternion
  2676. */
  2677. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2678. /**
  2679. * Returns the dot product (float) between the quaternions "left" and "right"
  2680. * @param left defines the left operand
  2681. * @param right defines the right operand
  2682. * @returns the dot product
  2683. */
  2684. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2685. /**
  2686. * Checks if the two quaternions are close to each other
  2687. * @param quat0 defines the first quaternion to check
  2688. * @param quat1 defines the second quaternion to check
  2689. * @returns true if the two quaternions are close to each other
  2690. */
  2691. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2692. /**
  2693. * Creates an empty quaternion
  2694. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2695. */
  2696. static Zero(): Quaternion;
  2697. /**
  2698. * Inverse a given quaternion
  2699. * @param q defines the source quaternion
  2700. * @returns a new quaternion as the inverted current quaternion
  2701. */
  2702. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2703. /**
  2704. * Inverse a given quaternion
  2705. * @param q defines the source quaternion
  2706. * @param result the quaternion the result will be stored in
  2707. * @returns the result quaternion
  2708. */
  2709. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2710. /**
  2711. * Creates an identity quaternion
  2712. * @returns the identity quaternion
  2713. */
  2714. static Identity(): Quaternion;
  2715. /**
  2716. * Gets a boolean indicating if the given quaternion is identity
  2717. * @param quaternion defines the quaternion to check
  2718. * @returns true if the quaternion is identity
  2719. */
  2720. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2721. /**
  2722. * Creates a quaternion from a rotation around an axis
  2723. * @param axis defines the axis to use
  2724. * @param angle defines the angle to use
  2725. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2726. */
  2727. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2728. /**
  2729. * Creates a rotation around an axis and stores it into the given quaternion
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @param result defines the target quaternion
  2733. * @returns the target quaternion
  2734. */
  2735. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2736. /**
  2737. * Creates a new quaternion from data stored into an array
  2738. * @param array defines the data source
  2739. * @param offset defines the offset in the source array where the data starts
  2740. * @returns a new quaternion
  2741. */
  2742. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2743. /**
  2744. * Create a quaternion from Euler rotation angles
  2745. * @param x Pitch
  2746. * @param y Yaw
  2747. * @param z Roll
  2748. * @returns the new Quaternion
  2749. */
  2750. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2751. /**
  2752. * Updates a quaternion from Euler rotation angles
  2753. * @param x Pitch
  2754. * @param y Yaw
  2755. * @param z Roll
  2756. * @param result the quaternion to store the result
  2757. * @returns the updated quaternion
  2758. */
  2759. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2760. /**
  2761. * Create a quaternion from Euler rotation vector
  2762. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2763. * @returns the new Quaternion
  2764. */
  2765. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2766. /**
  2767. * Updates a quaternion from Euler rotation vector
  2768. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2769. * @param result the quaternion to store the result
  2770. * @returns the updated quaternion
  2771. */
  2772. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2775. * @param yaw defines the rotation around Y axis
  2776. * @param pitch defines the rotation around X axis
  2777. * @param roll defines the rotation around Z axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2781. /**
  2782. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2783. * @param yaw defines the rotation around Y axis
  2784. * @param pitch defines the rotation around X axis
  2785. * @param roll defines the rotation around Z axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2789. /**
  2790. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2791. * @param alpha defines the rotation around first axis
  2792. * @param beta defines the rotation around second axis
  2793. * @param gamma defines the rotation around third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2797. /**
  2798. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2799. * @param alpha defines the rotation around first axis
  2800. * @param beta defines the rotation around second axis
  2801. * @param gamma defines the rotation around third axis
  2802. * @param result defines the target quaternion
  2803. */
  2804. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2805. /**
  2806. * 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)
  2807. * @param axis1 defines the first axis
  2808. * @param axis2 defines the second axis
  2809. * @param axis3 defines the third axis
  2810. * @returns the new quaternion
  2811. */
  2812. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2813. /**
  2814. * 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
  2815. * @param axis1 defines the first axis
  2816. * @param axis2 defines the second axis
  2817. * @param axis3 defines the third axis
  2818. * @param ref defines the target quaternion
  2819. */
  2820. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2821. /**
  2822. * Interpolates between two quaternions
  2823. * @param left defines first quaternion
  2824. * @param right defines second quaternion
  2825. * @param amount defines the gradient to use
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. /**
  2830. * Interpolates between two quaternions and stores it into a target quaternion
  2831. * @param left defines first quaternion
  2832. * @param right defines second quaternion
  2833. * @param amount defines the gradient to use
  2834. * @param result defines the target quaternion
  2835. */
  2836. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2837. /**
  2838. * Interpolate between two quaternions using Hermite interpolation
  2839. * @param value1 defines first quaternion
  2840. * @param tangent1 defines the incoming tangent
  2841. * @param value2 defines second quaternion
  2842. * @param tangent2 defines the outgoing tangent
  2843. * @param amount defines the target quaternion
  2844. * @returns the new interpolated quaternion
  2845. */
  2846. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2847. }
  2848. /**
  2849. * Class used to store matrix data (4x4)
  2850. */
  2851. export class Matrix {
  2852. private static _updateFlagSeed;
  2853. private static _identityReadOnly;
  2854. private _isIdentity;
  2855. private _isIdentityDirty;
  2856. private _isIdentity3x2;
  2857. private _isIdentity3x2Dirty;
  2858. /**
  2859. * Gets the update flag of the matrix which is an unique number for the matrix.
  2860. * It will be incremented every time the matrix data change.
  2861. * You can use it to speed the comparison between two versions of the same matrix.
  2862. */
  2863. updateFlag: number;
  2864. private readonly _m;
  2865. /**
  2866. * Gets the internal data of the matrix
  2867. */
  2868. readonly m: DeepImmutable<Float32Array>;
  2869. /** @hidden */
  2870. _markAsUpdated(): void;
  2871. /** @hidden */
  2872. private _updateIdentityStatus;
  2873. /**
  2874. * Creates an empty matrix (filled with zeros)
  2875. */
  2876. constructor();
  2877. /**
  2878. * Check if the current matrix is identity
  2879. * @returns true is the matrix is the identity matrix
  2880. */
  2881. isIdentity(): boolean;
  2882. /**
  2883. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2884. * @returns true is the matrix is the identity matrix
  2885. */
  2886. isIdentityAs3x2(): boolean;
  2887. /**
  2888. * Gets the determinant of the matrix
  2889. * @returns the matrix determinant
  2890. */
  2891. determinant(): number;
  2892. /**
  2893. * Returns the matrix as a Float32Array
  2894. * @returns the matrix underlying array
  2895. */
  2896. toArray(): DeepImmutable<Float32Array>;
  2897. /**
  2898. * Returns the matrix as a Float32Array
  2899. * @returns the matrix underlying array.
  2900. */
  2901. asArray(): DeepImmutable<Float32Array>;
  2902. /**
  2903. * Inverts the current matrix in place
  2904. * @returns the current inverted matrix
  2905. */
  2906. invert(): Matrix;
  2907. /**
  2908. * Sets all the matrix elements to zero
  2909. * @returns the current matrix
  2910. */
  2911. reset(): Matrix;
  2912. /**
  2913. * Adds the current matrix with a second one
  2914. * @param other defines the matrix to add
  2915. * @returns a new matrix as the addition of the current matrix and the given one
  2916. */
  2917. add(other: DeepImmutable<Matrix>): Matrix;
  2918. /**
  2919. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2920. * @param other defines the matrix to add
  2921. * @param result defines the target matrix
  2922. * @returns the current matrix
  2923. */
  2924. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2925. /**
  2926. * Adds in place the given matrix to the current matrix
  2927. * @param other defines the second operand
  2928. * @returns the current updated matrix
  2929. */
  2930. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2931. /**
  2932. * Sets the given matrix to the current inverted Matrix
  2933. * @param other defines the target matrix
  2934. * @returns the unmodified current matrix
  2935. */
  2936. invertToRef(other: Matrix): Matrix;
  2937. /**
  2938. * add a value at the specified position in the current Matrix
  2939. * @param index the index of the value within the matrix. between 0 and 15.
  2940. * @param value the value to be added
  2941. * @returns the current updated matrix
  2942. */
  2943. addAtIndex(index: number, value: number): Matrix;
  2944. /**
  2945. * mutiply the specified position in the current Matrix by a value
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. multiplyAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector (using 3 floats) in the current matrix
  2953. * @param x defines the 1st component of the translation
  2954. * @param y defines the 2nd component of the translation
  2955. * @param z defines the 3rd component of the translation
  2956. * @returns the current updated matrix
  2957. */
  2958. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2959. /**
  2960. * Adds the translation vector (using 3 floats) in the current matrix
  2961. * @param x defines the 1st component of the translation
  2962. * @param y defines the 2nd component of the translation
  2963. * @param z defines the 3rd component of the translation
  2964. * @returns the current updated matrix
  2965. */
  2966. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2967. /**
  2968. * Inserts the translation vector in the current matrix
  2969. * @param vector3 defines the translation to insert
  2970. * @returns the current updated matrix
  2971. */
  2972. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2973. /**
  2974. * Gets the translation value of the current matrix
  2975. * @returns a new Vector3 as the extracted translation from the matrix
  2976. */
  2977. getTranslation(): Vector3;
  2978. /**
  2979. * Fill a Vector3 with the extracted translation from the matrix
  2980. * @param result defines the Vector3 where to store the translation
  2981. * @returns the current matrix
  2982. */
  2983. getTranslationToRef(result: Vector3): Matrix;
  2984. /**
  2985. * Remove rotation and scaling part from the matrix
  2986. * @returns the updated matrix
  2987. */
  2988. removeRotationAndScaling(): Matrix;
  2989. /**
  2990. * Multiply two matrices
  2991. * @param other defines the second operand
  2992. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2993. */
  2994. multiply(other: DeepImmutable<Matrix>): Matrix;
  2995. /**
  2996. * Copy the current matrix from the given one
  2997. * @param other defines the source matrix
  2998. * @returns the current updated matrix
  2999. */
  3000. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3001. /**
  3002. * Populates the given array from the starting index with the current matrix values
  3003. * @param array defines the target array
  3004. * @param offset defines the offset in the target array where to start storing values
  3005. * @returns the current matrix
  3006. */
  3007. copyToArray(array: Float32Array, offset?: number): Matrix;
  3008. /**
  3009. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3010. * @param other defines the second operand
  3011. * @param result defines the matrix where to store the multiplication
  3012. * @returns the current matrix
  3013. */
  3014. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3015. /**
  3016. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the array where to store the multiplication
  3019. * @param offset defines the offset in the target array where to start storing values
  3020. * @returns the current matrix
  3021. */
  3022. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3023. /**
  3024. * Check equality between this matrix and a second one
  3025. * @param value defines the second matrix to compare
  3026. * @returns true is the current matrix and the given one values are strictly equal
  3027. */
  3028. equals(value: DeepImmutable<Matrix>): boolean;
  3029. /**
  3030. * Clone the current matrix
  3031. * @returns a new matrix from the current matrix
  3032. */
  3033. clone(): Matrix;
  3034. /**
  3035. * Returns the name of the current matrix class
  3036. * @returns the string "Matrix"
  3037. */
  3038. getClassName(): string;
  3039. /**
  3040. * Gets the hash code of the current matrix
  3041. * @returns the hash code
  3042. */
  3043. getHashCode(): number;
  3044. /**
  3045. * Decomposes the current Matrix into a translation, rotation and scaling components
  3046. * @param scale defines the scale vector3 given as a reference to update
  3047. * @param rotation defines the rotation quaternion given as a reference to update
  3048. * @param translation defines the translation vector3 given as a reference to update
  3049. * @returns true if operation was successful
  3050. */
  3051. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3052. /**
  3053. * Gets specific row of the matrix
  3054. * @param index defines the number of the row to get
  3055. * @returns the index-th row of the current matrix as a new Vector4
  3056. */
  3057. getRow(index: number): Nullable<Vector4>;
  3058. /**
  3059. * Sets the index-th row of the current matrix to the vector4 values
  3060. * @param index defines the number of the row to set
  3061. * @param row defines the target vector4
  3062. * @returns the updated current matrix
  3063. */
  3064. setRow(index: number, row: Vector4): Matrix;
  3065. /**
  3066. * Compute the transpose of the matrix
  3067. * @returns the new transposed matrix
  3068. */
  3069. transpose(): Matrix;
  3070. /**
  3071. * Compute the transpose of the matrix and store it in a given matrix
  3072. * @param result defines the target matrix
  3073. * @returns the current matrix
  3074. */
  3075. transposeToRef(result: Matrix): Matrix;
  3076. /**
  3077. * Sets the index-th row of the current matrix with the given 4 x float values
  3078. * @param index defines the row index
  3079. * @param x defines the x component to set
  3080. * @param y defines the y component to set
  3081. * @param z defines the z component to set
  3082. * @param w defines the w component to set
  3083. * @returns the updated current matrix
  3084. */
  3085. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3086. /**
  3087. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3088. * @param scale defines the scale factor
  3089. * @returns a new matrix
  3090. */
  3091. scale(scale: number): Matrix;
  3092. /**
  3093. * Scale the current matrix values by a factor to a given result matrix
  3094. * @param scale defines the scale factor
  3095. * @param result defines the matrix to store the result
  3096. * @returns the current matrix
  3097. */
  3098. scaleToRef(scale: number, result: Matrix): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor and add the result to a given matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the Matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3108. * @param ref matrix to store the result
  3109. */
  3110. toNormalMatrix(ref: Matrix): void;
  3111. /**
  3112. * Gets only rotation part of the current matrix
  3113. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3114. */
  3115. getRotationMatrix(): Matrix;
  3116. /**
  3117. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3118. * @param result defines the target matrix to store data to
  3119. * @returns the current matrix
  3120. */
  3121. getRotationMatrixToRef(result: Matrix): Matrix;
  3122. /**
  3123. * Toggles model matrix from being right handed to left handed in place and vice versa
  3124. */
  3125. toggleModelMatrixHandInPlace(): void;
  3126. /**
  3127. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3128. */
  3129. toggleProjectionMatrixHandInPlace(): void;
  3130. /**
  3131. * Creates a matrix from an array
  3132. * @param array defines the source array
  3133. * @param offset defines an offset in the source array
  3134. * @returns a new Matrix set from the starting index of the given array
  3135. */
  3136. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3137. /**
  3138. * Copy the content of an array into a given matrix
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @param result defines the target matrix
  3142. */
  3143. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3144. /**
  3145. * Stores an array into a matrix after having multiplied each component by a given factor
  3146. * @param array defines the source array
  3147. * @param offset defines the offset in the source array
  3148. * @param scale defines the scaling factor
  3149. * @param result defines the target matrix
  3150. */
  3151. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3152. /**
  3153. * Gets an identity matrix that must not be updated
  3154. */
  3155. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3156. /**
  3157. * Stores a list of values (16) inside a given matrix
  3158. * @param initialM11 defines 1st value of 1st row
  3159. * @param initialM12 defines 2nd value of 1st row
  3160. * @param initialM13 defines 3rd value of 1st row
  3161. * @param initialM14 defines 4th value of 1st row
  3162. * @param initialM21 defines 1st value of 2nd row
  3163. * @param initialM22 defines 2nd value of 2nd row
  3164. * @param initialM23 defines 3rd value of 2nd row
  3165. * @param initialM24 defines 4th value of 2nd row
  3166. * @param initialM31 defines 1st value of 3rd row
  3167. * @param initialM32 defines 2nd value of 3rd row
  3168. * @param initialM33 defines 3rd value of 3rd row
  3169. * @param initialM34 defines 4th value of 3rd row
  3170. * @param initialM41 defines 1st value of 4th row
  3171. * @param initialM42 defines 2nd value of 4th row
  3172. * @param initialM43 defines 3rd value of 4th row
  3173. * @param initialM44 defines 4th value of 4th row
  3174. * @param result defines the target matrix
  3175. */
  3176. 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;
  3177. /**
  3178. * Creates new matrix from a list of values (16)
  3179. * @param initialM11 defines 1st value of 1st row
  3180. * @param initialM12 defines 2nd value of 1st row
  3181. * @param initialM13 defines 3rd value of 1st row
  3182. * @param initialM14 defines 4th value of 1st row
  3183. * @param initialM21 defines 1st value of 2nd row
  3184. * @param initialM22 defines 2nd value of 2nd row
  3185. * @param initialM23 defines 3rd value of 2nd row
  3186. * @param initialM24 defines 4th value of 2nd row
  3187. * @param initialM31 defines 1st value of 3rd row
  3188. * @param initialM32 defines 2nd value of 3rd row
  3189. * @param initialM33 defines 3rd value of 3rd row
  3190. * @param initialM34 defines 4th value of 3rd row
  3191. * @param initialM41 defines 1st value of 4th row
  3192. * @param initialM42 defines 2nd value of 4th row
  3193. * @param initialM43 defines 3rd value of 4th row
  3194. * @param initialM44 defines 4th value of 4th row
  3195. * @returns the new matrix
  3196. */
  3197. 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;
  3198. /**
  3199. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3200. * @param scale defines the scale vector3
  3201. * @param rotation defines the rotation quaternion
  3202. * @param translation defines the translation vector3
  3203. * @returns a new matrix
  3204. */
  3205. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3206. /**
  3207. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3208. * @param scale defines the scale vector3
  3209. * @param rotation defines the rotation quaternion
  3210. * @param translation defines the translation vector3
  3211. * @param result defines the target matrix
  3212. */
  3213. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3214. /**
  3215. * Creates a new identity matrix
  3216. * @returns a new identity matrix
  3217. */
  3218. static Identity(): Matrix;
  3219. /**
  3220. * Creates a new identity matrix and stores the result in a given matrix
  3221. * @param result defines the target matrix
  3222. */
  3223. static IdentityToRef(result: Matrix): void;
  3224. /**
  3225. * Creates a new zero matrix
  3226. * @returns a new zero matrix
  3227. */
  3228. static Zero(): Matrix;
  3229. /**
  3230. * Creates a new rotation matrix for "angle" radians around the X axis
  3231. * @param angle defines the angle (in radians) to use
  3232. * @return the new matrix
  3233. */
  3234. static RotationX(angle: number): Matrix;
  3235. /**
  3236. * Creates a new matrix as the invert of a given matrix
  3237. * @param source defines the source matrix
  3238. * @returns the new matrix
  3239. */
  3240. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3241. /**
  3242. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3243. * @param angle defines the angle (in radians) to use
  3244. * @param result defines the target matrix
  3245. */
  3246. static RotationXToRef(angle: number, result: Matrix): void;
  3247. /**
  3248. * Creates a new rotation matrix for "angle" radians around the Y axis
  3249. * @param angle defines the angle (in radians) to use
  3250. * @return the new matrix
  3251. */
  3252. static RotationY(angle: number): Matrix;
  3253. /**
  3254. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationYToRef(angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a new rotation matrix for "angle" radians around the Z axis
  3261. * @param angle defines the angle (in radians) to use
  3262. * @return the new matrix
  3263. */
  3264. static RotationZ(angle: number): Matrix;
  3265. /**
  3266. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3267. * @param angle defines the angle (in radians) to use
  3268. * @param result defines the target matrix
  3269. */
  3270. static RotationZToRef(angle: number, result: Matrix): void;
  3271. /**
  3272. * Creates a new rotation matrix for "angle" radians around the given axis
  3273. * @param axis defines the axis to use
  3274. * @param angle defines the angle (in radians) to use
  3275. * @return the new matrix
  3276. */
  3277. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @param result defines the target matrix
  3283. */
  3284. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3285. /**
  3286. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3287. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3288. * @param from defines the vector to align
  3289. * @param to defines the vector to align to
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3293. /**
  3294. * Creates a rotation matrix
  3295. * @param yaw defines the yaw angle in radians (Y axis)
  3296. * @param pitch defines the pitch angle in radians (X axis)
  3297. * @param roll defines the roll angle in radians (X axis)
  3298. * @returns the new rotation matrix
  3299. */
  3300. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3301. /**
  3302. * Creates a rotation matrix and stores it in a given matrix
  3303. * @param yaw defines the yaw angle in radians (Y axis)
  3304. * @param pitch defines the pitch angle in radians (X axis)
  3305. * @param roll defines the roll angle in radians (X axis)
  3306. * @param result defines the target matrix
  3307. */
  3308. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3309. /**
  3310. * Creates a scaling matrix
  3311. * @param x defines the scale factor on X axis
  3312. * @param y defines the scale factor on Y axis
  3313. * @param z defines the scale factor on Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Scaling(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a scaling matrix and stores it in a given matrix
  3319. * @param x defines the scale factor on X axis
  3320. * @param y defines the scale factor on Y axis
  3321. * @param z defines the scale factor on Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Creates a translation matrix
  3327. * @param x defines the translation on X axis
  3328. * @param y defines the translation on Y axis
  3329. * @param z defines the translationon Z axis
  3330. * @returns the new matrix
  3331. */
  3332. static Translation(x: number, y: number, z: number): Matrix;
  3333. /**
  3334. * Creates a translation matrix and stores it in a given matrix
  3335. * @param x defines the translation on X axis
  3336. * @param y defines the translation on Y axis
  3337. * @param z defines the translationon Z axis
  3338. * @param result defines the target matrix
  3339. */
  3340. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3341. /**
  3342. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3343. * @param startValue defines the start value
  3344. * @param endValue defines the end value
  3345. * @param gradient defines the gradient factor
  3346. * @returns the new matrix
  3347. */
  3348. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3349. /**
  3350. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3351. * @param startValue defines the start value
  3352. * @param endValue defines the end value
  3353. * @param gradient defines the gradient factor
  3354. * @param result defines the Matrix object where to store data
  3355. */
  3356. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3357. /**
  3358. * Builds a new matrix whose values are computed by:
  3359. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3360. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3361. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3362. * @param startValue defines the first matrix
  3363. * @param endValue defines the second matrix
  3364. * @param gradient defines the gradient between the two matrices
  3365. * @returns the new matrix
  3366. */
  3367. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3368. /**
  3369. * Update a matrix to values which are computed by:
  3370. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3371. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3372. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3373. * @param startValue defines the first matrix
  3374. * @param endValue defines the second matrix
  3375. * @param gradient defines the gradient between the two matrices
  3376. * @param result defines the target matrix
  3377. */
  3378. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3379. /**
  3380. * 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"
  3381. * This function works in left handed mode
  3382. * @param eye defines the final position of the entity
  3383. * @param target defines where the entity should look at
  3384. * @param up defines the up vector for the entity
  3385. * @returns the new matrix
  3386. */
  3387. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3388. /**
  3389. * 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".
  3390. * This function works in left handed mode
  3391. * @param eye defines the final position of the entity
  3392. * @param target defines where the entity should look at
  3393. * @param up defines the up vector for the entity
  3394. * @param result defines the target matrix
  3395. */
  3396. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3397. /**
  3398. * 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"
  3399. * This function works in right handed mode
  3400. * @param eye defines the final position of the entity
  3401. * @param target defines where the entity should look at
  3402. * @param up defines the up vector for the entity
  3403. * @returns the new matrix
  3404. */
  3405. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3406. /**
  3407. * 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".
  3408. * This function works in right handed mode
  3409. * @param eye defines the final position of the entity
  3410. * @param target defines where the entity should look at
  3411. * @param up defines the up vector for the entity
  3412. * @param result defines the target matrix
  3413. */
  3414. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3415. /**
  3416. * Create a left-handed orthographic projection matrix
  3417. * @param width defines the viewport width
  3418. * @param height defines the viewport height
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @returns a new matrix as a left-handed orthographic projection matrix
  3422. */
  3423. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3424. /**
  3425. * Store a left-handed orthographic projection to a given matrix
  3426. * @param width defines the viewport width
  3427. * @param height defines the viewport height
  3428. * @param znear defines the near clip plane
  3429. * @param zfar defines the far clip plane
  3430. * @param result defines the target matrix
  3431. */
  3432. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3433. /**
  3434. * Create a left-handed orthographic projection matrix
  3435. * @param left defines the viewport left coordinate
  3436. * @param right defines the viewport right coordinate
  3437. * @param bottom defines the viewport bottom coordinate
  3438. * @param top defines the viewport top coordinate
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @returns a new matrix as a left-handed orthographic projection matrix
  3442. */
  3443. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3444. /**
  3445. * Stores a left-handed orthographic projection into a given matrix
  3446. * @param left defines the viewport left coordinate
  3447. * @param right defines the viewport right coordinate
  3448. * @param bottom defines the viewport bottom coordinate
  3449. * @param top defines the viewport top coordinate
  3450. * @param znear defines the near clip plane
  3451. * @param zfar defines the far clip plane
  3452. * @param result defines the target matrix
  3453. */
  3454. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3455. /**
  3456. * Creates a right-handed orthographic projection matrix
  3457. * @param left defines the viewport left coordinate
  3458. * @param right defines the viewport right coordinate
  3459. * @param bottom defines the viewport bottom coordinate
  3460. * @param top defines the viewport top coordinate
  3461. * @param znear defines the near clip plane
  3462. * @param zfar defines the far clip plane
  3463. * @returns a new matrix as a right-handed orthographic projection matrix
  3464. */
  3465. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3466. /**
  3467. * Stores a right-handed orthographic projection into a given matrix
  3468. * @param left defines the viewport left coordinate
  3469. * @param right defines the viewport right coordinate
  3470. * @param bottom defines the viewport bottom coordinate
  3471. * @param top defines the viewport top coordinate
  3472. * @param znear defines the near clip plane
  3473. * @param zfar defines the far clip plane
  3474. * @param result defines the target matrix
  3475. */
  3476. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3477. /**
  3478. * Creates a left-handed perspective projection matrix
  3479. * @param width defines the viewport width
  3480. * @param height defines the viewport height
  3481. * @param znear defines the near clip plane
  3482. * @param zfar defines the far clip plane
  3483. * @returns a new matrix as a left-handed perspective projection matrix
  3484. */
  3485. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3486. /**
  3487. * Creates a left-handed perspective projection matrix
  3488. * @param fov defines the horizontal field of view
  3489. * @param aspect defines the aspect ratio
  3490. * @param znear defines the near clip plane
  3491. * @param zfar defines the far clip plane
  3492. * @returns a new matrix as a left-handed perspective projection matrix
  3493. */
  3494. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3495. /**
  3496. * Stores a left-handed perspective projection into a given matrix
  3497. * @param fov defines the horizontal field of view
  3498. * @param aspect defines the aspect ratio
  3499. * @param znear defines the near clip plane
  3500. * @param zfar defines the far clip plane
  3501. * @param result defines the target matrix
  3502. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3503. */
  3504. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3505. /**
  3506. * Creates a right-handed perspective projection matrix
  3507. * @param fov defines the horizontal field of view
  3508. * @param aspect defines the aspect ratio
  3509. * @param znear defines the near clip plane
  3510. * @param zfar defines the far clip plane
  3511. * @returns a new matrix as a right-handed perspective projection matrix
  3512. */
  3513. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3514. /**
  3515. * Stores a right-handed perspective projection into a given matrix
  3516. * @param fov defines the horizontal field of view
  3517. * @param aspect defines the aspect ratio
  3518. * @param znear defines the near clip plane
  3519. * @param zfar defines the far clip plane
  3520. * @param result defines the target matrix
  3521. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3522. */
  3523. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3524. /**
  3525. * Stores a perspective projection for WebVR info a given matrix
  3526. * @param fov defines the field of view
  3527. * @param znear defines the near clip plane
  3528. * @param zfar defines the far clip plane
  3529. * @param result defines the target matrix
  3530. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3531. */
  3532. static PerspectiveFovWebVRToRef(fov: {
  3533. upDegrees: number;
  3534. downDegrees: number;
  3535. leftDegrees: number;
  3536. rightDegrees: number;
  3537. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3538. /**
  3539. * Computes a complete transformation matrix
  3540. * @param viewport defines the viewport to use
  3541. * @param world defines the world matrix
  3542. * @param view defines the view matrix
  3543. * @param projection defines the projection matrix
  3544. * @param zmin defines the near clip plane
  3545. * @param zmax defines the far clip plane
  3546. * @returns the transformation matrix
  3547. */
  3548. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3549. /**
  3550. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3551. * @param matrix defines the matrix to use
  3552. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3553. */
  3554. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3555. /**
  3556. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3557. * @param matrix defines the matrix to use
  3558. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3559. */
  3560. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3561. /**
  3562. * Compute the transpose of a given matrix
  3563. * @param matrix defines the matrix to transpose
  3564. * @returns the new matrix
  3565. */
  3566. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3567. /**
  3568. * Compute the transpose of a matrix and store it in a target matrix
  3569. * @param matrix defines the matrix to transpose
  3570. * @param result defines the target matrix
  3571. */
  3572. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3573. /**
  3574. * Computes a reflection matrix from a plane
  3575. * @param plane defines the reflection plane
  3576. * @returns a new matrix
  3577. */
  3578. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3579. /**
  3580. * Computes a reflection matrix from a plane
  3581. * @param plane defines the reflection plane
  3582. * @param result defines the target matrix
  3583. */
  3584. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3585. /**
  3586. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3587. * @param xaxis defines the value of the 1st axis
  3588. * @param yaxis defines the value of the 2nd axis
  3589. * @param zaxis defines the value of the 3rd axis
  3590. * @param result defines the target matrix
  3591. */
  3592. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3593. /**
  3594. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3595. * @param quat defines the quaternion to use
  3596. * @param result defines the target matrix
  3597. */
  3598. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3599. }
  3600. /**
  3601. * Represens a plane by the equation ax + by + cz + d = 0
  3602. */
  3603. export class Plane {
  3604. /**
  3605. * Normal of the plane (a,b,c)
  3606. */
  3607. normal: Vector3;
  3608. /**
  3609. * d component of the plane
  3610. */
  3611. d: number;
  3612. /**
  3613. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3614. * @param a a component of the plane
  3615. * @param b b component of the plane
  3616. * @param c c component of the plane
  3617. * @param d d component of the plane
  3618. */
  3619. constructor(a: number, b: number, c: number, d: number);
  3620. /**
  3621. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3622. */
  3623. asArray(): number[];
  3624. /**
  3625. * @returns a new plane copied from the current Plane.
  3626. */
  3627. clone(): Plane;
  3628. /**
  3629. * @returns the string "Plane".
  3630. */
  3631. getClassName(): string;
  3632. /**
  3633. * @returns the Plane hash code.
  3634. */
  3635. getHashCode(): number;
  3636. /**
  3637. * Normalize the current Plane in place.
  3638. * @returns the updated Plane.
  3639. */
  3640. normalize(): Plane;
  3641. /**
  3642. * Applies a transformation the plane and returns the result
  3643. * @param transformation the transformation matrix to be applied to the plane
  3644. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3645. */
  3646. transform(transformation: DeepImmutable<Matrix>): Plane;
  3647. /**
  3648. * Calcualtte the dot product between the point and the plane normal
  3649. * @param point point to calculate the dot product with
  3650. * @returns the dot product (float) of the point coordinates and the plane normal.
  3651. */
  3652. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3653. /**
  3654. * Updates the current Plane from the plane defined by the three given points.
  3655. * @param point1 one of the points used to contruct the plane
  3656. * @param point2 one of the points used to contruct the plane
  3657. * @param point3 one of the points used to contruct the plane
  3658. * @returns the updated Plane.
  3659. */
  3660. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3661. /**
  3662. * Checks if the plane is facing a given direction
  3663. * @param direction the direction to check if the plane is facing
  3664. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3665. * @returns True is the vector "direction" is the same side than the plane normal.
  3666. */
  3667. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3668. /**
  3669. * Calculates the distance to a point
  3670. * @param point point to calculate distance to
  3671. * @returns the signed distance (float) from the given point to the Plane.
  3672. */
  3673. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3674. /**
  3675. * Creates a plane from an array
  3676. * @param array the array to create a plane from
  3677. * @returns a new Plane from the given array.
  3678. */
  3679. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3680. /**
  3681. * Creates a plane from three points
  3682. * @param point1 point used to create the plane
  3683. * @param point2 point used to create the plane
  3684. * @param point3 point used to create the plane
  3685. * @returns a new Plane defined by the three given points.
  3686. */
  3687. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3688. /**
  3689. * Creates a plane from an origin point and a normal
  3690. * @param origin origin of the plane to be constructed
  3691. * @param normal normal of the plane to be constructed
  3692. * @returns a new Plane the normal vector to this plane at the given origin point.
  3693. * Note : the vector "normal" is updated because normalized.
  3694. */
  3695. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3696. /**
  3697. * Calculates the distance from a plane and a point
  3698. * @param origin origin of the plane to be constructed
  3699. * @param normal normal of the plane to be constructed
  3700. * @param point point to calculate distance to
  3701. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3702. */
  3703. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3704. }
  3705. /**
  3706. * Class used to represent a viewport on screen
  3707. */
  3708. export class Viewport {
  3709. /** viewport left coordinate */
  3710. x: number;
  3711. /** viewport top coordinate */
  3712. y: number;
  3713. /**viewport width */
  3714. width: number;
  3715. /** viewport height */
  3716. height: number;
  3717. /**
  3718. * Creates a Viewport object located at (x, y) and sized (width, height)
  3719. * @param x defines viewport left coordinate
  3720. * @param y defines viewport top coordinate
  3721. * @param width defines the viewport width
  3722. * @param height defines the viewport height
  3723. */
  3724. constructor(
  3725. /** viewport left coordinate */
  3726. x: number,
  3727. /** viewport top coordinate */
  3728. y: number,
  3729. /**viewport width */
  3730. width: number,
  3731. /** viewport height */
  3732. height: number);
  3733. /**
  3734. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3735. * @param renderWidth defines the rendering width
  3736. * @param renderHeight defines the rendering height
  3737. * @returns a new Viewport
  3738. */
  3739. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3740. /**
  3741. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @param ref defines the target viewport
  3745. * @returns the current viewport
  3746. */
  3747. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3748. /**
  3749. * Returns a new Viewport copied from the current one
  3750. * @returns a new Viewport
  3751. */
  3752. clone(): Viewport;
  3753. }
  3754. /**
  3755. * Reprasents a camera frustum
  3756. */
  3757. export class Frustum {
  3758. /**
  3759. * Gets the planes representing the frustum
  3760. * @param transform matrix to be applied to the returned planes
  3761. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3762. */
  3763. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3764. /**
  3765. * Gets the near frustum plane transformed by the transform matrix
  3766. * @param transform transformation matrix to be applied to the resulting frustum plane
  3767. * @param frustumPlane the resuling frustum plane
  3768. */
  3769. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3770. /**
  3771. * Gets the far frustum plane transformed by the transform matrix
  3772. * @param transform transformation matrix to be applied to the resulting frustum plane
  3773. * @param frustumPlane the resuling frustum plane
  3774. */
  3775. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3776. /**
  3777. * Gets the left frustum plane transformed by the transform matrix
  3778. * @param transform transformation matrix to be applied to the resulting frustum plane
  3779. * @param frustumPlane the resuling frustum plane
  3780. */
  3781. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3782. /**
  3783. * Gets the right frustum plane transformed by the transform matrix
  3784. * @param transform transformation matrix to be applied to the resulting frustum plane
  3785. * @param frustumPlane the resuling frustum plane
  3786. */
  3787. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3788. /**
  3789. * Gets the top frustum plane transformed by the transform matrix
  3790. * @param transform transformation matrix to be applied to the resulting frustum plane
  3791. * @param frustumPlane the resuling frustum plane
  3792. */
  3793. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3794. /**
  3795. * Gets the bottom frustum plane transformed by the transform matrix
  3796. * @param transform transformation matrix to be applied to the resulting frustum plane
  3797. * @param frustumPlane the resuling frustum plane
  3798. */
  3799. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3800. /**
  3801. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3802. * @param transform transformation matrix to be applied to the resulting frustum planes
  3803. * @param frustumPlanes the resuling frustum planes
  3804. */
  3805. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3806. }
  3807. /** Defines supported spaces */
  3808. export enum Space {
  3809. /** Local (object) space */
  3810. LOCAL = 0,
  3811. /** World space */
  3812. WORLD = 1,
  3813. /** Bone space */
  3814. BONE = 2
  3815. }
  3816. /** Defines the 3 main axes */
  3817. export class Axis {
  3818. /** X axis */
  3819. static X: Vector3;
  3820. /** Y axis */
  3821. static Y: Vector3;
  3822. /** Z axis */
  3823. static Z: Vector3;
  3824. }
  3825. /** Class used to represent a Bezier curve */
  3826. export class BezierCurve {
  3827. /**
  3828. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3829. * @param t defines the time
  3830. * @param x1 defines the left coordinate on X axis
  3831. * @param y1 defines the left coordinate on Y axis
  3832. * @param x2 defines the right coordinate on X axis
  3833. * @param y2 defines the right coordinate on Y axis
  3834. * @returns the interpolated value
  3835. */
  3836. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3837. }
  3838. /**
  3839. * Defines potential orientation for back face culling
  3840. */
  3841. export enum Orientation {
  3842. /**
  3843. * Clockwise
  3844. */
  3845. CW = 0,
  3846. /** Counter clockwise */
  3847. CCW = 1
  3848. }
  3849. /**
  3850. * Defines angle representation
  3851. */
  3852. export class Angle {
  3853. private _radians;
  3854. /**
  3855. * Creates an Angle object of "radians" radians (float).
  3856. * @param radians the angle in radians
  3857. */
  3858. constructor(radians: number);
  3859. /**
  3860. * Get value in degrees
  3861. * @returns the Angle value in degrees (float)
  3862. */
  3863. degrees(): number;
  3864. /**
  3865. * Get value in radians
  3866. * @returns the Angle value in radians (float)
  3867. */
  3868. radians(): number;
  3869. /**
  3870. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3871. * @param a defines first vector
  3872. * @param b defines second vector
  3873. * @returns a new Angle
  3874. */
  3875. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3876. /**
  3877. * Gets a new Angle object from the given float in radians
  3878. * @param radians defines the angle value in radians
  3879. * @returns a new Angle
  3880. */
  3881. static FromRadians(radians: number): Angle;
  3882. /**
  3883. * Gets a new Angle object from the given float in degrees
  3884. * @param degrees defines the angle value in degrees
  3885. * @returns a new Angle
  3886. */
  3887. static FromDegrees(degrees: number): Angle;
  3888. }
  3889. /**
  3890. * This represents an arc in a 2d space.
  3891. */
  3892. export class Arc2 {
  3893. /** Defines the start point of the arc */
  3894. startPoint: Vector2;
  3895. /** Defines the mid point of the arc */
  3896. midPoint: Vector2;
  3897. /** Defines the end point of the arc */
  3898. endPoint: Vector2;
  3899. /**
  3900. * Defines the center point of the arc.
  3901. */
  3902. centerPoint: Vector2;
  3903. /**
  3904. * Defines the radius of the arc.
  3905. */
  3906. radius: number;
  3907. /**
  3908. * Defines the angle of the arc (from mid point to end point).
  3909. */
  3910. angle: Angle;
  3911. /**
  3912. * Defines the start angle of the arc (from start point to middle point).
  3913. */
  3914. startAngle: Angle;
  3915. /**
  3916. * Defines the orientation of the arc (clock wise/counter clock wise).
  3917. */
  3918. orientation: Orientation;
  3919. /**
  3920. * Creates an Arc object from the three given points : start, middle and end.
  3921. * @param startPoint Defines the start point of the arc
  3922. * @param midPoint Defines the midlle point of the arc
  3923. * @param endPoint Defines the end point of the arc
  3924. */
  3925. constructor(
  3926. /** Defines the start point of the arc */
  3927. startPoint: Vector2,
  3928. /** Defines the mid point of the arc */
  3929. midPoint: Vector2,
  3930. /** Defines the end point of the arc */
  3931. endPoint: Vector2);
  3932. }
  3933. /**
  3934. * Represents a 2D path made up of multiple 2D points
  3935. */
  3936. export class Path2 {
  3937. private _points;
  3938. private _length;
  3939. /**
  3940. * If the path start and end point are the same
  3941. */
  3942. closed: boolean;
  3943. /**
  3944. * Creates a Path2 object from the starting 2D coordinates x and y.
  3945. * @param x the starting points x value
  3946. * @param y the starting points y value
  3947. */
  3948. constructor(x: number, y: number);
  3949. /**
  3950. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3951. * @param x the added points x value
  3952. * @param y the added points y value
  3953. * @returns the updated Path2.
  3954. */
  3955. addLineTo(x: number, y: number): Path2;
  3956. /**
  3957. * 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.
  3958. * @param midX middle point x value
  3959. * @param midY middle point y value
  3960. * @param endX end point x value
  3961. * @param endY end point y value
  3962. * @param numberOfSegments (default: 36)
  3963. * @returns the updated Path2.
  3964. */
  3965. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3966. /**
  3967. * Closes the Path2.
  3968. * @returns the Path2.
  3969. */
  3970. close(): Path2;
  3971. /**
  3972. * Gets the sum of the distance between each sequential point in the path
  3973. * @returns the Path2 total length (float).
  3974. */
  3975. length(): number;
  3976. /**
  3977. * Gets the points which construct the path
  3978. * @returns the Path2 internal array of points.
  3979. */
  3980. getPoints(): Vector2[];
  3981. /**
  3982. * Retreives the point at the distance aways from the starting point
  3983. * @param normalizedLengthPosition the length along the path to retreive the point from
  3984. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3985. */
  3986. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3987. /**
  3988. * Creates a new path starting from an x and y position
  3989. * @param x starting x value
  3990. * @param y starting y value
  3991. * @returns a new Path2 starting at the coordinates (x, y).
  3992. */
  3993. static StartingAt(x: number, y: number): Path2;
  3994. }
  3995. /**
  3996. * Represents a 3D path made up of multiple 3D points
  3997. */
  3998. export class Path3D {
  3999. /**
  4000. * an array of Vector3, the curve axis of the Path3D
  4001. */
  4002. path: Vector3[];
  4003. private _curve;
  4004. private _distances;
  4005. private _tangents;
  4006. private _normals;
  4007. private _binormals;
  4008. private _raw;
  4009. /**
  4010. * new Path3D(path, normal, raw)
  4011. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4012. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4013. * @param path an array of Vector3, the curve axis of the Path3D
  4014. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4015. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4016. */
  4017. constructor(
  4018. /**
  4019. * an array of Vector3, the curve axis of the Path3D
  4020. */
  4021. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4022. /**
  4023. * Returns the Path3D array of successive Vector3 designing its curve.
  4024. * @returns the Path3D array of successive Vector3 designing its curve.
  4025. */
  4026. getCurve(): Vector3[];
  4027. /**
  4028. * Returns an array populated with tangent vectors on each Path3D curve point.
  4029. * @returns an array populated with tangent vectors on each Path3D curve point.
  4030. */
  4031. getTangents(): Vector3[];
  4032. /**
  4033. * Returns an array populated with normal vectors on each Path3D curve point.
  4034. * @returns an array populated with normal vectors on each Path3D curve point.
  4035. */
  4036. getNormals(): Vector3[];
  4037. /**
  4038. * Returns an array populated with binormal vectors on each Path3D curve point.
  4039. * @returns an array populated with binormal vectors on each Path3D curve point.
  4040. */
  4041. getBinormals(): Vector3[];
  4042. /**
  4043. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4044. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4045. */
  4046. getDistances(): number[];
  4047. /**
  4048. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4049. * @param path path which all values are copied into the curves points
  4050. * @param firstNormal which should be projected onto the curve
  4051. * @returns the same object updated.
  4052. */
  4053. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4054. private _compute;
  4055. private _getFirstNonNullVector;
  4056. private _getLastNonNullVector;
  4057. private _normalVector;
  4058. }
  4059. /**
  4060. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4061. * A Curve3 is designed from a series of successive Vector3.
  4062. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4063. */
  4064. export class Curve3 {
  4065. private _points;
  4066. private _length;
  4067. /**
  4068. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4069. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4070. * @param v1 (Vector3) the control point
  4071. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4072. * @param nbPoints (integer) the wanted number of points in the curve
  4073. * @returns the created Curve3
  4074. */
  4075. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4076. /**
  4077. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4078. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4079. * @param v1 (Vector3) the first control point
  4080. * @param v2 (Vector3) the second control point
  4081. * @param v3 (Vector3) the end point of the Cubic Bezier
  4082. * @param nbPoints (integer) the wanted number of points in the curve
  4083. * @returns the created Curve3
  4084. */
  4085. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4086. /**
  4087. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4088. * @param p1 (Vector3) the origin point of the Hermite Spline
  4089. * @param t1 (Vector3) the tangent vector at the origin point
  4090. * @param p2 (Vector3) the end point of the Hermite Spline
  4091. * @param t2 (Vector3) the tangent vector at the end point
  4092. * @param nbPoints (integer) the wanted number of points in the curve
  4093. * @returns the created Curve3
  4094. */
  4095. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4096. /**
  4097. * Returns a Curve3 object along a CatmullRom Spline curve :
  4098. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4099. * @param nbPoints (integer) the wanted number of points between each curve control points
  4100. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4101. * @returns the created Curve3
  4102. */
  4103. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4104. /**
  4105. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4106. * A Curve3 is designed from a series of successive Vector3.
  4107. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4108. * @param points points which make up the curve
  4109. */
  4110. constructor(points: Vector3[]);
  4111. /**
  4112. * @returns the Curve3 stored array of successive Vector3
  4113. */
  4114. getPoints(): Vector3[];
  4115. /**
  4116. * @returns the computed length (float) of the curve.
  4117. */
  4118. length(): number;
  4119. /**
  4120. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4121. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4122. * curveA and curveB keep unchanged.
  4123. * @param curve the curve to continue from this curve
  4124. * @returns the newly constructed curve
  4125. */
  4126. continue(curve: DeepImmutable<Curve3>): Curve3;
  4127. private _computeLength;
  4128. }
  4129. /**
  4130. * Contains position and normal vectors for a vertex
  4131. */
  4132. export class PositionNormalVertex {
  4133. /** the position of the vertex (defaut: 0,0,0) */
  4134. position: Vector3;
  4135. /** the normal of the vertex (defaut: 0,1,0) */
  4136. normal: Vector3;
  4137. /**
  4138. * Creates a PositionNormalVertex
  4139. * @param position the position of the vertex (defaut: 0,0,0)
  4140. * @param normal the normal of the vertex (defaut: 0,1,0)
  4141. */
  4142. constructor(
  4143. /** the position of the vertex (defaut: 0,0,0) */
  4144. position?: Vector3,
  4145. /** the normal of the vertex (defaut: 0,1,0) */
  4146. normal?: Vector3);
  4147. /**
  4148. * Clones the PositionNormalVertex
  4149. * @returns the cloned PositionNormalVertex
  4150. */
  4151. clone(): PositionNormalVertex;
  4152. }
  4153. /**
  4154. * Contains position, normal and uv vectors for a vertex
  4155. */
  4156. export class PositionNormalTextureVertex {
  4157. /** the position of the vertex (defaut: 0,0,0) */
  4158. position: Vector3;
  4159. /** the normal of the vertex (defaut: 0,1,0) */
  4160. normal: Vector3;
  4161. /** the uv of the vertex (default: 0,0) */
  4162. uv: Vector2;
  4163. /**
  4164. * Creates a PositionNormalTextureVertex
  4165. * @param position the position of the vertex (defaut: 0,0,0)
  4166. * @param normal the normal of the vertex (defaut: 0,1,0)
  4167. * @param uv the uv of the vertex (default: 0,0)
  4168. */
  4169. constructor(
  4170. /** the position of the vertex (defaut: 0,0,0) */
  4171. position?: Vector3,
  4172. /** the normal of the vertex (defaut: 0,1,0) */
  4173. normal?: Vector3,
  4174. /** the uv of the vertex (default: 0,0) */
  4175. uv?: Vector2);
  4176. /**
  4177. * Clones the PositionNormalTextureVertex
  4178. * @returns the cloned PositionNormalTextureVertex
  4179. */
  4180. clone(): PositionNormalTextureVertex;
  4181. }
  4182. /**
  4183. * @hidden
  4184. */
  4185. export class Tmp {
  4186. static Color3: Color3[];
  4187. static Color4: Color4[];
  4188. static Vector2: Vector2[];
  4189. static Vector3: Vector3[];
  4190. static Vector4: Vector4[];
  4191. static Quaternion: Quaternion[];
  4192. static Matrix: Matrix[];
  4193. }
  4194. }
  4195. declare module BABYLON {
  4196. /**
  4197. * Class used to enable access to offline support
  4198. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4199. */
  4200. export interface IOfflineProvider {
  4201. /**
  4202. * Gets a boolean indicating if scene must be saved in the database
  4203. */
  4204. enableSceneOffline: boolean;
  4205. /**
  4206. * Gets a boolean indicating if textures must be saved in the database
  4207. */
  4208. enableTexturesOffline: boolean;
  4209. /**
  4210. * Open the offline support and make it available
  4211. * @param successCallback defines the callback to call on success
  4212. * @param errorCallback defines the callback to call on error
  4213. */
  4214. open(successCallback: () => void, errorCallback: () => void): void;
  4215. /**
  4216. * Loads an image from the offline support
  4217. * @param url defines the url to load from
  4218. * @param image defines the target DOM image
  4219. */
  4220. loadImage(url: string, image: HTMLImageElement): void;
  4221. /**
  4222. * Loads a file from offline support
  4223. * @param url defines the URL to load from
  4224. * @param sceneLoaded defines a callback to call on success
  4225. * @param progressCallBack defines a callback to call when progress changed
  4226. * @param errorCallback defines a callback to call on error
  4227. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4228. */
  4229. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4230. }
  4231. }
  4232. declare module BABYLON {
  4233. /**
  4234. * A class serves as a medium between the observable and its observers
  4235. */
  4236. export class EventState {
  4237. /**
  4238. * Create a new EventState
  4239. * @param mask defines the mask associated with this state
  4240. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4241. * @param target defines the original target of the state
  4242. * @param currentTarget defines the current target of the state
  4243. */
  4244. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4245. /**
  4246. * Initialize the current event state
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. * @returns the current event state
  4252. */
  4253. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4254. /**
  4255. * An Observer can set this property to true to prevent subsequent observers of being notified
  4256. */
  4257. skipNextObservers: boolean;
  4258. /**
  4259. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4260. */
  4261. mask: number;
  4262. /**
  4263. * The object that originally notified the event
  4264. */
  4265. target?: any;
  4266. /**
  4267. * The current object in the bubbling phase
  4268. */
  4269. currentTarget?: any;
  4270. /**
  4271. * This will be populated with the return value of the last function that was executed.
  4272. * If it is the first function in the callback chain it will be the event data.
  4273. */
  4274. lastReturnValue?: any;
  4275. }
  4276. /**
  4277. * Represent an Observer registered to a given Observable object.
  4278. */
  4279. export class Observer<T> {
  4280. /**
  4281. * Defines the callback to call when the observer is notified
  4282. */
  4283. callback: (eventData: T, eventState: EventState) => void;
  4284. /**
  4285. * Defines the mask of the observer (used to filter notifications)
  4286. */
  4287. mask: number;
  4288. /**
  4289. * Defines the current scope used to restore the JS context
  4290. */
  4291. scope: any;
  4292. /** @hidden */
  4293. _willBeUnregistered: boolean;
  4294. /**
  4295. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4296. */
  4297. unregisterOnNextCall: boolean;
  4298. /**
  4299. * Creates a new observer
  4300. * @param callback defines the callback to call when the observer is notified
  4301. * @param mask defines the mask of the observer (used to filter notifications)
  4302. * @param scope defines the current scope used to restore the JS context
  4303. */
  4304. constructor(
  4305. /**
  4306. * Defines the callback to call when the observer is notified
  4307. */
  4308. callback: (eventData: T, eventState: EventState) => void,
  4309. /**
  4310. * Defines the mask of the observer (used to filter notifications)
  4311. */
  4312. mask: number,
  4313. /**
  4314. * Defines the current scope used to restore the JS context
  4315. */
  4316. scope?: any);
  4317. }
  4318. /**
  4319. * Represent a list of observers registered to multiple Observables object.
  4320. */
  4321. export class MultiObserver<T> {
  4322. private _observers;
  4323. private _observables;
  4324. /**
  4325. * Release associated resources
  4326. */
  4327. dispose(): void;
  4328. /**
  4329. * Raise a callback when one of the observable will notify
  4330. * @param observables defines a list of observables to watch
  4331. * @param callback defines the callback to call on notification
  4332. * @param mask defines the mask used to filter notifications
  4333. * @param scope defines the current scope used to restore the JS context
  4334. * @returns the new MultiObserver
  4335. */
  4336. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4337. }
  4338. /**
  4339. * The Observable class is a simple implementation of the Observable pattern.
  4340. *
  4341. * 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.
  4342. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4343. * 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).
  4344. * 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.
  4345. */
  4346. export class Observable<T> {
  4347. private _observers;
  4348. private _eventState;
  4349. private _onObserverAdded;
  4350. /**
  4351. * Creates a new observable
  4352. * @param onObserverAdded defines a callback to call when a new observer is added
  4353. */
  4354. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4355. /**
  4356. * Create a new Observer with the specified callback
  4357. * @param callback the callback that will be executed for that Observer
  4358. * @param mask the mask used to filter observers
  4359. * @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.
  4360. * @param scope optional scope for the callback to be called from
  4361. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4362. * @returns the new observer created for the callback
  4363. */
  4364. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4365. /**
  4366. * Create a new Observer with the specified callback and unregisters after the next notification
  4367. * @param callback the callback that will be executed for that Observer
  4368. * @returns the new observer created for the callback
  4369. */
  4370. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4371. /**
  4372. * Remove an Observer from the Observable object
  4373. * @param observer the instance of the Observer to remove
  4374. * @returns false if it doesn't belong to this Observable
  4375. */
  4376. remove(observer: Nullable<Observer<T>>): boolean;
  4377. /**
  4378. * Remove a callback from the Observable object
  4379. * @param callback the callback to remove
  4380. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4381. * @returns false if it doesn't belong to this Observable
  4382. */
  4383. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4384. private _deferUnregister;
  4385. private _remove;
  4386. /**
  4387. * Moves the observable to the top of the observer list making it get called first when notified
  4388. * @param observer the observer to move
  4389. */
  4390. makeObserverTopPriority(observer: Observer<T>): void;
  4391. /**
  4392. * Moves the observable to the bottom of the observer list making it get called last when notified
  4393. * @param observer the observer to move
  4394. */
  4395. makeObserverBottomPriority(observer: Observer<T>): void;
  4396. /**
  4397. * Notify all Observers by calling their respective callback with the given data
  4398. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4399. * @param eventData defines the data to send to all observers
  4400. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4401. * @param target defines the original target of the state
  4402. * @param currentTarget defines the current target of the state
  4403. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4404. */
  4405. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4406. /**
  4407. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4408. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4409. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4410. * and it is crucial that all callbacks will be executed.
  4411. * The order of the callbacks is kept, callbacks are not executed parallel.
  4412. *
  4413. * @param eventData The data to be sent to each callback
  4414. * @param mask is used to filter observers defaults to -1
  4415. * @param target defines the callback target (see EventState)
  4416. * @param currentTarget defines he current object in the bubbling phase
  4417. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4418. */
  4419. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4420. /**
  4421. * Notify a specific observer
  4422. * @param observer defines the observer to notify
  4423. * @param eventData defines the data to be sent to each callback
  4424. * @param mask is used to filter observers defaults to -1
  4425. */
  4426. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4427. /**
  4428. * Gets a boolean indicating if the observable has at least one observer
  4429. * @returns true is the Observable has at least one Observer registered
  4430. */
  4431. hasObservers(): boolean;
  4432. /**
  4433. * Clear the list of observers
  4434. */
  4435. clear(): void;
  4436. /**
  4437. * Clone the current observable
  4438. * @returns a new observable
  4439. */
  4440. clone(): Observable<T>;
  4441. /**
  4442. * Does this observable handles observer registered with a given mask
  4443. * @param mask defines the mask to be tested
  4444. * @return whether or not one observer registered with the given mask is handeled
  4445. **/
  4446. hasSpecificMask(mask?: number): boolean;
  4447. }
  4448. }
  4449. declare module BABYLON {
  4450. /**
  4451. * Class used to help managing file picking and drag'n'drop
  4452. * File Storage
  4453. */
  4454. export class FilesInputStore {
  4455. /**
  4456. * List of files ready to be loaded
  4457. */
  4458. static FilesToLoad: {
  4459. [key: string]: File;
  4460. };
  4461. }
  4462. }
  4463. declare module BABYLON {
  4464. /** Defines the cross module used constants to avoid circular dependncies */
  4465. export class Constants {
  4466. /** Defines that alpha blending is disabled */
  4467. static readonly ALPHA_DISABLE: number;
  4468. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4469. static readonly ALPHA_ADD: number;
  4470. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4471. static readonly ALPHA_COMBINE: number;
  4472. /** Defines that alpha blending to DEST - SRC * DEST */
  4473. static readonly ALPHA_SUBTRACT: number;
  4474. /** Defines that alpha blending to SRC * DEST */
  4475. static readonly ALPHA_MULTIPLY: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4477. static readonly ALPHA_MAXIMIZED: number;
  4478. /** Defines that alpha blending to SRC + DEST */
  4479. static readonly ALPHA_ONEONE: number;
  4480. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4481. static readonly ALPHA_PREMULTIPLIED: number;
  4482. /**
  4483. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4484. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4485. */
  4486. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4487. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4488. static readonly ALPHA_INTERPOLATE: number;
  4489. /**
  4490. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4491. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4492. */
  4493. static readonly ALPHA_SCREENMODE: number;
  4494. /** Defines that the ressource is not delayed*/
  4495. static readonly DELAYLOADSTATE_NONE: number;
  4496. /** Defines that the ressource was successfully delay loaded */
  4497. static readonly DELAYLOADSTATE_LOADED: number;
  4498. /** Defines that the ressource is currently delay loading */
  4499. static readonly DELAYLOADSTATE_LOADING: number;
  4500. /** Defines that the ressource is delayed and has not started loading */
  4501. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4502. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4503. static readonly NEVER: number;
  4504. /** 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 */
  4505. static readonly ALWAYS: number;
  4506. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4507. static readonly LESS: number;
  4508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4509. static readonly EQUAL: number;
  4510. /** 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 */
  4511. static readonly LEQUAL: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4513. static readonly GREATER: number;
  4514. /** 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 */
  4515. static readonly GEQUAL: number;
  4516. /** 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 */
  4517. static readonly NOTEQUAL: number;
  4518. /** Passed to stencilOperation to specify that stencil value must be kept */
  4519. static readonly KEEP: number;
  4520. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4521. static readonly REPLACE: number;
  4522. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4523. static readonly INCR: number;
  4524. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4525. static readonly DECR: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4527. static readonly INVERT: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4529. static readonly INCR_WRAP: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4531. static readonly DECR_WRAP: number;
  4532. /** Texture is not repeating outside of 0..1 UVs */
  4533. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4534. /** Texture is repeating outside of 0..1 UVs */
  4535. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4536. /** Texture is repeating and mirrored */
  4537. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4538. /** ALPHA */
  4539. static readonly TEXTUREFORMAT_ALPHA: number;
  4540. /** LUMINANCE */
  4541. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4542. /** LUMINANCE_ALPHA */
  4543. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4544. /** RGB */
  4545. static readonly TEXTUREFORMAT_RGB: number;
  4546. /** RGBA */
  4547. static readonly TEXTUREFORMAT_RGBA: number;
  4548. /** RED */
  4549. static readonly TEXTUREFORMAT_RED: number;
  4550. /** RED (2nd reference) */
  4551. static readonly TEXTUREFORMAT_R: number;
  4552. /** RG */
  4553. static readonly TEXTUREFORMAT_RG: number;
  4554. /** RED_INTEGER */
  4555. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4556. /** RED_INTEGER (2nd reference) */
  4557. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4558. /** RG_INTEGER */
  4559. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4560. /** RGB_INTEGER */
  4561. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4562. /** RGBA_INTEGER */
  4563. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4564. /** UNSIGNED_BYTE */
  4565. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4566. /** UNSIGNED_BYTE (2nd reference) */
  4567. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4568. /** FLOAT */
  4569. static readonly TEXTURETYPE_FLOAT: number;
  4570. /** HALF_FLOAT */
  4571. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4572. /** BYTE */
  4573. static readonly TEXTURETYPE_BYTE: number;
  4574. /** SHORT */
  4575. static readonly TEXTURETYPE_SHORT: number;
  4576. /** UNSIGNED_SHORT */
  4577. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4578. /** INT */
  4579. static readonly TEXTURETYPE_INT: number;
  4580. /** UNSIGNED_INT */
  4581. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4582. /** UNSIGNED_SHORT_4_4_4_4 */
  4583. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4584. /** UNSIGNED_SHORT_5_5_5_1 */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4586. /** UNSIGNED_SHORT_5_6_5 */
  4587. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4588. /** UNSIGNED_INT_2_10_10_10_REV */
  4589. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4590. /** UNSIGNED_INT_24_8 */
  4591. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4592. /** UNSIGNED_INT_10F_11F_11F_REV */
  4593. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4594. /** UNSIGNED_INT_5_9_9_9_REV */
  4595. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4596. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4597. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4598. /** nearest is mag = nearest and min = nearest and mip = linear */
  4599. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4600. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4601. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4602. /** Trilinear is mag = linear and min = linear and mip = linear */
  4603. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4604. /** nearest is mag = nearest and min = nearest and mip = linear */
  4605. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4606. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4607. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4608. /** Trilinear is mag = linear and min = linear and mip = linear */
  4609. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4610. /** mag = nearest and min = nearest and mip = nearest */
  4611. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4612. /** mag = nearest and min = linear and mip = nearest */
  4613. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4614. /** mag = nearest and min = linear and mip = linear */
  4615. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4616. /** mag = nearest and min = linear and mip = none */
  4617. static readonly TEXTURE_NEAREST_LINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = none */
  4619. static readonly TEXTURE_NEAREST_NEAREST: number;
  4620. /** mag = linear and min = nearest and mip = nearest */
  4621. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4622. /** mag = linear and min = nearest and mip = linear */
  4623. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4624. /** mag = linear and min = linear and mip = none */
  4625. static readonly TEXTURE_LINEAR_LINEAR: number;
  4626. /** mag = linear and min = nearest and mip = none */
  4627. static readonly TEXTURE_LINEAR_NEAREST: number;
  4628. /** Explicit coordinates mode */
  4629. static readonly TEXTURE_EXPLICIT_MODE: number;
  4630. /** Spherical coordinates mode */
  4631. static readonly TEXTURE_SPHERICAL_MODE: number;
  4632. /** Planar coordinates mode */
  4633. static readonly TEXTURE_PLANAR_MODE: number;
  4634. /** Cubic coordinates mode */
  4635. static readonly TEXTURE_CUBIC_MODE: number;
  4636. /** Projection coordinates mode */
  4637. static readonly TEXTURE_PROJECTION_MODE: number;
  4638. /** Skybox coordinates mode */
  4639. static readonly TEXTURE_SKYBOX_MODE: number;
  4640. /** Inverse Cubic coordinates mode */
  4641. static readonly TEXTURE_INVCUBIC_MODE: number;
  4642. /** Equirectangular coordinates mode */
  4643. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4644. /** Equirectangular Fixed coordinates mode */
  4645. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4646. /** Equirectangular Fixed Mirrored coordinates mode */
  4647. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4648. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4649. static readonly SCALEMODE_FLOOR: number;
  4650. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4651. static readonly SCALEMODE_NEAREST: number;
  4652. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4653. static readonly SCALEMODE_CEILING: number;
  4654. /**
  4655. * The dirty texture flag value
  4656. */
  4657. static readonly MATERIAL_TextureDirtyFlag: number;
  4658. /**
  4659. * The dirty light flag value
  4660. */
  4661. static readonly MATERIAL_LightDirtyFlag: number;
  4662. /**
  4663. * The dirty fresnel flag value
  4664. */
  4665. static readonly MATERIAL_FresnelDirtyFlag: number;
  4666. /**
  4667. * The dirty attribute flag value
  4668. */
  4669. static readonly MATERIAL_AttributesDirtyFlag: number;
  4670. /**
  4671. * The dirty misc flag value
  4672. */
  4673. static readonly MATERIAL_MiscDirtyFlag: number;
  4674. /**
  4675. * The all dirty flag value
  4676. */
  4677. static readonly MATERIAL_AllDirtyFlag: number;
  4678. /**
  4679. * Returns the triangle fill mode
  4680. */
  4681. static readonly MATERIAL_TriangleFillMode: number;
  4682. /**
  4683. * Returns the wireframe mode
  4684. */
  4685. static readonly MATERIAL_WireFrameFillMode: number;
  4686. /**
  4687. * Returns the point fill mode
  4688. */
  4689. static readonly MATERIAL_PointFillMode: number;
  4690. /**
  4691. * Returns the point list draw mode
  4692. */
  4693. static readonly MATERIAL_PointListDrawMode: number;
  4694. /**
  4695. * Returns the line list draw mode
  4696. */
  4697. static readonly MATERIAL_LineListDrawMode: number;
  4698. /**
  4699. * Returns the line loop draw mode
  4700. */
  4701. static readonly MATERIAL_LineLoopDrawMode: number;
  4702. /**
  4703. * Returns the line strip draw mode
  4704. */
  4705. static readonly MATERIAL_LineStripDrawMode: number;
  4706. /**
  4707. * Returns the triangle strip draw mode
  4708. */
  4709. static readonly MATERIAL_TriangleStripDrawMode: number;
  4710. /**
  4711. * Returns the triangle fan draw mode
  4712. */
  4713. static readonly MATERIAL_TriangleFanDrawMode: number;
  4714. /**
  4715. * Stores the clock-wise side orientation
  4716. */
  4717. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4718. /**
  4719. * Stores the counter clock-wise side orientation
  4720. */
  4721. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4722. /**
  4723. * Nothing
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_NothingTrigger: number;
  4727. /**
  4728. * On pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnPickTrigger: number;
  4732. /**
  4733. * On left pick
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnLeftPickTrigger: number;
  4737. /**
  4738. * On right pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnRightPickTrigger: number;
  4742. /**
  4743. * On center pick
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnCenterPickTrigger: number;
  4747. /**
  4748. * On pick down
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnPickDownTrigger: number;
  4752. /**
  4753. * On double pick
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnDoublePickTrigger: number;
  4757. /**
  4758. * On pick up
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnPickUpTrigger: number;
  4762. /**
  4763. * On pick out.
  4764. * This trigger will only be raised if you also declared a OnPickDown
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPickOutTrigger: number;
  4768. /**
  4769. * On long press
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnLongPressTrigger: number;
  4773. /**
  4774. * On pointer over
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnPointerOverTrigger: number;
  4778. /**
  4779. * On pointer out
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnPointerOutTrigger: number;
  4783. /**
  4784. * On every frame
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnEveryFrameTrigger: number;
  4788. /**
  4789. * On intersection enter
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4793. /**
  4794. * On intersection exit
  4795. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4796. */
  4797. static readonly ACTION_OnIntersectionExitTrigger: number;
  4798. /**
  4799. * On key down
  4800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4801. */
  4802. static readonly ACTION_OnKeyDownTrigger: number;
  4803. /**
  4804. * On key up
  4805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4806. */
  4807. static readonly ACTION_OnKeyUpTrigger: number;
  4808. /**
  4809. * Billboard mode will only apply to Y axis
  4810. */
  4811. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4812. /**
  4813. * Billboard mode will apply to all axes
  4814. */
  4815. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4816. /**
  4817. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4820. /**
  4821. * Gets or sets base Assets URL
  4822. */
  4823. static readonly PARTICLES_BaseAssetsUrl: string;
  4824. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4825. * Test order :
  4826. * Is the bounding sphere outside the frustum ?
  4827. * If not, are the bounding box vertices outside the frustum ?
  4828. * It not, then the cullable object is in the frustum.
  4829. */
  4830. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4831. /** Culling strategy : Bounding Sphere Only.
  4832. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4833. * It's also less accurate than the standard because some not visible objects can still be selected.
  4834. * Test : is the bounding sphere outside the frustum ?
  4835. * If not, then the cullable object is in the frustum.
  4836. */
  4837. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4838. /** Culling strategy : Optimistic Inclusion.
  4839. * This in an inclusion test first, then the standard exclusion test.
  4840. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4841. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4842. * Anyway, it's as accurate as the standard strategy.
  4843. * Test :
  4844. * Is the cullable object bounding sphere center in the frustum ?
  4845. * If not, apply the default culling strategy.
  4846. */
  4847. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4848. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4849. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4850. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4851. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4852. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4853. * Test :
  4854. * Is the cullable object bounding sphere center in the frustum ?
  4855. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4856. */
  4857. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4858. /**
  4859. * No logging while loading
  4860. */
  4861. static readonly SCENELOADER_NO_LOGGING: number;
  4862. /**
  4863. * Minimal logging while loading
  4864. */
  4865. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4866. /**
  4867. * Summary logging while loading
  4868. */
  4869. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4870. /**
  4871. * Detailled logging while loading
  4872. */
  4873. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4874. }
  4875. }
  4876. declare module BABYLON {
  4877. /**
  4878. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4879. * Babylon.js
  4880. */
  4881. export class DomManagement {
  4882. /**
  4883. * Checks if the window object exists
  4884. * @returns true if the window object exists
  4885. */
  4886. static IsWindowObjectExist(): boolean;
  4887. /**
  4888. * Extracts text content from a DOM element hierarchy
  4889. * @param element defines the root element
  4890. * @returns a string
  4891. */
  4892. static GetDOMTextContent(element: HTMLElement): string;
  4893. }
  4894. }
  4895. declare module BABYLON {
  4896. /**
  4897. * Logger used througouht the application to allow configuration of
  4898. * the log level required for the messages.
  4899. */
  4900. export class Logger {
  4901. /**
  4902. * No log
  4903. */
  4904. static readonly NoneLogLevel: number;
  4905. /**
  4906. * Only message logs
  4907. */
  4908. static readonly MessageLogLevel: number;
  4909. /**
  4910. * Only warning logs
  4911. */
  4912. static readonly WarningLogLevel: number;
  4913. /**
  4914. * Only error logs
  4915. */
  4916. static readonly ErrorLogLevel: number;
  4917. /**
  4918. * All logs
  4919. */
  4920. static readonly AllLogLevel: number;
  4921. private static _LogCache;
  4922. /**
  4923. * Gets a value indicating the number of loading errors
  4924. * @ignorenaming
  4925. */
  4926. static errorsCount: number;
  4927. /**
  4928. * Callback called when a new log is added
  4929. */
  4930. static OnNewCacheEntry: (entry: string) => void;
  4931. private static _AddLogEntry;
  4932. private static _FormatMessage;
  4933. private static _LogDisabled;
  4934. private static _LogEnabled;
  4935. private static _WarnDisabled;
  4936. private static _WarnEnabled;
  4937. private static _ErrorDisabled;
  4938. private static _ErrorEnabled;
  4939. /**
  4940. * Log a message to the console
  4941. */
  4942. static Log: (message: string) => void;
  4943. /**
  4944. * Write a warning message to the console
  4945. */
  4946. static Warn: (message: string) => void;
  4947. /**
  4948. * Write an error message to the console
  4949. */
  4950. static Error: (message: string) => void;
  4951. /**
  4952. * Gets current log cache (list of logs)
  4953. */
  4954. static readonly LogCache: string;
  4955. /**
  4956. * Clears the log cache
  4957. */
  4958. static ClearLogCache(): void;
  4959. /**
  4960. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4961. */
  4962. static LogLevels: number;
  4963. }
  4964. }
  4965. declare module BABYLON {
  4966. /** @hidden */
  4967. export class _TypeStore {
  4968. /** @hidden */
  4969. static RegisteredTypes: {
  4970. [key: string]: Object;
  4971. };
  4972. /** @hidden */
  4973. static GetClass(fqdn: string): any;
  4974. }
  4975. }
  4976. declare module BABYLON {
  4977. /**
  4978. * Class containing a set of static utilities functions for deep copy.
  4979. */
  4980. export class DeepCopier {
  4981. /**
  4982. * Tries to copy an object by duplicating every property
  4983. * @param source defines the source object
  4984. * @param destination defines the target object
  4985. * @param doNotCopyList defines a list of properties to avoid
  4986. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4987. */
  4988. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4989. }
  4990. }
  4991. declare module BABYLON {
  4992. /**
  4993. * Class containing a set of static utilities functions for precision date
  4994. */
  4995. export class PrecisionDate {
  4996. /**
  4997. * Gets either window.performance.now() if supported or Date.now() else
  4998. */
  4999. static readonly Now: number;
  5000. }
  5001. }
  5002. declare module BABYLON {
  5003. /** @hidden */
  5004. export class _DevTools {
  5005. static WarnImport(name: string): string;
  5006. }
  5007. }
  5008. declare module BABYLON {
  5009. /**
  5010. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5011. */
  5012. export class WebRequest {
  5013. private _xhr;
  5014. /**
  5015. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5016. * i.e. when loading files, where the server/service expects an Authorization header
  5017. */
  5018. static CustomRequestHeaders: {
  5019. [key: string]: string;
  5020. };
  5021. /**
  5022. * Add callback functions in this array to update all the requests before they get sent to the network
  5023. */
  5024. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5025. private _injectCustomRequestHeaders;
  5026. /**
  5027. * Gets or sets a function to be called when loading progress changes
  5028. */
  5029. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5030. /**
  5031. * Returns client's state
  5032. */
  5033. readonly readyState: number;
  5034. /**
  5035. * Returns client's status
  5036. */
  5037. readonly status: number;
  5038. /**
  5039. * Returns client's status as a text
  5040. */
  5041. readonly statusText: string;
  5042. /**
  5043. * Returns client's response
  5044. */
  5045. readonly response: any;
  5046. /**
  5047. * Returns client's response url
  5048. */
  5049. readonly responseURL: string;
  5050. /**
  5051. * Returns client's response as text
  5052. */
  5053. readonly responseText: string;
  5054. /**
  5055. * Gets or sets the expected response type
  5056. */
  5057. responseType: XMLHttpRequestResponseType;
  5058. /** @hidden */
  5059. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5060. /** @hidden */
  5061. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5062. /**
  5063. * Cancels any network activity
  5064. */
  5065. abort(): void;
  5066. /**
  5067. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5068. * @param body defines an optional request body
  5069. */
  5070. send(body?: Document | BodyInit | null): void;
  5071. /**
  5072. * Sets the request method, request URL
  5073. * @param method defines the method to use (GET, POST, etc..)
  5074. * @param url defines the url to connect with
  5075. */
  5076. open(method: string, url: string): void;
  5077. }
  5078. }
  5079. declare module BABYLON {
  5080. /**
  5081. * Class used to evalaute queries containing `and` and `or` operators
  5082. */
  5083. export class AndOrNotEvaluator {
  5084. /**
  5085. * Evaluate a query
  5086. * @param query defines the query to evaluate
  5087. * @param evaluateCallback defines the callback used to filter result
  5088. * @returns true if the query matches
  5089. */
  5090. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5091. private static _HandleParenthesisContent;
  5092. private static _SimplifyNegation;
  5093. }
  5094. }
  5095. declare module BABYLON {
  5096. /**
  5097. * Class used to store custom tags
  5098. */
  5099. export class Tags {
  5100. /**
  5101. * Adds support for tags on the given object
  5102. * @param obj defines the object to use
  5103. */
  5104. static EnableFor(obj: any): void;
  5105. /**
  5106. * Removes tags support
  5107. * @param obj defines the object to use
  5108. */
  5109. static DisableFor(obj: any): void;
  5110. /**
  5111. * Gets a boolean indicating if the given object has tags
  5112. * @param obj defines the object to use
  5113. * @returns a boolean
  5114. */
  5115. static HasTags(obj: any): boolean;
  5116. /**
  5117. * Gets the tags available on a given object
  5118. * @param obj defines the object to use
  5119. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5120. * @returns the tags
  5121. */
  5122. static GetTags(obj: any, asString?: boolean): any;
  5123. /**
  5124. * Adds tags to an object
  5125. * @param obj defines the object to use
  5126. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5127. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5128. */
  5129. static AddTagsTo(obj: any, tagsString: string): void;
  5130. /**
  5131. * @hidden
  5132. */
  5133. static _AddTagTo(obj: any, tag: string): void;
  5134. /**
  5135. * Removes specific tags from a specific object
  5136. * @param obj defines the object to use
  5137. * @param tagsString defines the tags to remove
  5138. */
  5139. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5140. /**
  5141. * @hidden
  5142. */
  5143. static _RemoveTagFrom(obj: any, tag: string): void;
  5144. /**
  5145. * Defines if tags hosted on an object match a given query
  5146. * @param obj defines the object to use
  5147. * @param tagsQuery defines the tag query
  5148. * @returns a boolean
  5149. */
  5150. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5151. }
  5152. }
  5153. declare module BABYLON {
  5154. /**
  5155. * Manages the defines for the Material
  5156. */
  5157. export class MaterialDefines {
  5158. private _keys;
  5159. private _isDirty;
  5160. /** @hidden */
  5161. _renderId: number;
  5162. /** @hidden */
  5163. _areLightsDirty: boolean;
  5164. /** @hidden */
  5165. _areAttributesDirty: boolean;
  5166. /** @hidden */
  5167. _areTexturesDirty: boolean;
  5168. /** @hidden */
  5169. _areFresnelDirty: boolean;
  5170. /** @hidden */
  5171. _areMiscDirty: boolean;
  5172. /** @hidden */
  5173. _areImageProcessingDirty: boolean;
  5174. /** @hidden */
  5175. _normals: boolean;
  5176. /** @hidden */
  5177. _uvs: boolean;
  5178. /** @hidden */
  5179. _needNormals: boolean;
  5180. /** @hidden */
  5181. _needUVs: boolean;
  5182. /**
  5183. * Specifies if the material needs to be re-calculated
  5184. */
  5185. readonly isDirty: boolean;
  5186. /**
  5187. * Marks the material to indicate that it has been re-calculated
  5188. */
  5189. markAsProcessed(): void;
  5190. /**
  5191. * Marks the material to indicate that it needs to be re-calculated
  5192. */
  5193. markAsUnprocessed(): void;
  5194. /**
  5195. * Marks the material to indicate all of its defines need to be re-calculated
  5196. */
  5197. markAllAsDirty(): void;
  5198. /**
  5199. * Marks the material to indicate that image processing needs to be re-calculated
  5200. */
  5201. markAsImageProcessingDirty(): void;
  5202. /**
  5203. * Marks the material to indicate the lights need to be re-calculated
  5204. */
  5205. markAsLightDirty(): void;
  5206. /**
  5207. * Marks the attribute state as changed
  5208. */
  5209. markAsAttributesDirty(): void;
  5210. /**
  5211. * Marks the texture state as changed
  5212. */
  5213. markAsTexturesDirty(): void;
  5214. /**
  5215. * Marks the fresnel state as changed
  5216. */
  5217. markAsFresnelDirty(): void;
  5218. /**
  5219. * Marks the misc state as changed
  5220. */
  5221. markAsMiscDirty(): void;
  5222. /**
  5223. * Rebuilds the material defines
  5224. */
  5225. rebuild(): void;
  5226. /**
  5227. * Specifies if two material defines are equal
  5228. * @param other - A material define instance to compare to
  5229. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5230. */
  5231. isEqual(other: MaterialDefines): boolean;
  5232. /**
  5233. * Clones this instance's defines to another instance
  5234. * @param other - material defines to clone values to
  5235. */
  5236. cloneTo(other: MaterialDefines): void;
  5237. /**
  5238. * Resets the material define values
  5239. */
  5240. reset(): void;
  5241. /**
  5242. * Converts the material define values to a string
  5243. * @returns - String of material define information
  5244. */
  5245. toString(): string;
  5246. }
  5247. }
  5248. declare module BABYLON {
  5249. /**
  5250. * Class used to store and describe the pipeline context associated with an effect
  5251. */
  5252. export interface IPipelineContext {
  5253. /**
  5254. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5255. */
  5256. isAsync: boolean;
  5257. /**
  5258. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5259. */
  5260. isReady: boolean;
  5261. /** @hidden */
  5262. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5263. }
  5264. }
  5265. declare module BABYLON {
  5266. /**
  5267. * Class used to store gfx data (like WebGLBuffer)
  5268. */
  5269. export class DataBuffer {
  5270. /**
  5271. * Gets or sets the number of objects referencing this buffer
  5272. */
  5273. references: number;
  5274. /** Gets or sets the size of the underlying buffer */
  5275. capacity: number;
  5276. /**
  5277. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5278. */
  5279. is32Bits: boolean;
  5280. /**
  5281. * Gets the underlying buffer
  5282. */
  5283. readonly underlyingResource: any;
  5284. }
  5285. }
  5286. declare module BABYLON {
  5287. /**
  5288. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5289. */
  5290. export class PerformanceMonitor {
  5291. private _enabled;
  5292. private _rollingFrameTime;
  5293. private _lastFrameTimeMs;
  5294. /**
  5295. * constructor
  5296. * @param frameSampleSize The number of samples required to saturate the sliding window
  5297. */
  5298. constructor(frameSampleSize?: number);
  5299. /**
  5300. * Samples current frame
  5301. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5302. */
  5303. sampleFrame(timeMs?: number): void;
  5304. /**
  5305. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5306. */
  5307. readonly averageFrameTime: number;
  5308. /**
  5309. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5310. */
  5311. readonly averageFrameTimeVariance: number;
  5312. /**
  5313. * Returns the frame time of the most recent frame
  5314. */
  5315. readonly instantaneousFrameTime: number;
  5316. /**
  5317. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5318. */
  5319. readonly averageFPS: number;
  5320. /**
  5321. * Returns the average framerate in frames per second using the most recent frame time
  5322. */
  5323. readonly instantaneousFPS: number;
  5324. /**
  5325. * Returns true if enough samples have been taken to completely fill the sliding window
  5326. */
  5327. readonly isSaturated: boolean;
  5328. /**
  5329. * Enables contributions to the sliding window sample set
  5330. */
  5331. enable(): void;
  5332. /**
  5333. * Disables contributions to the sliding window sample set
  5334. * Samples will not be interpolated over the disabled period
  5335. */
  5336. disable(): void;
  5337. /**
  5338. * Returns true if sampling is enabled
  5339. */
  5340. readonly isEnabled: boolean;
  5341. /**
  5342. * Resets performance monitor
  5343. */
  5344. reset(): void;
  5345. }
  5346. /**
  5347. * RollingAverage
  5348. *
  5349. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5350. */
  5351. export class RollingAverage {
  5352. /**
  5353. * Current average
  5354. */
  5355. average: number;
  5356. /**
  5357. * Current variance
  5358. */
  5359. variance: number;
  5360. protected _samples: Array<number>;
  5361. protected _sampleCount: number;
  5362. protected _pos: number;
  5363. protected _m2: number;
  5364. /**
  5365. * constructor
  5366. * @param length The number of samples required to saturate the sliding window
  5367. */
  5368. constructor(length: number);
  5369. /**
  5370. * Adds a sample to the sample set
  5371. * @param v The sample value
  5372. */
  5373. add(v: number): void;
  5374. /**
  5375. * Returns previously added values or null if outside of history or outside the sliding window domain
  5376. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5377. * @return Value previously recorded with add() or null if outside of range
  5378. */
  5379. history(i: number): number;
  5380. /**
  5381. * Returns true if enough samples have been taken to completely fill the sliding window
  5382. * @return true if sample-set saturated
  5383. */
  5384. isSaturated(): boolean;
  5385. /**
  5386. * Resets the rolling average (equivalent to 0 samples taken so far)
  5387. */
  5388. reset(): void;
  5389. /**
  5390. * Wraps a value around the sample range boundaries
  5391. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5392. * @return Wrapped position in sample range
  5393. */
  5394. protected _wrapPosition(i: number): number;
  5395. }
  5396. }
  5397. declare module BABYLON {
  5398. /**
  5399. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5400. * The underlying implementation relies on an associative array to ensure the best performances.
  5401. * The value can be anything including 'null' but except 'undefined'
  5402. */
  5403. export class StringDictionary<T> {
  5404. /**
  5405. * This will clear this dictionary and copy the content from the 'source' one.
  5406. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5407. * @param source the dictionary to take the content from and copy to this dictionary
  5408. */
  5409. copyFrom(source: StringDictionary<T>): void;
  5410. /**
  5411. * Get a value based from its key
  5412. * @param key the given key to get the matching value from
  5413. * @return the value if found, otherwise undefined is returned
  5414. */
  5415. get(key: string): T | undefined;
  5416. /**
  5417. * Get a value from its key or add it if it doesn't exist.
  5418. * This method will ensure you that a given key/data will be present in the dictionary.
  5419. * @param key the given key to get the matching value from
  5420. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5421. * The factory will only be invoked if there's no data for the given key.
  5422. * @return the value corresponding to the key.
  5423. */
  5424. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5425. /**
  5426. * Get a value from its key if present in the dictionary otherwise add it
  5427. * @param key the key to get the value from
  5428. * @param val if there's no such key/value pair in the dictionary add it with this value
  5429. * @return the value corresponding to the key
  5430. */
  5431. getOrAdd(key: string, val: T): T;
  5432. /**
  5433. * Check if there's a given key in the dictionary
  5434. * @param key the key to check for
  5435. * @return true if the key is present, false otherwise
  5436. */
  5437. contains(key: string): boolean;
  5438. /**
  5439. * Add a new key and its corresponding value
  5440. * @param key the key to add
  5441. * @param value the value corresponding to the key
  5442. * @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
  5443. */
  5444. add(key: string, value: T): boolean;
  5445. /**
  5446. * Update a specific value associated to a key
  5447. * @param key defines the key to use
  5448. * @param value defines the value to store
  5449. * @returns true if the value was updated (or false if the key was not found)
  5450. */
  5451. set(key: string, value: T): boolean;
  5452. /**
  5453. * Get the element of the given key and remove it from the dictionary
  5454. * @param key defines the key to search
  5455. * @returns the value associated with the key or null if not found
  5456. */
  5457. getAndRemove(key: string): Nullable<T>;
  5458. /**
  5459. * Remove a key/value from the dictionary.
  5460. * @param key the key to remove
  5461. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5462. */
  5463. remove(key: string): boolean;
  5464. /**
  5465. * Clear the whole content of the dictionary
  5466. */
  5467. clear(): void;
  5468. /**
  5469. * Gets the current count
  5470. */
  5471. readonly count: number;
  5472. /**
  5473. * Execute a callback on each key/val of the dictionary.
  5474. * Note that you can remove any element in this dictionary in the callback implementation
  5475. * @param callback the callback to execute on a given key/value pair
  5476. */
  5477. forEach(callback: (key: string, val: T) => void): void;
  5478. /**
  5479. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5480. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5481. * Note that you can remove any element in this dictionary in the callback implementation
  5482. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5483. * @returns the first item
  5484. */
  5485. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5486. private _count;
  5487. private _data;
  5488. }
  5489. }
  5490. declare module BABYLON {
  5491. /**
  5492. * Helper class that provides a small promise polyfill
  5493. */
  5494. export class PromisePolyfill {
  5495. /**
  5496. * Static function used to check if the polyfill is required
  5497. * If this is the case then the function will inject the polyfill to window.Promise
  5498. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5499. */
  5500. static Apply(force?: boolean): void;
  5501. }
  5502. }
  5503. declare module BABYLON {
  5504. /**
  5505. * Class used to store data that will be store in GPU memory
  5506. */
  5507. export class Buffer {
  5508. private _engine;
  5509. private _buffer;
  5510. /** @hidden */
  5511. _data: Nullable<DataArray>;
  5512. private _updatable;
  5513. private _instanced;
  5514. /**
  5515. * Gets the byte stride.
  5516. */
  5517. readonly byteStride: number;
  5518. /**
  5519. * Constructor
  5520. * @param engine the engine
  5521. * @param data the data to use for this buffer
  5522. * @param updatable whether the data is updatable
  5523. * @param stride the stride (optional)
  5524. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5525. * @param instanced whether the buffer is instanced (optional)
  5526. * @param useBytes set to true if the stride in in bytes (optional)
  5527. */
  5528. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5529. /**
  5530. * Create a new VertexBuffer based on the current buffer
  5531. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5532. * @param offset defines offset in the buffer (0 by default)
  5533. * @param size defines the size in floats of attributes (position is 3 for instance)
  5534. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5535. * @param instanced defines if the vertex buffer contains indexed data
  5536. * @param useBytes defines if the offset and stride are in bytes
  5537. * @returns the new vertex buffer
  5538. */
  5539. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5540. /**
  5541. * Gets a boolean indicating if the Buffer is updatable?
  5542. * @returns true if the buffer is updatable
  5543. */
  5544. isUpdatable(): boolean;
  5545. /**
  5546. * Gets current buffer's data
  5547. * @returns a DataArray or null
  5548. */
  5549. getData(): Nullable<DataArray>;
  5550. /**
  5551. * Gets underlying native buffer
  5552. * @returns underlying native buffer
  5553. */
  5554. getBuffer(): Nullable<DataBuffer>;
  5555. /**
  5556. * Gets the stride in float32 units (i.e. byte stride / 4).
  5557. * May not be an integer if the byte stride is not divisible by 4.
  5558. * DEPRECATED. Use byteStride instead.
  5559. * @returns the stride in float32 units
  5560. */
  5561. getStrideSize(): number;
  5562. /**
  5563. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5564. * @param data defines the data to store
  5565. */
  5566. create(data?: Nullable<DataArray>): void;
  5567. /** @hidden */
  5568. _rebuild(): void;
  5569. /**
  5570. * Update current buffer data
  5571. * @param data defines the data to store
  5572. */
  5573. update(data: DataArray): void;
  5574. /**
  5575. * Updates the data directly.
  5576. * @param data the new data
  5577. * @param offset the new offset
  5578. * @param vertexCount the vertex count (optional)
  5579. * @param useBytes set to true if the offset is in bytes
  5580. */
  5581. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5582. /**
  5583. * Release all resources
  5584. */
  5585. dispose(): void;
  5586. }
  5587. /**
  5588. * Specialized buffer used to store vertex data
  5589. */
  5590. export class VertexBuffer {
  5591. /** @hidden */
  5592. _buffer: Buffer;
  5593. private _kind;
  5594. private _size;
  5595. private _ownsBuffer;
  5596. private _instanced;
  5597. private _instanceDivisor;
  5598. /**
  5599. * The byte type.
  5600. */
  5601. static readonly BYTE: number;
  5602. /**
  5603. * The unsigned byte type.
  5604. */
  5605. static readonly UNSIGNED_BYTE: number;
  5606. /**
  5607. * The short type.
  5608. */
  5609. static readonly SHORT: number;
  5610. /**
  5611. * The unsigned short type.
  5612. */
  5613. static readonly UNSIGNED_SHORT: number;
  5614. /**
  5615. * The integer type.
  5616. */
  5617. static readonly INT: number;
  5618. /**
  5619. * The unsigned integer type.
  5620. */
  5621. static readonly UNSIGNED_INT: number;
  5622. /**
  5623. * The float type.
  5624. */
  5625. static readonly FLOAT: number;
  5626. /**
  5627. * Gets or sets the instance divisor when in instanced mode
  5628. */
  5629. instanceDivisor: number;
  5630. /**
  5631. * Gets the byte stride.
  5632. */
  5633. readonly byteStride: number;
  5634. /**
  5635. * Gets the byte offset.
  5636. */
  5637. readonly byteOffset: number;
  5638. /**
  5639. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5640. */
  5641. readonly normalized: boolean;
  5642. /**
  5643. * Gets the data type of each component in the array.
  5644. */
  5645. readonly type: number;
  5646. /**
  5647. * Constructor
  5648. * @param engine the engine
  5649. * @param data the data to use for this vertex buffer
  5650. * @param kind the vertex buffer kind
  5651. * @param updatable whether the data is updatable
  5652. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5653. * @param stride the stride (optional)
  5654. * @param instanced whether the buffer is instanced (optional)
  5655. * @param offset the offset of the data (optional)
  5656. * @param size the number of components (optional)
  5657. * @param type the type of the component (optional)
  5658. * @param normalized whether the data contains normalized data (optional)
  5659. * @param useBytes set to true if stride and offset are in bytes (optional)
  5660. */
  5661. 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);
  5662. /** @hidden */
  5663. _rebuild(): void;
  5664. /**
  5665. * Returns the kind of the VertexBuffer (string)
  5666. * @returns a string
  5667. */
  5668. getKind(): string;
  5669. /**
  5670. * Gets a boolean indicating if the VertexBuffer is updatable?
  5671. * @returns true if the buffer is updatable
  5672. */
  5673. isUpdatable(): boolean;
  5674. /**
  5675. * Gets current buffer's data
  5676. * @returns a DataArray or null
  5677. */
  5678. getData(): Nullable<DataArray>;
  5679. /**
  5680. * Gets underlying native buffer
  5681. * @returns underlying native buffer
  5682. */
  5683. getBuffer(): Nullable<DataBuffer>;
  5684. /**
  5685. * Gets the stride in float32 units (i.e. byte stride / 4).
  5686. * May not be an integer if the byte stride is not divisible by 4.
  5687. * DEPRECATED. Use byteStride instead.
  5688. * @returns the stride in float32 units
  5689. */
  5690. getStrideSize(): number;
  5691. /**
  5692. * Returns the offset as a multiple of the type byte length.
  5693. * DEPRECATED. Use byteOffset instead.
  5694. * @returns the offset in bytes
  5695. */
  5696. getOffset(): number;
  5697. /**
  5698. * Returns the number of components per vertex attribute (integer)
  5699. * @returns the size in float
  5700. */
  5701. getSize(): number;
  5702. /**
  5703. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5704. * @returns true if this buffer is instanced
  5705. */
  5706. getIsInstanced(): boolean;
  5707. /**
  5708. * Returns the instancing divisor, zero for non-instanced (integer).
  5709. * @returns a number
  5710. */
  5711. getInstanceDivisor(): number;
  5712. /**
  5713. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5714. * @param data defines the data to store
  5715. */
  5716. create(data?: DataArray): void;
  5717. /**
  5718. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5719. * This function will create a new buffer if the current one is not updatable
  5720. * @param data defines the data to store
  5721. */
  5722. update(data: DataArray): void;
  5723. /**
  5724. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5725. * Returns the directly updated WebGLBuffer.
  5726. * @param data the new data
  5727. * @param offset the new offset
  5728. * @param useBytes set to true if the offset is in bytes
  5729. */
  5730. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5731. /**
  5732. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5733. */
  5734. dispose(): void;
  5735. /**
  5736. * Enumerates each value of this vertex buffer as numbers.
  5737. * @param count the number of values to enumerate
  5738. * @param callback the callback function called for each value
  5739. */
  5740. forEach(count: number, callback: (value: number, index: number) => void): void;
  5741. /**
  5742. * Positions
  5743. */
  5744. static readonly PositionKind: string;
  5745. /**
  5746. * Normals
  5747. */
  5748. static readonly NormalKind: string;
  5749. /**
  5750. * Tangents
  5751. */
  5752. static readonly TangentKind: string;
  5753. /**
  5754. * Texture coordinates
  5755. */
  5756. static readonly UVKind: string;
  5757. /**
  5758. * Texture coordinates 2
  5759. */
  5760. static readonly UV2Kind: string;
  5761. /**
  5762. * Texture coordinates 3
  5763. */
  5764. static readonly UV3Kind: string;
  5765. /**
  5766. * Texture coordinates 4
  5767. */
  5768. static readonly UV4Kind: string;
  5769. /**
  5770. * Texture coordinates 5
  5771. */
  5772. static readonly UV5Kind: string;
  5773. /**
  5774. * Texture coordinates 6
  5775. */
  5776. static readonly UV6Kind: string;
  5777. /**
  5778. * Colors
  5779. */
  5780. static readonly ColorKind: string;
  5781. /**
  5782. * Matrix indices (for bones)
  5783. */
  5784. static readonly MatricesIndicesKind: string;
  5785. /**
  5786. * Matrix weights (for bones)
  5787. */
  5788. static readonly MatricesWeightsKind: string;
  5789. /**
  5790. * Additional matrix indices (for bones)
  5791. */
  5792. static readonly MatricesIndicesExtraKind: string;
  5793. /**
  5794. * Additional matrix weights (for bones)
  5795. */
  5796. static readonly MatricesWeightsExtraKind: string;
  5797. /**
  5798. * Deduces the stride given a kind.
  5799. * @param kind The kind string to deduce
  5800. * @returns The deduced stride
  5801. */
  5802. static DeduceStride(kind: string): number;
  5803. /**
  5804. * Gets the byte length of the given type.
  5805. * @param type the type
  5806. * @returns the number of bytes
  5807. */
  5808. static GetTypeByteLength(type: number): number;
  5809. /**
  5810. * Enumerates each value of the given parameters as numbers.
  5811. * @param data the data to enumerate
  5812. * @param byteOffset the byte offset of the data
  5813. * @param byteStride the byte stride of the data
  5814. * @param componentCount the number of components per element
  5815. * @param componentType the type of the component
  5816. * @param count the total number of components
  5817. * @param normalized whether the data is normalized
  5818. * @param callback the callback function called for each value
  5819. */
  5820. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5821. private static _GetFloatValue;
  5822. }
  5823. }
  5824. declare module BABYLON {
  5825. /**
  5826. * Class representing spherical harmonics coefficients to the 3rd degree
  5827. */
  5828. export class SphericalHarmonics {
  5829. /**
  5830. * Defines whether or not the harmonics have been prescaled for rendering.
  5831. */
  5832. preScaled: boolean;
  5833. /**
  5834. * The l0,0 coefficients of the spherical harmonics
  5835. */
  5836. l00: Vector3;
  5837. /**
  5838. * The l1,-1 coefficients of the spherical harmonics
  5839. */
  5840. l1_1: Vector3;
  5841. /**
  5842. * The l1,0 coefficients of the spherical harmonics
  5843. */
  5844. l10: Vector3;
  5845. /**
  5846. * The l1,1 coefficients of the spherical harmonics
  5847. */
  5848. l11: Vector3;
  5849. /**
  5850. * The l2,-2 coefficients of the spherical harmonics
  5851. */
  5852. l2_2: Vector3;
  5853. /**
  5854. * The l2,-1 coefficients of the spherical harmonics
  5855. */
  5856. l2_1: Vector3;
  5857. /**
  5858. * The l2,0 coefficients of the spherical harmonics
  5859. */
  5860. l20: Vector3;
  5861. /**
  5862. * The l2,1 coefficients of the spherical harmonics
  5863. */
  5864. l21: Vector3;
  5865. /**
  5866. * The l2,2 coefficients of the spherical harmonics
  5867. */
  5868. l22: Vector3;
  5869. /**
  5870. * Adds a light to the spherical harmonics
  5871. * @param direction the direction of the light
  5872. * @param color the color of the light
  5873. * @param deltaSolidAngle the delta solid angle of the light
  5874. */
  5875. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5876. /**
  5877. * Scales the spherical harmonics by the given amount
  5878. * @param scale the amount to scale
  5879. */
  5880. scaleInPlace(scale: number): void;
  5881. /**
  5882. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5883. *
  5884. * ```
  5885. * E_lm = A_l * L_lm
  5886. * ```
  5887. *
  5888. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5889. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5890. * the scaling factors are given in equation 9.
  5891. */
  5892. convertIncidentRadianceToIrradiance(): void;
  5893. /**
  5894. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5895. *
  5896. * ```
  5897. * L = (1/pi) * E * rho
  5898. * ```
  5899. *
  5900. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5901. */
  5902. convertIrradianceToLambertianRadiance(): void;
  5903. /**
  5904. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5905. * required operations at run time.
  5906. *
  5907. * This is simply done by scaling back the SH with Ylm constants parameter.
  5908. * The trigonometric part being applied by the shader at run time.
  5909. */
  5910. preScaleForRendering(): void;
  5911. /**
  5912. * Constructs a spherical harmonics from an array.
  5913. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5914. * @returns the spherical harmonics
  5915. */
  5916. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5917. /**
  5918. * Gets the spherical harmonics from polynomial
  5919. * @param polynomial the spherical polynomial
  5920. * @returns the spherical harmonics
  5921. */
  5922. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5923. }
  5924. /**
  5925. * Class representing spherical polynomial coefficients to the 3rd degree
  5926. */
  5927. export class SphericalPolynomial {
  5928. private _harmonics;
  5929. /**
  5930. * The spherical harmonics used to create the polynomials.
  5931. */
  5932. readonly preScaledHarmonics: SphericalHarmonics;
  5933. /**
  5934. * The x coefficients of the spherical polynomial
  5935. */
  5936. x: Vector3;
  5937. /**
  5938. * The y coefficients of the spherical polynomial
  5939. */
  5940. y: Vector3;
  5941. /**
  5942. * The z coefficients of the spherical polynomial
  5943. */
  5944. z: Vector3;
  5945. /**
  5946. * The xx coefficients of the spherical polynomial
  5947. */
  5948. xx: Vector3;
  5949. /**
  5950. * The yy coefficients of the spherical polynomial
  5951. */
  5952. yy: Vector3;
  5953. /**
  5954. * The zz coefficients of the spherical polynomial
  5955. */
  5956. zz: Vector3;
  5957. /**
  5958. * The xy coefficients of the spherical polynomial
  5959. */
  5960. xy: Vector3;
  5961. /**
  5962. * The yz coefficients of the spherical polynomial
  5963. */
  5964. yz: Vector3;
  5965. /**
  5966. * The zx coefficients of the spherical polynomial
  5967. */
  5968. zx: Vector3;
  5969. /**
  5970. * Adds an ambient color to the spherical polynomial
  5971. * @param color the color to add
  5972. */
  5973. addAmbient(color: Color3): void;
  5974. /**
  5975. * Scales the spherical polynomial by the given amount
  5976. * @param scale the amount to scale
  5977. */
  5978. scaleInPlace(scale: number): void;
  5979. /**
  5980. * Gets the spherical polynomial from harmonics
  5981. * @param harmonics the spherical harmonics
  5982. * @returns the spherical polynomial
  5983. */
  5984. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5985. /**
  5986. * Constructs a spherical polynomial from an array.
  5987. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5988. * @returns the spherical polynomial
  5989. */
  5990. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5991. }
  5992. }
  5993. declare module BABYLON {
  5994. /**
  5995. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5996. */
  5997. export interface CubeMapInfo {
  5998. /**
  5999. * The pixel array for the front face.
  6000. * This is stored in format, left to right, up to down format.
  6001. */
  6002. front: Nullable<ArrayBufferView>;
  6003. /**
  6004. * The pixel array for the back face.
  6005. * This is stored in format, left to right, up to down format.
  6006. */
  6007. back: Nullable<ArrayBufferView>;
  6008. /**
  6009. * The pixel array for the left face.
  6010. * This is stored in format, left to right, up to down format.
  6011. */
  6012. left: Nullable<ArrayBufferView>;
  6013. /**
  6014. * The pixel array for the right face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. right: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The pixel array for the up face.
  6020. * This is stored in format, left to right, up to down format.
  6021. */
  6022. up: Nullable<ArrayBufferView>;
  6023. /**
  6024. * The pixel array for the down face.
  6025. * This is stored in format, left to right, up to down format.
  6026. */
  6027. down: Nullable<ArrayBufferView>;
  6028. /**
  6029. * The size of the cubemap stored.
  6030. *
  6031. * Each faces will be size * size pixels.
  6032. */
  6033. size: number;
  6034. /**
  6035. * The format of the texture.
  6036. *
  6037. * RGBA, RGB.
  6038. */
  6039. format: number;
  6040. /**
  6041. * The type of the texture data.
  6042. *
  6043. * UNSIGNED_INT, FLOAT.
  6044. */
  6045. type: number;
  6046. /**
  6047. * Specifies whether the texture is in gamma space.
  6048. */
  6049. gammaSpace: boolean;
  6050. }
  6051. /**
  6052. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6053. */
  6054. export class PanoramaToCubeMapTools {
  6055. private static FACE_FRONT;
  6056. private static FACE_BACK;
  6057. private static FACE_RIGHT;
  6058. private static FACE_LEFT;
  6059. private static FACE_DOWN;
  6060. private static FACE_UP;
  6061. /**
  6062. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6063. *
  6064. * @param float32Array The source data.
  6065. * @param inputWidth The width of the input panorama.
  6066. * @param inputHeight The height of the input panorama.
  6067. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6068. * @return The cubemap data
  6069. */
  6070. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6071. private static CreateCubemapTexture;
  6072. private static CalcProjectionSpherical;
  6073. }
  6074. }
  6075. declare module BABYLON {
  6076. /**
  6077. * Helper class dealing with the extraction of spherical polynomial dataArray
  6078. * from a cube map.
  6079. */
  6080. export class CubeMapToSphericalPolynomialTools {
  6081. private static FileFaces;
  6082. /**
  6083. * Converts a texture to the according Spherical Polynomial data.
  6084. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6085. *
  6086. * @param texture The texture to extract the information from.
  6087. * @return The Spherical Polynomial data.
  6088. */
  6089. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6090. /**
  6091. * Converts a cubemap to the according Spherical Polynomial data.
  6092. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6093. *
  6094. * @param cubeInfo The Cube map to extract the information from.
  6095. * @return The Spherical Polynomial data.
  6096. */
  6097. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. /**
  6102. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6103. * during the life time of the application.
  6104. */
  6105. export class EngineStore {
  6106. /** Gets the list of created engines */
  6107. static Instances: Engine[];
  6108. /** @hidden */
  6109. static _LastCreatedScene: Nullable<Scene>;
  6110. /**
  6111. * Gets the latest created engine
  6112. */
  6113. static readonly LastCreatedEngine: Nullable<Engine>;
  6114. /**
  6115. * Gets the latest created scene
  6116. */
  6117. static readonly LastCreatedScene: Nullable<Scene>;
  6118. }
  6119. }
  6120. declare module BABYLON {
  6121. /**
  6122. * Define options used to create a render target texture
  6123. */
  6124. export class RenderTargetCreationOptions {
  6125. /**
  6126. * Specifies is mipmaps must be generated
  6127. */
  6128. generateMipMaps?: boolean;
  6129. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6130. generateDepthBuffer?: boolean;
  6131. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6132. generateStencilBuffer?: boolean;
  6133. /** Defines texture type (int by default) */
  6134. type?: number;
  6135. /** Defines sampling mode (trilinear by default) */
  6136. samplingMode?: number;
  6137. /** Defines format (RGBA by default) */
  6138. format?: number;
  6139. }
  6140. }
  6141. declare module BABYLON {
  6142. /**
  6143. * @hidden
  6144. **/
  6145. export class _AlphaState {
  6146. private _isAlphaBlendDirty;
  6147. private _isBlendFunctionParametersDirty;
  6148. private _isBlendEquationParametersDirty;
  6149. private _isBlendConstantsDirty;
  6150. private _alphaBlend;
  6151. private _blendFunctionParameters;
  6152. private _blendEquationParameters;
  6153. private _blendConstants;
  6154. /**
  6155. * Initializes the state.
  6156. */
  6157. constructor();
  6158. readonly isDirty: boolean;
  6159. alphaBlend: boolean;
  6160. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6161. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6162. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6163. reset(): void;
  6164. apply(gl: WebGLRenderingContext): void;
  6165. }
  6166. }
  6167. declare module BABYLON {
  6168. /**
  6169. * @hidden
  6170. **/
  6171. export class _DepthCullingState {
  6172. private _isDepthTestDirty;
  6173. private _isDepthMaskDirty;
  6174. private _isDepthFuncDirty;
  6175. private _isCullFaceDirty;
  6176. private _isCullDirty;
  6177. private _isZOffsetDirty;
  6178. private _isFrontFaceDirty;
  6179. private _depthTest;
  6180. private _depthMask;
  6181. private _depthFunc;
  6182. private _cull;
  6183. private _cullFace;
  6184. private _zOffset;
  6185. private _frontFace;
  6186. /**
  6187. * Initializes the state.
  6188. */
  6189. constructor();
  6190. readonly isDirty: boolean;
  6191. zOffset: number;
  6192. cullFace: Nullable<number>;
  6193. cull: Nullable<boolean>;
  6194. depthFunc: Nullable<number>;
  6195. depthMask: boolean;
  6196. depthTest: boolean;
  6197. frontFace: Nullable<number>;
  6198. reset(): void;
  6199. apply(gl: WebGLRenderingContext): void;
  6200. }
  6201. }
  6202. declare module BABYLON {
  6203. /**
  6204. * @hidden
  6205. **/
  6206. export class _StencilState {
  6207. /** 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 */
  6208. static readonly ALWAYS: number;
  6209. /** Passed to stencilOperation to specify that stencil value must be kept */
  6210. static readonly KEEP: number;
  6211. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6212. static readonly REPLACE: number;
  6213. private _isStencilTestDirty;
  6214. private _isStencilMaskDirty;
  6215. private _isStencilFuncDirty;
  6216. private _isStencilOpDirty;
  6217. private _stencilTest;
  6218. private _stencilMask;
  6219. private _stencilFunc;
  6220. private _stencilFuncRef;
  6221. private _stencilFuncMask;
  6222. private _stencilOpStencilFail;
  6223. private _stencilOpDepthFail;
  6224. private _stencilOpStencilDepthPass;
  6225. readonly isDirty: boolean;
  6226. stencilFunc: number;
  6227. stencilFuncRef: number;
  6228. stencilFuncMask: number;
  6229. stencilOpStencilFail: number;
  6230. stencilOpDepthFail: number;
  6231. stencilOpStencilDepthPass: number;
  6232. stencilMask: number;
  6233. stencilTest: boolean;
  6234. constructor();
  6235. reset(): void;
  6236. apply(gl: WebGLRenderingContext): void;
  6237. }
  6238. }
  6239. declare module BABYLON {
  6240. /**
  6241. * @hidden
  6242. **/
  6243. export class _TimeToken {
  6244. _startTimeQuery: Nullable<WebGLQuery>;
  6245. _endTimeQuery: Nullable<WebGLQuery>;
  6246. _timeElapsedQuery: Nullable<WebGLQuery>;
  6247. _timeElapsedQueryEnded: boolean;
  6248. }
  6249. }
  6250. declare module BABYLON {
  6251. /**
  6252. * Class used to store data associated with WebGL texture data for the engine
  6253. * This class should not be used directly
  6254. */
  6255. export class InternalTexture {
  6256. /** hidden */
  6257. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6258. /**
  6259. * The source of the texture data is unknown
  6260. */
  6261. static DATASOURCE_UNKNOWN: number;
  6262. /**
  6263. * Texture data comes from an URL
  6264. */
  6265. static DATASOURCE_URL: number;
  6266. /**
  6267. * Texture data is only used for temporary storage
  6268. */
  6269. static DATASOURCE_TEMP: number;
  6270. /**
  6271. * Texture data comes from raw data (ArrayBuffer)
  6272. */
  6273. static DATASOURCE_RAW: number;
  6274. /**
  6275. * Texture content is dynamic (video or dynamic texture)
  6276. */
  6277. static DATASOURCE_DYNAMIC: number;
  6278. /**
  6279. * Texture content is generated by rendering to it
  6280. */
  6281. static DATASOURCE_RENDERTARGET: number;
  6282. /**
  6283. * Texture content is part of a multi render target process
  6284. */
  6285. static DATASOURCE_MULTIRENDERTARGET: number;
  6286. /**
  6287. * Texture data comes from a cube data file
  6288. */
  6289. static DATASOURCE_CUBE: number;
  6290. /**
  6291. * Texture data comes from a raw cube data
  6292. */
  6293. static DATASOURCE_CUBERAW: number;
  6294. /**
  6295. * Texture data come from a prefiltered cube data file
  6296. */
  6297. static DATASOURCE_CUBEPREFILTERED: number;
  6298. /**
  6299. * Texture content is raw 3D data
  6300. */
  6301. static DATASOURCE_RAW3D: number;
  6302. /**
  6303. * Texture content is a depth texture
  6304. */
  6305. static DATASOURCE_DEPTHTEXTURE: number;
  6306. /**
  6307. * Texture data comes from a raw cube data encoded with RGBD
  6308. */
  6309. static DATASOURCE_CUBERAW_RGBD: number;
  6310. /**
  6311. * Defines if the texture is ready
  6312. */
  6313. isReady: boolean;
  6314. /**
  6315. * Defines if the texture is a cube texture
  6316. */
  6317. isCube: boolean;
  6318. /**
  6319. * Defines if the texture contains 3D data
  6320. */
  6321. is3D: boolean;
  6322. /**
  6323. * Defines if the texture contains multiview data
  6324. */
  6325. isMultiview: boolean;
  6326. /**
  6327. * Gets the URL used to load this texture
  6328. */
  6329. url: string;
  6330. /**
  6331. * Gets the sampling mode of the texture
  6332. */
  6333. samplingMode: number;
  6334. /**
  6335. * Gets a boolean indicating if the texture needs mipmaps generation
  6336. */
  6337. generateMipMaps: boolean;
  6338. /**
  6339. * Gets the number of samples used by the texture (WebGL2+ only)
  6340. */
  6341. samples: number;
  6342. /**
  6343. * Gets the type of the texture (int, float...)
  6344. */
  6345. type: number;
  6346. /**
  6347. * Gets the format of the texture (RGB, RGBA...)
  6348. */
  6349. format: number;
  6350. /**
  6351. * Observable called when the texture is loaded
  6352. */
  6353. onLoadedObservable: Observable<InternalTexture>;
  6354. /**
  6355. * Gets the width of the texture
  6356. */
  6357. width: number;
  6358. /**
  6359. * Gets the height of the texture
  6360. */
  6361. height: number;
  6362. /**
  6363. * Gets the depth of the texture
  6364. */
  6365. depth: number;
  6366. /**
  6367. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6368. */
  6369. baseWidth: number;
  6370. /**
  6371. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6372. */
  6373. baseHeight: number;
  6374. /**
  6375. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6376. */
  6377. baseDepth: number;
  6378. /**
  6379. * Gets a boolean indicating if the texture is inverted on Y axis
  6380. */
  6381. invertY: boolean;
  6382. /** @hidden */
  6383. _invertVScale: boolean;
  6384. /** @hidden */
  6385. _associatedChannel: number;
  6386. /** @hidden */
  6387. _dataSource: number;
  6388. /** @hidden */
  6389. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6390. /** @hidden */
  6391. _bufferView: Nullable<ArrayBufferView>;
  6392. /** @hidden */
  6393. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6394. /** @hidden */
  6395. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6396. /** @hidden */
  6397. _size: number;
  6398. /** @hidden */
  6399. _extension: string;
  6400. /** @hidden */
  6401. _files: Nullable<string[]>;
  6402. /** @hidden */
  6403. _workingCanvas: Nullable<HTMLCanvasElement>;
  6404. /** @hidden */
  6405. _workingContext: Nullable<CanvasRenderingContext2D>;
  6406. /** @hidden */
  6407. _framebuffer: Nullable<WebGLFramebuffer>;
  6408. /** @hidden */
  6409. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6410. /** @hidden */
  6411. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6412. /** @hidden */
  6413. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6414. /** @hidden */
  6415. _attachments: Nullable<number[]>;
  6416. /** @hidden */
  6417. _cachedCoordinatesMode: Nullable<number>;
  6418. /** @hidden */
  6419. _cachedWrapU: Nullable<number>;
  6420. /** @hidden */
  6421. _cachedWrapV: Nullable<number>;
  6422. /** @hidden */
  6423. _cachedWrapR: Nullable<number>;
  6424. /** @hidden */
  6425. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6426. /** @hidden */
  6427. _isDisabled: boolean;
  6428. /** @hidden */
  6429. _compression: Nullable<string>;
  6430. /** @hidden */
  6431. _generateStencilBuffer: boolean;
  6432. /** @hidden */
  6433. _generateDepthBuffer: boolean;
  6434. /** @hidden */
  6435. _comparisonFunction: number;
  6436. /** @hidden */
  6437. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6438. /** @hidden */
  6439. _lodGenerationScale: number;
  6440. /** @hidden */
  6441. _lodGenerationOffset: number;
  6442. /** @hidden */
  6443. _colorTextureArray: Nullable<WebGLTexture>;
  6444. /** @hidden */
  6445. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6446. /** @hidden */
  6447. _lodTextureHigh: Nullable<BaseTexture>;
  6448. /** @hidden */
  6449. _lodTextureMid: Nullable<BaseTexture>;
  6450. /** @hidden */
  6451. _lodTextureLow: Nullable<BaseTexture>;
  6452. /** @hidden */
  6453. _isRGBD: boolean;
  6454. /** @hidden */
  6455. _webGLTexture: Nullable<WebGLTexture>;
  6456. /** @hidden */
  6457. _references: number;
  6458. private _engine;
  6459. /**
  6460. * Gets the Engine the texture belongs to.
  6461. * @returns The babylon engine
  6462. */
  6463. getEngine(): Engine;
  6464. /**
  6465. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6466. */
  6467. readonly dataSource: number;
  6468. /**
  6469. * Creates a new InternalTexture
  6470. * @param engine defines the engine to use
  6471. * @param dataSource defines the type of data that will be used
  6472. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6473. */
  6474. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6475. /**
  6476. * Increments the number of references (ie. the number of Texture that point to it)
  6477. */
  6478. incrementReferences(): void;
  6479. /**
  6480. * Change the size of the texture (not the size of the content)
  6481. * @param width defines the new width
  6482. * @param height defines the new height
  6483. * @param depth defines the new depth (1 by default)
  6484. */
  6485. updateSize(width: int, height: int, depth?: int): void;
  6486. /** @hidden */
  6487. _rebuild(): void;
  6488. /** @hidden */
  6489. _swapAndDie(target: InternalTexture): void;
  6490. /**
  6491. * Dispose the current allocated resources
  6492. */
  6493. dispose(): void;
  6494. }
  6495. }
  6496. declare module BABYLON {
  6497. /**
  6498. * This represents the main contract an easing function should follow.
  6499. * Easing functions are used throughout the animation system.
  6500. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6501. */
  6502. export interface IEasingFunction {
  6503. /**
  6504. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6505. * of the easing function.
  6506. * The link below provides some of the most common examples of easing functions.
  6507. * @see https://easings.net/
  6508. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6509. * @returns the corresponding value on the curve defined by the easing function
  6510. */
  6511. ease(gradient: number): number;
  6512. }
  6513. /**
  6514. * Base class used for every default easing function.
  6515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6516. */
  6517. export class EasingFunction implements IEasingFunction {
  6518. /**
  6519. * Interpolation follows the mathematical formula associated with the easing function.
  6520. */
  6521. static readonly EASINGMODE_EASEIN: number;
  6522. /**
  6523. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6524. */
  6525. static readonly EASINGMODE_EASEOUT: number;
  6526. /**
  6527. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6528. */
  6529. static readonly EASINGMODE_EASEINOUT: number;
  6530. private _easingMode;
  6531. /**
  6532. * Sets the easing mode of the current function.
  6533. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6534. */
  6535. setEasingMode(easingMode: number): void;
  6536. /**
  6537. * Gets the current easing mode.
  6538. * @returns the easing mode
  6539. */
  6540. getEasingMode(): number;
  6541. /**
  6542. * @hidden
  6543. */
  6544. easeInCore(gradient: number): number;
  6545. /**
  6546. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6547. * of the easing function.
  6548. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6549. * @returns the corresponding value on the curve defined by the easing function
  6550. */
  6551. ease(gradient: number): number;
  6552. }
  6553. /**
  6554. * Easing function with a circle shape (see link below).
  6555. * @see https://easings.net/#easeInCirc
  6556. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6557. */
  6558. export class CircleEase extends EasingFunction implements IEasingFunction {
  6559. /** @hidden */
  6560. easeInCore(gradient: number): number;
  6561. }
  6562. /**
  6563. * Easing function with a ease back shape (see link below).
  6564. * @see https://easings.net/#easeInBack
  6565. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6566. */
  6567. export class BackEase extends EasingFunction implements IEasingFunction {
  6568. /** Defines the amplitude of the function */
  6569. amplitude: number;
  6570. /**
  6571. * Instantiates a back ease easing
  6572. * @see https://easings.net/#easeInBack
  6573. * @param amplitude Defines the amplitude of the function
  6574. */
  6575. constructor(
  6576. /** Defines the amplitude of the function */
  6577. amplitude?: number);
  6578. /** @hidden */
  6579. easeInCore(gradient: number): number;
  6580. }
  6581. /**
  6582. * Easing function with a bouncing shape (see link below).
  6583. * @see https://easings.net/#easeInBounce
  6584. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6585. */
  6586. export class BounceEase extends EasingFunction implements IEasingFunction {
  6587. /** Defines the number of bounces */
  6588. bounces: number;
  6589. /** Defines the amplitude of the bounce */
  6590. bounciness: number;
  6591. /**
  6592. * Instantiates a bounce easing
  6593. * @see https://easings.net/#easeInBounce
  6594. * @param bounces Defines the number of bounces
  6595. * @param bounciness Defines the amplitude of the bounce
  6596. */
  6597. constructor(
  6598. /** Defines the number of bounces */
  6599. bounces?: number,
  6600. /** Defines the amplitude of the bounce */
  6601. bounciness?: number);
  6602. /** @hidden */
  6603. easeInCore(gradient: number): number;
  6604. }
  6605. /**
  6606. * Easing function with a power of 3 shape (see link below).
  6607. * @see https://easings.net/#easeInCubic
  6608. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6609. */
  6610. export class CubicEase extends EasingFunction implements IEasingFunction {
  6611. /** @hidden */
  6612. easeInCore(gradient: number): number;
  6613. }
  6614. /**
  6615. * Easing function with an elastic shape (see link below).
  6616. * @see https://easings.net/#easeInElastic
  6617. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6618. */
  6619. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6620. /** Defines the number of oscillations*/
  6621. oscillations: number;
  6622. /** Defines the amplitude of the oscillations*/
  6623. springiness: number;
  6624. /**
  6625. * Instantiates an elastic easing function
  6626. * @see https://easings.net/#easeInElastic
  6627. * @param oscillations Defines the number of oscillations
  6628. * @param springiness Defines the amplitude of the oscillations
  6629. */
  6630. constructor(
  6631. /** Defines the number of oscillations*/
  6632. oscillations?: number,
  6633. /** Defines the amplitude of the oscillations*/
  6634. springiness?: number);
  6635. /** @hidden */
  6636. easeInCore(gradient: number): number;
  6637. }
  6638. /**
  6639. * Easing function with an exponential shape (see link below).
  6640. * @see https://easings.net/#easeInExpo
  6641. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6642. */
  6643. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6644. /** Defines the exponent of the function */
  6645. exponent: number;
  6646. /**
  6647. * Instantiates an exponential easing function
  6648. * @see https://easings.net/#easeInExpo
  6649. * @param exponent Defines the exponent of the function
  6650. */
  6651. constructor(
  6652. /** Defines the exponent of the function */
  6653. exponent?: number);
  6654. /** @hidden */
  6655. easeInCore(gradient: number): number;
  6656. }
  6657. /**
  6658. * Easing function with a power shape (see link below).
  6659. * @see https://easings.net/#easeInQuad
  6660. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6661. */
  6662. export class PowerEase extends EasingFunction implements IEasingFunction {
  6663. /** Defines the power of the function */
  6664. power: number;
  6665. /**
  6666. * Instantiates an power base easing function
  6667. * @see https://easings.net/#easeInQuad
  6668. * @param power Defines the power of the function
  6669. */
  6670. constructor(
  6671. /** Defines the power of the function */
  6672. power?: number);
  6673. /** @hidden */
  6674. easeInCore(gradient: number): number;
  6675. }
  6676. /**
  6677. * Easing function with a power of 2 shape (see link below).
  6678. * @see https://easings.net/#easeInQuad
  6679. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6680. */
  6681. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6682. /** @hidden */
  6683. easeInCore(gradient: number): number;
  6684. }
  6685. /**
  6686. * Easing function with a power of 4 shape (see link below).
  6687. * @see https://easings.net/#easeInQuart
  6688. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6689. */
  6690. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6691. /** @hidden */
  6692. easeInCore(gradient: number): number;
  6693. }
  6694. /**
  6695. * Easing function with a power of 5 shape (see link below).
  6696. * @see https://easings.net/#easeInQuint
  6697. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6698. */
  6699. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6700. /** @hidden */
  6701. easeInCore(gradient: number): number;
  6702. }
  6703. /**
  6704. * Easing function with a sin shape (see link below).
  6705. * @see https://easings.net/#easeInSine
  6706. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6707. */
  6708. export class SineEase extends EasingFunction implements IEasingFunction {
  6709. /** @hidden */
  6710. easeInCore(gradient: number): number;
  6711. }
  6712. /**
  6713. * Easing function with a bezier shape (see link below).
  6714. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6715. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6716. */
  6717. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6718. /** Defines the x component of the start tangent in the bezier curve */
  6719. x1: number;
  6720. /** Defines the y component of the start tangent in the bezier curve */
  6721. y1: number;
  6722. /** Defines the x component of the end tangent in the bezier curve */
  6723. x2: number;
  6724. /** Defines the y component of the end tangent in the bezier curve */
  6725. y2: number;
  6726. /**
  6727. * Instantiates a bezier function
  6728. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6729. * @param x1 Defines the x component of the start tangent in the bezier curve
  6730. * @param y1 Defines the y component of the start tangent in the bezier curve
  6731. * @param x2 Defines the x component of the end tangent in the bezier curve
  6732. * @param y2 Defines the y component of the end tangent in the bezier curve
  6733. */
  6734. constructor(
  6735. /** Defines the x component of the start tangent in the bezier curve */
  6736. x1?: number,
  6737. /** Defines the y component of the start tangent in the bezier curve */
  6738. y1?: number,
  6739. /** Defines the x component of the end tangent in the bezier curve */
  6740. x2?: number,
  6741. /** Defines the y component of the end tangent in the bezier curve */
  6742. y2?: number);
  6743. /** @hidden */
  6744. easeInCore(gradient: number): number;
  6745. }
  6746. }
  6747. declare module BABYLON {
  6748. /**
  6749. * Defines an interface which represents an animation key frame
  6750. */
  6751. export interface IAnimationKey {
  6752. /**
  6753. * Frame of the key frame
  6754. */
  6755. frame: number;
  6756. /**
  6757. * Value at the specifies key frame
  6758. */
  6759. value: any;
  6760. /**
  6761. * The input tangent for the cubic hermite spline
  6762. */
  6763. inTangent?: any;
  6764. /**
  6765. * The output tangent for the cubic hermite spline
  6766. */
  6767. outTangent?: any;
  6768. /**
  6769. * The animation interpolation type
  6770. */
  6771. interpolation?: AnimationKeyInterpolation;
  6772. }
  6773. /**
  6774. * Enum for the animation key frame interpolation type
  6775. */
  6776. export enum AnimationKeyInterpolation {
  6777. /**
  6778. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6779. */
  6780. STEP = 1
  6781. }
  6782. }
  6783. declare module BABYLON {
  6784. /**
  6785. * Represents the range of an animation
  6786. */
  6787. export class AnimationRange {
  6788. /**The name of the animation range**/
  6789. name: string;
  6790. /**The starting frame of the animation */
  6791. from: number;
  6792. /**The ending frame of the animation*/
  6793. to: number;
  6794. /**
  6795. * Initializes the range of an animation
  6796. * @param name The name of the animation range
  6797. * @param from The starting frame of the animation
  6798. * @param to The ending frame of the animation
  6799. */
  6800. constructor(
  6801. /**The name of the animation range**/
  6802. name: string,
  6803. /**The starting frame of the animation */
  6804. from: number,
  6805. /**The ending frame of the animation*/
  6806. to: number);
  6807. /**
  6808. * Makes a copy of the animation range
  6809. * @returns A copy of the animation range
  6810. */
  6811. clone(): AnimationRange;
  6812. }
  6813. }
  6814. declare module BABYLON {
  6815. /**
  6816. * Composed of a frame, and an action function
  6817. */
  6818. export class AnimationEvent {
  6819. /** The frame for which the event is triggered **/
  6820. frame: number;
  6821. /** The event to perform when triggered **/
  6822. action: (currentFrame: number) => void;
  6823. /** Specifies if the event should be triggered only once**/
  6824. onlyOnce?: boolean | undefined;
  6825. /**
  6826. * Specifies if the animation event is done
  6827. */
  6828. isDone: boolean;
  6829. /**
  6830. * Initializes the animation event
  6831. * @param frame The frame for which the event is triggered
  6832. * @param action The event to perform when triggered
  6833. * @param onlyOnce Specifies if the event should be triggered only once
  6834. */
  6835. constructor(
  6836. /** The frame for which the event is triggered **/
  6837. frame: number,
  6838. /** The event to perform when triggered **/
  6839. action: (currentFrame: number) => void,
  6840. /** Specifies if the event should be triggered only once**/
  6841. onlyOnce?: boolean | undefined);
  6842. /** @hidden */
  6843. _clone(): AnimationEvent;
  6844. }
  6845. }
  6846. declare module BABYLON {
  6847. /**
  6848. * Interface used to define a behavior
  6849. */
  6850. export interface Behavior<T> {
  6851. /** gets or sets behavior's name */
  6852. name: string;
  6853. /**
  6854. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6855. */
  6856. init(): void;
  6857. /**
  6858. * Called when the behavior is attached to a target
  6859. * @param target defines the target where the behavior is attached to
  6860. */
  6861. attach(target: T): void;
  6862. /**
  6863. * Called when the behavior is detached from its target
  6864. */
  6865. detach(): void;
  6866. }
  6867. /**
  6868. * Interface implemented by classes supporting behaviors
  6869. */
  6870. export interface IBehaviorAware<T> {
  6871. /**
  6872. * Attach a behavior
  6873. * @param behavior defines the behavior to attach
  6874. * @returns the current host
  6875. */
  6876. addBehavior(behavior: Behavior<T>): T;
  6877. /**
  6878. * Remove a behavior from the current object
  6879. * @param behavior defines the behavior to detach
  6880. * @returns the current host
  6881. */
  6882. removeBehavior(behavior: Behavior<T>): T;
  6883. /**
  6884. * Gets a behavior using its name to search
  6885. * @param name defines the name to search
  6886. * @returns the behavior or null if not found
  6887. */
  6888. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6889. }
  6890. }
  6891. declare module BABYLON {
  6892. /**
  6893. * @hidden
  6894. */
  6895. export class IntersectionInfo {
  6896. bu: Nullable<number>;
  6897. bv: Nullable<number>;
  6898. distance: number;
  6899. faceId: number;
  6900. subMeshId: number;
  6901. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6902. }
  6903. }
  6904. declare module BABYLON {
  6905. /**
  6906. * Class used to store bounding sphere information
  6907. */
  6908. export class BoundingSphere {
  6909. /**
  6910. * Gets the center of the bounding sphere in local space
  6911. */
  6912. readonly center: Vector3;
  6913. /**
  6914. * Radius of the bounding sphere in local space
  6915. */
  6916. radius: number;
  6917. /**
  6918. * Gets the center of the bounding sphere in world space
  6919. */
  6920. readonly centerWorld: Vector3;
  6921. /**
  6922. * Radius of the bounding sphere in world space
  6923. */
  6924. radiusWorld: number;
  6925. /**
  6926. * Gets the minimum vector in local space
  6927. */
  6928. readonly minimum: Vector3;
  6929. /**
  6930. * Gets the maximum vector in local space
  6931. */
  6932. readonly maximum: Vector3;
  6933. private _worldMatrix;
  6934. private static readonly TmpVector3;
  6935. /**
  6936. * Creates a new bounding sphere
  6937. * @param min defines the minimum vector (in local space)
  6938. * @param max defines the maximum vector (in local space)
  6939. * @param worldMatrix defines the new world matrix
  6940. */
  6941. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6942. /**
  6943. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6944. * @param min defines the new minimum vector (in local space)
  6945. * @param max defines the new maximum vector (in local space)
  6946. * @param worldMatrix defines the new world matrix
  6947. */
  6948. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6949. /**
  6950. * Scale the current bounding sphere by applying a scale factor
  6951. * @param factor defines the scale factor to apply
  6952. * @returns the current bounding box
  6953. */
  6954. scale(factor: number): BoundingSphere;
  6955. /**
  6956. * Gets the world matrix of the bounding box
  6957. * @returns a matrix
  6958. */
  6959. getWorldMatrix(): DeepImmutable<Matrix>;
  6960. /** @hidden */
  6961. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6962. /**
  6963. * Tests if the bounding sphere is intersecting the frustum planes
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @returns true if there is an intersection
  6966. */
  6967. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if the bounding sphere center is in between the frustum planes.
  6970. * Used for optimistic fast inclusion.
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @returns true if the sphere center is in between the frustum planes
  6973. */
  6974. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. /**
  6976. * Tests if a point is inside the bounding sphere
  6977. * @param point defines the point to test
  6978. * @returns true if the point is inside the bounding sphere
  6979. */
  6980. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6981. /**
  6982. * Checks if two sphere intersct
  6983. * @param sphere0 sphere 0
  6984. * @param sphere1 sphere 1
  6985. * @returns true if the speres intersect
  6986. */
  6987. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6988. }
  6989. }
  6990. declare module BABYLON {
  6991. /**
  6992. * Class used to store bounding box information
  6993. */
  6994. export class BoundingBox implements ICullable {
  6995. /**
  6996. * Gets the 8 vectors representing the bounding box in local space
  6997. */
  6998. readonly vectors: Vector3[];
  6999. /**
  7000. * Gets the center of the bounding box in local space
  7001. */
  7002. readonly center: Vector3;
  7003. /**
  7004. * Gets the center of the bounding box in world space
  7005. */
  7006. readonly centerWorld: Vector3;
  7007. /**
  7008. * Gets the extend size in local space
  7009. */
  7010. readonly extendSize: Vector3;
  7011. /**
  7012. * Gets the extend size in world space
  7013. */
  7014. readonly extendSizeWorld: Vector3;
  7015. /**
  7016. * Gets the OBB (object bounding box) directions
  7017. */
  7018. readonly directions: Vector3[];
  7019. /**
  7020. * Gets the 8 vectors representing the bounding box in world space
  7021. */
  7022. readonly vectorsWorld: Vector3[];
  7023. /**
  7024. * Gets the minimum vector in world space
  7025. */
  7026. readonly minimumWorld: Vector3;
  7027. /**
  7028. * Gets the maximum vector in world space
  7029. */
  7030. readonly maximumWorld: Vector3;
  7031. /**
  7032. * Gets the minimum vector in local space
  7033. */
  7034. readonly minimum: Vector3;
  7035. /**
  7036. * Gets the maximum vector in local space
  7037. */
  7038. readonly maximum: Vector3;
  7039. private _worldMatrix;
  7040. private static readonly TmpVector3;
  7041. /**
  7042. * @hidden
  7043. */
  7044. _tag: number;
  7045. /**
  7046. * Creates a new bounding box
  7047. * @param min defines the minimum vector (in local space)
  7048. * @param max defines the maximum vector (in local space)
  7049. * @param worldMatrix defines the new world matrix
  7050. */
  7051. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7052. /**
  7053. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7054. * @param min defines the new minimum vector (in local space)
  7055. * @param max defines the new maximum vector (in local space)
  7056. * @param worldMatrix defines the new world matrix
  7057. */
  7058. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7059. /**
  7060. * Scale the current bounding box by applying a scale factor
  7061. * @param factor defines the scale factor to apply
  7062. * @returns the current bounding box
  7063. */
  7064. scale(factor: number): BoundingBox;
  7065. /**
  7066. * Gets the world matrix of the bounding box
  7067. * @returns a matrix
  7068. */
  7069. getWorldMatrix(): DeepImmutable<Matrix>;
  7070. /** @hidden */
  7071. _update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Tests if the bounding box is intersecting the frustum planes
  7074. * @param frustumPlanes defines the frustum planes to test
  7075. * @returns true if there is an intersection
  7076. */
  7077. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7078. /**
  7079. * Tests if the bounding box is entirely inside the frustum planes
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @returns true if there is an inclusion
  7082. */
  7083. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if a point is inside the bounding box
  7086. * @param point defines the point to test
  7087. * @returns true if the point is inside the bounding box
  7088. */
  7089. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7090. /**
  7091. * Tests if the bounding box intersects with a bounding sphere
  7092. * @param sphere defines the sphere to test
  7093. * @returns true if there is an intersection
  7094. */
  7095. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7096. /**
  7097. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7098. * @param min defines the min vector to use
  7099. * @param max defines the max vector to use
  7100. * @returns true if there is an intersection
  7101. */
  7102. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7103. /**
  7104. * Tests if two bounding boxes are intersections
  7105. * @param box0 defines the first box to test
  7106. * @param box1 defines the second box to test
  7107. * @returns true if there is an intersection
  7108. */
  7109. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7110. /**
  7111. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7112. * @param minPoint defines the minimum vector of the bounding box
  7113. * @param maxPoint defines the maximum vector of the bounding box
  7114. * @param sphereCenter defines the sphere center
  7115. * @param sphereRadius defines the sphere radius
  7116. * @returns true if there is an intersection
  7117. */
  7118. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7119. /**
  7120. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7121. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7122. * @param frustumPlanes defines the frustum planes to test
  7123. * @return true if there is an inclusion
  7124. */
  7125. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7126. /**
  7127. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7128. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7129. * @param frustumPlanes defines the frustum planes to test
  7130. * @return true if there is an intersection
  7131. */
  7132. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7133. }
  7134. }
  7135. declare module BABYLON {
  7136. /** @hidden */
  7137. export class Collider {
  7138. /** Define if a collision was found */
  7139. collisionFound: boolean;
  7140. /**
  7141. * Define last intersection point in local space
  7142. */
  7143. intersectionPoint: Vector3;
  7144. /**
  7145. * Define last collided mesh
  7146. */
  7147. collidedMesh: Nullable<AbstractMesh>;
  7148. private _collisionPoint;
  7149. private _planeIntersectionPoint;
  7150. private _tempVector;
  7151. private _tempVector2;
  7152. private _tempVector3;
  7153. private _tempVector4;
  7154. private _edge;
  7155. private _baseToVertex;
  7156. private _destinationPoint;
  7157. private _slidePlaneNormal;
  7158. private _displacementVector;
  7159. /** @hidden */
  7160. _radius: Vector3;
  7161. /** @hidden */
  7162. _retry: number;
  7163. private _velocity;
  7164. private _basePoint;
  7165. private _epsilon;
  7166. /** @hidden */
  7167. _velocityWorldLength: number;
  7168. /** @hidden */
  7169. _basePointWorld: Vector3;
  7170. private _velocityWorld;
  7171. private _normalizedVelocity;
  7172. /** @hidden */
  7173. _initialVelocity: Vector3;
  7174. /** @hidden */
  7175. _initialPosition: Vector3;
  7176. private _nearestDistance;
  7177. private _collisionMask;
  7178. collisionMask: number;
  7179. /**
  7180. * Gets the plane normal used to compute the sliding response (in local space)
  7181. */
  7182. readonly slidePlaneNormal: Vector3;
  7183. /** @hidden */
  7184. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7185. /** @hidden */
  7186. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7187. /** @hidden */
  7188. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7189. /** @hidden */
  7190. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7191. /** @hidden */
  7192. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7193. /** @hidden */
  7194. _getResponse(pos: Vector3, vel: Vector3): void;
  7195. }
  7196. }
  7197. declare module BABYLON {
  7198. /**
  7199. * Interface for cullable objects
  7200. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7201. */
  7202. export interface ICullable {
  7203. /**
  7204. * Checks if the object or part of the object is in the frustum
  7205. * @param frustumPlanes Camera near/planes
  7206. * @returns true if the object is in frustum otherwise false
  7207. */
  7208. isInFrustum(frustumPlanes: Plane[]): boolean;
  7209. /**
  7210. * Checks if a cullable object (mesh...) is in the camera frustum
  7211. * Unlike isInFrustum this cheks the full bounding box
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7216. }
  7217. /**
  7218. * Info for a bounding data of a mesh
  7219. */
  7220. export class BoundingInfo implements ICullable {
  7221. /**
  7222. * Bounding box for the mesh
  7223. */
  7224. readonly boundingBox: BoundingBox;
  7225. /**
  7226. * Bounding sphere for the mesh
  7227. */
  7228. readonly boundingSphere: BoundingSphere;
  7229. private _isLocked;
  7230. private static readonly TmpVector3;
  7231. /**
  7232. * Constructs bounding info
  7233. * @param minimum min vector of the bounding box/sphere
  7234. * @param maximum max vector of the bounding box/sphere
  7235. * @param worldMatrix defines the new world matrix
  7236. */
  7237. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7238. /**
  7239. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7240. * @param min defines the new minimum vector (in local space)
  7241. * @param max defines the new maximum vector (in local space)
  7242. * @param worldMatrix defines the new world matrix
  7243. */
  7244. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7245. /**
  7246. * min vector of the bounding box/sphere
  7247. */
  7248. readonly minimum: Vector3;
  7249. /**
  7250. * max vector of the bounding box/sphere
  7251. */
  7252. readonly maximum: Vector3;
  7253. /**
  7254. * If the info is locked and won't be updated to avoid perf overhead
  7255. */
  7256. isLocked: boolean;
  7257. /**
  7258. * Updates the bounding sphere and box
  7259. * @param world world matrix to be used to update
  7260. */
  7261. update(world: DeepImmutable<Matrix>): void;
  7262. /**
  7263. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7264. * @param center New center of the bounding info
  7265. * @param extend New extend of the bounding info
  7266. * @returns the current bounding info
  7267. */
  7268. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7269. /**
  7270. * Scale the current bounding info by applying a scale factor
  7271. * @param factor defines the scale factor to apply
  7272. * @returns the current bounding info
  7273. */
  7274. scale(factor: number): BoundingInfo;
  7275. /**
  7276. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7277. * @param frustumPlanes defines the frustum to test
  7278. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7279. * @returns true if the bounding info is in the frustum planes
  7280. */
  7281. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7282. /**
  7283. * Gets the world distance between the min and max points of the bounding box
  7284. */
  7285. readonly diagonalLength: number;
  7286. /**
  7287. * Checks if a cullable object (mesh...) is in the camera frustum
  7288. * Unlike isInFrustum this cheks the full bounding box
  7289. * @param frustumPlanes Camera near/planes
  7290. * @returns true if the object is in frustum otherwise false
  7291. */
  7292. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7293. /** @hidden */
  7294. _checkCollision(collider: Collider): boolean;
  7295. /**
  7296. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7297. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7298. * @param point the point to check intersection with
  7299. * @returns if the point intersects
  7300. */
  7301. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7302. /**
  7303. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7304. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7305. * @param boundingInfo the bounding info to check intersection with
  7306. * @param precise if the intersection should be done using OBB
  7307. * @returns if the bounding info intersects
  7308. */
  7309. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7310. }
  7311. }
  7312. declare module BABYLON {
  7313. /**
  7314. * Defines an array and its length.
  7315. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7316. */
  7317. export interface ISmartArrayLike<T> {
  7318. /**
  7319. * The data of the array.
  7320. */
  7321. data: Array<T>;
  7322. /**
  7323. * The active length of the array.
  7324. */
  7325. length: number;
  7326. }
  7327. /**
  7328. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7329. */
  7330. export class SmartArray<T> implements ISmartArrayLike<T> {
  7331. /**
  7332. * The full set of data from the array.
  7333. */
  7334. data: Array<T>;
  7335. /**
  7336. * The active length of the array.
  7337. */
  7338. length: number;
  7339. protected _id: number;
  7340. /**
  7341. * Instantiates a Smart Array.
  7342. * @param capacity defines the default capacity of the array.
  7343. */
  7344. constructor(capacity: number);
  7345. /**
  7346. * Pushes a value at the end of the active data.
  7347. * @param value defines the object to push in the array.
  7348. */
  7349. push(value: T): void;
  7350. /**
  7351. * Iterates over the active data and apply the lambda to them.
  7352. * @param func defines the action to apply on each value.
  7353. */
  7354. forEach(func: (content: T) => void): void;
  7355. /**
  7356. * Sorts the full sets of data.
  7357. * @param compareFn defines the comparison function to apply.
  7358. */
  7359. sort(compareFn: (a: T, b: T) => number): void;
  7360. /**
  7361. * Resets the active data to an empty array.
  7362. */
  7363. reset(): void;
  7364. /**
  7365. * Releases all the data from the array as well as the array.
  7366. */
  7367. dispose(): void;
  7368. /**
  7369. * Concats the active data with a given array.
  7370. * @param array defines the data to concatenate with.
  7371. */
  7372. concat(array: any): void;
  7373. /**
  7374. * Returns the position of a value in the active data.
  7375. * @param value defines the value to find the index for
  7376. * @returns the index if found in the active data otherwise -1
  7377. */
  7378. indexOf(value: T): number;
  7379. /**
  7380. * Returns whether an element is part of the active data.
  7381. * @param value defines the value to look for
  7382. * @returns true if found in the active data otherwise false
  7383. */
  7384. contains(value: T): boolean;
  7385. private static _GlobalId;
  7386. }
  7387. /**
  7388. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7389. * The data in this array can only be present once
  7390. */
  7391. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7392. private _duplicateId;
  7393. /**
  7394. * Pushes a value at the end of the active data.
  7395. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7396. * @param value defines the object to push in the array.
  7397. */
  7398. push(value: T): void;
  7399. /**
  7400. * Pushes a value at the end of the active data.
  7401. * If the data is already present, it won t be added again
  7402. * @param value defines the object to push in the array.
  7403. * @returns true if added false if it was already present
  7404. */
  7405. pushNoDuplicate(value: T): boolean;
  7406. /**
  7407. * Resets the active data to an empty array.
  7408. */
  7409. reset(): void;
  7410. /**
  7411. * Concats the active data with a given array.
  7412. * This ensures no dupplicate will be present in the result.
  7413. * @param array defines the data to concatenate with.
  7414. */
  7415. concatWithNoDuplicate(array: any): void;
  7416. }
  7417. }
  7418. declare module BABYLON {
  7419. /**
  7420. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7421. * separate meshes. This can be use to improve performances.
  7422. * @see http://doc.babylonjs.com/how_to/multi_materials
  7423. */
  7424. export class MultiMaterial extends Material {
  7425. private _subMaterials;
  7426. /**
  7427. * Gets or Sets the list of Materials used within the multi material.
  7428. * They need to be ordered according to the submeshes order in the associated mesh
  7429. */
  7430. subMaterials: Nullable<Material>[];
  7431. /**
  7432. * Function used to align with Node.getChildren()
  7433. * @returns the list of Materials used within the multi material
  7434. */
  7435. getChildren(): Nullable<Material>[];
  7436. /**
  7437. * Instantiates a new Multi Material
  7438. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7439. * separate meshes. This can be use to improve performances.
  7440. * @see http://doc.babylonjs.com/how_to/multi_materials
  7441. * @param name Define the name in the scene
  7442. * @param scene Define the scene the material belongs to
  7443. */
  7444. constructor(name: string, scene: Scene);
  7445. private _hookArray;
  7446. /**
  7447. * Get one of the submaterial by its index in the submaterials array
  7448. * @param index The index to look the sub material at
  7449. * @returns The Material if the index has been defined
  7450. */
  7451. getSubMaterial(index: number): Nullable<Material>;
  7452. /**
  7453. * Get the list of active textures for the whole sub materials list.
  7454. * @returns All the textures that will be used during the rendering
  7455. */
  7456. getActiveTextures(): BaseTexture[];
  7457. /**
  7458. * Gets the current class name of the material e.g. "MultiMaterial"
  7459. * Mainly use in serialization.
  7460. * @returns the class name
  7461. */
  7462. getClassName(): string;
  7463. /**
  7464. * Checks if the material is ready to render the requested sub mesh
  7465. * @param mesh Define the mesh the submesh belongs to
  7466. * @param subMesh Define the sub mesh to look readyness for
  7467. * @param useInstances Define whether or not the material is used with instances
  7468. * @returns true if ready, otherwise false
  7469. */
  7470. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7471. /**
  7472. * Clones the current material and its related sub materials
  7473. * @param name Define the name of the newly cloned material
  7474. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7475. * @returns the cloned material
  7476. */
  7477. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7478. /**
  7479. * Serializes the materials into a JSON representation.
  7480. * @returns the JSON representation
  7481. */
  7482. serialize(): any;
  7483. /**
  7484. * Dispose the material and release its associated resources
  7485. * @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)
  7486. * @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)
  7487. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7488. */
  7489. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7490. /**
  7491. * Creates a MultiMaterial from parsed MultiMaterial data.
  7492. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7493. * @param scene defines the hosting scene
  7494. * @returns a new MultiMaterial
  7495. */
  7496. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7497. }
  7498. }
  7499. declare module BABYLON {
  7500. /**
  7501. * Class used to represent data loading progression
  7502. */
  7503. export class SceneLoaderFlags {
  7504. private static _ForceFullSceneLoadingForIncremental;
  7505. private static _ShowLoadingScreen;
  7506. private static _CleanBoneMatrixWeights;
  7507. private static _loggingLevel;
  7508. /**
  7509. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7510. */
  7511. static ForceFullSceneLoadingForIncremental: boolean;
  7512. /**
  7513. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7514. */
  7515. static ShowLoadingScreen: boolean;
  7516. /**
  7517. * Defines the current logging level (while loading the scene)
  7518. * @ignorenaming
  7519. */
  7520. static loggingLevel: number;
  7521. /**
  7522. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7523. */
  7524. static CleanBoneMatrixWeights: boolean;
  7525. }
  7526. }
  7527. declare module BABYLON {
  7528. /**
  7529. * 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.
  7530. * @see https://doc.babylonjs.com/how_to/transformnode
  7531. */
  7532. export class TransformNode extends Node {
  7533. /**
  7534. * Object will not rotate to face the camera
  7535. */
  7536. static BILLBOARDMODE_NONE: number;
  7537. /**
  7538. * Object will rotate to face the camera but only on the x axis
  7539. */
  7540. static BILLBOARDMODE_X: number;
  7541. /**
  7542. * Object will rotate to face the camera but only on the y axis
  7543. */
  7544. static BILLBOARDMODE_Y: number;
  7545. /**
  7546. * Object will rotate to face the camera but only on the z axis
  7547. */
  7548. static BILLBOARDMODE_Z: number;
  7549. /**
  7550. * Object will rotate to face the camera
  7551. */
  7552. static BILLBOARDMODE_ALL: number;
  7553. private _forward;
  7554. private _forwardInverted;
  7555. private _up;
  7556. private _right;
  7557. private _rightInverted;
  7558. private _position;
  7559. private _rotation;
  7560. private _rotationQuaternion;
  7561. protected _scaling: Vector3;
  7562. protected _isDirty: boolean;
  7563. private _transformToBoneReferal;
  7564. private _billboardMode;
  7565. /**
  7566. * Gets or sets the billboard mode. Default is 0.
  7567. *
  7568. * | Value | Type | Description |
  7569. * | --- | --- | --- |
  7570. * | 0 | BILLBOARDMODE_NONE | |
  7571. * | 1 | BILLBOARDMODE_X | |
  7572. * | 2 | BILLBOARDMODE_Y | |
  7573. * | 4 | BILLBOARDMODE_Z | |
  7574. * | 7 | BILLBOARDMODE_ALL | |
  7575. *
  7576. */
  7577. billboardMode: number;
  7578. private _preserveParentRotationForBillboard;
  7579. /**
  7580. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7581. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7582. */
  7583. preserveParentRotationForBillboard: boolean;
  7584. /**
  7585. * 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
  7586. */
  7587. scalingDeterminant: number;
  7588. private _infiniteDistance;
  7589. /**
  7590. * Gets or sets the distance of the object to max, often used by skybox
  7591. */
  7592. infiniteDistance: boolean;
  7593. /**
  7594. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7595. * By default the system will update normals to compensate
  7596. */
  7597. ignoreNonUniformScaling: boolean;
  7598. /**
  7599. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7600. */
  7601. reIntegrateRotationIntoRotationQuaternion: boolean;
  7602. /** @hidden */
  7603. _poseMatrix: Nullable<Matrix>;
  7604. /** @hidden */
  7605. _localMatrix: Matrix;
  7606. private _usePivotMatrix;
  7607. private _absolutePosition;
  7608. private _pivotMatrix;
  7609. private _pivotMatrixInverse;
  7610. protected _postMultiplyPivotMatrix: boolean;
  7611. protected _isWorldMatrixFrozen: boolean;
  7612. /** @hidden */
  7613. _indexInSceneTransformNodesArray: number;
  7614. /**
  7615. * An event triggered after the world matrix is updated
  7616. */
  7617. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7618. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7619. /**
  7620. * Gets a string identifying the name of the class
  7621. * @returns "TransformNode" string
  7622. */
  7623. getClassName(): string;
  7624. /**
  7625. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7626. */
  7627. position: Vector3;
  7628. /**
  7629. * 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)).
  7630. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7631. */
  7632. rotation: Vector3;
  7633. /**
  7634. * 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)).
  7635. */
  7636. scaling: Vector3;
  7637. /**
  7638. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7639. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7640. */
  7641. rotationQuaternion: Nullable<Quaternion>;
  7642. /**
  7643. * The forward direction of that transform in world space.
  7644. */
  7645. readonly forward: Vector3;
  7646. /**
  7647. * The up direction of that transform in world space.
  7648. */
  7649. readonly up: Vector3;
  7650. /**
  7651. * The right direction of that transform in world space.
  7652. */
  7653. readonly right: Vector3;
  7654. /**
  7655. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7656. * @param matrix the matrix to copy the pose from
  7657. * @returns this TransformNode.
  7658. */
  7659. updatePoseMatrix(matrix: Matrix): TransformNode;
  7660. /**
  7661. * Returns the mesh Pose matrix.
  7662. * @returns the pose matrix
  7663. */
  7664. getPoseMatrix(): Matrix;
  7665. /** @hidden */
  7666. _isSynchronized(): boolean;
  7667. /** @hidden */
  7668. _initCache(): void;
  7669. /**
  7670. * Flag the transform node as dirty (Forcing it to update everything)
  7671. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7672. * @returns this transform node
  7673. */
  7674. markAsDirty(property: string): TransformNode;
  7675. /**
  7676. * Returns the current mesh absolute position.
  7677. * Returns a Vector3.
  7678. */
  7679. readonly absolutePosition: Vector3;
  7680. /**
  7681. * Sets a new matrix to apply before all other transformation
  7682. * @param matrix defines the transform matrix
  7683. * @returns the current TransformNode
  7684. */
  7685. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7686. /**
  7687. * Sets a new pivot matrix to the current node
  7688. * @param matrix defines the new pivot matrix to use
  7689. * @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
  7690. * @returns the current TransformNode
  7691. */
  7692. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7693. /**
  7694. * Returns the mesh pivot matrix.
  7695. * Default : Identity.
  7696. * @returns the matrix
  7697. */
  7698. getPivotMatrix(): Matrix;
  7699. /**
  7700. * Prevents the World matrix to be computed any longer.
  7701. * @returns the TransformNode.
  7702. */
  7703. freezeWorldMatrix(): TransformNode;
  7704. /**
  7705. * Allows back the World matrix computation.
  7706. * @returns the TransformNode.
  7707. */
  7708. unfreezeWorldMatrix(): this;
  7709. /**
  7710. * True if the World matrix has been frozen.
  7711. */
  7712. readonly isWorldMatrixFrozen: boolean;
  7713. /**
  7714. * Retuns the mesh absolute position in the World.
  7715. * @returns a Vector3.
  7716. */
  7717. getAbsolutePosition(): Vector3;
  7718. /**
  7719. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7720. * @param absolutePosition the absolute position to set
  7721. * @returns the TransformNode.
  7722. */
  7723. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7724. /**
  7725. * Sets the mesh position in its local space.
  7726. * @param vector3 the position to set in localspace
  7727. * @returns the TransformNode.
  7728. */
  7729. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7730. /**
  7731. * Returns the mesh position in the local space from the current World matrix values.
  7732. * @returns a new Vector3.
  7733. */
  7734. getPositionExpressedInLocalSpace(): Vector3;
  7735. /**
  7736. * Translates the mesh along the passed Vector3 in its local space.
  7737. * @param vector3 the distance to translate in localspace
  7738. * @returns the TransformNode.
  7739. */
  7740. locallyTranslate(vector3: Vector3): TransformNode;
  7741. private static _lookAtVectorCache;
  7742. /**
  7743. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7744. * @param targetPoint the position (must be in same space as current mesh) to look at
  7745. * @param yawCor optional yaw (y-axis) correction in radians
  7746. * @param pitchCor optional pitch (x-axis) correction in radians
  7747. * @param rollCor optional roll (z-axis) correction in radians
  7748. * @param space the choosen space of the target
  7749. * @returns the TransformNode.
  7750. */
  7751. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7752. /**
  7753. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7754. * This Vector3 is expressed in the World space.
  7755. * @param localAxis axis to rotate
  7756. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7757. */
  7758. getDirection(localAxis: Vector3): Vector3;
  7759. /**
  7760. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7761. * localAxis is expressed in the mesh local space.
  7762. * result is computed in the Wordl space from the mesh World matrix.
  7763. * @param localAxis axis to rotate
  7764. * @param result the resulting transformnode
  7765. * @returns this TransformNode.
  7766. */
  7767. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7768. /**
  7769. * Sets this transform node rotation to the given local axis.
  7770. * @param localAxis the axis in local space
  7771. * @param yawCor optional yaw (y-axis) correction in radians
  7772. * @param pitchCor optional pitch (x-axis) correction in radians
  7773. * @param rollCor optional roll (z-axis) correction in radians
  7774. * @returns this TransformNode
  7775. */
  7776. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7777. /**
  7778. * Sets a new pivot point to the current node
  7779. * @param point defines the new pivot point to use
  7780. * @param space defines if the point is in world or local space (local by default)
  7781. * @returns the current TransformNode
  7782. */
  7783. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7784. /**
  7785. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7786. * @returns the pivot point
  7787. */
  7788. getPivotPoint(): Vector3;
  7789. /**
  7790. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7791. * @param result the vector3 to store the result
  7792. * @returns this TransformNode.
  7793. */
  7794. getPivotPointToRef(result: Vector3): TransformNode;
  7795. /**
  7796. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7797. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7798. */
  7799. getAbsolutePivotPoint(): Vector3;
  7800. /**
  7801. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7802. * @param result vector3 to store the result
  7803. * @returns this TransformNode.
  7804. */
  7805. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7806. /**
  7807. * Defines the passed node as the parent of the current node.
  7808. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7809. * @see https://doc.babylonjs.com/how_to/parenting
  7810. * @param node the node ot set as the parent
  7811. * @returns this TransformNode.
  7812. */
  7813. setParent(node: Nullable<Node>): TransformNode;
  7814. private _nonUniformScaling;
  7815. /**
  7816. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7817. */
  7818. readonly nonUniformScaling: boolean;
  7819. /** @hidden */
  7820. _updateNonUniformScalingState(value: boolean): boolean;
  7821. /**
  7822. * Attach the current TransformNode to another TransformNode associated with a bone
  7823. * @param bone Bone affecting the TransformNode
  7824. * @param affectedTransformNode TransformNode associated with the bone
  7825. * @returns this object
  7826. */
  7827. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7828. /**
  7829. * Detach the transform node if its associated with a bone
  7830. * @returns this object
  7831. */
  7832. detachFromBone(): TransformNode;
  7833. private static _rotationAxisCache;
  7834. /**
  7835. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7836. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7837. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7838. * The passed axis is also normalized.
  7839. * @param axis the axis to rotate around
  7840. * @param amount the amount to rotate in radians
  7841. * @param space Space to rotate in (Default: local)
  7842. * @returns the TransformNode.
  7843. */
  7844. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7845. /**
  7846. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7847. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7848. * The passed axis is also normalized. .
  7849. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7850. * @param point the point to rotate around
  7851. * @param axis the axis to rotate around
  7852. * @param amount the amount to rotate in radians
  7853. * @returns the TransformNode
  7854. */
  7855. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7856. /**
  7857. * Translates the mesh along the axis vector for the passed distance in the given space.
  7858. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7859. * @param axis the axis to translate in
  7860. * @param distance the distance to translate
  7861. * @param space Space to rotate in (Default: local)
  7862. * @returns the TransformNode.
  7863. */
  7864. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7865. /**
  7866. * Adds a rotation step to the mesh current rotation.
  7867. * x, y, z are Euler angles expressed in radians.
  7868. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7869. * This means this rotation is made in the mesh local space only.
  7870. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7871. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7872. * ```javascript
  7873. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7874. * ```
  7875. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7876. * 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.
  7877. * @param x Rotation to add
  7878. * @param y Rotation to add
  7879. * @param z Rotation to add
  7880. * @returns the TransformNode.
  7881. */
  7882. addRotation(x: number, y: number, z: number): TransformNode;
  7883. /**
  7884. * @hidden
  7885. */
  7886. protected _getEffectiveParent(): Nullable<Node>;
  7887. /**
  7888. * Computes the world matrix of the node
  7889. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7890. * @returns the world matrix
  7891. */
  7892. computeWorldMatrix(force?: boolean): Matrix;
  7893. protected _afterComputeWorldMatrix(): void;
  7894. /**
  7895. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7896. * @param func callback function to add
  7897. *
  7898. * @returns the TransformNode.
  7899. */
  7900. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7901. /**
  7902. * Removes a registered callback function.
  7903. * @param func callback function to remove
  7904. * @returns the TransformNode.
  7905. */
  7906. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7907. /**
  7908. * Gets the position of the current mesh in camera space
  7909. * @param camera defines the camera to use
  7910. * @returns a position
  7911. */
  7912. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7913. /**
  7914. * Returns the distance from the mesh to the active camera
  7915. * @param camera defines the camera to use
  7916. * @returns the distance
  7917. */
  7918. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7919. /**
  7920. * Clone the current transform node
  7921. * @param name Name of the new clone
  7922. * @param newParent New parent for the clone
  7923. * @param doNotCloneChildren Do not clone children hierarchy
  7924. * @returns the new transform node
  7925. */
  7926. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7927. /**
  7928. * Serializes the objects information.
  7929. * @param currentSerializationObject defines the object to serialize in
  7930. * @returns the serialized object
  7931. */
  7932. serialize(currentSerializationObject?: any): any;
  7933. /**
  7934. * Returns a new TransformNode object parsed from the source provided.
  7935. * @param parsedTransformNode is the source.
  7936. * @param scene the scne the object belongs to
  7937. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7938. * @returns a new TransformNode object parsed from the source provided.
  7939. */
  7940. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7941. /**
  7942. * Get all child-transformNodes of this node
  7943. * @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
  7944. * @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
  7945. * @returns an array of TransformNode
  7946. */
  7947. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7948. /**
  7949. * Releases resources associated with this transform node.
  7950. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7951. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7952. */
  7953. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7954. }
  7955. }
  7956. declare module BABYLON {
  7957. /**
  7958. * Class used to override all child animations of a given target
  7959. */
  7960. export class AnimationPropertiesOverride {
  7961. /**
  7962. * Gets or sets a value indicating if animation blending must be used
  7963. */
  7964. enableBlending: boolean;
  7965. /**
  7966. * Gets or sets the blending speed to use when enableBlending is true
  7967. */
  7968. blendingSpeed: number;
  7969. /**
  7970. * Gets or sets the default loop mode to use
  7971. */
  7972. loopMode: number;
  7973. }
  7974. }
  7975. declare module BABYLON {
  7976. /**
  7977. * Class used to store bone information
  7978. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7979. */
  7980. export class Bone extends Node {
  7981. /**
  7982. * defines the bone name
  7983. */
  7984. name: string;
  7985. private static _tmpVecs;
  7986. private static _tmpQuat;
  7987. private static _tmpMats;
  7988. /**
  7989. * Gets the list of child bones
  7990. */
  7991. children: Bone[];
  7992. /** Gets the animations associated with this bone */
  7993. animations: Animation[];
  7994. /**
  7995. * Gets or sets bone length
  7996. */
  7997. length: number;
  7998. /**
  7999. * @hidden Internal only
  8000. * Set this value to map this bone to a different index in the transform matrices
  8001. * Set this value to -1 to exclude the bone from the transform matrices
  8002. */
  8003. _index: Nullable<number>;
  8004. private _skeleton;
  8005. private _localMatrix;
  8006. private _restPose;
  8007. private _baseMatrix;
  8008. private _absoluteTransform;
  8009. private _invertedAbsoluteTransform;
  8010. private _parent;
  8011. private _scalingDeterminant;
  8012. private _worldTransform;
  8013. private _localScaling;
  8014. private _localRotation;
  8015. private _localPosition;
  8016. private _needToDecompose;
  8017. private _needToCompose;
  8018. /** @hidden */
  8019. _linkedTransformNode: Nullable<TransformNode>;
  8020. /** @hidden */
  8021. _waitingTransformNodeId: Nullable<string>;
  8022. /** @hidden */
  8023. /** @hidden */
  8024. _matrix: Matrix;
  8025. /**
  8026. * Create a new bone
  8027. * @param name defines the bone name
  8028. * @param skeleton defines the parent skeleton
  8029. * @param parentBone defines the parent (can be null if the bone is the root)
  8030. * @param localMatrix defines the local matrix
  8031. * @param restPose defines the rest pose matrix
  8032. * @param baseMatrix defines the base matrix
  8033. * @param index defines index of the bone in the hiearchy
  8034. */
  8035. constructor(
  8036. /**
  8037. * defines the bone name
  8038. */
  8039. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8040. /**
  8041. * Gets the current object class name.
  8042. * @return the class name
  8043. */
  8044. getClassName(): string;
  8045. /**
  8046. * Gets the parent skeleton
  8047. * @returns a skeleton
  8048. */
  8049. getSkeleton(): Skeleton;
  8050. /**
  8051. * Gets parent bone
  8052. * @returns a bone or null if the bone is the root of the bone hierarchy
  8053. */
  8054. getParent(): Nullable<Bone>;
  8055. /**
  8056. * Returns an array containing the root bones
  8057. * @returns an array containing the root bones
  8058. */
  8059. getChildren(): Array<Bone>;
  8060. /**
  8061. * Sets the parent bone
  8062. * @param parent defines the parent (can be null if the bone is the root)
  8063. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8064. */
  8065. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8066. /**
  8067. * Gets the local matrix
  8068. * @returns a matrix
  8069. */
  8070. getLocalMatrix(): Matrix;
  8071. /**
  8072. * Gets the base matrix (initial matrix which remains unchanged)
  8073. * @returns a matrix
  8074. */
  8075. getBaseMatrix(): Matrix;
  8076. /**
  8077. * Gets the rest pose matrix
  8078. * @returns a matrix
  8079. */
  8080. getRestPose(): Matrix;
  8081. /**
  8082. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8083. */
  8084. getWorldMatrix(): Matrix;
  8085. /**
  8086. * Sets the local matrix to rest pose matrix
  8087. */
  8088. returnToRest(): void;
  8089. /**
  8090. * Gets the inverse of the absolute transform matrix.
  8091. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8092. * @returns a matrix
  8093. */
  8094. getInvertedAbsoluteTransform(): Matrix;
  8095. /**
  8096. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8097. * @returns a matrix
  8098. */
  8099. getAbsoluteTransform(): Matrix;
  8100. /**
  8101. * Links with the given transform node.
  8102. * The local matrix of this bone is copied from the transform node every frame.
  8103. * @param transformNode defines the transform node to link to
  8104. */
  8105. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8106. /** Gets or sets current position (in local space) */
  8107. position: Vector3;
  8108. /** Gets or sets current rotation (in local space) */
  8109. rotation: Vector3;
  8110. /** Gets or sets current rotation quaternion (in local space) */
  8111. rotationQuaternion: Quaternion;
  8112. /** Gets or sets current scaling (in local space) */
  8113. scaling: Vector3;
  8114. /**
  8115. * Gets the animation properties override
  8116. */
  8117. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8118. private _decompose;
  8119. private _compose;
  8120. /**
  8121. * Update the base and local matrices
  8122. * @param matrix defines the new base or local matrix
  8123. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8124. * @param updateLocalMatrix defines if the local matrix should be updated
  8125. */
  8126. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8127. /** @hidden */
  8128. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8129. /**
  8130. * Flag the bone as dirty (Forcing it to update everything)
  8131. */
  8132. markAsDirty(): void;
  8133. private _markAsDirtyAndCompose;
  8134. private _markAsDirtyAndDecompose;
  8135. /**
  8136. * Translate the bone in local or world space
  8137. * @param vec The amount to translate the bone
  8138. * @param space The space that the translation is in
  8139. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8140. */
  8141. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8142. /**
  8143. * Set the postion of the bone in local or world space
  8144. * @param position The position to set the bone
  8145. * @param space The space that the position is in
  8146. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8147. */
  8148. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8149. /**
  8150. * Set the absolute position of the bone (world space)
  8151. * @param position The position to set the bone
  8152. * @param mesh The mesh that this bone is attached to
  8153. */
  8154. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8155. /**
  8156. * Scale the bone on the x, y and z axes (in local space)
  8157. * @param x The amount to scale the bone on the x axis
  8158. * @param y The amount to scale the bone on the y axis
  8159. * @param z The amount to scale the bone on the z axis
  8160. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8161. */
  8162. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8163. /**
  8164. * Set the bone scaling in local space
  8165. * @param scale defines the scaling vector
  8166. */
  8167. setScale(scale: Vector3): void;
  8168. /**
  8169. * Gets the current scaling in local space
  8170. * @returns the current scaling vector
  8171. */
  8172. getScale(): Vector3;
  8173. /**
  8174. * Gets the current scaling in local space and stores it in a target vector
  8175. * @param result defines the target vector
  8176. */
  8177. getScaleToRef(result: Vector3): void;
  8178. /**
  8179. * Set the yaw, pitch, and roll of the bone in local or world space
  8180. * @param yaw The rotation of the bone on the y axis
  8181. * @param pitch The rotation of the bone on the x axis
  8182. * @param roll The rotation of the bone on the z axis
  8183. * @param space The space that the axes of rotation are in
  8184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8185. */
  8186. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8187. /**
  8188. * Add a rotation to the bone on an axis in local or world space
  8189. * @param axis The axis to rotate the bone on
  8190. * @param amount The amount to rotate the bone
  8191. * @param space The space that the axis is in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. */
  8194. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8195. /**
  8196. * Set the rotation of the bone to a particular axis angle in local or world space
  8197. * @param axis The axis to rotate the bone on
  8198. * @param angle The angle that the bone should be rotated to
  8199. * @param space The space that the axis is in
  8200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8201. */
  8202. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8203. /**
  8204. * Set the euler rotation of the bone in local of world space
  8205. * @param rotation The euler rotation that the bone should be set to
  8206. * @param space The space that the rotation is in
  8207. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8208. */
  8209. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8210. /**
  8211. * Set the quaternion rotation of the bone in local of world space
  8212. * @param quat The quaternion rotation that the bone should be set to
  8213. * @param space The space that the rotation is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. */
  8216. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8217. /**
  8218. * Set the rotation matrix of the bone in local of world space
  8219. * @param rotMat The rotation matrix that the bone should be set to
  8220. * @param space The space that the rotation is in
  8221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8222. */
  8223. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8224. private _rotateWithMatrix;
  8225. private _getNegativeRotationToRef;
  8226. /**
  8227. * Get the position of the bone in local or world space
  8228. * @param space The space that the returned position is in
  8229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8230. * @returns The position of the bone
  8231. */
  8232. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8233. /**
  8234. * Copy the position of the bone to a vector3 in local or world space
  8235. * @param space The space that the returned position is in
  8236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8237. * @param result The vector3 to copy the position to
  8238. */
  8239. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8240. /**
  8241. * Get the absolute position of the bone (world space)
  8242. * @param mesh The mesh that this bone is attached to
  8243. * @returns The absolute position of the bone
  8244. */
  8245. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8246. /**
  8247. * Copy the absolute position of the bone (world space) to the result param
  8248. * @param mesh The mesh that this bone is attached to
  8249. * @param result The vector3 to copy the absolute position to
  8250. */
  8251. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8252. /**
  8253. * Compute the absolute transforms of this bone and its children
  8254. */
  8255. computeAbsoluteTransforms(): void;
  8256. /**
  8257. * Get the world direction from an axis that is in the local space of the bone
  8258. * @param localAxis The local direction that is used to compute the world direction
  8259. * @param mesh The mesh that this bone is attached to
  8260. * @returns The world direction
  8261. */
  8262. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8263. /**
  8264. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8265. * @param localAxis The local direction that is used to compute the world direction
  8266. * @param mesh The mesh that this bone is attached to
  8267. * @param result The vector3 that the world direction will be copied to
  8268. */
  8269. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8270. /**
  8271. * Get the euler rotation of the bone in local or world space
  8272. * @param space The space that the rotation should be in
  8273. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8274. * @returns The euler rotation
  8275. */
  8276. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8277. /**
  8278. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8279. * @param space The space that the rotation should be in
  8280. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8281. * @param result The vector3 that the rotation should be copied to
  8282. */
  8283. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8284. /**
  8285. * Get the quaternion rotation of the bone in either local or world space
  8286. * @param space The space that the rotation should be in
  8287. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8288. * @returns The quaternion rotation
  8289. */
  8290. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8291. /**
  8292. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8293. * @param space The space that the rotation should be in
  8294. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8295. * @param result The quaternion that the rotation should be copied to
  8296. */
  8297. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8298. /**
  8299. * Get the rotation matrix of the bone in local or world space
  8300. * @param space The space that the rotation should be in
  8301. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8302. * @returns The rotation matrix
  8303. */
  8304. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8305. /**
  8306. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8307. * @param space The space that the rotation should be in
  8308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8309. * @param result The quaternion that the rotation should be copied to
  8310. */
  8311. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8312. /**
  8313. * Get the world position of a point that is in the local space of the bone
  8314. * @param position The local position
  8315. * @param mesh The mesh that this bone is attached to
  8316. * @returns The world position
  8317. */
  8318. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8319. /**
  8320. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8321. * @param position The local position
  8322. * @param mesh The mesh that this bone is attached to
  8323. * @param result The vector3 that the world position should be copied to
  8324. */
  8325. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8326. /**
  8327. * Get the local position of a point that is in world space
  8328. * @param position The world position
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @returns The local position
  8331. */
  8332. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8333. /**
  8334. * Get the local position of a point that is in world space and copy it to the result param
  8335. * @param position The world position
  8336. * @param mesh The mesh that this bone is attached to
  8337. * @param result The vector3 that the local position should be copied to
  8338. */
  8339. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8340. }
  8341. }
  8342. declare module BABYLON {
  8343. /**
  8344. * Enum that determines the text-wrapping mode to use.
  8345. */
  8346. export enum InspectableType {
  8347. /**
  8348. * Checkbox for booleans
  8349. */
  8350. Checkbox = 0,
  8351. /**
  8352. * Sliders for numbers
  8353. */
  8354. Slider = 1,
  8355. /**
  8356. * Vector3
  8357. */
  8358. Vector3 = 2,
  8359. /**
  8360. * Quaternions
  8361. */
  8362. Quaternion = 3,
  8363. /**
  8364. * Color3
  8365. */
  8366. Color3 = 4
  8367. }
  8368. /**
  8369. * Interface used to define custom inspectable properties.
  8370. * This interface is used by the inspector to display custom property grids
  8371. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8372. */
  8373. export interface IInspectable {
  8374. /**
  8375. * Gets the label to display
  8376. */
  8377. label: string;
  8378. /**
  8379. * Gets the name of the property to edit
  8380. */
  8381. propertyName: string;
  8382. /**
  8383. * Gets the type of the editor to use
  8384. */
  8385. type: InspectableType;
  8386. /**
  8387. * Gets the minimum value of the property when using in "slider" mode
  8388. */
  8389. min?: number;
  8390. /**
  8391. * Gets the maximum value of the property when using in "slider" mode
  8392. */
  8393. max?: number;
  8394. /**
  8395. * Gets the setp to use when using in "slider" mode
  8396. */
  8397. step?: number;
  8398. }
  8399. }
  8400. declare module BABYLON {
  8401. /**
  8402. * This represents the required contract to create a new type of texture loader.
  8403. */
  8404. export interface IInternalTextureLoader {
  8405. /**
  8406. * Defines wether the loader supports cascade loading the different faces.
  8407. */
  8408. supportCascades: boolean;
  8409. /**
  8410. * This returns if the loader support the current file information.
  8411. * @param extension defines the file extension of the file being loaded
  8412. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8413. * @param fallback defines the fallback internal texture if any
  8414. * @param isBase64 defines whether the texture is encoded as a base64
  8415. * @param isBuffer defines whether the texture data are stored as a buffer
  8416. * @returns true if the loader can load the specified file
  8417. */
  8418. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8419. /**
  8420. * Transform the url before loading if required.
  8421. * @param rootUrl the url of the texture
  8422. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8423. * @returns the transformed texture
  8424. */
  8425. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8426. /**
  8427. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8428. * @param rootUrl the url of the texture
  8429. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8430. * @returns the fallback texture
  8431. */
  8432. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8433. /**
  8434. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8435. * @param data contains the texture data
  8436. * @param texture defines the BabylonJS internal texture
  8437. * @param createPolynomials will be true if polynomials have been requested
  8438. * @param onLoad defines the callback to trigger once the texture is ready
  8439. * @param onError defines the callback to trigger in case of error
  8440. */
  8441. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8442. /**
  8443. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8444. * @param data contains the texture data
  8445. * @param texture defines the BabylonJS internal texture
  8446. * @param callback defines the method to call once ready to upload
  8447. */
  8448. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8449. }
  8450. }
  8451. declare module BABYLON {
  8452. interface Engine {
  8453. /**
  8454. * Creates a depth stencil cube texture.
  8455. * This is only available in WebGL 2.
  8456. * @param size The size of face edge in the cube texture.
  8457. * @param options The options defining the cube texture.
  8458. * @returns The cube texture
  8459. */
  8460. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8461. /**
  8462. * Creates a cube texture
  8463. * @param rootUrl defines the url where the files to load is located
  8464. * @param scene defines the current scene
  8465. * @param files defines the list of files to load (1 per face)
  8466. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8467. * @param onLoad defines an optional callback raised when the texture is loaded
  8468. * @param onError defines an optional callback raised if there is an issue to load the texture
  8469. * @param format defines the format of the data
  8470. * @param forcedExtension defines the extension to use to pick the right loader
  8471. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8472. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8473. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8474. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8475. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8476. * @returns the cube texture as an InternalTexture
  8477. */
  8478. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8479. /**
  8480. * Creates a cube texture
  8481. * @param rootUrl defines the url where the files to load is located
  8482. * @param scene defines the current scene
  8483. * @param files defines the list of files to load (1 per face)
  8484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8485. * @param onLoad defines an optional callback raised when the texture is loaded
  8486. * @param onError defines an optional callback raised if there is an issue to load the texture
  8487. * @param format defines the format of the data
  8488. * @param forcedExtension defines the extension to use to pick the right loader
  8489. * @returns the cube texture as an InternalTexture
  8490. */
  8491. 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 | undefined, forcedExtension: any): InternalTexture;
  8492. /**
  8493. * Creates a cube texture
  8494. * @param rootUrl defines the url where the files to load is located
  8495. * @param scene defines the current scene
  8496. * @param files defines the list of files to load (1 per face)
  8497. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8498. * @param onLoad defines an optional callback raised when the texture is loaded
  8499. * @param onError defines an optional callback raised if there is an issue to load the texture
  8500. * @param format defines the format of the data
  8501. * @param forcedExtension defines the extension to use to pick the right loader
  8502. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8505. * @returns the cube texture as an InternalTexture
  8506. */
  8507. 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 | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8508. /** @hidden */
  8509. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8510. /** @hidden */
  8511. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8512. /** @hidden */
  8513. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8514. /** @hidden */
  8515. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8516. }
  8517. }
  8518. declare module BABYLON {
  8519. /**
  8520. * Class for creating a cube texture
  8521. */
  8522. export class CubeTexture extends BaseTexture {
  8523. private _delayedOnLoad;
  8524. /**
  8525. * The url of the texture
  8526. */
  8527. url: string;
  8528. /**
  8529. * Gets or sets the center of the bounding box associated with the cube texture.
  8530. * It must define where the camera used to render the texture was set
  8531. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8532. */
  8533. boundingBoxPosition: Vector3;
  8534. private _boundingBoxSize;
  8535. /**
  8536. * Gets or sets the size of the bounding box associated with the cube texture
  8537. * When defined, the cubemap will switch to local mode
  8538. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8539. * @example https://www.babylonjs-playground.com/#RNASML
  8540. */
  8541. /**
  8542. * Returns the bounding box size
  8543. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8544. */
  8545. boundingBoxSize: Vector3;
  8546. protected _rotationY: number;
  8547. /**
  8548. * Sets texture matrix rotation angle around Y axis in radians.
  8549. */
  8550. /**
  8551. * Gets texture matrix rotation angle around Y axis radians.
  8552. */
  8553. rotationY: number;
  8554. /**
  8555. * Are mip maps generated for this texture or not.
  8556. */
  8557. readonly noMipmap: boolean;
  8558. private _noMipmap;
  8559. private _files;
  8560. private _extensions;
  8561. private _textureMatrix;
  8562. private _format;
  8563. private _createPolynomials;
  8564. /** @hidden */
  8565. _prefiltered: boolean;
  8566. /**
  8567. * Creates a cube texture from an array of image urls
  8568. * @param files defines an array of image urls
  8569. * @param scene defines the hosting scene
  8570. * @param noMipmap specifies if mip maps are not used
  8571. * @returns a cube texture
  8572. */
  8573. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8574. /**
  8575. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8576. * @param url defines the url of the prefiltered texture
  8577. * @param scene defines the scene the texture is attached to
  8578. * @param forcedExtension defines the extension of the file if different from the url
  8579. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8580. * @return the prefiltered texture
  8581. */
  8582. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8583. /**
  8584. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8585. * as prefiltered data.
  8586. * @param rootUrl defines the url of the texture or the root name of the six images
  8587. * @param scene defines the scene the texture is attached to
  8588. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8589. * @param noMipmap defines if mipmaps should be created or not
  8590. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8591. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8592. * @param onError defines a callback triggered in case of error during load
  8593. * @param format defines the internal format to use for the texture once loaded
  8594. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8595. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8596. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8597. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8598. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8599. * @return the cube texture
  8600. */
  8601. 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);
  8602. /**
  8603. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8604. */
  8605. readonly isPrefiltered: boolean;
  8606. /**
  8607. * Get the current class name of the texture useful for serialization or dynamic coding.
  8608. * @returns "CubeTexture"
  8609. */
  8610. getClassName(): string;
  8611. /**
  8612. * Update the url (and optional buffer) of this texture if url was null during construction.
  8613. * @param url the url of the texture
  8614. * @param forcedExtension defines the extension to use
  8615. * @param onLoad callback called when the texture is loaded (defaults to null)
  8616. */
  8617. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8618. /**
  8619. * Delays loading of the cube texture
  8620. * @param forcedExtension defines the extension to use
  8621. */
  8622. delayLoad(forcedExtension?: string): void;
  8623. /**
  8624. * Returns the reflection texture matrix
  8625. * @returns the reflection texture matrix
  8626. */
  8627. getReflectionTextureMatrix(): Matrix;
  8628. /**
  8629. * Sets the reflection texture matrix
  8630. * @param value Reflection texture matrix
  8631. */
  8632. setReflectionTextureMatrix(value: Matrix): void;
  8633. /**
  8634. * Parses text to create a cube texture
  8635. * @param parsedTexture define the serialized text to read from
  8636. * @param scene defines the hosting scene
  8637. * @param rootUrl defines the root url of the cube texture
  8638. * @returns a cube texture
  8639. */
  8640. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8641. /**
  8642. * Makes a clone, or deep copy, of the cube texture
  8643. * @returns a new cube texture
  8644. */
  8645. clone(): CubeTexture;
  8646. }
  8647. }
  8648. declare module BABYLON {
  8649. /** @hidden */
  8650. export var postprocessVertexShader: {
  8651. name: string;
  8652. shader: string;
  8653. };
  8654. }
  8655. declare module BABYLON {
  8656. /**
  8657. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8658. * This is the base of the follow, arc rotate cameras and Free camera
  8659. * @see http://doc.babylonjs.com/features/cameras
  8660. */
  8661. export class TargetCamera extends Camera {
  8662. private static _RigCamTransformMatrix;
  8663. private static _TargetTransformMatrix;
  8664. private static _TargetFocalPoint;
  8665. /**
  8666. * Define the current direction the camera is moving to
  8667. */
  8668. cameraDirection: Vector3;
  8669. /**
  8670. * Define the current rotation the camera is rotating to
  8671. */
  8672. cameraRotation: Vector2;
  8673. /**
  8674. * When set, the up vector of the camera will be updated by the rotation of the camera
  8675. */
  8676. updateUpVectorFromRotation: boolean;
  8677. private _tmpQuaternion;
  8678. /**
  8679. * Define the current rotation of the camera
  8680. */
  8681. rotation: Vector3;
  8682. /**
  8683. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8684. */
  8685. rotationQuaternion: Quaternion;
  8686. /**
  8687. * Define the current speed of the camera
  8688. */
  8689. speed: number;
  8690. /**
  8691. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8692. * around all axis.
  8693. */
  8694. noRotationConstraint: boolean;
  8695. /**
  8696. * Define the current target of the camera as an object or a position.
  8697. */
  8698. lockedTarget: any;
  8699. /** @hidden */
  8700. _currentTarget: Vector3;
  8701. /** @hidden */
  8702. _initialFocalDistance: number;
  8703. /** @hidden */
  8704. _viewMatrix: Matrix;
  8705. /** @hidden */
  8706. _camMatrix: Matrix;
  8707. /** @hidden */
  8708. _cameraTransformMatrix: Matrix;
  8709. /** @hidden */
  8710. _cameraRotationMatrix: Matrix;
  8711. /** @hidden */
  8712. _referencePoint: Vector3;
  8713. /** @hidden */
  8714. _transformedReferencePoint: Vector3;
  8715. protected _globalCurrentTarget: Vector3;
  8716. protected _globalCurrentUpVector: Vector3;
  8717. /** @hidden */
  8718. _reset: () => void;
  8719. private _defaultUp;
  8720. /**
  8721. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8722. * This is the base of the follow, arc rotate cameras and Free camera
  8723. * @see http://doc.babylonjs.com/features/cameras
  8724. * @param name Defines the name of the camera in the scene
  8725. * @param position Defines the start position of the camera in the scene
  8726. * @param scene Defines the scene the camera belongs to
  8727. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8728. */
  8729. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8730. /**
  8731. * Gets the position in front of the camera at a given distance.
  8732. * @param distance The distance from the camera we want the position to be
  8733. * @returns the position
  8734. */
  8735. getFrontPosition(distance: number): Vector3;
  8736. /** @hidden */
  8737. _getLockedTargetPosition(): Nullable<Vector3>;
  8738. private _storedPosition;
  8739. private _storedRotation;
  8740. private _storedRotationQuaternion;
  8741. /**
  8742. * Store current camera state of the camera (fov, position, rotation, etc..)
  8743. * @returns the camera
  8744. */
  8745. storeState(): Camera;
  8746. /**
  8747. * Restored camera state. You must call storeState() first
  8748. * @returns whether it was successful or not
  8749. * @hidden
  8750. */
  8751. _restoreStateValues(): boolean;
  8752. /** @hidden */
  8753. _initCache(): void;
  8754. /** @hidden */
  8755. _updateCache(ignoreParentClass?: boolean): void;
  8756. /** @hidden */
  8757. _isSynchronizedViewMatrix(): boolean;
  8758. /** @hidden */
  8759. _computeLocalCameraSpeed(): number;
  8760. /**
  8761. * Defines the target the camera should look at.
  8762. * This will automatically adapt alpha beta and radius to fit within the new target.
  8763. * @param target Defines the new target as a Vector or a mesh
  8764. */
  8765. setTarget(target: Vector3): void;
  8766. /**
  8767. * Return the current target position of the camera. This value is expressed in local space.
  8768. * @returns the target position
  8769. */
  8770. getTarget(): Vector3;
  8771. /** @hidden */
  8772. _decideIfNeedsToMove(): boolean;
  8773. /** @hidden */
  8774. _updatePosition(): void;
  8775. /** @hidden */
  8776. _checkInputs(): void;
  8777. protected _updateCameraRotationMatrix(): void;
  8778. /**
  8779. * 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)
  8780. * @returns the current camera
  8781. */
  8782. private _rotateUpVectorWithCameraRotationMatrix;
  8783. private _cachedRotationZ;
  8784. private _cachedQuaternionRotationZ;
  8785. /** @hidden */
  8786. _getViewMatrix(): Matrix;
  8787. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8788. /**
  8789. * @hidden
  8790. */
  8791. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8792. /**
  8793. * @hidden
  8794. */
  8795. _updateRigCameras(): void;
  8796. private _getRigCamPositionAndTarget;
  8797. /**
  8798. * Gets the current object class name.
  8799. * @return the class name
  8800. */
  8801. getClassName(): string;
  8802. }
  8803. }
  8804. declare module BABYLON {
  8805. /**
  8806. * @ignore
  8807. * This is a list of all the different input types that are available in the application.
  8808. * Fo instance: ArcRotateCameraGamepadInput...
  8809. */
  8810. export var CameraInputTypes: {};
  8811. /**
  8812. * This is the contract to implement in order to create a new input class.
  8813. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8814. */
  8815. export interface ICameraInput<TCamera extends Camera> {
  8816. /**
  8817. * Defines the camera the input is attached to.
  8818. */
  8819. camera: Nullable<TCamera>;
  8820. /**
  8821. * Gets the class name of the current intput.
  8822. * @returns the class name
  8823. */
  8824. getClassName(): string;
  8825. /**
  8826. * Get the friendly name associated with the input class.
  8827. * @returns the input friendly name
  8828. */
  8829. getSimpleName(): string;
  8830. /**
  8831. * Attach the input controls to a specific dom element to get the input from.
  8832. * @param element Defines the element the controls should be listened from
  8833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8834. */
  8835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8836. /**
  8837. * Detach the current controls from the specified dom element.
  8838. * @param element Defines the element to stop listening the inputs from
  8839. */
  8840. detachControl(element: Nullable<HTMLElement>): void;
  8841. /**
  8842. * Update the current camera state depending on the inputs that have been used this frame.
  8843. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8844. */
  8845. checkInputs?: () => void;
  8846. }
  8847. /**
  8848. * Represents a map of input types to input instance or input index to input instance.
  8849. */
  8850. export interface CameraInputsMap<TCamera extends Camera> {
  8851. /**
  8852. * Accessor to the input by input type.
  8853. */
  8854. [name: string]: ICameraInput<TCamera>;
  8855. /**
  8856. * Accessor to the input by input index.
  8857. */
  8858. [idx: number]: ICameraInput<TCamera>;
  8859. }
  8860. /**
  8861. * This represents the input manager used within a camera.
  8862. * It helps dealing with all the different kind of input attached to a camera.
  8863. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8864. */
  8865. export class CameraInputsManager<TCamera extends Camera> {
  8866. /**
  8867. * Defines the list of inputs attahed to the camera.
  8868. */
  8869. attached: CameraInputsMap<TCamera>;
  8870. /**
  8871. * Defines the dom element the camera is collecting inputs from.
  8872. * This is null if the controls have not been attached.
  8873. */
  8874. attachedElement: Nullable<HTMLElement>;
  8875. /**
  8876. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8877. */
  8878. noPreventDefault: boolean;
  8879. /**
  8880. * Defined the camera the input manager belongs to.
  8881. */
  8882. camera: TCamera;
  8883. /**
  8884. * Update the current camera state depending on the inputs that have been used this frame.
  8885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8886. */
  8887. checkInputs: () => void;
  8888. /**
  8889. * Instantiate a new Camera Input Manager.
  8890. * @param camera Defines the camera the input manager blongs to
  8891. */
  8892. constructor(camera: TCamera);
  8893. /**
  8894. * Add an input method to a camera
  8895. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8896. * @param input camera input method
  8897. */
  8898. add(input: ICameraInput<TCamera>): void;
  8899. /**
  8900. * Remove a specific input method from a camera
  8901. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8902. * @param inputToRemove camera input method
  8903. */
  8904. remove(inputToRemove: ICameraInput<TCamera>): void;
  8905. /**
  8906. * Remove a specific input type from a camera
  8907. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8908. * @param inputType the type of the input to remove
  8909. */
  8910. removeByType(inputType: string): void;
  8911. private _addCheckInputs;
  8912. /**
  8913. * Attach the input controls to the currently attached dom element to listen the events from.
  8914. * @param input Defines the input to attach
  8915. */
  8916. attachInput(input: ICameraInput<TCamera>): void;
  8917. /**
  8918. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8919. * @param element Defines the dom element to collect the events from
  8920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8921. */
  8922. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8923. /**
  8924. * Detach the current manager inputs controls from a specific dom element.
  8925. * @param element Defines the dom element to collect the events from
  8926. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8927. */
  8928. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8929. /**
  8930. * Rebuild the dynamic inputCheck function from the current list of
  8931. * defined inputs in the manager.
  8932. */
  8933. rebuildInputCheck(): void;
  8934. /**
  8935. * Remove all attached input methods from a camera
  8936. */
  8937. clear(): void;
  8938. /**
  8939. * Serialize the current input manager attached to a camera.
  8940. * This ensures than once parsed,
  8941. * the input associated to the camera will be identical to the current ones
  8942. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8943. */
  8944. serialize(serializedCamera: any): void;
  8945. /**
  8946. * Parses an input manager serialized JSON to restore the previous list of inputs
  8947. * and states associated to a camera.
  8948. * @param parsedCamera Defines the JSON to parse
  8949. */
  8950. parse(parsedCamera: any): void;
  8951. }
  8952. }
  8953. declare module BABYLON {
  8954. /**
  8955. * Gather the list of keyboard event types as constants.
  8956. */
  8957. export class KeyboardEventTypes {
  8958. /**
  8959. * The keydown event is fired when a key becomes active (pressed).
  8960. */
  8961. static readonly KEYDOWN: number;
  8962. /**
  8963. * The keyup event is fired when a key has been released.
  8964. */
  8965. static readonly KEYUP: number;
  8966. }
  8967. /**
  8968. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8969. */
  8970. export class KeyboardInfo {
  8971. /**
  8972. * Defines the type of event (KeyboardEventTypes)
  8973. */
  8974. type: number;
  8975. /**
  8976. * Defines the related dom event
  8977. */
  8978. event: KeyboardEvent;
  8979. /**
  8980. * Instantiates a new keyboard info.
  8981. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8982. * @param type Defines the type of event (KeyboardEventTypes)
  8983. * @param event Defines the related dom event
  8984. */
  8985. constructor(
  8986. /**
  8987. * Defines the type of event (KeyboardEventTypes)
  8988. */
  8989. type: number,
  8990. /**
  8991. * Defines the related dom event
  8992. */
  8993. event: KeyboardEvent);
  8994. }
  8995. /**
  8996. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8997. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8998. */
  8999. export class KeyboardInfoPre extends KeyboardInfo {
  9000. /**
  9001. * Defines the type of event (KeyboardEventTypes)
  9002. */
  9003. type: number;
  9004. /**
  9005. * Defines the related dom event
  9006. */
  9007. event: KeyboardEvent;
  9008. /**
  9009. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9010. */
  9011. skipOnPointerObservable: boolean;
  9012. /**
  9013. * Instantiates a new keyboard pre info.
  9014. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9015. * @param type Defines the type of event (KeyboardEventTypes)
  9016. * @param event Defines the related dom event
  9017. */
  9018. constructor(
  9019. /**
  9020. * Defines the type of event (KeyboardEventTypes)
  9021. */
  9022. type: number,
  9023. /**
  9024. * Defines the related dom event
  9025. */
  9026. event: KeyboardEvent);
  9027. }
  9028. }
  9029. declare module BABYLON {
  9030. /**
  9031. * Manage the keyboard inputs to control the movement of a free camera.
  9032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9033. */
  9034. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9035. /**
  9036. * Defines the camera the input is attached to.
  9037. */
  9038. camera: FreeCamera;
  9039. /**
  9040. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9041. */
  9042. keysUp: number[];
  9043. /**
  9044. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9045. */
  9046. keysDown: number[];
  9047. /**
  9048. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9049. */
  9050. keysLeft: number[];
  9051. /**
  9052. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9053. */
  9054. keysRight: number[];
  9055. private _keys;
  9056. private _onCanvasBlurObserver;
  9057. private _onKeyboardObserver;
  9058. private _engine;
  9059. private _scene;
  9060. /**
  9061. * Attach the input controls to a specific dom element to get the input from.
  9062. * @param element Defines the element the controls should be listened from
  9063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9064. */
  9065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9066. /**
  9067. * Detach the current controls from the specified dom element.
  9068. * @param element Defines the element to stop listening the inputs from
  9069. */
  9070. detachControl(element: Nullable<HTMLElement>): void;
  9071. /**
  9072. * Update the current camera state depending on the inputs that have been used this frame.
  9073. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9074. */
  9075. checkInputs(): void;
  9076. /**
  9077. * Gets the class name of the current intput.
  9078. * @returns the class name
  9079. */
  9080. getClassName(): string;
  9081. /** @hidden */
  9082. _onLostFocus(): void;
  9083. /**
  9084. * Get the friendly name associated with the input class.
  9085. * @returns the input friendly name
  9086. */
  9087. getSimpleName(): string;
  9088. }
  9089. }
  9090. declare module BABYLON {
  9091. /**
  9092. * Interface describing all the common properties and methods a shadow light needs to implement.
  9093. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9094. * as well as binding the different shadow properties to the effects.
  9095. */
  9096. export interface IShadowLight extends Light {
  9097. /**
  9098. * The light id in the scene (used in scene.findLighById for instance)
  9099. */
  9100. id: string;
  9101. /**
  9102. * The position the shdow will be casted from.
  9103. */
  9104. position: Vector3;
  9105. /**
  9106. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9107. */
  9108. direction: Vector3;
  9109. /**
  9110. * The transformed position. Position of the light in world space taking parenting in account.
  9111. */
  9112. transformedPosition: Vector3;
  9113. /**
  9114. * The transformed direction. Direction of the light in world space taking parenting in account.
  9115. */
  9116. transformedDirection: Vector3;
  9117. /**
  9118. * The friendly name of the light in the scene.
  9119. */
  9120. name: string;
  9121. /**
  9122. * Defines the shadow projection clipping minimum z value.
  9123. */
  9124. shadowMinZ: number;
  9125. /**
  9126. * Defines the shadow projection clipping maximum z value.
  9127. */
  9128. shadowMaxZ: number;
  9129. /**
  9130. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9131. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9132. */
  9133. computeTransformedInformation(): boolean;
  9134. /**
  9135. * Gets the scene the light belongs to.
  9136. * @returns The scene
  9137. */
  9138. getScene(): Scene;
  9139. /**
  9140. * Callback defining a custom Projection Matrix Builder.
  9141. * This can be used to override the default projection matrix computation.
  9142. */
  9143. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9144. /**
  9145. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9146. * @param matrix The materix to updated with the projection information
  9147. * @param viewMatrix The transform matrix of the light
  9148. * @param renderList The list of mesh to render in the map
  9149. * @returns The current light
  9150. */
  9151. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9152. /**
  9153. * Gets the current depth scale used in ESM.
  9154. * @returns The scale
  9155. */
  9156. getDepthScale(): number;
  9157. /**
  9158. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9159. * @returns true if a cube texture needs to be use
  9160. */
  9161. needCube(): boolean;
  9162. /**
  9163. * Detects if the projection matrix requires to be recomputed this frame.
  9164. * @returns true if it requires to be recomputed otherwise, false.
  9165. */
  9166. needProjectionMatrixCompute(): boolean;
  9167. /**
  9168. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9169. */
  9170. forceProjectionMatrixCompute(): void;
  9171. /**
  9172. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9173. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9174. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9175. */
  9176. getShadowDirection(faceIndex?: number): Vector3;
  9177. /**
  9178. * Gets the minZ used for shadow according to both the scene and the light.
  9179. * @param activeCamera The camera we are returning the min for
  9180. * @returns the depth min z
  9181. */
  9182. getDepthMinZ(activeCamera: Camera): number;
  9183. /**
  9184. * Gets the maxZ used for shadow according to both the scene and the light.
  9185. * @param activeCamera The camera we are returning the max for
  9186. * @returns the depth max z
  9187. */
  9188. getDepthMaxZ(activeCamera: Camera): number;
  9189. }
  9190. /**
  9191. * Base implementation IShadowLight
  9192. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9193. */
  9194. export abstract class ShadowLight extends Light implements IShadowLight {
  9195. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9196. protected _position: Vector3;
  9197. protected _setPosition(value: Vector3): void;
  9198. /**
  9199. * Sets the position the shadow will be casted from. Also use as the light position for both
  9200. * point and spot lights.
  9201. */
  9202. /**
  9203. * Sets the position the shadow will be casted from. Also use as the light position for both
  9204. * point and spot lights.
  9205. */
  9206. position: Vector3;
  9207. protected _direction: Vector3;
  9208. protected _setDirection(value: Vector3): void;
  9209. /**
  9210. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9211. * Also use as the light direction on spot and directional lights.
  9212. */
  9213. /**
  9214. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9215. * Also use as the light direction on spot and directional lights.
  9216. */
  9217. direction: Vector3;
  9218. private _shadowMinZ;
  9219. /**
  9220. * Gets the shadow projection clipping minimum z value.
  9221. */
  9222. /**
  9223. * Sets the shadow projection clipping minimum z value.
  9224. */
  9225. shadowMinZ: number;
  9226. private _shadowMaxZ;
  9227. /**
  9228. * Sets the shadow projection clipping maximum z value.
  9229. */
  9230. /**
  9231. * Gets the shadow projection clipping maximum z value.
  9232. */
  9233. shadowMaxZ: number;
  9234. /**
  9235. * Callback defining a custom Projection Matrix Builder.
  9236. * This can be used to override the default projection matrix computation.
  9237. */
  9238. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9239. /**
  9240. * The transformed position. Position of the light in world space taking parenting in account.
  9241. */
  9242. transformedPosition: Vector3;
  9243. /**
  9244. * The transformed direction. Direction of the light in world space taking parenting in account.
  9245. */
  9246. transformedDirection: Vector3;
  9247. private _needProjectionMatrixCompute;
  9248. /**
  9249. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9250. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9251. */
  9252. computeTransformedInformation(): boolean;
  9253. /**
  9254. * Return the depth scale used for the shadow map.
  9255. * @returns the depth scale.
  9256. */
  9257. getDepthScale(): number;
  9258. /**
  9259. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9260. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9261. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9262. */
  9263. getShadowDirection(faceIndex?: number): Vector3;
  9264. /**
  9265. * Returns the ShadowLight absolute position in the World.
  9266. * @returns the position vector in world space
  9267. */
  9268. getAbsolutePosition(): Vector3;
  9269. /**
  9270. * Sets the ShadowLight direction toward the passed target.
  9271. * @param target The point to target in local space
  9272. * @returns the updated ShadowLight direction
  9273. */
  9274. setDirectionToTarget(target: Vector3): Vector3;
  9275. /**
  9276. * Returns the light rotation in euler definition.
  9277. * @returns the x y z rotation in local space.
  9278. */
  9279. getRotation(): Vector3;
  9280. /**
  9281. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9282. * @returns true if a cube texture needs to be use
  9283. */
  9284. needCube(): boolean;
  9285. /**
  9286. * Detects if the projection matrix requires to be recomputed this frame.
  9287. * @returns true if it requires to be recomputed otherwise, false.
  9288. */
  9289. needProjectionMatrixCompute(): boolean;
  9290. /**
  9291. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9292. */
  9293. forceProjectionMatrixCompute(): void;
  9294. /** @hidden */
  9295. _initCache(): void;
  9296. /** @hidden */
  9297. _isSynchronized(): boolean;
  9298. /**
  9299. * Computes the world matrix of the node
  9300. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9301. * @returns the world matrix
  9302. */
  9303. computeWorldMatrix(force?: boolean): Matrix;
  9304. /**
  9305. * Gets the minZ used for shadow according to both the scene and the light.
  9306. * @param activeCamera The camera we are returning the min for
  9307. * @returns the depth min z
  9308. */
  9309. getDepthMinZ(activeCamera: Camera): number;
  9310. /**
  9311. * Gets the maxZ used for shadow according to both the scene and the light.
  9312. * @param activeCamera The camera we are returning the max for
  9313. * @returns the depth max z
  9314. */
  9315. getDepthMaxZ(activeCamera: Camera): number;
  9316. /**
  9317. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9318. * @param matrix The materix to updated with the projection information
  9319. * @param viewMatrix The transform matrix of the light
  9320. * @param renderList The list of mesh to render in the map
  9321. * @returns The current light
  9322. */
  9323. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9324. }
  9325. }
  9326. declare module BABYLON {
  9327. /**
  9328. * "Static Class" containing the most commonly used helper while dealing with material for
  9329. * rendering purpose.
  9330. *
  9331. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9332. *
  9333. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9334. */
  9335. export class MaterialHelper {
  9336. /**
  9337. * Bind the current view position to an effect.
  9338. * @param effect The effect to be bound
  9339. * @param scene The scene the eyes position is used from
  9340. */
  9341. static BindEyePosition(effect: Effect, scene: Scene): void;
  9342. /**
  9343. * Helps preparing the defines values about the UVs in used in the effect.
  9344. * UVs are shared as much as we can accross channels in the shaders.
  9345. * @param texture The texture we are preparing the UVs for
  9346. * @param defines The defines to update
  9347. * @param key The channel key "diffuse", "specular"... used in the shader
  9348. */
  9349. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9350. /**
  9351. * Binds a texture matrix value to its corrsponding uniform
  9352. * @param texture The texture to bind the matrix for
  9353. * @param uniformBuffer The uniform buffer receivin the data
  9354. * @param key The channel key "diffuse", "specular"... used in the shader
  9355. */
  9356. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9357. /**
  9358. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9359. * @param mesh defines the current mesh
  9360. * @param scene defines the current scene
  9361. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9362. * @param pointsCloud defines if point cloud rendering has to be turned on
  9363. * @param fogEnabled defines if fog has to be turned on
  9364. * @param alphaTest defines if alpha testing has to be turned on
  9365. * @param defines defines the current list of defines
  9366. */
  9367. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9368. /**
  9369. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9370. * @param scene defines the current scene
  9371. * @param engine defines the current engine
  9372. * @param defines specifies the list of active defines
  9373. * @param useInstances defines if instances have to be turned on
  9374. * @param useClipPlane defines if clip plane have to be turned on
  9375. */
  9376. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9377. /**
  9378. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9379. * @param mesh The mesh containing the geometry data we will draw
  9380. * @param defines The defines to update
  9381. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9382. * @param useBones Precise whether bones should be used or not (override mesh info)
  9383. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9384. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9385. * @returns false if defines are considered not dirty and have not been checked
  9386. */
  9387. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9388. /**
  9389. * Prepares the defines related to multiview
  9390. * @param scene The scene we are intending to draw
  9391. * @param defines The defines to update
  9392. */
  9393. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9394. /**
  9395. * Prepares the defines related to the light information passed in parameter
  9396. * @param scene The scene we are intending to draw
  9397. * @param mesh The mesh the effect is compiling for
  9398. * @param defines The defines to update
  9399. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9400. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9401. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9402. * @returns true if normals will be required for the rest of the effect
  9403. */
  9404. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9405. /**
  9406. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9407. * that won t be acctive due to defines being turned off.
  9408. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9409. * @param samplersList The samplers list
  9410. * @param defines The defines helping in the list generation
  9411. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9412. */
  9413. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9414. /**
  9415. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9416. * @param defines The defines to update while falling back
  9417. * @param fallbacks The authorized effect fallbacks
  9418. * @param maxSimultaneousLights The maximum number of lights allowed
  9419. * @param rank the current rank of the Effect
  9420. * @returns The newly affected rank
  9421. */
  9422. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9423. /**
  9424. * Prepares the list of attributes required for morph targets according to the effect defines.
  9425. * @param attribs The current list of supported attribs
  9426. * @param mesh The mesh to prepare the morph targets attributes for
  9427. * @param defines The current Defines of the effect
  9428. */
  9429. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9430. /**
  9431. * Prepares the list of attributes required for bones according to the effect defines.
  9432. * @param attribs The current list of supported attribs
  9433. * @param mesh The mesh to prepare the bones attributes for
  9434. * @param defines The current Defines of the effect
  9435. * @param fallbacks The current efffect fallback strategy
  9436. */
  9437. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9438. /**
  9439. * Prepares the list of attributes required for instances according to the effect defines.
  9440. * @param attribs The current list of supported attribs
  9441. * @param defines The current Defines of the effect
  9442. */
  9443. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9444. /**
  9445. * Binds the light shadow information to the effect for the given mesh.
  9446. * @param light The light containing the generator
  9447. * @param scene The scene the lights belongs to
  9448. * @param mesh The mesh we are binding the information to render
  9449. * @param lightIndex The light index in the effect used to render the mesh
  9450. * @param effect The effect we are binding the data to
  9451. */
  9452. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9453. /**
  9454. * Binds the light information to the effect.
  9455. * @param light The light containing the generator
  9456. * @param effect The effect we are binding the data to
  9457. * @param lightIndex The light index in the effect used to render
  9458. */
  9459. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9460. /**
  9461. * Binds the lights information from the scene to the effect for the given mesh.
  9462. * @param scene The scene the lights belongs to
  9463. * @param mesh The mesh we are binding the information to render
  9464. * @param effect The effect we are binding the data to
  9465. * @param defines The generated defines for the effect
  9466. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9467. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9468. */
  9469. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9470. private static _tempFogColor;
  9471. /**
  9472. * Binds the fog information from the scene to the effect for the given mesh.
  9473. * @param scene The scene the lights belongs to
  9474. * @param mesh The mesh we are binding the information to render
  9475. * @param effect The effect we are binding the data to
  9476. * @param linearSpace Defines if the fog effect is applied in linear space
  9477. */
  9478. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9479. /**
  9480. * Binds the bones information from the mesh to the effect.
  9481. * @param mesh The mesh we are binding the information to render
  9482. * @param effect The effect we are binding the data to
  9483. */
  9484. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9485. /**
  9486. * Binds the morph targets information from the mesh to the effect.
  9487. * @param abstractMesh The mesh we are binding the information to render
  9488. * @param effect The effect we are binding the data to
  9489. */
  9490. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9491. /**
  9492. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9493. * @param defines The generated defines used in the effect
  9494. * @param effect The effect we are binding the data to
  9495. * @param scene The scene we are willing to render with logarithmic scale for
  9496. */
  9497. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9498. /**
  9499. * Binds the clip plane information from the scene to the effect.
  9500. * @param scene The scene the clip plane information are extracted from
  9501. * @param effect The effect we are binding the data to
  9502. */
  9503. static BindClipPlane(effect: Effect, scene: Scene): void;
  9504. }
  9505. }
  9506. declare module BABYLON {
  9507. /** @hidden */
  9508. export var kernelBlurVaryingDeclaration: {
  9509. name: string;
  9510. shader: string;
  9511. };
  9512. }
  9513. declare module BABYLON {
  9514. /** @hidden */
  9515. export var kernelBlurFragment: {
  9516. name: string;
  9517. shader: string;
  9518. };
  9519. }
  9520. declare module BABYLON {
  9521. /** @hidden */
  9522. export var kernelBlurFragment2: {
  9523. name: string;
  9524. shader: string;
  9525. };
  9526. }
  9527. declare module BABYLON {
  9528. /** @hidden */
  9529. export var kernelBlurPixelShader: {
  9530. name: string;
  9531. shader: string;
  9532. };
  9533. }
  9534. declare module BABYLON {
  9535. /** @hidden */
  9536. export var kernelBlurVertex: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module BABYLON {
  9542. /** @hidden */
  9543. export var kernelBlurVertexShader: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module BABYLON {
  9549. /**
  9550. * The Blur Post Process which blurs an image based on a kernel and direction.
  9551. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9552. */
  9553. export class BlurPostProcess extends PostProcess {
  9554. /** The direction in which to blur the image. */
  9555. direction: Vector2;
  9556. private blockCompilation;
  9557. protected _kernel: number;
  9558. protected _idealKernel: number;
  9559. protected _packedFloat: boolean;
  9560. private _staticDefines;
  9561. /**
  9562. * Sets the length in pixels of the blur sample region
  9563. */
  9564. /**
  9565. * Gets the length in pixels of the blur sample region
  9566. */
  9567. kernel: number;
  9568. /**
  9569. * Sets wether or not the blur needs to unpack/repack floats
  9570. */
  9571. /**
  9572. * Gets wether or not the blur is unpacking/repacking floats
  9573. */
  9574. packedFloat: boolean;
  9575. /**
  9576. * Creates a new instance BlurPostProcess
  9577. * @param name The name of the effect.
  9578. * @param direction The direction in which to blur the image.
  9579. * @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.
  9580. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9581. * @param camera The camera to apply the render pass to.
  9582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9583. * @param engine The engine which the post process will be applied. (default: current engine)
  9584. * @param reusable If the post process can be reused on the same frame. (default: false)
  9585. * @param textureType Type of textures used when performing the post process. (default: 0)
  9586. * @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)
  9587. */
  9588. constructor(name: string,
  9589. /** The direction in which to blur the image. */
  9590. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9591. /**
  9592. * Updates the effect with the current post process compile time values and recompiles the shader.
  9593. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9594. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9595. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9596. * @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
  9597. * @param onCompiled Called when the shader has been compiled.
  9598. * @param onError Called if there is an error when compiling a shader.
  9599. */
  9600. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9601. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9602. /**
  9603. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9604. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9605. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9606. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9607. * The gaps between physical kernels are compensated for in the weighting of the samples
  9608. * @param idealKernel Ideal blur kernel.
  9609. * @return Nearest best kernel.
  9610. */
  9611. protected _nearestBestKernel(idealKernel: number): number;
  9612. /**
  9613. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9614. * @param x The point on the Gaussian distribution to sample.
  9615. * @return the value of the Gaussian function at x.
  9616. */
  9617. protected _gaussianWeight(x: number): number;
  9618. /**
  9619. * Generates a string that can be used as a floating point number in GLSL.
  9620. * @param x Value to print.
  9621. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9622. * @return GLSL float string.
  9623. */
  9624. protected _glslFloat(x: number, decimalFigures?: number): string;
  9625. }
  9626. }
  9627. declare module BABYLON {
  9628. /** @hidden */
  9629. export var shadowMapPixelShader: {
  9630. name: string;
  9631. shader: string;
  9632. };
  9633. }
  9634. declare module BABYLON {
  9635. /** @hidden */
  9636. export var bonesDeclaration: {
  9637. name: string;
  9638. shader: string;
  9639. };
  9640. }
  9641. declare module BABYLON {
  9642. /** @hidden */
  9643. export var morphTargetsVertexGlobalDeclaration: {
  9644. name: string;
  9645. shader: string;
  9646. };
  9647. }
  9648. declare module BABYLON {
  9649. /** @hidden */
  9650. export var morphTargetsVertexDeclaration: {
  9651. name: string;
  9652. shader: string;
  9653. };
  9654. }
  9655. declare module BABYLON {
  9656. /** @hidden */
  9657. export var instancesDeclaration: {
  9658. name: string;
  9659. shader: string;
  9660. };
  9661. }
  9662. declare module BABYLON {
  9663. /** @hidden */
  9664. export var helperFunctions: {
  9665. name: string;
  9666. shader: string;
  9667. };
  9668. }
  9669. declare module BABYLON {
  9670. /** @hidden */
  9671. export var morphTargetsVertex: {
  9672. name: string;
  9673. shader: string;
  9674. };
  9675. }
  9676. declare module BABYLON {
  9677. /** @hidden */
  9678. export var instancesVertex: {
  9679. name: string;
  9680. shader: string;
  9681. };
  9682. }
  9683. declare module BABYLON {
  9684. /** @hidden */
  9685. export var bonesVertex: {
  9686. name: string;
  9687. shader: string;
  9688. };
  9689. }
  9690. declare module BABYLON {
  9691. /** @hidden */
  9692. export var shadowMapVertexShader: {
  9693. name: string;
  9694. shader: string;
  9695. };
  9696. }
  9697. declare module BABYLON {
  9698. /** @hidden */
  9699. export var depthBoxBlurPixelShader: {
  9700. name: string;
  9701. shader: string;
  9702. };
  9703. }
  9704. declare module BABYLON {
  9705. /**
  9706. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9707. */
  9708. export interface ICustomShaderOptions {
  9709. /**
  9710. * Gets or sets the custom shader name to use
  9711. */
  9712. shaderName: string;
  9713. /**
  9714. * The list of attribute names used in the shader
  9715. */
  9716. attributes?: string[];
  9717. /**
  9718. * The list of unifrom names used in the shader
  9719. */
  9720. uniforms?: string[];
  9721. /**
  9722. * The list of sampler names used in the shader
  9723. */
  9724. samplers?: string[];
  9725. /**
  9726. * The list of defines used in the shader
  9727. */
  9728. defines?: string[];
  9729. }
  9730. /**
  9731. * Interface to implement to create a shadow generator compatible with BJS.
  9732. */
  9733. export interface IShadowGenerator {
  9734. /**
  9735. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9736. * @returns The render target texture if present otherwise, null
  9737. */
  9738. getShadowMap(): Nullable<RenderTargetTexture>;
  9739. /**
  9740. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9741. * @returns The render target texture if the shadow map is present otherwise, null
  9742. */
  9743. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9744. /**
  9745. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9746. * @param subMesh The submesh we want to render in the shadow map
  9747. * @param useInstances Defines wether will draw in the map using instances
  9748. * @returns true if ready otherwise, false
  9749. */
  9750. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9751. /**
  9752. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9753. * @param defines Defines of the material we want to update
  9754. * @param lightIndex Index of the light in the enabled light list of the material
  9755. */
  9756. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9757. /**
  9758. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9759. * defined in the generator but impacting the effect).
  9760. * It implies the unifroms available on the materials are the standard BJS ones.
  9761. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9762. * @param effect The effect we are binfing the information for
  9763. */
  9764. bindShadowLight(lightIndex: string, effect: Effect): void;
  9765. /**
  9766. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9767. * (eq to shadow prjection matrix * light transform matrix)
  9768. * @returns The transform matrix used to create the shadow map
  9769. */
  9770. getTransformMatrix(): Matrix;
  9771. /**
  9772. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9773. * Cube and 2D textures for instance.
  9774. */
  9775. recreateShadowMap(): void;
  9776. /**
  9777. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9778. * @param onCompiled Callback triggered at the and of the effects compilation
  9779. * @param options Sets of optional options forcing the compilation with different modes
  9780. */
  9781. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9782. useInstances: boolean;
  9783. }>): void;
  9784. /**
  9785. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9786. * @param options Sets of optional options forcing the compilation with different modes
  9787. * @returns A promise that resolves when the compilation completes
  9788. */
  9789. forceCompilationAsync(options?: Partial<{
  9790. useInstances: boolean;
  9791. }>): Promise<void>;
  9792. /**
  9793. * Serializes the shadow generator setup to a json object.
  9794. * @returns The serialized JSON object
  9795. */
  9796. serialize(): any;
  9797. /**
  9798. * Disposes the Shadow map and related Textures and effects.
  9799. */
  9800. dispose(): void;
  9801. }
  9802. /**
  9803. * Default implementation IShadowGenerator.
  9804. * This is the main object responsible of generating shadows in the framework.
  9805. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9806. */
  9807. export class ShadowGenerator implements IShadowGenerator {
  9808. /**
  9809. * Shadow generator mode None: no filtering applied.
  9810. */
  9811. static readonly FILTER_NONE: number;
  9812. /**
  9813. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9814. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9815. */
  9816. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9817. /**
  9818. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9819. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9820. */
  9821. static readonly FILTER_POISSONSAMPLING: number;
  9822. /**
  9823. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9824. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9825. */
  9826. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9827. /**
  9828. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9829. * edge artifacts on steep falloff.
  9830. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9831. */
  9832. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9833. /**
  9834. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9835. * edge artifacts on steep falloff.
  9836. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9837. */
  9838. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9839. /**
  9840. * Shadow generator mode PCF: Percentage Closer Filtering
  9841. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9842. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9843. */
  9844. static readonly FILTER_PCF: number;
  9845. /**
  9846. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9847. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9848. * Contact Hardening
  9849. */
  9850. static readonly FILTER_PCSS: number;
  9851. /**
  9852. * Reserved for PCF and PCSS
  9853. * Highest Quality.
  9854. *
  9855. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9856. *
  9857. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9858. */
  9859. static readonly QUALITY_HIGH: number;
  9860. /**
  9861. * Reserved for PCF and PCSS
  9862. * Good tradeoff for quality/perf cross devices
  9863. *
  9864. * Execute PCF on a 3*3 kernel.
  9865. *
  9866. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9867. */
  9868. static readonly QUALITY_MEDIUM: number;
  9869. /**
  9870. * Reserved for PCF and PCSS
  9871. * The lowest quality but the fastest.
  9872. *
  9873. * Execute PCF on a 1*1 kernel.
  9874. *
  9875. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9876. */
  9877. static readonly QUALITY_LOW: number;
  9878. /** Gets or sets the custom shader name to use */
  9879. customShaderOptions: ICustomShaderOptions;
  9880. /**
  9881. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9882. */
  9883. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9884. /**
  9885. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9886. */
  9887. onAfterShadowMapRenderObservable: Observable<Effect>;
  9888. /**
  9889. * Observable triggered before a mesh is rendered in the shadow map.
  9890. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9891. */
  9892. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9893. /**
  9894. * Observable triggered after a mesh is rendered in the shadow map.
  9895. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9896. */
  9897. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9898. private _bias;
  9899. /**
  9900. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9901. */
  9902. /**
  9903. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9904. */
  9905. bias: number;
  9906. private _normalBias;
  9907. /**
  9908. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9909. */
  9910. /**
  9911. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9912. */
  9913. normalBias: number;
  9914. private _blurBoxOffset;
  9915. /**
  9916. * Gets the blur box offset: offset applied during the blur pass.
  9917. * Only useful if useKernelBlur = false
  9918. */
  9919. /**
  9920. * Sets the blur box offset: offset applied during the blur pass.
  9921. * Only useful if useKernelBlur = false
  9922. */
  9923. blurBoxOffset: number;
  9924. private _blurScale;
  9925. /**
  9926. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9927. * 2 means half of the size.
  9928. */
  9929. /**
  9930. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9931. * 2 means half of the size.
  9932. */
  9933. blurScale: number;
  9934. private _blurKernel;
  9935. /**
  9936. * Gets the blur kernel: kernel size of the blur pass.
  9937. * Only useful if useKernelBlur = true
  9938. */
  9939. /**
  9940. * Sets the blur kernel: kernel size of the blur pass.
  9941. * Only useful if useKernelBlur = true
  9942. */
  9943. blurKernel: number;
  9944. private _useKernelBlur;
  9945. /**
  9946. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9947. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9948. */
  9949. /**
  9950. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9951. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9952. */
  9953. useKernelBlur: boolean;
  9954. private _depthScale;
  9955. /**
  9956. * Gets the depth scale used in ESM mode.
  9957. */
  9958. /**
  9959. * Sets the depth scale used in ESM mode.
  9960. * This can override the scale stored on the light.
  9961. */
  9962. depthScale: number;
  9963. private _filter;
  9964. /**
  9965. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9966. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9967. */
  9968. /**
  9969. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9970. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9971. */
  9972. filter: number;
  9973. /**
  9974. * Gets if the current filter is set to Poisson Sampling.
  9975. */
  9976. /**
  9977. * Sets the current filter to Poisson Sampling.
  9978. */
  9979. usePoissonSampling: boolean;
  9980. /**
  9981. * Gets if the current filter is set to ESM.
  9982. */
  9983. /**
  9984. * Sets the current filter is to ESM.
  9985. */
  9986. useExponentialShadowMap: boolean;
  9987. /**
  9988. * Gets if the current filter is set to filtered ESM.
  9989. */
  9990. /**
  9991. * Gets if the current filter is set to filtered ESM.
  9992. */
  9993. useBlurExponentialShadowMap: boolean;
  9994. /**
  9995. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9996. * exponential to prevent steep falloff artifacts).
  9997. */
  9998. /**
  9999. * Sets the current filter to "close ESM" (using the inverse of the
  10000. * exponential to prevent steep falloff artifacts).
  10001. */
  10002. useCloseExponentialShadowMap: boolean;
  10003. /**
  10004. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10005. * exponential to prevent steep falloff artifacts).
  10006. */
  10007. /**
  10008. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10009. * exponential to prevent steep falloff artifacts).
  10010. */
  10011. useBlurCloseExponentialShadowMap: boolean;
  10012. /**
  10013. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10014. */
  10015. /**
  10016. * Sets the current filter to "PCF" (percentage closer filtering).
  10017. */
  10018. usePercentageCloserFiltering: boolean;
  10019. private _filteringQuality;
  10020. /**
  10021. * Gets the PCF or PCSS Quality.
  10022. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10023. */
  10024. /**
  10025. * Sets the PCF or PCSS Quality.
  10026. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10027. */
  10028. filteringQuality: number;
  10029. /**
  10030. * Gets if the current filter is set to "PCSS" (contact hardening).
  10031. */
  10032. /**
  10033. * Sets the current filter to "PCSS" (contact hardening).
  10034. */
  10035. useContactHardeningShadow: boolean;
  10036. private _contactHardeningLightSizeUVRatio;
  10037. /**
  10038. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10039. * Using a ratio helps keeping shape stability independently of the map size.
  10040. *
  10041. * It does not account for the light projection as it was having too much
  10042. * instability during the light setup or during light position changes.
  10043. *
  10044. * Only valid if useContactHardeningShadow is true.
  10045. */
  10046. /**
  10047. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10048. * Using a ratio helps keeping shape stability independently of the map size.
  10049. *
  10050. * It does not account for the light projection as it was having too much
  10051. * instability during the light setup or during light position changes.
  10052. *
  10053. * Only valid if useContactHardeningShadow is true.
  10054. */
  10055. contactHardeningLightSizeUVRatio: number;
  10056. private _darkness;
  10057. /**
  10058. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10059. * 0 means strongest and 1 would means no shadow.
  10060. * @returns the darkness.
  10061. */
  10062. getDarkness(): number;
  10063. /**
  10064. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10065. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10066. * @returns the shadow generator allowing fluent coding.
  10067. */
  10068. setDarkness(darkness: number): ShadowGenerator;
  10069. private _transparencyShadow;
  10070. /**
  10071. * Sets the ability to have transparent shadow (boolean).
  10072. * @param transparent True if transparent else False
  10073. * @returns the shadow generator allowing fluent coding
  10074. */
  10075. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10076. private _shadowMap;
  10077. private _shadowMap2;
  10078. /**
  10079. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10080. * @returns The render target texture if present otherwise, null
  10081. */
  10082. getShadowMap(): Nullable<RenderTargetTexture>;
  10083. /**
  10084. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10085. * @returns The render target texture if the shadow map is present otherwise, null
  10086. */
  10087. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10088. /**
  10089. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10090. * @param mesh Mesh to add
  10091. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10092. * @returns the Shadow Generator itself
  10093. */
  10094. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10095. /**
  10096. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10097. * @param mesh Mesh to remove
  10098. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10099. * @returns the Shadow Generator itself
  10100. */
  10101. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10102. /**
  10103. * Controls the extent to which the shadows fade out at the edge of the frustum
  10104. * Used only by directionals and spots
  10105. */
  10106. frustumEdgeFalloff: number;
  10107. private _light;
  10108. /**
  10109. * Returns the associated light object.
  10110. * @returns the light generating the shadow
  10111. */
  10112. getLight(): IShadowLight;
  10113. /**
  10114. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10115. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10116. * It might on the other hand introduce peter panning.
  10117. */
  10118. forceBackFacesOnly: boolean;
  10119. private _scene;
  10120. private _lightDirection;
  10121. private _effect;
  10122. private _viewMatrix;
  10123. private _projectionMatrix;
  10124. private _transformMatrix;
  10125. private _cachedPosition;
  10126. private _cachedDirection;
  10127. private _cachedDefines;
  10128. private _currentRenderID;
  10129. private _boxBlurPostprocess;
  10130. private _kernelBlurXPostprocess;
  10131. private _kernelBlurYPostprocess;
  10132. private _blurPostProcesses;
  10133. private _mapSize;
  10134. private _currentFaceIndex;
  10135. private _currentFaceIndexCache;
  10136. private _textureType;
  10137. private _defaultTextureMatrix;
  10138. /** @hidden */
  10139. static _SceneComponentInitialization: (scene: Scene) => void;
  10140. /**
  10141. * Creates a ShadowGenerator object.
  10142. * A ShadowGenerator is the required tool to use the shadows.
  10143. * Each light casting shadows needs to use its own ShadowGenerator.
  10144. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10145. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10146. * @param light The light object generating the shadows.
  10147. * @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.
  10148. */
  10149. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10150. private _initializeGenerator;
  10151. private _initializeShadowMap;
  10152. private _initializeBlurRTTAndPostProcesses;
  10153. private _renderForShadowMap;
  10154. private _renderSubMeshForShadowMap;
  10155. private _applyFilterValues;
  10156. /**
  10157. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10158. * @param onCompiled Callback triggered at the and of the effects compilation
  10159. * @param options Sets of optional options forcing the compilation with different modes
  10160. */
  10161. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10162. useInstances: boolean;
  10163. }>): void;
  10164. /**
  10165. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10166. * @param options Sets of optional options forcing the compilation with different modes
  10167. * @returns A promise that resolves when the compilation completes
  10168. */
  10169. forceCompilationAsync(options?: Partial<{
  10170. useInstances: boolean;
  10171. }>): Promise<void>;
  10172. /**
  10173. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10174. * @param subMesh The submesh we want to render in the shadow map
  10175. * @param useInstances Defines wether will draw in the map using instances
  10176. * @returns true if ready otherwise, false
  10177. */
  10178. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10179. /**
  10180. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10181. * @param defines Defines of the material we want to update
  10182. * @param lightIndex Index of the light in the enabled light list of the material
  10183. */
  10184. prepareDefines(defines: any, lightIndex: number): void;
  10185. /**
  10186. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10187. * defined in the generator but impacting the effect).
  10188. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10189. * @param effect The effect we are binfing the information for
  10190. */
  10191. bindShadowLight(lightIndex: string, effect: Effect): void;
  10192. /**
  10193. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10194. * (eq to shadow prjection matrix * light transform matrix)
  10195. * @returns The transform matrix used to create the shadow map
  10196. */
  10197. getTransformMatrix(): Matrix;
  10198. /**
  10199. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10200. * Cube and 2D textures for instance.
  10201. */
  10202. recreateShadowMap(): void;
  10203. private _disposeBlurPostProcesses;
  10204. private _disposeRTTandPostProcesses;
  10205. /**
  10206. * Disposes the ShadowGenerator.
  10207. * Returns nothing.
  10208. */
  10209. dispose(): void;
  10210. /**
  10211. * Serializes the shadow generator setup to a json object.
  10212. * @returns The serialized JSON object
  10213. */
  10214. serialize(): any;
  10215. /**
  10216. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10217. * @param parsedShadowGenerator The JSON object to parse
  10218. * @param scene The scene to create the shadow map for
  10219. * @returns The parsed shadow generator
  10220. */
  10221. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10222. }
  10223. }
  10224. declare module BABYLON {
  10225. /**
  10226. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10227. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10228. * 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.
  10229. */
  10230. export abstract class Light extends Node {
  10231. /**
  10232. * Falloff Default: light is falling off following the material specification:
  10233. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10234. */
  10235. static readonly FALLOFF_DEFAULT: number;
  10236. /**
  10237. * Falloff Physical: light is falling off following the inverse squared distance law.
  10238. */
  10239. static readonly FALLOFF_PHYSICAL: number;
  10240. /**
  10241. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10242. * to enhance interoperability with other engines.
  10243. */
  10244. static readonly FALLOFF_GLTF: number;
  10245. /**
  10246. * Falloff Standard: light is falling off like in the standard material
  10247. * to enhance interoperability with other materials.
  10248. */
  10249. static readonly FALLOFF_STANDARD: number;
  10250. /**
  10251. * If every light affecting the material is in this lightmapMode,
  10252. * material.lightmapTexture adds or multiplies
  10253. * (depends on material.useLightmapAsShadowmap)
  10254. * after every other light calculations.
  10255. */
  10256. static readonly LIGHTMAP_DEFAULT: number;
  10257. /**
  10258. * material.lightmapTexture as only diffuse lighting from this light
  10259. * adds only specular lighting from this light
  10260. * adds dynamic shadows
  10261. */
  10262. static readonly LIGHTMAP_SPECULAR: number;
  10263. /**
  10264. * material.lightmapTexture as only lighting
  10265. * no light calculation from this light
  10266. * only adds dynamic shadows from this light
  10267. */
  10268. static readonly LIGHTMAP_SHADOWSONLY: number;
  10269. /**
  10270. * Each light type uses the default quantity according to its type:
  10271. * point/spot lights use luminous intensity
  10272. * directional lights use illuminance
  10273. */
  10274. static readonly INTENSITYMODE_AUTOMATIC: number;
  10275. /**
  10276. * lumen (lm)
  10277. */
  10278. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10279. /**
  10280. * candela (lm/sr)
  10281. */
  10282. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10283. /**
  10284. * lux (lm/m^2)
  10285. */
  10286. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10287. /**
  10288. * nit (cd/m^2)
  10289. */
  10290. static readonly INTENSITYMODE_LUMINANCE: number;
  10291. /**
  10292. * Light type const id of the point light.
  10293. */
  10294. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10295. /**
  10296. * Light type const id of the directional light.
  10297. */
  10298. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10299. /**
  10300. * Light type const id of the spot light.
  10301. */
  10302. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10303. /**
  10304. * Light type const id of the hemispheric light.
  10305. */
  10306. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10307. /**
  10308. * Diffuse gives the basic color to an object.
  10309. */
  10310. diffuse: Color3;
  10311. /**
  10312. * Specular produces a highlight color on an object.
  10313. * Note: This is note affecting PBR materials.
  10314. */
  10315. specular: Color3;
  10316. /**
  10317. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10318. * falling off base on range or angle.
  10319. * This can be set to any values in Light.FALLOFF_x.
  10320. *
  10321. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10322. * other types of materials.
  10323. */
  10324. falloffType: number;
  10325. /**
  10326. * Strength of the light.
  10327. * Note: By default it is define in the framework own unit.
  10328. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10329. */
  10330. intensity: number;
  10331. private _range;
  10332. protected _inverseSquaredRange: number;
  10333. /**
  10334. * Defines how far from the source the light is impacting in scene units.
  10335. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10336. */
  10337. /**
  10338. * Defines how far from the source the light is impacting in scene units.
  10339. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10340. */
  10341. range: number;
  10342. /**
  10343. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10344. * of light.
  10345. */
  10346. private _photometricScale;
  10347. private _intensityMode;
  10348. /**
  10349. * Gets the photometric scale used to interpret the intensity.
  10350. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10351. */
  10352. /**
  10353. * Sets the photometric scale used to interpret the intensity.
  10354. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10355. */
  10356. intensityMode: number;
  10357. private _radius;
  10358. /**
  10359. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10360. */
  10361. /**
  10362. * sets the light radius used by PBR Materials to simulate soft area lights.
  10363. */
  10364. radius: number;
  10365. private _renderPriority;
  10366. /**
  10367. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10368. * exceeding the number allowed of the materials.
  10369. */
  10370. renderPriority: number;
  10371. private _shadowEnabled;
  10372. /**
  10373. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10374. * the current shadow generator.
  10375. */
  10376. /**
  10377. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10378. * the current shadow generator.
  10379. */
  10380. shadowEnabled: boolean;
  10381. private _includedOnlyMeshes;
  10382. /**
  10383. * Gets the only meshes impacted by this light.
  10384. */
  10385. /**
  10386. * Sets the only meshes impacted by this light.
  10387. */
  10388. includedOnlyMeshes: AbstractMesh[];
  10389. private _excludedMeshes;
  10390. /**
  10391. * Gets the meshes not impacted by this light.
  10392. */
  10393. /**
  10394. * Sets the meshes not impacted by this light.
  10395. */
  10396. excludedMeshes: AbstractMesh[];
  10397. private _excludeWithLayerMask;
  10398. /**
  10399. * Gets the layer id use to find what meshes are not impacted by the light.
  10400. * Inactive if 0
  10401. */
  10402. /**
  10403. * Sets the layer id use to find what meshes are not impacted by the light.
  10404. * Inactive if 0
  10405. */
  10406. excludeWithLayerMask: number;
  10407. private _includeOnlyWithLayerMask;
  10408. /**
  10409. * Gets the layer id use to find what meshes are impacted by the light.
  10410. * Inactive if 0
  10411. */
  10412. /**
  10413. * Sets the layer id use to find what meshes are impacted by the light.
  10414. * Inactive if 0
  10415. */
  10416. includeOnlyWithLayerMask: number;
  10417. private _lightmapMode;
  10418. /**
  10419. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10420. */
  10421. /**
  10422. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10423. */
  10424. lightmapMode: number;
  10425. /**
  10426. * Shadow generator associted to the light.
  10427. * @hidden Internal use only.
  10428. */
  10429. _shadowGenerator: Nullable<IShadowGenerator>;
  10430. /**
  10431. * @hidden Internal use only.
  10432. */
  10433. _excludedMeshesIds: string[];
  10434. /**
  10435. * @hidden Internal use only.
  10436. */
  10437. _includedOnlyMeshesIds: string[];
  10438. /**
  10439. * The current light unifom buffer.
  10440. * @hidden Internal use only.
  10441. */
  10442. _uniformBuffer: UniformBuffer;
  10443. /**
  10444. * Creates a Light object in the scene.
  10445. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10446. * @param name The firendly name of the light
  10447. * @param scene The scene the light belongs too
  10448. */
  10449. constructor(name: string, scene: Scene);
  10450. protected abstract _buildUniformLayout(): void;
  10451. /**
  10452. * Sets the passed Effect "effect" with the Light information.
  10453. * @param effect The effect to update
  10454. * @param lightIndex The index of the light in the effect to update
  10455. * @returns The light
  10456. */
  10457. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10458. /**
  10459. * Returns the string "Light".
  10460. * @returns the class name
  10461. */
  10462. getClassName(): string;
  10463. /** @hidden */
  10464. readonly _isLight: boolean;
  10465. /**
  10466. * Converts the light information to a readable string for debug purpose.
  10467. * @param fullDetails Supports for multiple levels of logging within scene loading
  10468. * @returns the human readable light info
  10469. */
  10470. toString(fullDetails?: boolean): string;
  10471. /** @hidden */
  10472. protected _syncParentEnabledState(): void;
  10473. /**
  10474. * Set the enabled state of this node.
  10475. * @param value - the new enabled state
  10476. */
  10477. setEnabled(value: boolean): void;
  10478. /**
  10479. * Returns the Light associated shadow generator if any.
  10480. * @return the associated shadow generator.
  10481. */
  10482. getShadowGenerator(): Nullable<IShadowGenerator>;
  10483. /**
  10484. * Returns a Vector3, the absolute light position in the World.
  10485. * @returns the world space position of the light
  10486. */
  10487. getAbsolutePosition(): Vector3;
  10488. /**
  10489. * Specifies if the light will affect the passed mesh.
  10490. * @param mesh The mesh to test against the light
  10491. * @return true the mesh is affected otherwise, false.
  10492. */
  10493. canAffectMesh(mesh: AbstractMesh): boolean;
  10494. /**
  10495. * Sort function to order lights for rendering.
  10496. * @param a First Light object to compare to second.
  10497. * @param b Second Light object to compare first.
  10498. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10499. */
  10500. static CompareLightsPriority(a: Light, b: Light): number;
  10501. /**
  10502. * Releases resources associated with this node.
  10503. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10504. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10505. */
  10506. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10507. /**
  10508. * Returns the light type ID (integer).
  10509. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10510. */
  10511. getTypeID(): number;
  10512. /**
  10513. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10514. * @returns the scaled intensity in intensity mode unit
  10515. */
  10516. getScaledIntensity(): number;
  10517. /**
  10518. * Returns a new Light object, named "name", from the current one.
  10519. * @param name The name of the cloned light
  10520. * @returns the new created light
  10521. */
  10522. clone(name: string): Nullable<Light>;
  10523. /**
  10524. * Serializes the current light into a Serialization object.
  10525. * @returns the serialized object.
  10526. */
  10527. serialize(): any;
  10528. /**
  10529. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10530. * This new light is named "name" and added to the passed scene.
  10531. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10532. * @param name The friendly name of the light
  10533. * @param scene The scene the new light will belong to
  10534. * @returns the constructor function
  10535. */
  10536. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10537. /**
  10538. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10539. * @param parsedLight The JSON representation of the light
  10540. * @param scene The scene to create the parsed light in
  10541. * @returns the created light after parsing
  10542. */
  10543. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10544. private _hookArrayForExcluded;
  10545. private _hookArrayForIncludedOnly;
  10546. private _resyncMeshes;
  10547. /**
  10548. * Forces the meshes to update their light related information in their rendering used effects
  10549. * @hidden Internal Use Only
  10550. */
  10551. _markMeshesAsLightDirty(): void;
  10552. /**
  10553. * Recomputes the cached photometric scale if needed.
  10554. */
  10555. private _computePhotometricScale;
  10556. /**
  10557. * Returns the Photometric Scale according to the light type and intensity mode.
  10558. */
  10559. private _getPhotometricScale;
  10560. /**
  10561. * Reorder the light in the scene according to their defined priority.
  10562. * @hidden Internal Use Only
  10563. */
  10564. _reorderLightsInScene(): void;
  10565. /**
  10566. * Prepares the list of defines specific to the light type.
  10567. * @param defines the list of defines
  10568. * @param lightIndex defines the index of the light for the effect
  10569. */
  10570. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10571. }
  10572. }
  10573. declare module BABYLON {
  10574. /**
  10575. * Interface used to define Action
  10576. */
  10577. export interface IAction {
  10578. /**
  10579. * Trigger for the action
  10580. */
  10581. trigger: number;
  10582. /** Options of the trigger */
  10583. triggerOptions: any;
  10584. /**
  10585. * Gets the trigger parameters
  10586. * @returns the trigger parameters
  10587. */
  10588. getTriggerParameter(): any;
  10589. /**
  10590. * Internal only - executes current action event
  10591. * @hidden
  10592. */
  10593. _executeCurrent(evt?: ActionEvent): void;
  10594. /**
  10595. * Serialize placeholder for child classes
  10596. * @param parent of child
  10597. * @returns the serialized object
  10598. */
  10599. serialize(parent: any): any;
  10600. /**
  10601. * Internal only
  10602. * @hidden
  10603. */
  10604. _prepare(): void;
  10605. /**
  10606. * Internal only - manager for action
  10607. * @hidden
  10608. */
  10609. _actionManager: AbstractActionManager;
  10610. }
  10611. /**
  10612. * The action to be carried out following a trigger
  10613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10614. */
  10615. export class Action implements IAction {
  10616. /** the trigger, with or without parameters, for the action */
  10617. triggerOptions: any;
  10618. /**
  10619. * Trigger for the action
  10620. */
  10621. trigger: number;
  10622. /**
  10623. * Internal only - manager for action
  10624. * @hidden
  10625. */
  10626. _actionManager: ActionManager;
  10627. private _nextActiveAction;
  10628. private _child;
  10629. private _condition?;
  10630. private _triggerParameter;
  10631. /**
  10632. * An event triggered prior to action being executed.
  10633. */
  10634. onBeforeExecuteObservable: Observable<Action>;
  10635. /**
  10636. * Creates a new Action
  10637. * @param triggerOptions the trigger, with or without parameters, for the action
  10638. * @param condition an optional determinant of action
  10639. */
  10640. constructor(
  10641. /** the trigger, with or without parameters, for the action */
  10642. triggerOptions: any, condition?: Condition);
  10643. /**
  10644. * Internal only
  10645. * @hidden
  10646. */
  10647. _prepare(): void;
  10648. /**
  10649. * Gets the trigger parameters
  10650. * @returns the trigger parameters
  10651. */
  10652. getTriggerParameter(): any;
  10653. /**
  10654. * Internal only - executes current action event
  10655. * @hidden
  10656. */
  10657. _executeCurrent(evt?: ActionEvent): void;
  10658. /**
  10659. * Execute placeholder for child classes
  10660. * @param evt optional action event
  10661. */
  10662. execute(evt?: ActionEvent): void;
  10663. /**
  10664. * Skips to next active action
  10665. */
  10666. skipToNextActiveAction(): void;
  10667. /**
  10668. * Adds action to chain of actions, may be a DoNothingAction
  10669. * @param action defines the next action to execute
  10670. * @returns The action passed in
  10671. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10672. */
  10673. then(action: Action): Action;
  10674. /**
  10675. * Internal only
  10676. * @hidden
  10677. */
  10678. _getProperty(propertyPath: string): string;
  10679. /**
  10680. * Internal only
  10681. * @hidden
  10682. */
  10683. _getEffectiveTarget(target: any, propertyPath: string): any;
  10684. /**
  10685. * Serialize placeholder for child classes
  10686. * @param parent of child
  10687. * @returns the serialized object
  10688. */
  10689. serialize(parent: any): any;
  10690. /**
  10691. * Internal only called by serialize
  10692. * @hidden
  10693. */
  10694. protected _serialize(serializedAction: any, parent?: any): any;
  10695. /**
  10696. * Internal only
  10697. * @hidden
  10698. */
  10699. static _SerializeValueAsString: (value: any) => string;
  10700. /**
  10701. * Internal only
  10702. * @hidden
  10703. */
  10704. static _GetTargetProperty: (target: Scene | Node) => {
  10705. name: string;
  10706. targetType: string;
  10707. value: string;
  10708. };
  10709. }
  10710. }
  10711. declare module BABYLON {
  10712. /**
  10713. * A Condition applied to an Action
  10714. */
  10715. export class Condition {
  10716. /**
  10717. * Internal only - manager for action
  10718. * @hidden
  10719. */
  10720. _actionManager: ActionManager;
  10721. /**
  10722. * Internal only
  10723. * @hidden
  10724. */
  10725. _evaluationId: number;
  10726. /**
  10727. * Internal only
  10728. * @hidden
  10729. */
  10730. _currentResult: boolean;
  10731. /**
  10732. * Creates a new Condition
  10733. * @param actionManager the manager of the action the condition is applied to
  10734. */
  10735. constructor(actionManager: ActionManager);
  10736. /**
  10737. * Check if the current condition is valid
  10738. * @returns a boolean
  10739. */
  10740. isValid(): boolean;
  10741. /**
  10742. * Internal only
  10743. * @hidden
  10744. */
  10745. _getProperty(propertyPath: string): string;
  10746. /**
  10747. * Internal only
  10748. * @hidden
  10749. */
  10750. _getEffectiveTarget(target: any, propertyPath: string): any;
  10751. /**
  10752. * Serialize placeholder for child classes
  10753. * @returns the serialized object
  10754. */
  10755. serialize(): any;
  10756. /**
  10757. * Internal only
  10758. * @hidden
  10759. */
  10760. protected _serialize(serializedCondition: any): any;
  10761. }
  10762. /**
  10763. * Defines specific conditional operators as extensions of Condition
  10764. */
  10765. export class ValueCondition extends Condition {
  10766. /** path to specify the property of the target the conditional operator uses */
  10767. propertyPath: string;
  10768. /** the value compared by the conditional operator against the current value of the property */
  10769. value: any;
  10770. /** the conditional operator, default ValueCondition.IsEqual */
  10771. operator: number;
  10772. /**
  10773. * Internal only
  10774. * @hidden
  10775. */
  10776. private static _IsEqual;
  10777. /**
  10778. * Internal only
  10779. * @hidden
  10780. */
  10781. private static _IsDifferent;
  10782. /**
  10783. * Internal only
  10784. * @hidden
  10785. */
  10786. private static _IsGreater;
  10787. /**
  10788. * Internal only
  10789. * @hidden
  10790. */
  10791. private static _IsLesser;
  10792. /**
  10793. * returns the number for IsEqual
  10794. */
  10795. static readonly IsEqual: number;
  10796. /**
  10797. * Returns the number for IsDifferent
  10798. */
  10799. static readonly IsDifferent: number;
  10800. /**
  10801. * Returns the number for IsGreater
  10802. */
  10803. static readonly IsGreater: number;
  10804. /**
  10805. * Returns the number for IsLesser
  10806. */
  10807. static readonly IsLesser: number;
  10808. /**
  10809. * Internal only The action manager for the condition
  10810. * @hidden
  10811. */
  10812. _actionManager: ActionManager;
  10813. /**
  10814. * Internal only
  10815. * @hidden
  10816. */
  10817. private _target;
  10818. /**
  10819. * Internal only
  10820. * @hidden
  10821. */
  10822. private _effectiveTarget;
  10823. /**
  10824. * Internal only
  10825. * @hidden
  10826. */
  10827. private _property;
  10828. /**
  10829. * Creates a new ValueCondition
  10830. * @param actionManager manager for the action the condition applies to
  10831. * @param target for the action
  10832. * @param propertyPath path to specify the property of the target the conditional operator uses
  10833. * @param value the value compared by the conditional operator against the current value of the property
  10834. * @param operator the conditional operator, default ValueCondition.IsEqual
  10835. */
  10836. constructor(actionManager: ActionManager, target: any,
  10837. /** path to specify the property of the target the conditional operator uses */
  10838. propertyPath: string,
  10839. /** the value compared by the conditional operator against the current value of the property */
  10840. value: any,
  10841. /** the conditional operator, default ValueCondition.IsEqual */
  10842. operator?: number);
  10843. /**
  10844. * Compares the given value with the property value for the specified conditional operator
  10845. * @returns the result of the comparison
  10846. */
  10847. isValid(): boolean;
  10848. /**
  10849. * Serialize the ValueCondition into a JSON compatible object
  10850. * @returns serialization object
  10851. */
  10852. serialize(): any;
  10853. /**
  10854. * Gets the name of the conditional operator for the ValueCondition
  10855. * @param operator the conditional operator
  10856. * @returns the name
  10857. */
  10858. static GetOperatorName(operator: number): string;
  10859. }
  10860. /**
  10861. * Defines a predicate condition as an extension of Condition
  10862. */
  10863. export class PredicateCondition extends Condition {
  10864. /** defines the predicate function used to validate the condition */
  10865. predicate: () => boolean;
  10866. /**
  10867. * Internal only - manager for action
  10868. * @hidden
  10869. */
  10870. _actionManager: ActionManager;
  10871. /**
  10872. * Creates a new PredicateCondition
  10873. * @param actionManager manager for the action the condition applies to
  10874. * @param predicate defines the predicate function used to validate the condition
  10875. */
  10876. constructor(actionManager: ActionManager,
  10877. /** defines the predicate function used to validate the condition */
  10878. predicate: () => boolean);
  10879. /**
  10880. * @returns the validity of the predicate condition
  10881. */
  10882. isValid(): boolean;
  10883. }
  10884. /**
  10885. * Defines a state condition as an extension of Condition
  10886. */
  10887. export class StateCondition extends Condition {
  10888. /** Value to compare with target state */
  10889. value: string;
  10890. /**
  10891. * Internal only - manager for action
  10892. * @hidden
  10893. */
  10894. _actionManager: ActionManager;
  10895. /**
  10896. * Internal only
  10897. * @hidden
  10898. */
  10899. private _target;
  10900. /**
  10901. * Creates a new StateCondition
  10902. * @param actionManager manager for the action the condition applies to
  10903. * @param target of the condition
  10904. * @param value to compare with target state
  10905. */
  10906. constructor(actionManager: ActionManager, target: any,
  10907. /** Value to compare with target state */
  10908. value: string);
  10909. /**
  10910. * Gets a boolean indicating if the current condition is met
  10911. * @returns the validity of the state
  10912. */
  10913. isValid(): boolean;
  10914. /**
  10915. * Serialize the StateCondition into a JSON compatible object
  10916. * @returns serialization object
  10917. */
  10918. serialize(): any;
  10919. }
  10920. }
  10921. declare module BABYLON {
  10922. /**
  10923. * This defines an action responsible to toggle a boolean once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class SwitchBooleanAction extends Action {
  10927. /**
  10928. * The path to the boolean property in the target object
  10929. */
  10930. propertyPath: string;
  10931. private _target;
  10932. private _effectiveTarget;
  10933. private _property;
  10934. /**
  10935. * Instantiate the action
  10936. * @param triggerOptions defines the trigger options
  10937. * @param target defines the object containing the boolean
  10938. * @param propertyPath defines the path to the boolean property in the target object
  10939. * @param condition defines the trigger related conditions
  10940. */
  10941. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10942. /** @hidden */
  10943. _prepare(): void;
  10944. /**
  10945. * Execute the action toggle the boolean value.
  10946. */
  10947. execute(): void;
  10948. /**
  10949. * Serializes the actions and its related information.
  10950. * @param parent defines the object to serialize in
  10951. * @returns the serialized object
  10952. */
  10953. serialize(parent: any): any;
  10954. }
  10955. /**
  10956. * This defines an action responsible to set a the state field of the target
  10957. * to a desired value once triggered.
  10958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10959. */
  10960. export class SetStateAction extends Action {
  10961. /**
  10962. * The value to store in the state field.
  10963. */
  10964. value: string;
  10965. private _target;
  10966. /**
  10967. * Instantiate the action
  10968. * @param triggerOptions defines the trigger options
  10969. * @param target defines the object containing the state property
  10970. * @param value defines the value to store in the state field
  10971. * @param condition defines the trigger related conditions
  10972. */
  10973. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10974. /**
  10975. * Execute the action and store the value on the target state property.
  10976. */
  10977. execute(): void;
  10978. /**
  10979. * Serializes the actions and its related information.
  10980. * @param parent defines the object to serialize in
  10981. * @returns the serialized object
  10982. */
  10983. serialize(parent: any): any;
  10984. }
  10985. /**
  10986. * This defines an action responsible to set a property of the target
  10987. * to a desired value once triggered.
  10988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10989. */
  10990. export class SetValueAction extends Action {
  10991. /**
  10992. * The path of the property to set in the target.
  10993. */
  10994. propertyPath: string;
  10995. /**
  10996. * The value to set in the property
  10997. */
  10998. value: any;
  10999. private _target;
  11000. private _effectiveTarget;
  11001. private _property;
  11002. /**
  11003. * Instantiate the action
  11004. * @param triggerOptions defines the trigger options
  11005. * @param target defines the object containing the property
  11006. * @param propertyPath defines the path of the property to set in the target
  11007. * @param value defines the value to set in the property
  11008. * @param condition defines the trigger related conditions
  11009. */
  11010. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11011. /** @hidden */
  11012. _prepare(): void;
  11013. /**
  11014. * Execute the action and set the targetted property to the desired value.
  11015. */
  11016. execute(): void;
  11017. /**
  11018. * Serializes the actions and its related information.
  11019. * @param parent defines the object to serialize in
  11020. * @returns the serialized object
  11021. */
  11022. serialize(parent: any): any;
  11023. }
  11024. /**
  11025. * This defines an action responsible to increment the target value
  11026. * to a desired value once triggered.
  11027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11028. */
  11029. export class IncrementValueAction extends Action {
  11030. /**
  11031. * The path of the property to increment in the target.
  11032. */
  11033. propertyPath: string;
  11034. /**
  11035. * The value we should increment the property by.
  11036. */
  11037. value: any;
  11038. private _target;
  11039. private _effectiveTarget;
  11040. private _property;
  11041. /**
  11042. * Instantiate the action
  11043. * @param triggerOptions defines the trigger options
  11044. * @param target defines the object containing the property
  11045. * @param propertyPath defines the path of the property to increment in the target
  11046. * @param value defines the value value we should increment the property by
  11047. * @param condition defines the trigger related conditions
  11048. */
  11049. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11050. /** @hidden */
  11051. _prepare(): void;
  11052. /**
  11053. * Execute the action and increment the target of the value amount.
  11054. */
  11055. execute(): void;
  11056. /**
  11057. * Serializes the actions and its related information.
  11058. * @param parent defines the object to serialize in
  11059. * @returns the serialized object
  11060. */
  11061. serialize(parent: any): any;
  11062. }
  11063. /**
  11064. * This defines an action responsible to start an animation once triggered.
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11066. */
  11067. export class PlayAnimationAction extends Action {
  11068. /**
  11069. * Where the animation should start (animation frame)
  11070. */
  11071. from: number;
  11072. /**
  11073. * Where the animation should stop (animation frame)
  11074. */
  11075. to: number;
  11076. /**
  11077. * Define if the animation should loop or stop after the first play.
  11078. */
  11079. loop?: boolean;
  11080. private _target;
  11081. /**
  11082. * Instantiate the action
  11083. * @param triggerOptions defines the trigger options
  11084. * @param target defines the target animation or animation name
  11085. * @param from defines from where the animation should start (animation frame)
  11086. * @param end defines where the animation should stop (animation frame)
  11087. * @param loop defines if the animation should loop or stop after the first play
  11088. * @param condition defines the trigger related conditions
  11089. */
  11090. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11091. /** @hidden */
  11092. _prepare(): void;
  11093. /**
  11094. * Execute the action and play the animation.
  11095. */
  11096. execute(): void;
  11097. /**
  11098. * Serializes the actions and its related information.
  11099. * @param parent defines the object to serialize in
  11100. * @returns the serialized object
  11101. */
  11102. serialize(parent: any): any;
  11103. }
  11104. /**
  11105. * This defines an action responsible to stop an animation once triggered.
  11106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11107. */
  11108. export class StopAnimationAction extends Action {
  11109. private _target;
  11110. /**
  11111. * Instantiate the action
  11112. * @param triggerOptions defines the trigger options
  11113. * @param target defines the target animation or animation name
  11114. * @param condition defines the trigger related conditions
  11115. */
  11116. constructor(triggerOptions: any, target: any, condition?: Condition);
  11117. /** @hidden */
  11118. _prepare(): void;
  11119. /**
  11120. * Execute the action and stop the animation.
  11121. */
  11122. execute(): void;
  11123. /**
  11124. * Serializes the actions and its related information.
  11125. * @param parent defines the object to serialize in
  11126. * @returns the serialized object
  11127. */
  11128. serialize(parent: any): any;
  11129. }
  11130. /**
  11131. * This defines an action responsible that does nothing once triggered.
  11132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11133. */
  11134. export class DoNothingAction extends Action {
  11135. /**
  11136. * Instantiate the action
  11137. * @param triggerOptions defines the trigger options
  11138. * @param condition defines the trigger related conditions
  11139. */
  11140. constructor(triggerOptions?: any, condition?: Condition);
  11141. /**
  11142. * Execute the action and do nothing.
  11143. */
  11144. execute(): void;
  11145. /**
  11146. * Serializes the actions and its related information.
  11147. * @param parent defines the object to serialize in
  11148. * @returns the serialized object
  11149. */
  11150. serialize(parent: any): any;
  11151. }
  11152. /**
  11153. * This defines an action responsible to trigger several actions once triggered.
  11154. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11155. */
  11156. export class CombineAction extends Action {
  11157. /**
  11158. * The list of aggregated animations to run.
  11159. */
  11160. children: Action[];
  11161. /**
  11162. * Instantiate the action
  11163. * @param triggerOptions defines the trigger options
  11164. * @param children defines the list of aggregated animations to run
  11165. * @param condition defines the trigger related conditions
  11166. */
  11167. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11168. /** @hidden */
  11169. _prepare(): void;
  11170. /**
  11171. * Execute the action and executes all the aggregated actions.
  11172. */
  11173. execute(evt: ActionEvent): void;
  11174. /**
  11175. * Serializes the actions and its related information.
  11176. * @param parent defines the object to serialize in
  11177. * @returns the serialized object
  11178. */
  11179. serialize(parent: any): any;
  11180. }
  11181. /**
  11182. * This defines an action responsible to run code (external event) once triggered.
  11183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11184. */
  11185. export class ExecuteCodeAction extends Action {
  11186. /**
  11187. * The callback function to run.
  11188. */
  11189. func: (evt: ActionEvent) => void;
  11190. /**
  11191. * Instantiate the action
  11192. * @param triggerOptions defines the trigger options
  11193. * @param func defines the callback function to run
  11194. * @param condition defines the trigger related conditions
  11195. */
  11196. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11197. /**
  11198. * Execute the action and run the attached code.
  11199. */
  11200. execute(evt: ActionEvent): void;
  11201. }
  11202. /**
  11203. * This defines an action responsible to set the parent property of the target once triggered.
  11204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11205. */
  11206. export class SetParentAction extends Action {
  11207. private _parent;
  11208. private _target;
  11209. /**
  11210. * Instantiate the action
  11211. * @param triggerOptions defines the trigger options
  11212. * @param target defines the target containing the parent property
  11213. * @param parent defines from where the animation should start (animation frame)
  11214. * @param condition defines the trigger related conditions
  11215. */
  11216. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11217. /** @hidden */
  11218. _prepare(): void;
  11219. /**
  11220. * Execute the action and set the parent property.
  11221. */
  11222. execute(): void;
  11223. /**
  11224. * Serializes the actions and its related information.
  11225. * @param parent defines the object to serialize in
  11226. * @returns the serialized object
  11227. */
  11228. serialize(parent: any): any;
  11229. }
  11230. }
  11231. declare module BABYLON {
  11232. /**
  11233. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11234. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11236. */
  11237. export class ActionManager extends AbstractActionManager {
  11238. /**
  11239. * Nothing
  11240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11241. */
  11242. static readonly NothingTrigger: number;
  11243. /**
  11244. * On pick
  11245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11246. */
  11247. static readonly OnPickTrigger: number;
  11248. /**
  11249. * On left pick
  11250. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11251. */
  11252. static readonly OnLeftPickTrigger: number;
  11253. /**
  11254. * On right pick
  11255. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11256. */
  11257. static readonly OnRightPickTrigger: number;
  11258. /**
  11259. * On center pick
  11260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11261. */
  11262. static readonly OnCenterPickTrigger: number;
  11263. /**
  11264. * On pick down
  11265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11266. */
  11267. static readonly OnPickDownTrigger: number;
  11268. /**
  11269. * On double pick
  11270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11271. */
  11272. static readonly OnDoublePickTrigger: number;
  11273. /**
  11274. * On pick up
  11275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11276. */
  11277. static readonly OnPickUpTrigger: number;
  11278. /**
  11279. * On pick out.
  11280. * This trigger will only be raised if you also declared a OnPickDown
  11281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11282. */
  11283. static readonly OnPickOutTrigger: number;
  11284. /**
  11285. * On long press
  11286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11287. */
  11288. static readonly OnLongPressTrigger: number;
  11289. /**
  11290. * On pointer over
  11291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11292. */
  11293. static readonly OnPointerOverTrigger: number;
  11294. /**
  11295. * On pointer out
  11296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11297. */
  11298. static readonly OnPointerOutTrigger: number;
  11299. /**
  11300. * On every frame
  11301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11302. */
  11303. static readonly OnEveryFrameTrigger: number;
  11304. /**
  11305. * On intersection enter
  11306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11307. */
  11308. static readonly OnIntersectionEnterTrigger: number;
  11309. /**
  11310. * On intersection exit
  11311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11312. */
  11313. static readonly OnIntersectionExitTrigger: number;
  11314. /**
  11315. * On key down
  11316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11317. */
  11318. static readonly OnKeyDownTrigger: number;
  11319. /**
  11320. * On key up
  11321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11322. */
  11323. static readonly OnKeyUpTrigger: number;
  11324. private _scene;
  11325. /**
  11326. * Creates a new action manager
  11327. * @param scene defines the hosting scene
  11328. */
  11329. constructor(scene: Scene);
  11330. /**
  11331. * Releases all associated resources
  11332. */
  11333. dispose(): void;
  11334. /**
  11335. * Gets hosting scene
  11336. * @returns the hosting scene
  11337. */
  11338. getScene(): Scene;
  11339. /**
  11340. * Does this action manager handles actions of any of the given triggers
  11341. * @param triggers defines the triggers to be tested
  11342. * @return a boolean indicating whether one (or more) of the triggers is handled
  11343. */
  11344. hasSpecificTriggers(triggers: number[]): boolean;
  11345. /**
  11346. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11347. * speed.
  11348. * @param triggerA defines the trigger to be tested
  11349. * @param triggerB defines the trigger to be tested
  11350. * @return a boolean indicating whether one (or more) of the triggers is handled
  11351. */
  11352. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11353. /**
  11354. * Does this action manager handles actions of a given trigger
  11355. * @param trigger defines the trigger to be tested
  11356. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11357. * @return whether the trigger is handled
  11358. */
  11359. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11360. /**
  11361. * Does this action manager has pointer triggers
  11362. */
  11363. readonly hasPointerTriggers: boolean;
  11364. /**
  11365. * Does this action manager has pick triggers
  11366. */
  11367. readonly hasPickTriggers: boolean;
  11368. /**
  11369. * Registers an action to this action manager
  11370. * @param action defines the action to be registered
  11371. * @return the action amended (prepared) after registration
  11372. */
  11373. registerAction(action: IAction): Nullable<IAction>;
  11374. /**
  11375. * Unregisters an action to this action manager
  11376. * @param action defines the action to be unregistered
  11377. * @return a boolean indicating whether the action has been unregistered
  11378. */
  11379. unregisterAction(action: IAction): Boolean;
  11380. /**
  11381. * Process a specific trigger
  11382. * @param trigger defines the trigger to process
  11383. * @param evt defines the event details to be processed
  11384. */
  11385. processTrigger(trigger: number, evt?: IActionEvent): void;
  11386. /** @hidden */
  11387. _getEffectiveTarget(target: any, propertyPath: string): any;
  11388. /** @hidden */
  11389. _getProperty(propertyPath: string): string;
  11390. /**
  11391. * Serialize this manager to a JSON object
  11392. * @param name defines the property name to store this manager
  11393. * @returns a JSON representation of this manager
  11394. */
  11395. serialize(name: string): any;
  11396. /**
  11397. * Creates a new ActionManager from a JSON data
  11398. * @param parsedActions defines the JSON data to read from
  11399. * @param object defines the hosting mesh
  11400. * @param scene defines the hosting scene
  11401. */
  11402. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11403. /**
  11404. * Get a trigger name by index
  11405. * @param trigger defines the trigger index
  11406. * @returns a trigger name
  11407. */
  11408. static GetTriggerName(trigger: number): string;
  11409. }
  11410. }
  11411. declare module BABYLON {
  11412. /**
  11413. * Class representing a ray with position and direction
  11414. */
  11415. export class Ray {
  11416. /** origin point */
  11417. origin: Vector3;
  11418. /** direction */
  11419. direction: Vector3;
  11420. /** length of the ray */
  11421. length: number;
  11422. private static readonly TmpVector3;
  11423. private _tmpRay;
  11424. /**
  11425. * Creates a new ray
  11426. * @param origin origin point
  11427. * @param direction direction
  11428. * @param length length of the ray
  11429. */
  11430. constructor(
  11431. /** origin point */
  11432. origin: Vector3,
  11433. /** direction */
  11434. direction: Vector3,
  11435. /** length of the ray */
  11436. length?: number);
  11437. /**
  11438. * Checks if the ray intersects a box
  11439. * @param minimum bound of the box
  11440. * @param maximum bound of the box
  11441. * @param intersectionTreshold extra extend to be added to the box in all direction
  11442. * @returns if the box was hit
  11443. */
  11444. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11445. /**
  11446. * Checks if the ray intersects a box
  11447. * @param box the bounding box to check
  11448. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11449. * @returns if the box was hit
  11450. */
  11451. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11452. /**
  11453. * If the ray hits a sphere
  11454. * @param sphere the bounding sphere to check
  11455. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11456. * @returns true if it hits the sphere
  11457. */
  11458. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11459. /**
  11460. * If the ray hits a triange
  11461. * @param vertex0 triangle vertex
  11462. * @param vertex1 triangle vertex
  11463. * @param vertex2 triangle vertex
  11464. * @returns intersection information if hit
  11465. */
  11466. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11467. /**
  11468. * Checks if ray intersects a plane
  11469. * @param plane the plane to check
  11470. * @returns the distance away it was hit
  11471. */
  11472. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11473. /**
  11474. * Checks if ray intersects a mesh
  11475. * @param mesh the mesh to check
  11476. * @param fastCheck if only the bounding box should checked
  11477. * @returns picking info of the intersecton
  11478. */
  11479. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11480. /**
  11481. * Checks if ray intersects a mesh
  11482. * @param meshes the meshes to check
  11483. * @param fastCheck if only the bounding box should checked
  11484. * @param results array to store result in
  11485. * @returns Array of picking infos
  11486. */
  11487. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11488. private _comparePickingInfo;
  11489. private static smallnum;
  11490. private static rayl;
  11491. /**
  11492. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11493. * @param sega the first point of the segment to test the intersection against
  11494. * @param segb the second point of the segment to test the intersection against
  11495. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11496. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11497. */
  11498. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11499. /**
  11500. * Update the ray from viewport position
  11501. * @param x position
  11502. * @param y y position
  11503. * @param viewportWidth viewport width
  11504. * @param viewportHeight viewport height
  11505. * @param world world matrix
  11506. * @param view view matrix
  11507. * @param projection projection matrix
  11508. * @returns this ray updated
  11509. */
  11510. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11511. /**
  11512. * Creates a ray with origin and direction of 0,0,0
  11513. * @returns the new ray
  11514. */
  11515. static Zero(): Ray;
  11516. /**
  11517. * Creates a new ray from screen space and viewport
  11518. * @param x position
  11519. * @param y y position
  11520. * @param viewportWidth viewport width
  11521. * @param viewportHeight viewport height
  11522. * @param world world matrix
  11523. * @param view view matrix
  11524. * @param projection projection matrix
  11525. * @returns new ray
  11526. */
  11527. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11528. /**
  11529. * 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
  11530. * transformed to the given world matrix.
  11531. * @param origin The origin point
  11532. * @param end The end point
  11533. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11534. * @returns the new ray
  11535. */
  11536. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11537. /**
  11538. * Transforms a ray by a matrix
  11539. * @param ray ray to transform
  11540. * @param matrix matrix to apply
  11541. * @returns the resulting new ray
  11542. */
  11543. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11544. /**
  11545. * Transforms a ray by a matrix
  11546. * @param ray ray to transform
  11547. * @param matrix matrix to apply
  11548. * @param result ray to store result in
  11549. */
  11550. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11551. /**
  11552. * Unproject a ray from screen space to object space
  11553. * @param sourceX defines the screen space x coordinate to use
  11554. * @param sourceY defines the screen space y coordinate to use
  11555. * @param viewportWidth defines the current width of the viewport
  11556. * @param viewportHeight defines the current height of the viewport
  11557. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11558. * @param view defines the view matrix to use
  11559. * @param projection defines the projection matrix to use
  11560. */
  11561. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11562. }
  11563. /**
  11564. * Type used to define predicate used to select faces when a mesh intersection is detected
  11565. */
  11566. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11567. interface Scene {
  11568. /** @hidden */
  11569. _tempPickingRay: Nullable<Ray>;
  11570. /** @hidden */
  11571. _cachedRayForTransform: Ray;
  11572. /** @hidden */
  11573. _pickWithRayInverseMatrix: Matrix;
  11574. /** @hidden */
  11575. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11576. /** @hidden */
  11577. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11578. }
  11579. }
  11580. declare module BABYLON {
  11581. /**
  11582. * Groups all the scene component constants in one place to ease maintenance.
  11583. * @hidden
  11584. */
  11585. export class SceneComponentConstants {
  11586. static readonly NAME_EFFECTLAYER: string;
  11587. static readonly NAME_LAYER: string;
  11588. static readonly NAME_LENSFLARESYSTEM: string;
  11589. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11590. static readonly NAME_PARTICLESYSTEM: string;
  11591. static readonly NAME_GAMEPAD: string;
  11592. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11593. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11594. static readonly NAME_DEPTHRENDERER: string;
  11595. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11596. static readonly NAME_SPRITE: string;
  11597. static readonly NAME_OUTLINERENDERER: string;
  11598. static readonly NAME_PROCEDURALTEXTURE: string;
  11599. static readonly NAME_SHADOWGENERATOR: string;
  11600. static readonly NAME_OCTREE: string;
  11601. static readonly NAME_PHYSICSENGINE: string;
  11602. static readonly NAME_AUDIO: string;
  11603. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11604. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11605. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11606. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11607. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11608. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11609. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11610. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11611. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11612. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11613. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11614. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11615. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11616. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11617. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11618. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11619. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11620. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11621. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11622. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11623. static readonly STEP_AFTERRENDER_AUDIO: number;
  11624. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11625. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11626. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11627. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11628. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11629. static readonly STEP_POINTERMOVE_SPRITE: number;
  11630. static readonly STEP_POINTERDOWN_SPRITE: number;
  11631. static readonly STEP_POINTERUP_SPRITE: number;
  11632. }
  11633. /**
  11634. * This represents a scene component.
  11635. *
  11636. * This is used to decouple the dependency the scene is having on the different workloads like
  11637. * layers, post processes...
  11638. */
  11639. export interface ISceneComponent {
  11640. /**
  11641. * The name of the component. Each component must have a unique name.
  11642. */
  11643. name: string;
  11644. /**
  11645. * The scene the component belongs to.
  11646. */
  11647. scene: Scene;
  11648. /**
  11649. * Register the component to one instance of a scene.
  11650. */
  11651. register(): void;
  11652. /**
  11653. * Rebuilds the elements related to this component in case of
  11654. * context lost for instance.
  11655. */
  11656. rebuild(): void;
  11657. /**
  11658. * Disposes the component and the associated ressources.
  11659. */
  11660. dispose(): void;
  11661. }
  11662. /**
  11663. * This represents a SERIALIZABLE scene component.
  11664. *
  11665. * This extends Scene Component to add Serialization methods on top.
  11666. */
  11667. export interface ISceneSerializableComponent extends ISceneComponent {
  11668. /**
  11669. * Adds all the element from the container to the scene
  11670. * @param container the container holding the elements
  11671. */
  11672. addFromContainer(container: AbstractScene): void;
  11673. /**
  11674. * Removes all the elements in the container from the scene
  11675. * @param container contains the elements to remove
  11676. * @param dispose if the removed element should be disposed (default: false)
  11677. */
  11678. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11679. /**
  11680. * Serializes the component data to the specified json object
  11681. * @param serializationObject The object to serialize to
  11682. */
  11683. serialize(serializationObject: any): void;
  11684. }
  11685. /**
  11686. * Strong typing of a Mesh related stage step action
  11687. */
  11688. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11689. /**
  11690. * Strong typing of a Evaluate Sub Mesh related stage step action
  11691. */
  11692. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11693. /**
  11694. * Strong typing of a Active Mesh related stage step action
  11695. */
  11696. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11697. /**
  11698. * Strong typing of a Camera related stage step action
  11699. */
  11700. export type CameraStageAction = (camera: Camera) => void;
  11701. /**
  11702. * Strong typing of a Camera Frame buffer related stage step action
  11703. */
  11704. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11705. /**
  11706. * Strong typing of a Render Target related stage step action
  11707. */
  11708. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11709. /**
  11710. * Strong typing of a RenderingGroup related stage step action
  11711. */
  11712. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11713. /**
  11714. * Strong typing of a Mesh Render related stage step action
  11715. */
  11716. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11717. /**
  11718. * Strong typing of a simple stage step action
  11719. */
  11720. export type SimpleStageAction = () => void;
  11721. /**
  11722. * Strong typing of a render target action.
  11723. */
  11724. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11725. /**
  11726. * Strong typing of a pointer move action.
  11727. */
  11728. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11729. /**
  11730. * Strong typing of a pointer up/down action.
  11731. */
  11732. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11733. /**
  11734. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11735. * @hidden
  11736. */
  11737. export class Stage<T extends Function> extends Array<{
  11738. index: number;
  11739. component: ISceneComponent;
  11740. action: T;
  11741. }> {
  11742. /**
  11743. * Hide ctor from the rest of the world.
  11744. * @param items The items to add.
  11745. */
  11746. private constructor();
  11747. /**
  11748. * Creates a new Stage.
  11749. * @returns A new instance of a Stage
  11750. */
  11751. static Create<T extends Function>(): Stage<T>;
  11752. /**
  11753. * Registers a step in an ordered way in the targeted stage.
  11754. * @param index Defines the position to register the step in
  11755. * @param component Defines the component attached to the step
  11756. * @param action Defines the action to launch during the step
  11757. */
  11758. registerStep(index: number, component: ISceneComponent, action: T): void;
  11759. /**
  11760. * Clears all the steps from the stage.
  11761. */
  11762. clear(): void;
  11763. }
  11764. }
  11765. declare module BABYLON {
  11766. interface Scene {
  11767. /** @hidden */
  11768. _pointerOverSprite: Nullable<Sprite>;
  11769. /** @hidden */
  11770. _pickedDownSprite: Nullable<Sprite>;
  11771. /** @hidden */
  11772. _tempSpritePickingRay: Nullable<Ray>;
  11773. /**
  11774. * All of the sprite managers added to this scene
  11775. * @see http://doc.babylonjs.com/babylon101/sprites
  11776. */
  11777. spriteManagers: Array<ISpriteManager>;
  11778. /**
  11779. * An event triggered when sprites rendering is about to start
  11780. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11781. */
  11782. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11783. /**
  11784. * An event triggered when sprites rendering is done
  11785. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11786. */
  11787. onAfterSpritesRenderingObservable: Observable<Scene>;
  11788. /** @hidden */
  11789. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11790. /** Launch a ray to try to pick a sprite in the scene
  11791. * @param x position on screen
  11792. * @param y position on screen
  11793. * @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
  11794. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11795. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11796. * @returns a PickingInfo
  11797. */
  11798. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11799. /** Use the given ray to pick a sprite in the scene
  11800. * @param ray The ray (in world space) to use to pick meshes
  11801. * @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
  11802. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11803. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11804. * @returns a PickingInfo
  11805. */
  11806. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11807. /**
  11808. * Force the sprite under the pointer
  11809. * @param sprite defines the sprite to use
  11810. */
  11811. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11812. /**
  11813. * Gets the sprite under the pointer
  11814. * @returns a Sprite or null if no sprite is under the pointer
  11815. */
  11816. getPointerOverSprite(): Nullable<Sprite>;
  11817. }
  11818. /**
  11819. * Defines the sprite scene component responsible to manage sprites
  11820. * in a given scene.
  11821. */
  11822. export class SpriteSceneComponent implements ISceneComponent {
  11823. /**
  11824. * The component name helpfull to identify the component in the list of scene components.
  11825. */
  11826. readonly name: string;
  11827. /**
  11828. * The scene the component belongs to.
  11829. */
  11830. scene: Scene;
  11831. /** @hidden */
  11832. private _spritePredicate;
  11833. /**
  11834. * Creates a new instance of the component for the given scene
  11835. * @param scene Defines the scene to register the component in
  11836. */
  11837. constructor(scene: Scene);
  11838. /**
  11839. * Registers the component in a given scene
  11840. */
  11841. register(): void;
  11842. /**
  11843. * Rebuilds the elements related to this component in case of
  11844. * context lost for instance.
  11845. */
  11846. rebuild(): void;
  11847. /**
  11848. * Disposes the component and the associated ressources.
  11849. */
  11850. dispose(): void;
  11851. private _pickSpriteButKeepRay;
  11852. private _pointerMove;
  11853. private _pointerDown;
  11854. private _pointerUp;
  11855. }
  11856. }
  11857. declare module BABYLON {
  11858. /** @hidden */
  11859. export var fogFragmentDeclaration: {
  11860. name: string;
  11861. shader: string;
  11862. };
  11863. }
  11864. declare module BABYLON {
  11865. /** @hidden */
  11866. export var fogFragment: {
  11867. name: string;
  11868. shader: string;
  11869. };
  11870. }
  11871. declare module BABYLON {
  11872. /** @hidden */
  11873. export var spritesPixelShader: {
  11874. name: string;
  11875. shader: string;
  11876. };
  11877. }
  11878. declare module BABYLON {
  11879. /** @hidden */
  11880. export var fogVertexDeclaration: {
  11881. name: string;
  11882. shader: string;
  11883. };
  11884. }
  11885. declare module BABYLON {
  11886. /** @hidden */
  11887. export var spritesVertexShader: {
  11888. name: string;
  11889. shader: string;
  11890. };
  11891. }
  11892. declare module BABYLON {
  11893. /**
  11894. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11895. */
  11896. export interface ISpriteManager extends IDisposable {
  11897. /**
  11898. * Restricts the camera to viewing objects with the same layerMask.
  11899. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11900. */
  11901. layerMask: number;
  11902. /**
  11903. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11904. */
  11905. isPickable: boolean;
  11906. /**
  11907. * Specifies the rendering group id for this mesh (0 by default)
  11908. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11909. */
  11910. renderingGroupId: number;
  11911. /**
  11912. * Defines the list of sprites managed by the manager.
  11913. */
  11914. sprites: Array<Sprite>;
  11915. /**
  11916. * Tests the intersection of a sprite with a specific ray.
  11917. * @param ray The ray we are sending to test the collision
  11918. * @param camera The camera space we are sending rays in
  11919. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11920. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11921. * @returns picking info or null.
  11922. */
  11923. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11924. /**
  11925. * Renders the list of sprites on screen.
  11926. */
  11927. render(): void;
  11928. }
  11929. /**
  11930. * Class used to manage multiple sprites on the same spritesheet
  11931. * @see http://doc.babylonjs.com/babylon101/sprites
  11932. */
  11933. export class SpriteManager implements ISpriteManager {
  11934. /** defines the manager's name */
  11935. name: string;
  11936. /** Gets the list of sprites */
  11937. sprites: Sprite[];
  11938. /** Gets or sets the rendering group id (0 by default) */
  11939. renderingGroupId: number;
  11940. /** Gets or sets camera layer mask */
  11941. layerMask: number;
  11942. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11943. fogEnabled: boolean;
  11944. /** Gets or sets a boolean indicating if the sprites are pickable */
  11945. isPickable: boolean;
  11946. /** Defines the default width of a cell in the spritesheet */
  11947. cellWidth: number;
  11948. /** Defines the default height of a cell in the spritesheet */
  11949. cellHeight: number;
  11950. /**
  11951. * An event triggered when the manager is disposed.
  11952. */
  11953. onDisposeObservable: Observable<SpriteManager>;
  11954. private _onDisposeObserver;
  11955. /**
  11956. * Callback called when the manager is disposed
  11957. */
  11958. onDispose: () => void;
  11959. private _capacity;
  11960. private _spriteTexture;
  11961. private _epsilon;
  11962. private _scene;
  11963. private _vertexData;
  11964. private _buffer;
  11965. private _vertexBuffers;
  11966. private _indexBuffer;
  11967. private _effectBase;
  11968. private _effectFog;
  11969. /**
  11970. * Gets or sets the spritesheet texture
  11971. */
  11972. texture: Texture;
  11973. /**
  11974. * Creates a new sprite manager
  11975. * @param name defines the manager's name
  11976. * @param imgUrl defines the sprite sheet url
  11977. * @param capacity defines the maximum allowed number of sprites
  11978. * @param cellSize defines the size of a sprite cell
  11979. * @param scene defines the hosting scene
  11980. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11981. * @param samplingMode defines the smapling mode to use with spritesheet
  11982. */
  11983. constructor(
  11984. /** defines the manager's name */
  11985. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11986. private _appendSpriteVertex;
  11987. /**
  11988. * Intersects the sprites with a ray
  11989. * @param ray defines the ray to intersect with
  11990. * @param camera defines the current active camera
  11991. * @param predicate defines a predicate used to select candidate sprites
  11992. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11993. * @returns null if no hit or a PickingInfo
  11994. */
  11995. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11996. /**
  11997. * Render all child sprites
  11998. */
  11999. render(): void;
  12000. /**
  12001. * Release associated resources
  12002. */
  12003. dispose(): void;
  12004. }
  12005. }
  12006. declare module BABYLON {
  12007. /**
  12008. * Class used to represent a sprite
  12009. * @see http://doc.babylonjs.com/babylon101/sprites
  12010. */
  12011. export class Sprite {
  12012. /** defines the name */
  12013. name: string;
  12014. /** Gets or sets the current world position */
  12015. position: Vector3;
  12016. /** Gets or sets the main color */
  12017. color: Color4;
  12018. /** Gets or sets the width */
  12019. width: number;
  12020. /** Gets or sets the height */
  12021. height: number;
  12022. /** Gets or sets rotation angle */
  12023. angle: number;
  12024. /** Gets or sets the cell index in the sprite sheet */
  12025. cellIndex: number;
  12026. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12027. invertU: number;
  12028. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12029. invertV: number;
  12030. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12031. disposeWhenFinishedAnimating: boolean;
  12032. /** Gets the list of attached animations */
  12033. animations: Animation[];
  12034. /** Gets or sets a boolean indicating if the sprite can be picked */
  12035. isPickable: boolean;
  12036. /**
  12037. * Gets or sets the associated action manager
  12038. */
  12039. actionManager: Nullable<ActionManager>;
  12040. private _animationStarted;
  12041. private _loopAnimation;
  12042. private _fromIndex;
  12043. private _toIndex;
  12044. private _delay;
  12045. private _direction;
  12046. private _manager;
  12047. private _time;
  12048. private _onAnimationEnd;
  12049. /**
  12050. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12051. */
  12052. isVisible: boolean;
  12053. /**
  12054. * Gets or sets the sprite size
  12055. */
  12056. size: number;
  12057. /**
  12058. * Creates a new Sprite
  12059. * @param name defines the name
  12060. * @param manager defines the manager
  12061. */
  12062. constructor(
  12063. /** defines the name */
  12064. name: string, manager: ISpriteManager);
  12065. /**
  12066. * Starts an animation
  12067. * @param from defines the initial key
  12068. * @param to defines the end key
  12069. * @param loop defines if the animation must loop
  12070. * @param delay defines the start delay (in ms)
  12071. * @param onAnimationEnd defines a callback to call when animation ends
  12072. */
  12073. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12074. /** Stops current animation (if any) */
  12075. stopAnimation(): void;
  12076. /** @hidden */
  12077. _animate(deltaTime: number): void;
  12078. /** Release associated resources */
  12079. dispose(): void;
  12080. }
  12081. }
  12082. declare module BABYLON {
  12083. /**
  12084. * Information about the result of picking within a scene
  12085. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12086. */
  12087. export class PickingInfo {
  12088. /** @hidden */
  12089. _pickingUnavailable: boolean;
  12090. /**
  12091. * If the pick collided with an object
  12092. */
  12093. hit: boolean;
  12094. /**
  12095. * Distance away where the pick collided
  12096. */
  12097. distance: number;
  12098. /**
  12099. * The location of pick collision
  12100. */
  12101. pickedPoint: Nullable<Vector3>;
  12102. /**
  12103. * The mesh corresponding the the pick collision
  12104. */
  12105. pickedMesh: Nullable<AbstractMesh>;
  12106. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12107. bu: number;
  12108. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12109. bv: number;
  12110. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12111. faceId: number;
  12112. /** Id of the the submesh that was picked */
  12113. subMeshId: number;
  12114. /** If a sprite was picked, this will be the sprite the pick collided with */
  12115. pickedSprite: Nullable<Sprite>;
  12116. /**
  12117. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12118. */
  12119. originMesh: Nullable<AbstractMesh>;
  12120. /**
  12121. * The ray that was used to perform the picking.
  12122. */
  12123. ray: Nullable<Ray>;
  12124. /**
  12125. * Gets the normal correspodning to the face the pick collided with
  12126. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12127. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12128. * @returns The normal correspodning to the face the pick collided with
  12129. */
  12130. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12131. /**
  12132. * Gets the texture coordinates of where the pick occured
  12133. * @returns the vector containing the coordnates of the texture
  12134. */
  12135. getTextureCoordinates(): Nullable<Vector2>;
  12136. }
  12137. }
  12138. declare module BABYLON {
  12139. /**
  12140. * Gather the list of pointer event types as constants.
  12141. */
  12142. export class PointerEventTypes {
  12143. /**
  12144. * 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.
  12145. */
  12146. static readonly POINTERDOWN: number;
  12147. /**
  12148. * The pointerup event is fired when a pointer is no longer active.
  12149. */
  12150. static readonly POINTERUP: number;
  12151. /**
  12152. * The pointermove event is fired when a pointer changes coordinates.
  12153. */
  12154. static readonly POINTERMOVE: number;
  12155. /**
  12156. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12157. */
  12158. static readonly POINTERWHEEL: number;
  12159. /**
  12160. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12161. */
  12162. static readonly POINTERPICK: number;
  12163. /**
  12164. * The pointertap event is fired when a the object has been touched and released without drag.
  12165. */
  12166. static readonly POINTERTAP: number;
  12167. /**
  12168. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12169. */
  12170. static readonly POINTERDOUBLETAP: number;
  12171. }
  12172. /**
  12173. * Base class of pointer info types.
  12174. */
  12175. export class PointerInfoBase {
  12176. /**
  12177. * Defines the type of event (PointerEventTypes)
  12178. */
  12179. type: number;
  12180. /**
  12181. * Defines the related dom event
  12182. */
  12183. event: PointerEvent | MouseWheelEvent;
  12184. /**
  12185. * Instantiates the base class of pointers info.
  12186. * @param type Defines the type of event (PointerEventTypes)
  12187. * @param event Defines the related dom event
  12188. */
  12189. constructor(
  12190. /**
  12191. * Defines the type of event (PointerEventTypes)
  12192. */
  12193. type: number,
  12194. /**
  12195. * Defines the related dom event
  12196. */
  12197. event: PointerEvent | MouseWheelEvent);
  12198. }
  12199. /**
  12200. * This class is used to store pointer related info for the onPrePointerObservable event.
  12201. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12202. */
  12203. export class PointerInfoPre extends PointerInfoBase {
  12204. /**
  12205. * Ray from a pointer if availible (eg. 6dof controller)
  12206. */
  12207. ray: Nullable<Ray>;
  12208. /**
  12209. * Defines the local position of the pointer on the canvas.
  12210. */
  12211. localPosition: Vector2;
  12212. /**
  12213. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12214. */
  12215. skipOnPointerObservable: boolean;
  12216. /**
  12217. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12218. * @param type Defines the type of event (PointerEventTypes)
  12219. * @param event Defines the related dom event
  12220. * @param localX Defines the local x coordinates of the pointer when the event occured
  12221. * @param localY Defines the local y coordinates of the pointer when the event occured
  12222. */
  12223. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12224. }
  12225. /**
  12226. * This type contains all the data related to a pointer event in Babylon.js.
  12227. * 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.
  12228. */
  12229. export class PointerInfo extends PointerInfoBase {
  12230. /**
  12231. * Defines the picking info associated to the info (if any)\
  12232. */
  12233. pickInfo: Nullable<PickingInfo>;
  12234. /**
  12235. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12236. * @param type Defines the type of event (PointerEventTypes)
  12237. * @param event Defines the related dom event
  12238. * @param pickInfo Defines the picking info associated to the info (if any)\
  12239. */
  12240. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12241. /**
  12242. * Defines the picking info associated to the info (if any)\
  12243. */
  12244. pickInfo: Nullable<PickingInfo>);
  12245. }
  12246. /**
  12247. * Data relating to a touch event on the screen.
  12248. */
  12249. export interface PointerTouch {
  12250. /**
  12251. * X coordinate of touch.
  12252. */
  12253. x: number;
  12254. /**
  12255. * Y coordinate of touch.
  12256. */
  12257. y: number;
  12258. /**
  12259. * Id of touch. Unique for each finger.
  12260. */
  12261. pointerId: number;
  12262. /**
  12263. * Event type passed from DOM.
  12264. */
  12265. type: any;
  12266. }
  12267. }
  12268. declare module BABYLON {
  12269. /**
  12270. * Manage the mouse inputs to control the movement of a free camera.
  12271. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12272. */
  12273. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12274. /**
  12275. * Define if touch is enabled in the mouse input
  12276. */
  12277. touchEnabled: boolean;
  12278. /**
  12279. * Defines the camera the input is attached to.
  12280. */
  12281. camera: FreeCamera;
  12282. /**
  12283. * Defines the buttons associated with the input to handle camera move.
  12284. */
  12285. buttons: number[];
  12286. /**
  12287. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12288. */
  12289. angularSensibility: number;
  12290. private _pointerInput;
  12291. private _onMouseMove;
  12292. private _observer;
  12293. private previousPosition;
  12294. /**
  12295. * Observable for when a pointer move event occurs containing the move offset
  12296. */
  12297. onPointerMovedObservable: Observable<{
  12298. offsetX: number;
  12299. offsetY: number;
  12300. }>;
  12301. /**
  12302. * @hidden
  12303. * If the camera should be rotated automatically based on pointer movement
  12304. */
  12305. _allowCameraRotation: boolean;
  12306. /**
  12307. * Manage the mouse inputs to control the movement of a free camera.
  12308. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12309. * @param touchEnabled Defines if touch is enabled or not
  12310. */
  12311. constructor(
  12312. /**
  12313. * Define if touch is enabled in the mouse input
  12314. */
  12315. touchEnabled?: boolean);
  12316. /**
  12317. * Attach the input controls to a specific dom element to get the input from.
  12318. * @param element Defines the element the controls should be listened from
  12319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12320. */
  12321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12322. /**
  12323. * Called on JS contextmenu event.
  12324. * Override this method to provide functionality.
  12325. */
  12326. protected onContextMenu(evt: PointerEvent): void;
  12327. /**
  12328. * Detach the current controls from the specified dom element.
  12329. * @param element Defines the element to stop listening the inputs from
  12330. */
  12331. detachControl(element: Nullable<HTMLElement>): void;
  12332. /**
  12333. * Gets the class name of the current intput.
  12334. * @returns the class name
  12335. */
  12336. getClassName(): string;
  12337. /**
  12338. * Get the friendly name associated with the input class.
  12339. * @returns the input friendly name
  12340. */
  12341. getSimpleName(): string;
  12342. }
  12343. }
  12344. declare module BABYLON {
  12345. /**
  12346. * Manage the touch inputs to control the movement of a free camera.
  12347. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12348. */
  12349. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12350. /**
  12351. * Defines the camera the input is attached to.
  12352. */
  12353. camera: FreeCamera;
  12354. /**
  12355. * Defines the touch sensibility for rotation.
  12356. * The higher the faster.
  12357. */
  12358. touchAngularSensibility: number;
  12359. /**
  12360. * Defines the touch sensibility for move.
  12361. * The higher the faster.
  12362. */
  12363. touchMoveSensibility: number;
  12364. private _offsetX;
  12365. private _offsetY;
  12366. private _pointerPressed;
  12367. private _pointerInput;
  12368. private _observer;
  12369. private _onLostFocus;
  12370. /**
  12371. * Attach the input controls to a specific dom element to get the input from.
  12372. * @param element Defines the element the controls should be listened from
  12373. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12374. */
  12375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12376. /**
  12377. * Detach the current controls from the specified dom element.
  12378. * @param element Defines the element to stop listening the inputs from
  12379. */
  12380. detachControl(element: Nullable<HTMLElement>): void;
  12381. /**
  12382. * Update the current camera state depending on the inputs that have been used this frame.
  12383. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12384. */
  12385. checkInputs(): void;
  12386. /**
  12387. * Gets the class name of the current intput.
  12388. * @returns the class name
  12389. */
  12390. getClassName(): string;
  12391. /**
  12392. * Get the friendly name associated with the input class.
  12393. * @returns the input friendly name
  12394. */
  12395. getSimpleName(): string;
  12396. }
  12397. }
  12398. declare module BABYLON {
  12399. /**
  12400. * Default Inputs manager for the FreeCamera.
  12401. * It groups all the default supported inputs for ease of use.
  12402. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12403. */
  12404. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12405. /**
  12406. * @hidden
  12407. */
  12408. _mouseInput: Nullable<FreeCameraMouseInput>;
  12409. /**
  12410. * Instantiates a new FreeCameraInputsManager.
  12411. * @param camera Defines the camera the inputs belong to
  12412. */
  12413. constructor(camera: FreeCamera);
  12414. /**
  12415. * Add keyboard input support to the input manager.
  12416. * @returns the current input manager
  12417. */
  12418. addKeyboard(): FreeCameraInputsManager;
  12419. /**
  12420. * Add mouse input support to the input manager.
  12421. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12422. * @returns the current input manager
  12423. */
  12424. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12425. /**
  12426. * Removes the mouse input support from the manager
  12427. * @returns the current input manager
  12428. */
  12429. removeMouse(): FreeCameraInputsManager;
  12430. /**
  12431. * Add touch input support to the input manager.
  12432. * @returns the current input manager
  12433. */
  12434. addTouch(): FreeCameraInputsManager;
  12435. /**
  12436. * Remove all attached input methods from a camera
  12437. */
  12438. clear(): void;
  12439. }
  12440. }
  12441. declare module BABYLON {
  12442. /**
  12443. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12444. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12445. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12446. */
  12447. export class FreeCamera extends TargetCamera {
  12448. /**
  12449. * Define the collision ellipsoid of the camera.
  12450. * This is helpful to simulate a camera body like the player body around the camera
  12451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12452. */
  12453. ellipsoid: Vector3;
  12454. /**
  12455. * Define an offset for the position of the ellipsoid around the camera.
  12456. * This can be helpful to determine the center of the body near the gravity center of the body
  12457. * instead of its head.
  12458. */
  12459. ellipsoidOffset: Vector3;
  12460. /**
  12461. * Enable or disable collisions of the camera with the rest of the scene objects.
  12462. */
  12463. checkCollisions: boolean;
  12464. /**
  12465. * Enable or disable gravity on the camera.
  12466. */
  12467. applyGravity: boolean;
  12468. /**
  12469. * Define the input manager associated to the camera.
  12470. */
  12471. inputs: FreeCameraInputsManager;
  12472. /**
  12473. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12474. * Higher values reduce sensitivity.
  12475. */
  12476. /**
  12477. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12478. * Higher values reduce sensitivity.
  12479. */
  12480. angularSensibility: number;
  12481. /**
  12482. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12483. */
  12484. keysUp: number[];
  12485. /**
  12486. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12487. */
  12488. keysDown: number[];
  12489. /**
  12490. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12491. */
  12492. keysLeft: number[];
  12493. /**
  12494. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12495. */
  12496. keysRight: number[];
  12497. /**
  12498. * Event raised when the camera collide with a mesh in the scene.
  12499. */
  12500. onCollide: (collidedMesh: AbstractMesh) => void;
  12501. private _collider;
  12502. private _needMoveForGravity;
  12503. private _oldPosition;
  12504. private _diffPosition;
  12505. private _newPosition;
  12506. /** @hidden */
  12507. _localDirection: Vector3;
  12508. /** @hidden */
  12509. _transformedDirection: Vector3;
  12510. /**
  12511. * Instantiates a Free Camera.
  12512. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12513. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12514. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12515. * @param name Define the name of the camera in the scene
  12516. * @param position Define the start position of the camera in the scene
  12517. * @param scene Define the scene the camera belongs to
  12518. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12519. */
  12520. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12521. /**
  12522. * Attached controls to the current camera.
  12523. * @param element Defines the element the controls should be listened from
  12524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12525. */
  12526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12527. /**
  12528. * Detach the current controls from the camera.
  12529. * The camera will stop reacting to inputs.
  12530. * @param element Defines the element to stop listening the inputs from
  12531. */
  12532. detachControl(element: HTMLElement): void;
  12533. private _collisionMask;
  12534. /**
  12535. * Define a collision mask to limit the list of object the camera can collide with
  12536. */
  12537. collisionMask: number;
  12538. /** @hidden */
  12539. _collideWithWorld(displacement: Vector3): void;
  12540. private _onCollisionPositionChange;
  12541. /** @hidden */
  12542. _checkInputs(): void;
  12543. /** @hidden */
  12544. _decideIfNeedsToMove(): boolean;
  12545. /** @hidden */
  12546. _updatePosition(): void;
  12547. /**
  12548. * Destroy the camera and release the current resources hold by it.
  12549. */
  12550. dispose(): void;
  12551. /**
  12552. * Gets the current object class name.
  12553. * @return the class name
  12554. */
  12555. getClassName(): string;
  12556. }
  12557. }
  12558. declare module BABYLON {
  12559. /**
  12560. * Represents a gamepad control stick position
  12561. */
  12562. export class StickValues {
  12563. /**
  12564. * The x component of the control stick
  12565. */
  12566. x: number;
  12567. /**
  12568. * The y component of the control stick
  12569. */
  12570. y: number;
  12571. /**
  12572. * Initializes the gamepad x and y control stick values
  12573. * @param x The x component of the gamepad control stick value
  12574. * @param y The y component of the gamepad control stick value
  12575. */
  12576. constructor(
  12577. /**
  12578. * The x component of the control stick
  12579. */
  12580. x: number,
  12581. /**
  12582. * The y component of the control stick
  12583. */
  12584. y: number);
  12585. }
  12586. /**
  12587. * An interface which manages callbacks for gamepad button changes
  12588. */
  12589. export interface GamepadButtonChanges {
  12590. /**
  12591. * Called when a gamepad has been changed
  12592. */
  12593. changed: boolean;
  12594. /**
  12595. * Called when a gamepad press event has been triggered
  12596. */
  12597. pressChanged: boolean;
  12598. /**
  12599. * Called when a touch event has been triggered
  12600. */
  12601. touchChanged: boolean;
  12602. /**
  12603. * Called when a value has changed
  12604. */
  12605. valueChanged: boolean;
  12606. }
  12607. /**
  12608. * Represents a gamepad
  12609. */
  12610. export class Gamepad {
  12611. /**
  12612. * The id of the gamepad
  12613. */
  12614. id: string;
  12615. /**
  12616. * The index of the gamepad
  12617. */
  12618. index: number;
  12619. /**
  12620. * The browser gamepad
  12621. */
  12622. browserGamepad: any;
  12623. /**
  12624. * Specifies what type of gamepad this represents
  12625. */
  12626. type: number;
  12627. private _leftStick;
  12628. private _rightStick;
  12629. /** @hidden */
  12630. _isConnected: boolean;
  12631. private _leftStickAxisX;
  12632. private _leftStickAxisY;
  12633. private _rightStickAxisX;
  12634. private _rightStickAxisY;
  12635. /**
  12636. * Triggered when the left control stick has been changed
  12637. */
  12638. private _onleftstickchanged;
  12639. /**
  12640. * Triggered when the right control stick has been changed
  12641. */
  12642. private _onrightstickchanged;
  12643. /**
  12644. * Represents a gamepad controller
  12645. */
  12646. static GAMEPAD: number;
  12647. /**
  12648. * Represents a generic controller
  12649. */
  12650. static GENERIC: number;
  12651. /**
  12652. * Represents an XBox controller
  12653. */
  12654. static XBOX: number;
  12655. /**
  12656. * Represents a pose-enabled controller
  12657. */
  12658. static POSE_ENABLED: number;
  12659. /**
  12660. * Specifies whether the left control stick should be Y-inverted
  12661. */
  12662. protected _invertLeftStickY: boolean;
  12663. /**
  12664. * Specifies if the gamepad has been connected
  12665. */
  12666. readonly isConnected: boolean;
  12667. /**
  12668. * Initializes the gamepad
  12669. * @param id The id of the gamepad
  12670. * @param index The index of the gamepad
  12671. * @param browserGamepad The browser gamepad
  12672. * @param leftStickX The x component of the left joystick
  12673. * @param leftStickY The y component of the left joystick
  12674. * @param rightStickX The x component of the right joystick
  12675. * @param rightStickY The y component of the right joystick
  12676. */
  12677. constructor(
  12678. /**
  12679. * The id of the gamepad
  12680. */
  12681. id: string,
  12682. /**
  12683. * The index of the gamepad
  12684. */
  12685. index: number,
  12686. /**
  12687. * The browser gamepad
  12688. */
  12689. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12690. /**
  12691. * Callback triggered when the left joystick has changed
  12692. * @param callback
  12693. */
  12694. onleftstickchanged(callback: (values: StickValues) => void): void;
  12695. /**
  12696. * Callback triggered when the right joystick has changed
  12697. * @param callback
  12698. */
  12699. onrightstickchanged(callback: (values: StickValues) => void): void;
  12700. /**
  12701. * Gets the left joystick
  12702. */
  12703. /**
  12704. * Sets the left joystick values
  12705. */
  12706. leftStick: StickValues;
  12707. /**
  12708. * Gets the right joystick
  12709. */
  12710. /**
  12711. * Sets the right joystick value
  12712. */
  12713. rightStick: StickValues;
  12714. /**
  12715. * Updates the gamepad joystick positions
  12716. */
  12717. update(): void;
  12718. /**
  12719. * Disposes the gamepad
  12720. */
  12721. dispose(): void;
  12722. }
  12723. /**
  12724. * Represents a generic gamepad
  12725. */
  12726. export class GenericPad extends Gamepad {
  12727. private _buttons;
  12728. private _onbuttondown;
  12729. private _onbuttonup;
  12730. /**
  12731. * Observable triggered when a button has been pressed
  12732. */
  12733. onButtonDownObservable: Observable<number>;
  12734. /**
  12735. * Observable triggered when a button has been released
  12736. */
  12737. onButtonUpObservable: Observable<number>;
  12738. /**
  12739. * Callback triggered when a button has been pressed
  12740. * @param callback Called when a button has been pressed
  12741. */
  12742. onbuttondown(callback: (buttonPressed: number) => void): void;
  12743. /**
  12744. * Callback triggered when a button has been released
  12745. * @param callback Called when a button has been released
  12746. */
  12747. onbuttonup(callback: (buttonReleased: number) => void): void;
  12748. /**
  12749. * Initializes the generic gamepad
  12750. * @param id The id of the generic gamepad
  12751. * @param index The index of the generic gamepad
  12752. * @param browserGamepad The browser gamepad
  12753. */
  12754. constructor(id: string, index: number, browserGamepad: any);
  12755. private _setButtonValue;
  12756. /**
  12757. * Updates the generic gamepad
  12758. */
  12759. update(): void;
  12760. /**
  12761. * Disposes the generic gamepad
  12762. */
  12763. dispose(): void;
  12764. }
  12765. }
  12766. declare module BABYLON {
  12767. /**
  12768. * Defines the types of pose enabled controllers that are supported
  12769. */
  12770. export enum PoseEnabledControllerType {
  12771. /**
  12772. * HTC Vive
  12773. */
  12774. VIVE = 0,
  12775. /**
  12776. * Oculus Rift
  12777. */
  12778. OCULUS = 1,
  12779. /**
  12780. * Windows mixed reality
  12781. */
  12782. WINDOWS = 2,
  12783. /**
  12784. * Samsung gear VR
  12785. */
  12786. GEAR_VR = 3,
  12787. /**
  12788. * Google Daydream
  12789. */
  12790. DAYDREAM = 4,
  12791. /**
  12792. * Generic
  12793. */
  12794. GENERIC = 5
  12795. }
  12796. /**
  12797. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12798. */
  12799. export interface MutableGamepadButton {
  12800. /**
  12801. * Value of the button/trigger
  12802. */
  12803. value: number;
  12804. /**
  12805. * If the button/trigger is currently touched
  12806. */
  12807. touched: boolean;
  12808. /**
  12809. * If the button/trigger is currently pressed
  12810. */
  12811. pressed: boolean;
  12812. }
  12813. /**
  12814. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12815. * @hidden
  12816. */
  12817. export interface ExtendedGamepadButton extends GamepadButton {
  12818. /**
  12819. * If the button/trigger is currently pressed
  12820. */
  12821. readonly pressed: boolean;
  12822. /**
  12823. * If the button/trigger is currently touched
  12824. */
  12825. readonly touched: boolean;
  12826. /**
  12827. * Value of the button/trigger
  12828. */
  12829. readonly value: number;
  12830. }
  12831. /** @hidden */
  12832. export interface _GamePadFactory {
  12833. /**
  12834. * Returns wether or not the current gamepad can be created for this type of controller.
  12835. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12836. * @returns true if it can be created, otherwise false
  12837. */
  12838. canCreate(gamepadInfo: any): boolean;
  12839. /**
  12840. * Creates a new instance of the Gamepad.
  12841. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12842. * @returns the new gamepad instance
  12843. */
  12844. create(gamepadInfo: any): Gamepad;
  12845. }
  12846. /**
  12847. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12848. */
  12849. export class PoseEnabledControllerHelper {
  12850. /** @hidden */
  12851. static _ControllerFactories: _GamePadFactory[];
  12852. /** @hidden */
  12853. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12854. /**
  12855. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12856. * @param vrGamepad the gamepad to initialized
  12857. * @returns a vr controller of the type the gamepad identified as
  12858. */
  12859. static InitiateController(vrGamepad: any): Gamepad;
  12860. }
  12861. /**
  12862. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12863. */
  12864. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12865. private _deviceRoomPosition;
  12866. private _deviceRoomRotationQuaternion;
  12867. /**
  12868. * The device position in babylon space
  12869. */
  12870. devicePosition: Vector3;
  12871. /**
  12872. * The device rotation in babylon space
  12873. */
  12874. deviceRotationQuaternion: Quaternion;
  12875. /**
  12876. * The scale factor of the device in babylon space
  12877. */
  12878. deviceScaleFactor: number;
  12879. /**
  12880. * (Likely devicePosition should be used instead) The device position in its room space
  12881. */
  12882. position: Vector3;
  12883. /**
  12884. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12885. */
  12886. rotationQuaternion: Quaternion;
  12887. /**
  12888. * The type of controller (Eg. Windows mixed reality)
  12889. */
  12890. controllerType: PoseEnabledControllerType;
  12891. protected _calculatedPosition: Vector3;
  12892. private _calculatedRotation;
  12893. /**
  12894. * The raw pose from the device
  12895. */
  12896. rawPose: DevicePose;
  12897. private _trackPosition;
  12898. private _maxRotationDistFromHeadset;
  12899. private _draggedRoomRotation;
  12900. /**
  12901. * @hidden
  12902. */
  12903. _disableTrackPosition(fixedPosition: Vector3): void;
  12904. /**
  12905. * Internal, the mesh attached to the controller
  12906. * @hidden
  12907. */
  12908. _mesh: Nullable<AbstractMesh>;
  12909. private _poseControlledCamera;
  12910. private _leftHandSystemQuaternion;
  12911. /**
  12912. * Internal, matrix used to convert room space to babylon space
  12913. * @hidden
  12914. */
  12915. _deviceToWorld: Matrix;
  12916. /**
  12917. * Node to be used when casting a ray from the controller
  12918. * @hidden
  12919. */
  12920. _pointingPoseNode: Nullable<TransformNode>;
  12921. /**
  12922. * Name of the child mesh that can be used to cast a ray from the controller
  12923. */
  12924. static readonly POINTING_POSE: string;
  12925. /**
  12926. * Creates a new PoseEnabledController from a gamepad
  12927. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12928. */
  12929. constructor(browserGamepad: any);
  12930. private _workingMatrix;
  12931. /**
  12932. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12933. */
  12934. update(): void;
  12935. /**
  12936. * Updates only the pose device and mesh without doing any button event checking
  12937. */
  12938. protected _updatePoseAndMesh(): void;
  12939. /**
  12940. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12941. * @param poseData raw pose fromthe device
  12942. */
  12943. updateFromDevice(poseData: DevicePose): void;
  12944. /**
  12945. * @hidden
  12946. */
  12947. _meshAttachedObservable: Observable<AbstractMesh>;
  12948. /**
  12949. * Attaches a mesh to the controller
  12950. * @param mesh the mesh to be attached
  12951. */
  12952. attachToMesh(mesh: AbstractMesh): void;
  12953. /**
  12954. * Attaches the controllers mesh to a camera
  12955. * @param camera the camera the mesh should be attached to
  12956. */
  12957. attachToPoseControlledCamera(camera: TargetCamera): void;
  12958. /**
  12959. * Disposes of the controller
  12960. */
  12961. dispose(): void;
  12962. /**
  12963. * The mesh that is attached to the controller
  12964. */
  12965. readonly mesh: Nullable<AbstractMesh>;
  12966. /**
  12967. * Gets the ray of the controller in the direction the controller is pointing
  12968. * @param length the length the resulting ray should be
  12969. * @returns a ray in the direction the controller is pointing
  12970. */
  12971. getForwardRay(length?: number): Ray;
  12972. }
  12973. }
  12974. declare module BABYLON {
  12975. /**
  12976. * Defines the WebVRController object that represents controllers tracked in 3D space
  12977. */
  12978. export abstract class WebVRController extends PoseEnabledController {
  12979. /**
  12980. * Internal, the default controller model for the controller
  12981. */
  12982. protected _defaultModel: AbstractMesh;
  12983. /**
  12984. * Fired when the trigger state has changed
  12985. */
  12986. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12987. /**
  12988. * Fired when the main button state has changed
  12989. */
  12990. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12991. /**
  12992. * Fired when the secondary button state has changed
  12993. */
  12994. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12995. /**
  12996. * Fired when the pad state has changed
  12997. */
  12998. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12999. /**
  13000. * Fired when controllers stick values have changed
  13001. */
  13002. onPadValuesChangedObservable: Observable<StickValues>;
  13003. /**
  13004. * Array of button availible on the controller
  13005. */
  13006. protected _buttons: Array<MutableGamepadButton>;
  13007. private _onButtonStateChange;
  13008. /**
  13009. * Fired when a controller button's state has changed
  13010. * @param callback the callback containing the button that was modified
  13011. */
  13012. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13013. /**
  13014. * X and Y axis corrisponding to the controllers joystick
  13015. */
  13016. pad: StickValues;
  13017. /**
  13018. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13019. */
  13020. hand: string;
  13021. /**
  13022. * The default controller model for the controller
  13023. */
  13024. readonly defaultModel: AbstractMesh;
  13025. /**
  13026. * Creates a new WebVRController from a gamepad
  13027. * @param vrGamepad the gamepad that the WebVRController should be created from
  13028. */
  13029. constructor(vrGamepad: any);
  13030. /**
  13031. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13032. */
  13033. update(): void;
  13034. /**
  13035. * Function to be called when a button is modified
  13036. */
  13037. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13038. /**
  13039. * Loads a mesh and attaches it to the controller
  13040. * @param scene the scene the mesh should be added to
  13041. * @param meshLoaded callback for when the mesh has been loaded
  13042. */
  13043. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13044. private _setButtonValue;
  13045. private _changes;
  13046. private _checkChanges;
  13047. /**
  13048. * Disposes of th webVRCOntroller
  13049. */
  13050. dispose(): void;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * The HemisphericLight simulates the ambient environment light,
  13056. * so the passed direction is the light reflection direction, not the incoming direction.
  13057. */
  13058. export class HemisphericLight extends Light {
  13059. /**
  13060. * The groundColor is the light in the opposite direction to the one specified during creation.
  13061. * 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.
  13062. */
  13063. groundColor: Color3;
  13064. /**
  13065. * The light reflection direction, not the incoming direction.
  13066. */
  13067. direction: Vector3;
  13068. /**
  13069. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13070. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13071. * The HemisphericLight can't cast shadows.
  13072. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13073. * @param name The friendly name of the light
  13074. * @param direction The direction of the light reflection
  13075. * @param scene The scene the light belongs to
  13076. */
  13077. constructor(name: string, direction: Vector3, scene: Scene);
  13078. protected _buildUniformLayout(): void;
  13079. /**
  13080. * Returns the string "HemisphericLight".
  13081. * @return The class name
  13082. */
  13083. getClassName(): string;
  13084. /**
  13085. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13086. * Returns the updated direction.
  13087. * @param target The target the direction should point to
  13088. * @return The computed direction
  13089. */
  13090. setDirectionToTarget(target: Vector3): Vector3;
  13091. /**
  13092. * Returns the shadow generator associated to the light.
  13093. * @returns Always null for hemispheric lights because it does not support shadows.
  13094. */
  13095. getShadowGenerator(): Nullable<IShadowGenerator>;
  13096. /**
  13097. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13098. * @param effect The effect to update
  13099. * @param lightIndex The index of the light in the effect to update
  13100. * @returns The hemispheric light
  13101. */
  13102. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13103. /**
  13104. * Computes the world matrix of the node
  13105. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13106. * @param useWasUpdatedFlag defines a reserved property
  13107. * @returns the world matrix
  13108. */
  13109. computeWorldMatrix(): Matrix;
  13110. /**
  13111. * Returns the integer 3.
  13112. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13113. */
  13114. getTypeID(): number;
  13115. /**
  13116. * Prepares the list of defines specific to the light type.
  13117. * @param defines the list of defines
  13118. * @param lightIndex defines the index of the light for the effect
  13119. */
  13120. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13121. }
  13122. }
  13123. declare module BABYLON {
  13124. /** @hidden */
  13125. export var vrMultiviewToSingleviewPixelShader: {
  13126. name: string;
  13127. shader: string;
  13128. };
  13129. }
  13130. declare module BABYLON {
  13131. /**
  13132. * Renders to multiple views with a single draw call
  13133. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13134. */
  13135. export class MultiviewRenderTarget extends RenderTargetTexture {
  13136. /**
  13137. * Creates a multiview render target
  13138. * @param scene scene used with the render target
  13139. * @param size the size of the render target (used for each view)
  13140. */
  13141. constructor(scene: Scene, size?: number | {
  13142. width: number;
  13143. height: number;
  13144. } | {
  13145. ratio: number;
  13146. });
  13147. /**
  13148. * @hidden
  13149. * @param faceIndex the face index, if its a cube texture
  13150. */
  13151. _bindFrameBuffer(faceIndex?: number): void;
  13152. /**
  13153. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13154. * @returns the view count
  13155. */
  13156. getViewCount(): number;
  13157. }
  13158. }
  13159. declare module BABYLON {
  13160. interface Engine {
  13161. /**
  13162. * Creates a new multiview render target
  13163. * @param width defines the width of the texture
  13164. * @param height defines the height of the texture
  13165. * @returns the created multiview texture
  13166. */
  13167. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13168. /**
  13169. * Binds a multiview framebuffer to be drawn to
  13170. * @param multiviewTexture texture to bind
  13171. */
  13172. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13173. }
  13174. interface Camera {
  13175. /**
  13176. * @hidden
  13177. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13178. */
  13179. _useMultiviewToSingleView: boolean;
  13180. /**
  13181. * @hidden
  13182. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13183. */
  13184. _multiviewTexture: Nullable<RenderTargetTexture>;
  13185. /**
  13186. * @hidden
  13187. * ensures the multiview texture of the camera exists and has the specified width/height
  13188. * @param width height to set on the multiview texture
  13189. * @param height width to set on the multiview texture
  13190. */
  13191. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13192. }
  13193. interface Scene {
  13194. /** @hidden */
  13195. _transformMatrixR: Matrix;
  13196. /** @hidden */
  13197. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13198. /** @hidden */
  13199. _createMultiviewUbo(): void;
  13200. /** @hidden */
  13201. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13202. /** @hidden */
  13203. _renderMultiviewToSingleView(camera: Camera): void;
  13204. }
  13205. }
  13206. declare module BABYLON {
  13207. /**
  13208. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13209. * This will not be used for webXR as it supports displaying texture arrays directly
  13210. */
  13211. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13212. /**
  13213. * Initializes a VRMultiviewToSingleview
  13214. * @param name name of the post process
  13215. * @param camera camera to be applied to
  13216. * @param scaleFactor scaling factor to the size of the output texture
  13217. */
  13218. constructor(name: string, camera: Camera, scaleFactor: number);
  13219. }
  13220. }
  13221. declare module BABYLON {
  13222. /**
  13223. * Defines the interface used by display changed events
  13224. */
  13225. interface IDisplayChangedEventArgs {
  13226. /** Gets the vrDisplay object (if any) */
  13227. vrDisplay: Nullable<any>;
  13228. /** Gets a boolean indicating if webVR is supported */
  13229. vrSupported: boolean;
  13230. }
  13231. interface Engine {
  13232. /** @hidden */
  13233. _vrDisplay: any;
  13234. /** @hidden */
  13235. _vrSupported: boolean;
  13236. /** @hidden */
  13237. _oldSize: Size;
  13238. /** @hidden */
  13239. _oldHardwareScaleFactor: number;
  13240. /** @hidden */
  13241. _vrExclusivePointerMode: boolean;
  13242. /** @hidden */
  13243. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13244. /** @hidden */
  13245. _onVRDisplayPointerRestricted: () => void;
  13246. /** @hidden */
  13247. _onVRDisplayPointerUnrestricted: () => void;
  13248. /** @hidden */
  13249. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13250. /** @hidden */
  13251. _onVrDisplayDisconnect: Nullable<() => void>;
  13252. /** @hidden */
  13253. _onVrDisplayPresentChange: Nullable<() => void>;
  13254. /**
  13255. * Observable signaled when VR display mode changes
  13256. */
  13257. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13258. /**
  13259. * Observable signaled when VR request present is complete
  13260. */
  13261. onVRRequestPresentComplete: Observable<boolean>;
  13262. /**
  13263. * Observable signaled when VR request present starts
  13264. */
  13265. onVRRequestPresentStart: Observable<Engine>;
  13266. /**
  13267. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13268. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13269. */
  13270. isInVRExclusivePointerMode: boolean;
  13271. /**
  13272. * Gets a boolean indicating if a webVR device was detected
  13273. * @returns true if a webVR device was detected
  13274. */
  13275. isVRDevicePresent(): boolean;
  13276. /**
  13277. * Gets the current webVR device
  13278. * @returns the current webVR device (or null)
  13279. */
  13280. getVRDevice(): any;
  13281. /**
  13282. * Initializes a webVR display and starts listening to display change events
  13283. * The onVRDisplayChangedObservable will be notified upon these changes
  13284. * @returns A promise containing a VRDisplay and if vr is supported
  13285. */
  13286. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13287. /** @hidden */
  13288. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13289. /**
  13290. * Call this function to switch to webVR mode
  13291. * Will do nothing if webVR is not supported or if there is no webVR device
  13292. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13293. */
  13294. enableVR(): void;
  13295. /** @hidden */
  13296. _onVRFullScreenTriggered(): void;
  13297. }
  13298. }
  13299. declare module BABYLON {
  13300. /**
  13301. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13302. * IMPORTANT!! The data is right-hand data.
  13303. * @export
  13304. * @interface DevicePose
  13305. */
  13306. export interface DevicePose {
  13307. /**
  13308. * The position of the device, values in array are [x,y,z].
  13309. */
  13310. readonly position: Nullable<Float32Array>;
  13311. /**
  13312. * The linearVelocity of the device, values in array are [x,y,z].
  13313. */
  13314. readonly linearVelocity: Nullable<Float32Array>;
  13315. /**
  13316. * The linearAcceleration of the device, values in array are [x,y,z].
  13317. */
  13318. readonly linearAcceleration: Nullable<Float32Array>;
  13319. /**
  13320. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13321. */
  13322. readonly orientation: Nullable<Float32Array>;
  13323. /**
  13324. * The angularVelocity of the device, values in array are [x,y,z].
  13325. */
  13326. readonly angularVelocity: Nullable<Float32Array>;
  13327. /**
  13328. * The angularAcceleration of the device, values in array are [x,y,z].
  13329. */
  13330. readonly angularAcceleration: Nullable<Float32Array>;
  13331. }
  13332. /**
  13333. * Interface representing a pose controlled object in Babylon.
  13334. * A pose controlled object has both regular pose values as well as pose values
  13335. * from an external device such as a VR head mounted display
  13336. */
  13337. export interface PoseControlled {
  13338. /**
  13339. * The position of the object in babylon space.
  13340. */
  13341. position: Vector3;
  13342. /**
  13343. * The rotation quaternion of the object in babylon space.
  13344. */
  13345. rotationQuaternion: Quaternion;
  13346. /**
  13347. * The position of the device in babylon space.
  13348. */
  13349. devicePosition?: Vector3;
  13350. /**
  13351. * The rotation quaternion of the device in babylon space.
  13352. */
  13353. deviceRotationQuaternion: Quaternion;
  13354. /**
  13355. * The raw pose coming from the device.
  13356. */
  13357. rawPose: Nullable<DevicePose>;
  13358. /**
  13359. * The scale of the device to be used when translating from device space to babylon space.
  13360. */
  13361. deviceScaleFactor: number;
  13362. /**
  13363. * Updates the poseControlled values based on the input device pose.
  13364. * @param poseData the pose data to update the object with
  13365. */
  13366. updateFromDevice(poseData: DevicePose): void;
  13367. }
  13368. /**
  13369. * Set of options to customize the webVRCamera
  13370. */
  13371. export interface WebVROptions {
  13372. /**
  13373. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13374. */
  13375. trackPosition?: boolean;
  13376. /**
  13377. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13378. */
  13379. positionScale?: number;
  13380. /**
  13381. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13382. */
  13383. displayName?: string;
  13384. /**
  13385. * Should the native controller meshes be initialized. (default: true)
  13386. */
  13387. controllerMeshes?: boolean;
  13388. /**
  13389. * Creating a default HemiLight only on controllers. (default: true)
  13390. */
  13391. defaultLightingOnControllers?: boolean;
  13392. /**
  13393. * If you don't want to use the default VR button of the helper. (default: false)
  13394. */
  13395. useCustomVRButton?: boolean;
  13396. /**
  13397. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13398. */
  13399. customVRButton?: HTMLButtonElement;
  13400. /**
  13401. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13402. */
  13403. rayLength?: number;
  13404. /**
  13405. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13406. */
  13407. defaultHeight?: number;
  13408. /**
  13409. * If multiview should be used if availible (default: false)
  13410. */
  13411. useMultiview?: boolean;
  13412. }
  13413. /**
  13414. * This represents a WebVR camera.
  13415. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13416. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13417. */
  13418. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13419. private webVROptions;
  13420. /**
  13421. * @hidden
  13422. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13423. */
  13424. _vrDevice: any;
  13425. /**
  13426. * The rawPose of the vrDevice.
  13427. */
  13428. rawPose: Nullable<DevicePose>;
  13429. private _onVREnabled;
  13430. private _specsVersion;
  13431. private _attached;
  13432. private _frameData;
  13433. protected _descendants: Array<Node>;
  13434. private _deviceRoomPosition;
  13435. /** @hidden */
  13436. _deviceRoomRotationQuaternion: Quaternion;
  13437. private _standingMatrix;
  13438. /**
  13439. * Represents device position in babylon space.
  13440. */
  13441. devicePosition: Vector3;
  13442. /**
  13443. * Represents device rotation in babylon space.
  13444. */
  13445. deviceRotationQuaternion: Quaternion;
  13446. /**
  13447. * The scale of the device to be used when translating from device space to babylon space.
  13448. */
  13449. deviceScaleFactor: number;
  13450. private _deviceToWorld;
  13451. private _worldToDevice;
  13452. /**
  13453. * References to the webVR controllers for the vrDevice.
  13454. */
  13455. controllers: Array<WebVRController>;
  13456. /**
  13457. * Emits an event when a controller is attached.
  13458. */
  13459. onControllersAttachedObservable: Observable<WebVRController[]>;
  13460. /**
  13461. * Emits an event when a controller's mesh has been loaded;
  13462. */
  13463. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13464. /**
  13465. * Emits an event when the HMD's pose has been updated.
  13466. */
  13467. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13468. private _poseSet;
  13469. /**
  13470. * If the rig cameras be used as parent instead of this camera.
  13471. */
  13472. rigParenting: boolean;
  13473. private _lightOnControllers;
  13474. private _defaultHeight?;
  13475. /**
  13476. * Instantiates a WebVRFreeCamera.
  13477. * @param name The name of the WebVRFreeCamera
  13478. * @param position The starting anchor position for the camera
  13479. * @param scene The scene the camera belongs to
  13480. * @param webVROptions a set of customizable options for the webVRCamera
  13481. */
  13482. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13483. /**
  13484. * Gets the device distance from the ground in meters.
  13485. * @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.
  13486. */
  13487. deviceDistanceToRoomGround(): number;
  13488. /**
  13489. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13490. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13491. */
  13492. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13493. /**
  13494. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13495. * @returns A promise with a boolean set to if the standing matrix is supported.
  13496. */
  13497. useStandingMatrixAsync(): Promise<boolean>;
  13498. /**
  13499. * Disposes the camera
  13500. */
  13501. dispose(): void;
  13502. /**
  13503. * Gets a vrController by name.
  13504. * @param name The name of the controller to retreive
  13505. * @returns the controller matching the name specified or null if not found
  13506. */
  13507. getControllerByName(name: string): Nullable<WebVRController>;
  13508. private _leftController;
  13509. /**
  13510. * The controller corrisponding to the users left hand.
  13511. */
  13512. readonly leftController: Nullable<WebVRController>;
  13513. private _rightController;
  13514. /**
  13515. * The controller corrisponding to the users right hand.
  13516. */
  13517. readonly rightController: Nullable<WebVRController>;
  13518. /**
  13519. * Casts a ray forward from the vrCamera's gaze.
  13520. * @param length Length of the ray (default: 100)
  13521. * @returns the ray corrisponding to the gaze
  13522. */
  13523. getForwardRay(length?: number): Ray;
  13524. /**
  13525. * @hidden
  13526. * Updates the camera based on device's frame data
  13527. */
  13528. _checkInputs(): void;
  13529. /**
  13530. * Updates the poseControlled values based on the input device pose.
  13531. * @param poseData Pose coming from the device
  13532. */
  13533. updateFromDevice(poseData: DevicePose): void;
  13534. private _htmlElementAttached;
  13535. private _detachIfAttached;
  13536. /**
  13537. * WebVR's attach control will start broadcasting frames to the device.
  13538. * Note that in certain browsers (chrome for example) this function must be called
  13539. * within a user-interaction callback. Example:
  13540. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13541. *
  13542. * @param element html element to attach the vrDevice to
  13543. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13544. */
  13545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13546. /**
  13547. * Detaches the camera from the html element and disables VR
  13548. *
  13549. * @param element html element to detach from
  13550. */
  13551. detachControl(element: HTMLElement): void;
  13552. /**
  13553. * @returns the name of this class
  13554. */
  13555. getClassName(): string;
  13556. /**
  13557. * Calls resetPose on the vrDisplay
  13558. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13559. */
  13560. resetToCurrentRotation(): void;
  13561. /**
  13562. * @hidden
  13563. * Updates the rig cameras (left and right eye)
  13564. */
  13565. _updateRigCameras(): void;
  13566. private _workingVector;
  13567. private _oneVector;
  13568. private _workingMatrix;
  13569. private updateCacheCalled;
  13570. private _correctPositionIfNotTrackPosition;
  13571. /**
  13572. * @hidden
  13573. * Updates the cached values of the camera
  13574. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13575. */
  13576. _updateCache(ignoreParentClass?: boolean): void;
  13577. /**
  13578. * @hidden
  13579. * Get current device position in babylon world
  13580. */
  13581. _computeDevicePosition(): void;
  13582. /**
  13583. * Updates the current device position and rotation in the babylon world
  13584. */
  13585. update(): void;
  13586. /**
  13587. * @hidden
  13588. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13589. * @returns an identity matrix
  13590. */
  13591. _getViewMatrix(): Matrix;
  13592. private _tmpMatrix;
  13593. /**
  13594. * This function is called by the two RIG cameras.
  13595. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13596. * @hidden
  13597. */
  13598. _getWebVRViewMatrix(): Matrix;
  13599. /** @hidden */
  13600. _getWebVRProjectionMatrix(): Matrix;
  13601. private _onGamepadConnectedObserver;
  13602. private _onGamepadDisconnectedObserver;
  13603. private _updateCacheWhenTrackingDisabledObserver;
  13604. /**
  13605. * Initializes the controllers and their meshes
  13606. */
  13607. initControllers(): void;
  13608. }
  13609. }
  13610. declare module BABYLON {
  13611. /**
  13612. * Size options for a post process
  13613. */
  13614. export type PostProcessOptions = {
  13615. width: number;
  13616. height: number;
  13617. };
  13618. /**
  13619. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13620. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13621. */
  13622. export class PostProcess {
  13623. /** Name of the PostProcess. */
  13624. name: string;
  13625. /**
  13626. * Gets or sets the unique id of the post process
  13627. */
  13628. uniqueId: number;
  13629. /**
  13630. * Width of the texture to apply the post process on
  13631. */
  13632. width: number;
  13633. /**
  13634. * Height of the texture to apply the post process on
  13635. */
  13636. height: number;
  13637. /**
  13638. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13639. * @hidden
  13640. */
  13641. _outputTexture: Nullable<InternalTexture>;
  13642. /**
  13643. * Sampling mode used by the shader
  13644. * See https://doc.babylonjs.com/classes/3.1/texture
  13645. */
  13646. renderTargetSamplingMode: number;
  13647. /**
  13648. * Clear color to use when screen clearing
  13649. */
  13650. clearColor: Color4;
  13651. /**
  13652. * If the buffer needs to be cleared before applying the post process. (default: true)
  13653. * Should be set to false if shader will overwrite all previous pixels.
  13654. */
  13655. autoClear: boolean;
  13656. /**
  13657. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13658. */
  13659. alphaMode: number;
  13660. /**
  13661. * Sets the setAlphaBlendConstants of the babylon engine
  13662. */
  13663. alphaConstants: Color4;
  13664. /**
  13665. * Animations to be used for the post processing
  13666. */
  13667. animations: Animation[];
  13668. /**
  13669. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13670. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13671. */
  13672. enablePixelPerfectMode: boolean;
  13673. /**
  13674. * Force the postprocess to be applied without taking in account viewport
  13675. */
  13676. forceFullscreenViewport: boolean;
  13677. /**
  13678. * List of inspectable custom properties (used by the Inspector)
  13679. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13680. */
  13681. inspectableCustomProperties: IInspectable[];
  13682. /**
  13683. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13684. *
  13685. * | Value | Type | Description |
  13686. * | ----- | ----------------------------------- | ----------- |
  13687. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13688. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13689. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13690. *
  13691. */
  13692. scaleMode: number;
  13693. /**
  13694. * Force textures to be a power of two (default: false)
  13695. */
  13696. alwaysForcePOT: boolean;
  13697. private _samples;
  13698. /**
  13699. * Number of sample textures (default: 1)
  13700. */
  13701. samples: number;
  13702. /**
  13703. * Modify the scale of the post process to be the same as the viewport (default: false)
  13704. */
  13705. adaptScaleToCurrentViewport: boolean;
  13706. private _camera;
  13707. private _scene;
  13708. private _engine;
  13709. private _options;
  13710. private _reusable;
  13711. private _textureType;
  13712. /**
  13713. * Smart array of input and output textures for the post process.
  13714. * @hidden
  13715. */
  13716. _textures: SmartArray<InternalTexture>;
  13717. /**
  13718. * The index in _textures that corresponds to the output texture.
  13719. * @hidden
  13720. */
  13721. _currentRenderTextureInd: number;
  13722. private _effect;
  13723. private _samplers;
  13724. private _fragmentUrl;
  13725. private _vertexUrl;
  13726. private _parameters;
  13727. private _scaleRatio;
  13728. protected _indexParameters: any;
  13729. private _shareOutputWithPostProcess;
  13730. private _texelSize;
  13731. private _forcedOutputTexture;
  13732. /**
  13733. * Returns the fragment url or shader name used in the post process.
  13734. * @returns the fragment url or name in the shader store.
  13735. */
  13736. getEffectName(): string;
  13737. /**
  13738. * An event triggered when the postprocess is activated.
  13739. */
  13740. onActivateObservable: Observable<Camera>;
  13741. private _onActivateObserver;
  13742. /**
  13743. * A function that is added to the onActivateObservable
  13744. */
  13745. onActivate: Nullable<(camera: Camera) => void>;
  13746. /**
  13747. * An event triggered when the postprocess changes its size.
  13748. */
  13749. onSizeChangedObservable: Observable<PostProcess>;
  13750. private _onSizeChangedObserver;
  13751. /**
  13752. * A function that is added to the onSizeChangedObservable
  13753. */
  13754. onSizeChanged: (postProcess: PostProcess) => void;
  13755. /**
  13756. * An event triggered when the postprocess applies its effect.
  13757. */
  13758. onApplyObservable: Observable<Effect>;
  13759. private _onApplyObserver;
  13760. /**
  13761. * A function that is added to the onApplyObservable
  13762. */
  13763. onApply: (effect: Effect) => void;
  13764. /**
  13765. * An event triggered before rendering the postprocess
  13766. */
  13767. onBeforeRenderObservable: Observable<Effect>;
  13768. private _onBeforeRenderObserver;
  13769. /**
  13770. * A function that is added to the onBeforeRenderObservable
  13771. */
  13772. onBeforeRender: (effect: Effect) => void;
  13773. /**
  13774. * An event triggered after rendering the postprocess
  13775. */
  13776. onAfterRenderObservable: Observable<Effect>;
  13777. private _onAfterRenderObserver;
  13778. /**
  13779. * A function that is added to the onAfterRenderObservable
  13780. */
  13781. onAfterRender: (efect: Effect) => void;
  13782. /**
  13783. * 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
  13784. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13785. */
  13786. inputTexture: InternalTexture;
  13787. /**
  13788. * Gets the camera which post process is applied to.
  13789. * @returns The camera the post process is applied to.
  13790. */
  13791. getCamera(): Camera;
  13792. /**
  13793. * Gets the texel size of the postprocess.
  13794. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13795. */
  13796. readonly texelSize: Vector2;
  13797. /**
  13798. * Creates a new instance PostProcess
  13799. * @param name The name of the PostProcess.
  13800. * @param fragmentUrl The url of the fragment shader to be used.
  13801. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13802. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13803. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13804. * @param camera The camera to apply the render pass to.
  13805. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13806. * @param engine The engine which the post process will be applied. (default: current engine)
  13807. * @param reusable If the post process can be reused on the same frame. (default: false)
  13808. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13809. * @param textureType Type of textures used when performing the post process. (default: 0)
  13810. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13811. * @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
  13812. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13813. */
  13814. constructor(
  13815. /** Name of the PostProcess. */
  13816. 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);
  13817. /**
  13818. * Gets a string idenfifying the name of the class
  13819. * @returns "PostProcess" string
  13820. */
  13821. getClassName(): string;
  13822. /**
  13823. * Gets the engine which this post process belongs to.
  13824. * @returns The engine the post process was enabled with.
  13825. */
  13826. getEngine(): Engine;
  13827. /**
  13828. * The effect that is created when initializing the post process.
  13829. * @returns The created effect corrisponding the the postprocess.
  13830. */
  13831. getEffect(): Effect;
  13832. /**
  13833. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13834. * @param postProcess The post process to share the output with.
  13835. * @returns This post process.
  13836. */
  13837. shareOutputWith(postProcess: PostProcess): PostProcess;
  13838. /**
  13839. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13840. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13841. */
  13842. useOwnOutput(): void;
  13843. /**
  13844. * Updates the effect with the current post process compile time values and recompiles the shader.
  13845. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13846. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13847. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13848. * @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
  13849. * @param onCompiled Called when the shader has been compiled.
  13850. * @param onError Called if there is an error when compiling a shader.
  13851. */
  13852. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13853. /**
  13854. * The post process is reusable if it can be used multiple times within one frame.
  13855. * @returns If the post process is reusable
  13856. */
  13857. isReusable(): boolean;
  13858. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13859. markTextureDirty(): void;
  13860. /**
  13861. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13862. * 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.
  13863. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13864. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13865. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13866. * @returns The target texture that was bound to be written to.
  13867. */
  13868. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13869. /**
  13870. * If the post process is supported.
  13871. */
  13872. readonly isSupported: boolean;
  13873. /**
  13874. * The aspect ratio of the output texture.
  13875. */
  13876. readonly aspectRatio: number;
  13877. /**
  13878. * Get a value indicating if the post-process is ready to be used
  13879. * @returns true if the post-process is ready (shader is compiled)
  13880. */
  13881. isReady(): boolean;
  13882. /**
  13883. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13884. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13885. */
  13886. apply(): Nullable<Effect>;
  13887. private _disposeTextures;
  13888. /**
  13889. * Disposes the post process.
  13890. * @param camera The camera to dispose the post process on.
  13891. */
  13892. dispose(camera?: Camera): void;
  13893. }
  13894. }
  13895. declare module BABYLON {
  13896. /**
  13897. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13898. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13899. */
  13900. export class PostProcessManager {
  13901. private _scene;
  13902. private _indexBuffer;
  13903. private _vertexBuffers;
  13904. /**
  13905. * Creates a new instance PostProcess
  13906. * @param scene The scene that the post process is associated with.
  13907. */
  13908. constructor(scene: Scene);
  13909. private _prepareBuffers;
  13910. private _buildIndexBuffer;
  13911. /**
  13912. * Rebuilds the vertex buffers of the manager.
  13913. * @hidden
  13914. */
  13915. _rebuild(): void;
  13916. /**
  13917. * Prepares a frame to be run through a post process.
  13918. * @param sourceTexture The input texture to the post procesess. (default: null)
  13919. * @param postProcesses An array of post processes to be run. (default: null)
  13920. * @returns True if the post processes were able to be run.
  13921. * @hidden
  13922. */
  13923. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13924. /**
  13925. * Manually render a set of post processes to a texture.
  13926. * @param postProcesses An array of post processes to be run.
  13927. * @param targetTexture The target texture to render to.
  13928. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13929. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13930. * @param lodLevel defines which lod of the texture to render to
  13931. */
  13932. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13933. /**
  13934. * Finalize the result of the output of the postprocesses.
  13935. * @param doNotPresent If true the result will not be displayed to the screen.
  13936. * @param targetTexture The target texture to render to.
  13937. * @param faceIndex The index of the face to bind the target texture to.
  13938. * @param postProcesses The array of post processes to render.
  13939. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13940. * @hidden
  13941. */
  13942. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13943. /**
  13944. * Disposes of the post process manager.
  13945. */
  13946. dispose(): void;
  13947. }
  13948. }
  13949. declare module BABYLON {
  13950. interface AbstractScene {
  13951. /**
  13952. * The list of procedural textures added to the scene
  13953. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13954. */
  13955. proceduralTextures: Array<ProceduralTexture>;
  13956. }
  13957. /**
  13958. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13959. * in a given scene.
  13960. */
  13961. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13962. /**
  13963. * The component name helpfull to identify the component in the list of scene components.
  13964. */
  13965. readonly name: string;
  13966. /**
  13967. * The scene the component belongs to.
  13968. */
  13969. scene: Scene;
  13970. /**
  13971. * Creates a new instance of the component for the given scene
  13972. * @param scene Defines the scene to register the component in
  13973. */
  13974. constructor(scene: Scene);
  13975. /**
  13976. * Registers the component in a given scene
  13977. */
  13978. register(): void;
  13979. /**
  13980. * Rebuilds the elements related to this component in case of
  13981. * context lost for instance.
  13982. */
  13983. rebuild(): void;
  13984. /**
  13985. * Disposes the component and the associated ressources.
  13986. */
  13987. dispose(): void;
  13988. private _beforeClear;
  13989. }
  13990. }
  13991. declare module BABYLON {
  13992. interface Engine {
  13993. /**
  13994. * Creates a new render target cube texture
  13995. * @param size defines the size of the texture
  13996. * @param options defines the options used to create the texture
  13997. * @returns a new render target cube texture stored in an InternalTexture
  13998. */
  13999. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14000. }
  14001. }
  14002. declare module BABYLON {
  14003. /** @hidden */
  14004. export var proceduralVertexShader: {
  14005. name: string;
  14006. shader: string;
  14007. };
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  14012. * This is the base class of any Procedural texture and contains most of the shareable code.
  14013. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14014. */
  14015. export class ProceduralTexture extends Texture {
  14016. isCube: boolean;
  14017. /**
  14018. * Define if the texture is enabled or not (disabled texture will not render)
  14019. */
  14020. isEnabled: boolean;
  14021. /**
  14022. * Define if the texture must be cleared before rendering (default is true)
  14023. */
  14024. autoClear: boolean;
  14025. /**
  14026. * Callback called when the texture is generated
  14027. */
  14028. onGenerated: () => void;
  14029. /**
  14030. * Event raised when the texture is generated
  14031. */
  14032. onGeneratedObservable: Observable<ProceduralTexture>;
  14033. /** @hidden */
  14034. _generateMipMaps: boolean;
  14035. /** @hidden **/
  14036. _effect: Effect;
  14037. /** @hidden */
  14038. _textures: {
  14039. [key: string]: Texture;
  14040. };
  14041. private _size;
  14042. private _currentRefreshId;
  14043. private _refreshRate;
  14044. private _vertexBuffers;
  14045. private _indexBuffer;
  14046. private _uniforms;
  14047. private _samplers;
  14048. private _fragment;
  14049. private _floats;
  14050. private _ints;
  14051. private _floatsArrays;
  14052. private _colors3;
  14053. private _colors4;
  14054. private _vectors2;
  14055. private _vectors3;
  14056. private _matrices;
  14057. private _fallbackTexture;
  14058. private _fallbackTextureUsed;
  14059. private _engine;
  14060. private _cachedDefines;
  14061. private _contentUpdateId;
  14062. private _contentData;
  14063. /**
  14064. * Instantiates a new procedural texture.
  14065. * 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.
  14066. * This is the base class of any Procedural texture and contains most of the shareable code.
  14067. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14068. * @param name Define the name of the texture
  14069. * @param size Define the size of the texture to create
  14070. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14071. * @param scene Define the scene the texture belongs to
  14072. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14073. * @param generateMipMaps Define if the texture should creates mip maps or not
  14074. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14075. */
  14076. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14077. /**
  14078. * The effect that is created when initializing the post process.
  14079. * @returns The created effect corrisponding the the postprocess.
  14080. */
  14081. getEffect(): Effect;
  14082. /**
  14083. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14084. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14085. */
  14086. getContent(): Nullable<ArrayBufferView>;
  14087. private _createIndexBuffer;
  14088. /** @hidden */
  14089. _rebuild(): void;
  14090. /**
  14091. * Resets the texture in order to recreate its associated resources.
  14092. * This can be called in case of context loss
  14093. */
  14094. reset(): void;
  14095. protected _getDefines(): string;
  14096. /**
  14097. * Is the texture ready to be used ? (rendered at least once)
  14098. * @returns true if ready, otherwise, false.
  14099. */
  14100. isReady(): boolean;
  14101. /**
  14102. * Resets the refresh counter of the texture and start bak from scratch.
  14103. * Could be useful to regenerate the texture if it is setup to render only once.
  14104. */
  14105. resetRefreshCounter(): void;
  14106. /**
  14107. * Set the fragment shader to use in order to render the texture.
  14108. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14109. */
  14110. setFragment(fragment: any): void;
  14111. /**
  14112. * Define the refresh rate of the texture or the rendering frequency.
  14113. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14114. */
  14115. refreshRate: number;
  14116. /** @hidden */
  14117. _shouldRender(): boolean;
  14118. /**
  14119. * Get the size the texture is rendering at.
  14120. * @returns the size (texture is always squared)
  14121. */
  14122. getRenderSize(): number;
  14123. /**
  14124. * Resize the texture to new value.
  14125. * @param size Define the new size the texture should have
  14126. * @param generateMipMaps Define whether the new texture should create mip maps
  14127. */
  14128. resize(size: number, generateMipMaps: boolean): void;
  14129. private _checkUniform;
  14130. /**
  14131. * Set a texture in the shader program used to render.
  14132. * @param name Define the name of the uniform samplers as defined in the shader
  14133. * @param texture Define the texture to bind to this sampler
  14134. * @return the texture itself allowing "fluent" like uniform updates
  14135. */
  14136. setTexture(name: string, texture: Texture): ProceduralTexture;
  14137. /**
  14138. * Set a float in the shader.
  14139. * @param name Define the name of the uniform as defined in the shader
  14140. * @param value Define the value to give to the uniform
  14141. * @return the texture itself allowing "fluent" like uniform updates
  14142. */
  14143. setFloat(name: string, value: number): ProceduralTexture;
  14144. /**
  14145. * Set a int in the shader.
  14146. * @param name Define the name of the uniform as defined in the shader
  14147. * @param value Define the value to give to the uniform
  14148. * @return the texture itself allowing "fluent" like uniform updates
  14149. */
  14150. setInt(name: string, value: number): ProceduralTexture;
  14151. /**
  14152. * Set an array of floats in the shader.
  14153. * @param name Define the name of the uniform as defined in the shader
  14154. * @param value Define the value to give to the uniform
  14155. * @return the texture itself allowing "fluent" like uniform updates
  14156. */
  14157. setFloats(name: string, value: number[]): ProceduralTexture;
  14158. /**
  14159. * Set a vec3 in the shader from a Color3.
  14160. * @param name Define the name of the uniform as defined in the shader
  14161. * @param value Define the value to give to the uniform
  14162. * @return the texture itself allowing "fluent" like uniform updates
  14163. */
  14164. setColor3(name: string, value: Color3): ProceduralTexture;
  14165. /**
  14166. * Set a vec4 in the shader from a Color4.
  14167. * @param name Define the name of the uniform as defined in the shader
  14168. * @param value Define the value to give to the uniform
  14169. * @return the texture itself allowing "fluent" like uniform updates
  14170. */
  14171. setColor4(name: string, value: Color4): ProceduralTexture;
  14172. /**
  14173. * Set a vec2 in the shader from a Vector2.
  14174. * @param name Define the name of the uniform as defined in the shader
  14175. * @param value Define the value to give to the uniform
  14176. * @return the texture itself allowing "fluent" like uniform updates
  14177. */
  14178. setVector2(name: string, value: Vector2): ProceduralTexture;
  14179. /**
  14180. * Set a vec3 in the shader from a Vector3.
  14181. * @param name Define the name of the uniform as defined in the shader
  14182. * @param value Define the value to give to the uniform
  14183. * @return the texture itself allowing "fluent" like uniform updates
  14184. */
  14185. setVector3(name: string, value: Vector3): ProceduralTexture;
  14186. /**
  14187. * Set a mat4 in the shader from a MAtrix.
  14188. * @param name Define the name of the uniform as defined in the shader
  14189. * @param value Define the value to give to the uniform
  14190. * @return the texture itself allowing "fluent" like uniform updates
  14191. */
  14192. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14193. /**
  14194. * Render the texture to its associated render target.
  14195. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14196. */
  14197. render(useCameraPostProcess?: boolean): void;
  14198. /**
  14199. * Clone the texture.
  14200. * @returns the cloned texture
  14201. */
  14202. clone(): ProceduralTexture;
  14203. /**
  14204. * Dispose the texture and release its asoociated resources.
  14205. */
  14206. dispose(): void;
  14207. }
  14208. }
  14209. declare module BABYLON {
  14210. /**
  14211. * This represents the base class for particle system in Babylon.
  14212. * 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.
  14213. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14214. * @example https://doc.babylonjs.com/babylon101/particles
  14215. */
  14216. export class BaseParticleSystem {
  14217. /**
  14218. * Source color is added to the destination color without alpha affecting the result
  14219. */
  14220. static BLENDMODE_ONEONE: number;
  14221. /**
  14222. * Blend current color and particle color using particle’s alpha
  14223. */
  14224. static BLENDMODE_STANDARD: number;
  14225. /**
  14226. * Add current color and particle color multiplied by particle’s alpha
  14227. */
  14228. static BLENDMODE_ADD: number;
  14229. /**
  14230. * Multiply current color with particle color
  14231. */
  14232. static BLENDMODE_MULTIPLY: number;
  14233. /**
  14234. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14235. */
  14236. static BLENDMODE_MULTIPLYADD: number;
  14237. /**
  14238. * List of animations used by the particle system.
  14239. */
  14240. animations: Animation[];
  14241. /**
  14242. * The id of the Particle system.
  14243. */
  14244. id: string;
  14245. /**
  14246. * The friendly name of the Particle system.
  14247. */
  14248. name: string;
  14249. /**
  14250. * The rendering group used by the Particle system to chose when to render.
  14251. */
  14252. renderingGroupId: number;
  14253. /**
  14254. * The emitter represents the Mesh or position we are attaching the particle system to.
  14255. */
  14256. emitter: Nullable<AbstractMesh | Vector3>;
  14257. /**
  14258. * The maximum number of particles to emit per frame
  14259. */
  14260. emitRate: number;
  14261. /**
  14262. * If you want to launch only a few particles at once, that can be done, as well.
  14263. */
  14264. manualEmitCount: number;
  14265. /**
  14266. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14267. */
  14268. updateSpeed: number;
  14269. /**
  14270. * The amount of time the particle system is running (depends of the overall update speed).
  14271. */
  14272. targetStopDuration: number;
  14273. /**
  14274. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14275. */
  14276. disposeOnStop: boolean;
  14277. /**
  14278. * Minimum power of emitting particles.
  14279. */
  14280. minEmitPower: number;
  14281. /**
  14282. * Maximum power of emitting particles.
  14283. */
  14284. maxEmitPower: number;
  14285. /**
  14286. * Minimum life time of emitting particles.
  14287. */
  14288. minLifeTime: number;
  14289. /**
  14290. * Maximum life time of emitting particles.
  14291. */
  14292. maxLifeTime: number;
  14293. /**
  14294. * Minimum Size of emitting particles.
  14295. */
  14296. minSize: number;
  14297. /**
  14298. * Maximum Size of emitting particles.
  14299. */
  14300. maxSize: number;
  14301. /**
  14302. * Minimum scale of emitting particles on X axis.
  14303. */
  14304. minScaleX: number;
  14305. /**
  14306. * Maximum scale of emitting particles on X axis.
  14307. */
  14308. maxScaleX: number;
  14309. /**
  14310. * Minimum scale of emitting particles on Y axis.
  14311. */
  14312. minScaleY: number;
  14313. /**
  14314. * Maximum scale of emitting particles on Y axis.
  14315. */
  14316. maxScaleY: number;
  14317. /**
  14318. * Gets or sets the minimal initial rotation in radians.
  14319. */
  14320. minInitialRotation: number;
  14321. /**
  14322. * Gets or sets the maximal initial rotation in radians.
  14323. */
  14324. maxInitialRotation: number;
  14325. /**
  14326. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14327. */
  14328. minAngularSpeed: number;
  14329. /**
  14330. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14331. */
  14332. maxAngularSpeed: number;
  14333. /**
  14334. * The texture used to render each particle. (this can be a spritesheet)
  14335. */
  14336. particleTexture: Nullable<Texture>;
  14337. /**
  14338. * The layer mask we are rendering the particles through.
  14339. */
  14340. layerMask: number;
  14341. /**
  14342. * This can help using your own shader to render the particle system.
  14343. * The according effect will be created
  14344. */
  14345. customShader: any;
  14346. /**
  14347. * By default particle system starts as soon as they are created. This prevents the
  14348. * automatic start to happen and let you decide when to start emitting particles.
  14349. */
  14350. preventAutoStart: boolean;
  14351. private _noiseTexture;
  14352. /**
  14353. * Gets or sets a texture used to add random noise to particle positions
  14354. */
  14355. noiseTexture: Nullable<ProceduralTexture>;
  14356. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14357. noiseStrength: Vector3;
  14358. /**
  14359. * Callback triggered when the particle animation is ending.
  14360. */
  14361. onAnimationEnd: Nullable<() => void>;
  14362. /**
  14363. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14364. */
  14365. blendMode: number;
  14366. /**
  14367. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14368. * to override the particles.
  14369. */
  14370. forceDepthWrite: boolean;
  14371. /** 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 */
  14372. preWarmCycles: number;
  14373. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14374. preWarmStepOffset: number;
  14375. /**
  14376. * 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)
  14377. */
  14378. spriteCellChangeSpeed: number;
  14379. /**
  14380. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14381. */
  14382. startSpriteCellID: number;
  14383. /**
  14384. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14385. */
  14386. endSpriteCellID: number;
  14387. /**
  14388. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14389. */
  14390. spriteCellWidth: number;
  14391. /**
  14392. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14393. */
  14394. spriteCellHeight: number;
  14395. /**
  14396. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14397. */
  14398. spriteRandomStartCell: boolean;
  14399. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14400. translationPivot: Vector2;
  14401. /** @hidden */
  14402. protected _isAnimationSheetEnabled: boolean;
  14403. /**
  14404. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14405. */
  14406. beginAnimationOnStart: boolean;
  14407. /**
  14408. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14409. */
  14410. beginAnimationFrom: number;
  14411. /**
  14412. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14413. */
  14414. beginAnimationTo: number;
  14415. /**
  14416. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14417. */
  14418. beginAnimationLoop: boolean;
  14419. /**
  14420. * Gets or sets a world offset applied to all particles
  14421. */
  14422. worldOffset: Vector3;
  14423. /**
  14424. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14425. */
  14426. isAnimationSheetEnabled: boolean;
  14427. /**
  14428. * Get hosting scene
  14429. * @returns the scene
  14430. */
  14431. getScene(): Scene;
  14432. /**
  14433. * You can use gravity if you want to give an orientation to your particles.
  14434. */
  14435. gravity: Vector3;
  14436. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14437. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14438. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14439. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14440. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14441. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14442. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14443. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14444. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14445. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14446. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14447. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14448. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14449. /**
  14450. * Defines the delay in milliseconds before starting the system (0 by default)
  14451. */
  14452. startDelay: number;
  14453. /**
  14454. * Gets the current list of drag gradients.
  14455. * You must use addDragGradient and removeDragGradient to udpate this list
  14456. * @returns the list of drag gradients
  14457. */
  14458. getDragGradients(): Nullable<Array<FactorGradient>>;
  14459. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14460. limitVelocityDamping: number;
  14461. /**
  14462. * Gets the current list of limit velocity gradients.
  14463. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14464. * @returns the list of limit velocity gradients
  14465. */
  14466. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14467. /**
  14468. * Gets the current list of color gradients.
  14469. * You must use addColorGradient and removeColorGradient to udpate this list
  14470. * @returns the list of color gradients
  14471. */
  14472. getColorGradients(): Nullable<Array<ColorGradient>>;
  14473. /**
  14474. * Gets the current list of size gradients.
  14475. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14476. * @returns the list of size gradients
  14477. */
  14478. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14479. /**
  14480. * Gets the current list of color remap gradients.
  14481. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14482. * @returns the list of color remap gradients
  14483. */
  14484. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14485. /**
  14486. * Gets the current list of alpha remap gradients.
  14487. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14488. * @returns the list of alpha remap gradients
  14489. */
  14490. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14491. /**
  14492. * Gets the current list of life time gradients.
  14493. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14494. * @returns the list of life time gradients
  14495. */
  14496. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14497. /**
  14498. * Gets the current list of angular speed gradients.
  14499. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14500. * @returns the list of angular speed gradients
  14501. */
  14502. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14503. /**
  14504. * Gets the current list of velocity gradients.
  14505. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14506. * @returns the list of velocity gradients
  14507. */
  14508. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14509. /**
  14510. * Gets the current list of start size gradients.
  14511. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14512. * @returns the list of start size gradients
  14513. */
  14514. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14515. /**
  14516. * Gets the current list of emit rate gradients.
  14517. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14518. * @returns the list of emit rate gradients
  14519. */
  14520. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14521. /**
  14522. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14523. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14524. */
  14525. direction1: Vector3;
  14526. /**
  14527. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14529. */
  14530. direction2: Vector3;
  14531. /**
  14532. * 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.
  14533. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14534. */
  14535. minEmitBox: Vector3;
  14536. /**
  14537. * 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.
  14538. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14539. */
  14540. maxEmitBox: Vector3;
  14541. /**
  14542. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14543. */
  14544. color1: Color4;
  14545. /**
  14546. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14547. */
  14548. color2: Color4;
  14549. /**
  14550. * Color the particle will have at the end of its lifetime
  14551. */
  14552. colorDead: Color4;
  14553. /**
  14554. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14555. */
  14556. textureMask: Color4;
  14557. /**
  14558. * The particle emitter type defines the emitter used by the particle system.
  14559. * It can be for example box, sphere, or cone...
  14560. */
  14561. particleEmitterType: IParticleEmitterType;
  14562. /** @hidden */
  14563. _isSubEmitter: boolean;
  14564. /**
  14565. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14566. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14567. */
  14568. billboardMode: number;
  14569. protected _isBillboardBased: boolean;
  14570. /**
  14571. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14572. */
  14573. isBillboardBased: boolean;
  14574. /**
  14575. * The scene the particle system belongs to.
  14576. */
  14577. protected _scene: Scene;
  14578. /**
  14579. * Local cache of defines for image processing.
  14580. */
  14581. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14582. /**
  14583. * Default configuration related to image processing available in the standard Material.
  14584. */
  14585. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14586. /**
  14587. * Gets the image processing configuration used either in this material.
  14588. */
  14589. /**
  14590. * Sets the Default image processing configuration used either in the this material.
  14591. *
  14592. * If sets to null, the scene one is in use.
  14593. */
  14594. imageProcessingConfiguration: ImageProcessingConfiguration;
  14595. /**
  14596. * Attaches a new image processing configuration to the Standard Material.
  14597. * @param configuration
  14598. */
  14599. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14600. /** @hidden */
  14601. protected _reset(): void;
  14602. /** @hidden */
  14603. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14604. /**
  14605. * Instantiates a particle system.
  14606. * 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.
  14607. * @param name The name of the particle system
  14608. */
  14609. constructor(name: string);
  14610. /**
  14611. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14614. * @returns the emitter
  14615. */
  14616. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14617. /**
  14618. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14619. * @param radius The radius of the hemisphere to emit from
  14620. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14621. * @returns the emitter
  14622. */
  14623. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14624. /**
  14625. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14626. * @param radius The radius of the sphere to emit from
  14627. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14628. * @returns the emitter
  14629. */
  14630. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14631. /**
  14632. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14633. * @param radius The radius of the sphere to emit from
  14634. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14635. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14636. * @returns the emitter
  14637. */
  14638. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14639. /**
  14640. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14641. * @param radius The radius of the emission cylinder
  14642. * @param height The height of the emission cylinder
  14643. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14644. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14645. * @returns the emitter
  14646. */
  14647. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14648. /**
  14649. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14650. * @param radius The radius of the cylinder to emit from
  14651. * @param height The height of the emission cylinder
  14652. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14653. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14654. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14655. * @returns the emitter
  14656. */
  14657. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14658. /**
  14659. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14660. * @param radius The radius of the cone to emit from
  14661. * @param angle The base angle of the cone
  14662. * @returns the emitter
  14663. */
  14664. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14665. /**
  14666. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14667. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14668. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14669. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14670. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14671. * @returns the emitter
  14672. */
  14673. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14674. }
  14675. }
  14676. declare module BABYLON {
  14677. /**
  14678. * Type of sub emitter
  14679. */
  14680. export enum SubEmitterType {
  14681. /**
  14682. * Attached to the particle over it's lifetime
  14683. */
  14684. ATTACHED = 0,
  14685. /**
  14686. * Created when the particle dies
  14687. */
  14688. END = 1
  14689. }
  14690. /**
  14691. * Sub emitter class used to emit particles from an existing particle
  14692. */
  14693. export class SubEmitter {
  14694. /**
  14695. * the particle system to be used by the sub emitter
  14696. */
  14697. particleSystem: ParticleSystem;
  14698. /**
  14699. * Type of the submitter (Default: END)
  14700. */
  14701. type: SubEmitterType;
  14702. /**
  14703. * 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)
  14704. * Note: This only is supported when using an emitter of type Mesh
  14705. */
  14706. inheritDirection: boolean;
  14707. /**
  14708. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14709. */
  14710. inheritedVelocityAmount: number;
  14711. /**
  14712. * Creates a sub emitter
  14713. * @param particleSystem the particle system to be used by the sub emitter
  14714. */
  14715. constructor(
  14716. /**
  14717. * the particle system to be used by the sub emitter
  14718. */
  14719. particleSystem: ParticleSystem);
  14720. /**
  14721. * Clones the sub emitter
  14722. * @returns the cloned sub emitter
  14723. */
  14724. clone(): SubEmitter;
  14725. /**
  14726. * Serialize current object to a JSON object
  14727. * @returns the serialized object
  14728. */
  14729. serialize(): any;
  14730. /** @hidden */
  14731. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14732. /**
  14733. * Creates a new SubEmitter from a serialized JSON version
  14734. * @param serializationObject defines the JSON object to read from
  14735. * @param scene defines the hosting scene
  14736. * @param rootUrl defines the rootUrl for data loading
  14737. * @returns a new SubEmitter
  14738. */
  14739. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14740. /** Release associated resources */
  14741. dispose(): void;
  14742. }
  14743. }
  14744. declare module BABYLON {
  14745. /** @hidden */
  14746. export var clipPlaneFragmentDeclaration: {
  14747. name: string;
  14748. shader: string;
  14749. };
  14750. }
  14751. declare module BABYLON {
  14752. /** @hidden */
  14753. export var imageProcessingDeclaration: {
  14754. name: string;
  14755. shader: string;
  14756. };
  14757. }
  14758. declare module BABYLON {
  14759. /** @hidden */
  14760. export var imageProcessingFunctions: {
  14761. name: string;
  14762. shader: string;
  14763. };
  14764. }
  14765. declare module BABYLON {
  14766. /** @hidden */
  14767. export var clipPlaneFragment: {
  14768. name: string;
  14769. shader: string;
  14770. };
  14771. }
  14772. declare module BABYLON {
  14773. /** @hidden */
  14774. export var particlesPixelShader: {
  14775. name: string;
  14776. shader: string;
  14777. };
  14778. }
  14779. declare module BABYLON {
  14780. /** @hidden */
  14781. export var clipPlaneVertexDeclaration: {
  14782. name: string;
  14783. shader: string;
  14784. };
  14785. }
  14786. declare module BABYLON {
  14787. /** @hidden */
  14788. export var clipPlaneVertex: {
  14789. name: string;
  14790. shader: string;
  14791. };
  14792. }
  14793. declare module BABYLON {
  14794. /** @hidden */
  14795. export var particlesVertexShader: {
  14796. name: string;
  14797. shader: string;
  14798. };
  14799. }
  14800. declare module BABYLON {
  14801. /**
  14802. * This represents a particle system in Babylon.
  14803. * 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.
  14804. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14805. * @example https://doc.babylonjs.com/babylon101/particles
  14806. */
  14807. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14808. /**
  14809. * Billboard mode will only apply to Y axis
  14810. */
  14811. static readonly BILLBOARDMODE_Y: number;
  14812. /**
  14813. * Billboard mode will apply to all axes
  14814. */
  14815. static readonly BILLBOARDMODE_ALL: number;
  14816. /**
  14817. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14818. */
  14819. static readonly BILLBOARDMODE_STRETCHED: number;
  14820. /**
  14821. * This function can be defined to provide custom update for active particles.
  14822. * This function will be called instead of regular update (age, position, color, etc.).
  14823. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14824. */
  14825. updateFunction: (particles: Particle[]) => void;
  14826. private _emitterWorldMatrix;
  14827. /**
  14828. * This function can be defined to specify initial direction for every new particle.
  14829. * It by default use the emitterType defined function
  14830. */
  14831. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14832. /**
  14833. * This function can be defined to specify initial position for every new particle.
  14834. * It by default use the emitterType defined function
  14835. */
  14836. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14837. /**
  14838. * @hidden
  14839. */
  14840. _inheritedVelocityOffset: Vector3;
  14841. /**
  14842. * An event triggered when the system is disposed
  14843. */
  14844. onDisposeObservable: Observable<ParticleSystem>;
  14845. private _onDisposeObserver;
  14846. /**
  14847. * Sets a callback that will be triggered when the system is disposed
  14848. */
  14849. onDispose: () => void;
  14850. private _particles;
  14851. private _epsilon;
  14852. private _capacity;
  14853. private _stockParticles;
  14854. private _newPartsExcess;
  14855. private _vertexData;
  14856. private _vertexBuffer;
  14857. private _vertexBuffers;
  14858. private _spriteBuffer;
  14859. private _indexBuffer;
  14860. private _effect;
  14861. private _customEffect;
  14862. private _cachedDefines;
  14863. private _scaledColorStep;
  14864. private _colorDiff;
  14865. private _scaledDirection;
  14866. private _scaledGravity;
  14867. private _currentRenderId;
  14868. private _alive;
  14869. private _useInstancing;
  14870. private _started;
  14871. private _stopped;
  14872. private _actualFrame;
  14873. private _scaledUpdateSpeed;
  14874. private _vertexBufferSize;
  14875. /** @hidden */
  14876. _currentEmitRateGradient: Nullable<FactorGradient>;
  14877. /** @hidden */
  14878. _currentEmitRate1: number;
  14879. /** @hidden */
  14880. _currentEmitRate2: number;
  14881. /** @hidden */
  14882. _currentStartSizeGradient: Nullable<FactorGradient>;
  14883. /** @hidden */
  14884. _currentStartSize1: number;
  14885. /** @hidden */
  14886. _currentStartSize2: number;
  14887. private readonly _rawTextureWidth;
  14888. private _rampGradientsTexture;
  14889. private _useRampGradients;
  14890. /** Gets or sets a boolean indicating that ramp gradients must be used
  14891. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14892. */
  14893. useRampGradients: boolean;
  14894. /**
  14895. * 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.
  14896. * 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: [])
  14897. */
  14898. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14899. private _subEmitters;
  14900. /**
  14901. * @hidden
  14902. * If the particle systems emitter should be disposed when the particle system is disposed
  14903. */
  14904. _disposeEmitterOnDispose: boolean;
  14905. /**
  14906. * The current active Sub-systems, this property is used by the root particle system only.
  14907. */
  14908. activeSubSystems: Array<ParticleSystem>;
  14909. private _rootParticleSystem;
  14910. /**
  14911. * Gets the current list of active particles
  14912. */
  14913. readonly particles: Particle[];
  14914. /**
  14915. * Returns the string "ParticleSystem"
  14916. * @returns a string containing the class name
  14917. */
  14918. getClassName(): string;
  14919. /**
  14920. * Instantiates a particle system.
  14921. * 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.
  14922. * @param name The name of the particle system
  14923. * @param capacity The max number of particles alive at the same time
  14924. * @param scene The scene the particle system belongs to
  14925. * @param customEffect a custom effect used to change the way particles are rendered by default
  14926. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14927. * @param epsilon Offset used to render the particles
  14928. */
  14929. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14930. private _addFactorGradient;
  14931. private _removeFactorGradient;
  14932. /**
  14933. * Adds a new life time gradient
  14934. * @param gradient defines the gradient to use (between 0 and 1)
  14935. * @param factor defines the life time factor to affect to the specified gradient
  14936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14937. * @returns the current particle system
  14938. */
  14939. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14940. /**
  14941. * Remove a specific life time gradient
  14942. * @param gradient defines the gradient to remove
  14943. * @returns the current particle system
  14944. */
  14945. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14946. /**
  14947. * Adds a new size gradient
  14948. * @param gradient defines the gradient to use (between 0 and 1)
  14949. * @param factor defines the size factor to affect to the specified gradient
  14950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14951. * @returns the current particle system
  14952. */
  14953. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14954. /**
  14955. * Remove a specific size gradient
  14956. * @param gradient defines the gradient to remove
  14957. * @returns the current particle system
  14958. */
  14959. removeSizeGradient(gradient: number): IParticleSystem;
  14960. /**
  14961. * Adds a new color remap gradient
  14962. * @param gradient defines the gradient to use (between 0 and 1)
  14963. * @param min defines the color remap minimal range
  14964. * @param max defines the color remap maximal range
  14965. * @returns the current particle system
  14966. */
  14967. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14968. /**
  14969. * Remove a specific color remap gradient
  14970. * @param gradient defines the gradient to remove
  14971. * @returns the current particle system
  14972. */
  14973. removeColorRemapGradient(gradient: number): IParticleSystem;
  14974. /**
  14975. * Adds a new alpha remap gradient
  14976. * @param gradient defines the gradient to use (between 0 and 1)
  14977. * @param min defines the alpha remap minimal range
  14978. * @param max defines the alpha remap maximal range
  14979. * @returns the current particle system
  14980. */
  14981. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14982. /**
  14983. * Remove a specific alpha remap gradient
  14984. * @param gradient defines the gradient to remove
  14985. * @returns the current particle system
  14986. */
  14987. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14988. /**
  14989. * Adds a new angular speed gradient
  14990. * @param gradient defines the gradient to use (between 0 and 1)
  14991. * @param factor defines the angular speed to affect to the specified gradient
  14992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14993. * @returns the current particle system
  14994. */
  14995. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14996. /**
  14997. * Remove a specific angular speed gradient
  14998. * @param gradient defines the gradient to remove
  14999. * @returns the current particle system
  15000. */
  15001. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15002. /**
  15003. * Adds a new velocity gradient
  15004. * @param gradient defines the gradient to use (between 0 and 1)
  15005. * @param factor defines the velocity to affect to the specified gradient
  15006. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15007. * @returns the current particle system
  15008. */
  15009. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15010. /**
  15011. * Remove a specific velocity gradient
  15012. * @param gradient defines the gradient to remove
  15013. * @returns the current particle system
  15014. */
  15015. removeVelocityGradient(gradient: number): IParticleSystem;
  15016. /**
  15017. * Adds a new limit velocity gradient
  15018. * @param gradient defines the gradient to use (between 0 and 1)
  15019. * @param factor defines the limit velocity value to affect to the specified gradient
  15020. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15021. * @returns the current particle system
  15022. */
  15023. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15024. /**
  15025. * Remove a specific limit velocity gradient
  15026. * @param gradient defines the gradient to remove
  15027. * @returns the current particle system
  15028. */
  15029. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15030. /**
  15031. * Adds a new drag gradient
  15032. * @param gradient defines the gradient to use (between 0 and 1)
  15033. * @param factor defines the drag value to affect to the specified gradient
  15034. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15035. * @returns the current particle system
  15036. */
  15037. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15038. /**
  15039. * Remove a specific drag gradient
  15040. * @param gradient defines the gradient to remove
  15041. * @returns the current particle system
  15042. */
  15043. removeDragGradient(gradient: number): IParticleSystem;
  15044. /**
  15045. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15046. * @param gradient defines the gradient to use (between 0 and 1)
  15047. * @param factor defines the emit rate value to affect to the specified gradient
  15048. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15049. * @returns the current particle system
  15050. */
  15051. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15052. /**
  15053. * Remove a specific emit rate gradient
  15054. * @param gradient defines the gradient to remove
  15055. * @returns the current particle system
  15056. */
  15057. removeEmitRateGradient(gradient: number): IParticleSystem;
  15058. /**
  15059. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15060. * @param gradient defines the gradient to use (between 0 and 1)
  15061. * @param factor defines the start size value to affect to the specified gradient
  15062. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15063. * @returns the current particle system
  15064. */
  15065. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15066. /**
  15067. * Remove a specific start size gradient
  15068. * @param gradient defines the gradient to remove
  15069. * @returns the current particle system
  15070. */
  15071. removeStartSizeGradient(gradient: number): IParticleSystem;
  15072. private _createRampGradientTexture;
  15073. /**
  15074. * Gets the current list of ramp gradients.
  15075. * You must use addRampGradient and removeRampGradient to udpate this list
  15076. * @returns the list of ramp gradients
  15077. */
  15078. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15079. /**
  15080. * Adds a new ramp gradient used to remap particle colors
  15081. * @param gradient defines the gradient to use (between 0 and 1)
  15082. * @param color defines the color to affect to the specified gradient
  15083. * @returns the current particle system
  15084. */
  15085. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15086. /**
  15087. * Remove a specific ramp gradient
  15088. * @param gradient defines the gradient to remove
  15089. * @returns the current particle system
  15090. */
  15091. removeRampGradient(gradient: number): ParticleSystem;
  15092. /**
  15093. * Adds a new color gradient
  15094. * @param gradient defines the gradient to use (between 0 and 1)
  15095. * @param color1 defines the color to affect to the specified gradient
  15096. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15097. * @returns this particle system
  15098. */
  15099. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15100. /**
  15101. * Remove a specific color gradient
  15102. * @param gradient defines the gradient to remove
  15103. * @returns this particle system
  15104. */
  15105. removeColorGradient(gradient: number): IParticleSystem;
  15106. private _fetchR;
  15107. protected _reset(): void;
  15108. private _resetEffect;
  15109. private _createVertexBuffers;
  15110. private _createIndexBuffer;
  15111. /**
  15112. * Gets the maximum number of particles active at the same time.
  15113. * @returns The max number of active particles.
  15114. */
  15115. getCapacity(): number;
  15116. /**
  15117. * Gets whether there are still active particles in the system.
  15118. * @returns True if it is alive, otherwise false.
  15119. */
  15120. isAlive(): boolean;
  15121. /**
  15122. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15123. * @returns True if it has been started, otherwise false.
  15124. */
  15125. isStarted(): boolean;
  15126. private _prepareSubEmitterInternalArray;
  15127. /**
  15128. * Starts the particle system and begins to emit
  15129. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15130. */
  15131. start(delay?: number): void;
  15132. /**
  15133. * Stops the particle system.
  15134. * @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.
  15135. */
  15136. stop(stopSubEmitters?: boolean): void;
  15137. /**
  15138. * Remove all active particles
  15139. */
  15140. reset(): void;
  15141. /**
  15142. * @hidden (for internal use only)
  15143. */
  15144. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15145. /**
  15146. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15147. * Its lifetime will start back at 0.
  15148. */
  15149. recycleParticle: (particle: Particle) => void;
  15150. private _stopSubEmitters;
  15151. private _createParticle;
  15152. private _removeFromRoot;
  15153. private _emitFromParticle;
  15154. private _update;
  15155. /** @hidden */
  15156. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15157. /** @hidden */
  15158. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15159. /** @hidden */
  15160. private _getEffect;
  15161. /**
  15162. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15163. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15164. */
  15165. animate(preWarmOnly?: boolean): void;
  15166. private _appendParticleVertices;
  15167. /**
  15168. * Rebuilds the particle system.
  15169. */
  15170. rebuild(): void;
  15171. /**
  15172. * Is this system ready to be used/rendered
  15173. * @return true if the system is ready
  15174. */
  15175. isReady(): boolean;
  15176. private _render;
  15177. /**
  15178. * Renders the particle system in its current state.
  15179. * @returns the current number of particles
  15180. */
  15181. render(): number;
  15182. /**
  15183. * Disposes the particle system and free the associated resources
  15184. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15185. */
  15186. dispose(disposeTexture?: boolean): void;
  15187. /**
  15188. * Clones the particle system.
  15189. * @param name The name of the cloned object
  15190. * @param newEmitter The new emitter to use
  15191. * @returns the cloned particle system
  15192. */
  15193. clone(name: string, newEmitter: any): ParticleSystem;
  15194. /**
  15195. * Serializes the particle system to a JSON object.
  15196. * @returns the JSON object
  15197. */
  15198. serialize(): any;
  15199. /** @hidden */
  15200. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15201. /** @hidden */
  15202. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15203. /**
  15204. * Parses a JSON object to create a particle system.
  15205. * @param parsedParticleSystem The JSON object to parse
  15206. * @param scene The scene to create the particle system in
  15207. * @param rootUrl The root url to use to load external dependencies like texture
  15208. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15209. * @returns the Parsed particle system
  15210. */
  15211. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15212. }
  15213. }
  15214. declare module BABYLON {
  15215. /**
  15216. * A particle represents one of the element emitted by a particle system.
  15217. * This is mainly define by its coordinates, direction, velocity and age.
  15218. */
  15219. export class Particle {
  15220. /**
  15221. * The particle system the particle belongs to.
  15222. */
  15223. particleSystem: ParticleSystem;
  15224. private static _Count;
  15225. /**
  15226. * Unique ID of the particle
  15227. */
  15228. id: number;
  15229. /**
  15230. * The world position of the particle in the scene.
  15231. */
  15232. position: Vector3;
  15233. /**
  15234. * The world direction of the particle in the scene.
  15235. */
  15236. direction: Vector3;
  15237. /**
  15238. * The color of the particle.
  15239. */
  15240. color: Color4;
  15241. /**
  15242. * The color change of the particle per step.
  15243. */
  15244. colorStep: Color4;
  15245. /**
  15246. * Defines how long will the life of the particle be.
  15247. */
  15248. lifeTime: number;
  15249. /**
  15250. * The current age of the particle.
  15251. */
  15252. age: number;
  15253. /**
  15254. * The current size of the particle.
  15255. */
  15256. size: number;
  15257. /**
  15258. * The current scale of the particle.
  15259. */
  15260. scale: Vector2;
  15261. /**
  15262. * The current angle of the particle.
  15263. */
  15264. angle: number;
  15265. /**
  15266. * Defines how fast is the angle changing.
  15267. */
  15268. angularSpeed: number;
  15269. /**
  15270. * Defines the cell index used by the particle to be rendered from a sprite.
  15271. */
  15272. cellIndex: number;
  15273. /**
  15274. * The information required to support color remapping
  15275. */
  15276. remapData: Vector4;
  15277. /** @hidden */
  15278. _randomCellOffset?: number;
  15279. /** @hidden */
  15280. _initialDirection: Nullable<Vector3>;
  15281. /** @hidden */
  15282. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15283. /** @hidden */
  15284. _initialStartSpriteCellID: number;
  15285. /** @hidden */
  15286. _initialEndSpriteCellID: number;
  15287. /** @hidden */
  15288. _currentColorGradient: Nullable<ColorGradient>;
  15289. /** @hidden */
  15290. _currentColor1: Color4;
  15291. /** @hidden */
  15292. _currentColor2: Color4;
  15293. /** @hidden */
  15294. _currentSizeGradient: Nullable<FactorGradient>;
  15295. /** @hidden */
  15296. _currentSize1: number;
  15297. /** @hidden */
  15298. _currentSize2: number;
  15299. /** @hidden */
  15300. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15301. /** @hidden */
  15302. _currentAngularSpeed1: number;
  15303. /** @hidden */
  15304. _currentAngularSpeed2: number;
  15305. /** @hidden */
  15306. _currentVelocityGradient: Nullable<FactorGradient>;
  15307. /** @hidden */
  15308. _currentVelocity1: number;
  15309. /** @hidden */
  15310. _currentVelocity2: number;
  15311. /** @hidden */
  15312. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15313. /** @hidden */
  15314. _currentLimitVelocity1: number;
  15315. /** @hidden */
  15316. _currentLimitVelocity2: number;
  15317. /** @hidden */
  15318. _currentDragGradient: Nullable<FactorGradient>;
  15319. /** @hidden */
  15320. _currentDrag1: number;
  15321. /** @hidden */
  15322. _currentDrag2: number;
  15323. /** @hidden */
  15324. _randomNoiseCoordinates1: Vector3;
  15325. /** @hidden */
  15326. _randomNoiseCoordinates2: Vector3;
  15327. /**
  15328. * Creates a new instance Particle
  15329. * @param particleSystem the particle system the particle belongs to
  15330. */
  15331. constructor(
  15332. /**
  15333. * The particle system the particle belongs to.
  15334. */
  15335. particleSystem: ParticleSystem);
  15336. private updateCellInfoFromSystem;
  15337. /**
  15338. * Defines how the sprite cell index is updated for the particle
  15339. */
  15340. updateCellIndex(): void;
  15341. /** @hidden */
  15342. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15343. /** @hidden */
  15344. _inheritParticleInfoToSubEmitters(): void;
  15345. /** @hidden */
  15346. _reset(): void;
  15347. /**
  15348. * Copy the properties of particle to another one.
  15349. * @param other the particle to copy the information to.
  15350. */
  15351. copyTo(other: Particle): void;
  15352. }
  15353. }
  15354. declare module BABYLON {
  15355. /**
  15356. * Particle emitter represents a volume emitting particles.
  15357. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15358. */
  15359. export interface IParticleEmitterType {
  15360. /**
  15361. * Called by the particle System when the direction is computed for the created particle.
  15362. * @param worldMatrix is the world matrix of the particle system
  15363. * @param directionToUpdate is the direction vector to update with the result
  15364. * @param particle is the particle we are computed the direction for
  15365. */
  15366. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15367. /**
  15368. * Called by the particle System when the position is computed for the created particle.
  15369. * @param worldMatrix is the world matrix of the particle system
  15370. * @param positionToUpdate is the position vector to update with the result
  15371. * @param particle is the particle we are computed the position for
  15372. */
  15373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15374. /**
  15375. * Clones the current emitter and returns a copy of it
  15376. * @returns the new emitter
  15377. */
  15378. clone(): IParticleEmitterType;
  15379. /**
  15380. * Called by the GPUParticleSystem to setup the update shader
  15381. * @param effect defines the update shader
  15382. */
  15383. applyToShader(effect: Effect): void;
  15384. /**
  15385. * Returns a string to use to update the GPU particles update shader
  15386. * @returns the effect defines string
  15387. */
  15388. getEffectDefines(): string;
  15389. /**
  15390. * Returns a string representing the class name
  15391. * @returns a string containing the class name
  15392. */
  15393. getClassName(): string;
  15394. /**
  15395. * Serializes the particle system to a JSON object.
  15396. * @returns the JSON object
  15397. */
  15398. serialize(): any;
  15399. /**
  15400. * Parse properties from a JSON object
  15401. * @param serializationObject defines the JSON object
  15402. */
  15403. parse(serializationObject: any): void;
  15404. }
  15405. }
  15406. declare module BABYLON {
  15407. /**
  15408. * Particle emitter emitting particles from the inside of a box.
  15409. * It emits the particles randomly between 2 given directions.
  15410. */
  15411. export class BoxParticleEmitter implements IParticleEmitterType {
  15412. /**
  15413. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15414. */
  15415. direction1: Vector3;
  15416. /**
  15417. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15418. */
  15419. direction2: Vector3;
  15420. /**
  15421. * 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.
  15422. */
  15423. minEmitBox: Vector3;
  15424. /**
  15425. * 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.
  15426. */
  15427. maxEmitBox: Vector3;
  15428. /**
  15429. * Creates a new instance BoxParticleEmitter
  15430. */
  15431. constructor();
  15432. /**
  15433. * Called by the particle System when the direction is computed for the created particle.
  15434. * @param worldMatrix is the world matrix of the particle system
  15435. * @param directionToUpdate is the direction vector to update with the result
  15436. * @param particle is the particle we are computed the direction for
  15437. */
  15438. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15439. /**
  15440. * Called by the particle System when the position is computed for the created particle.
  15441. * @param worldMatrix is the world matrix of the particle system
  15442. * @param positionToUpdate is the position vector to update with the result
  15443. * @param particle is the particle we are computed the position for
  15444. */
  15445. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15446. /**
  15447. * Clones the current emitter and returns a copy of it
  15448. * @returns the new emitter
  15449. */
  15450. clone(): BoxParticleEmitter;
  15451. /**
  15452. * Called by the GPUParticleSystem to setup the update shader
  15453. * @param effect defines the update shader
  15454. */
  15455. applyToShader(effect: Effect): void;
  15456. /**
  15457. * Returns a string to use to update the GPU particles update shader
  15458. * @returns a string containng the defines string
  15459. */
  15460. getEffectDefines(): string;
  15461. /**
  15462. * Returns the string "BoxParticleEmitter"
  15463. * @returns a string containing the class name
  15464. */
  15465. getClassName(): string;
  15466. /**
  15467. * Serializes the particle system to a JSON object.
  15468. * @returns the JSON object
  15469. */
  15470. serialize(): any;
  15471. /**
  15472. * Parse properties from a JSON object
  15473. * @param serializationObject defines the JSON object
  15474. */
  15475. parse(serializationObject: any): void;
  15476. }
  15477. }
  15478. declare module BABYLON {
  15479. /**
  15480. * Particle emitter emitting particles from the inside of a cone.
  15481. * It emits the particles alongside the cone volume from the base to the particle.
  15482. * The emission direction might be randomized.
  15483. */
  15484. export class ConeParticleEmitter implements IParticleEmitterType {
  15485. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15486. directionRandomizer: number;
  15487. private _radius;
  15488. private _angle;
  15489. private _height;
  15490. /**
  15491. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15492. */
  15493. radiusRange: number;
  15494. /**
  15495. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15496. */
  15497. heightRange: number;
  15498. /**
  15499. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15500. */
  15501. emitFromSpawnPointOnly: boolean;
  15502. /**
  15503. * Gets or sets the radius of the emission cone
  15504. */
  15505. radius: number;
  15506. /**
  15507. * Gets or sets the angle of the emission cone
  15508. */
  15509. angle: number;
  15510. private _buildHeight;
  15511. /**
  15512. * Creates a new instance ConeParticleEmitter
  15513. * @param radius the radius of the emission cone (1 by default)
  15514. * @param angle the cone base angle (PI by default)
  15515. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15516. */
  15517. constructor(radius?: number, angle?: number,
  15518. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15519. directionRandomizer?: number);
  15520. /**
  15521. * Called by the particle System when the direction is computed for the created particle.
  15522. * @param worldMatrix is the world matrix of the particle system
  15523. * @param directionToUpdate is the direction vector to update with the result
  15524. * @param particle is the particle we are computed the direction for
  15525. */
  15526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15527. /**
  15528. * Called by the particle System when the position is computed for the created particle.
  15529. * @param worldMatrix is the world matrix of the particle system
  15530. * @param positionToUpdate is the position vector to update with the result
  15531. * @param particle is the particle we are computed the position for
  15532. */
  15533. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15534. /**
  15535. * Clones the current emitter and returns a copy of it
  15536. * @returns the new emitter
  15537. */
  15538. clone(): ConeParticleEmitter;
  15539. /**
  15540. * Called by the GPUParticleSystem to setup the update shader
  15541. * @param effect defines the update shader
  15542. */
  15543. applyToShader(effect: Effect): void;
  15544. /**
  15545. * Returns a string to use to update the GPU particles update shader
  15546. * @returns a string containng the defines string
  15547. */
  15548. getEffectDefines(): string;
  15549. /**
  15550. * Returns the string "ConeParticleEmitter"
  15551. * @returns a string containing the class name
  15552. */
  15553. getClassName(): string;
  15554. /**
  15555. * Serializes the particle system to a JSON object.
  15556. * @returns the JSON object
  15557. */
  15558. serialize(): any;
  15559. /**
  15560. * Parse properties from a JSON object
  15561. * @param serializationObject defines the JSON object
  15562. */
  15563. parse(serializationObject: any): void;
  15564. }
  15565. }
  15566. declare module BABYLON {
  15567. /**
  15568. * Particle emitter emitting particles from the inside of a cylinder.
  15569. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15570. */
  15571. export class CylinderParticleEmitter implements IParticleEmitterType {
  15572. /**
  15573. * The radius of the emission cylinder.
  15574. */
  15575. radius: number;
  15576. /**
  15577. * The height of the emission cylinder.
  15578. */
  15579. height: number;
  15580. /**
  15581. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15582. */
  15583. radiusRange: number;
  15584. /**
  15585. * How much to randomize the particle direction [0-1].
  15586. */
  15587. directionRandomizer: number;
  15588. /**
  15589. * Creates a new instance CylinderParticleEmitter
  15590. * @param radius the radius of the emission cylinder (1 by default)
  15591. * @param height the height of the emission cylinder (1 by default)
  15592. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15593. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15594. */
  15595. constructor(
  15596. /**
  15597. * The radius of the emission cylinder.
  15598. */
  15599. radius?: number,
  15600. /**
  15601. * The height of the emission cylinder.
  15602. */
  15603. height?: number,
  15604. /**
  15605. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15606. */
  15607. radiusRange?: number,
  15608. /**
  15609. * How much to randomize the particle direction [0-1].
  15610. */
  15611. directionRandomizer?: number);
  15612. /**
  15613. * Called by the particle System when the direction is computed for the created particle.
  15614. * @param worldMatrix is the world matrix of the particle system
  15615. * @param directionToUpdate is the direction vector to update with the result
  15616. * @param particle is the particle we are computed the direction for
  15617. */
  15618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15619. /**
  15620. * Called by the particle System when the position is computed for the created particle.
  15621. * @param worldMatrix is the world matrix of the particle system
  15622. * @param positionToUpdate is the position vector to update with the result
  15623. * @param particle is the particle we are computed the position for
  15624. */
  15625. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15626. /**
  15627. * Clones the current emitter and returns a copy of it
  15628. * @returns the new emitter
  15629. */
  15630. clone(): CylinderParticleEmitter;
  15631. /**
  15632. * Called by the GPUParticleSystem to setup the update shader
  15633. * @param effect defines the update shader
  15634. */
  15635. applyToShader(effect: Effect): void;
  15636. /**
  15637. * Returns a string to use to update the GPU particles update shader
  15638. * @returns a string containng the defines string
  15639. */
  15640. getEffectDefines(): string;
  15641. /**
  15642. * Returns the string "CylinderParticleEmitter"
  15643. * @returns a string containing the class name
  15644. */
  15645. getClassName(): string;
  15646. /**
  15647. * Serializes the particle system to a JSON object.
  15648. * @returns the JSON object
  15649. */
  15650. serialize(): any;
  15651. /**
  15652. * Parse properties from a JSON object
  15653. * @param serializationObject defines the JSON object
  15654. */
  15655. parse(serializationObject: any): void;
  15656. }
  15657. /**
  15658. * Particle emitter emitting particles from the inside of a cylinder.
  15659. * It emits the particles randomly between two vectors.
  15660. */
  15661. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15662. /**
  15663. * The min limit of the emission direction.
  15664. */
  15665. direction1: Vector3;
  15666. /**
  15667. * The max limit of the emission direction.
  15668. */
  15669. direction2: Vector3;
  15670. /**
  15671. * Creates a new instance CylinderDirectedParticleEmitter
  15672. * @param radius the radius of the emission cylinder (1 by default)
  15673. * @param height the height of the emission cylinder (1 by default)
  15674. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15675. * @param direction1 the min limit of the emission direction (up vector by default)
  15676. * @param direction2 the max limit of the emission direction (up vector by default)
  15677. */
  15678. constructor(radius?: number, height?: number, radiusRange?: number,
  15679. /**
  15680. * The min limit of the emission direction.
  15681. */
  15682. direction1?: Vector3,
  15683. /**
  15684. * The max limit of the emission direction.
  15685. */
  15686. direction2?: Vector3);
  15687. /**
  15688. * Called by the particle System when the direction is computed for the created particle.
  15689. * @param worldMatrix is the world matrix of the particle system
  15690. * @param directionToUpdate is the direction vector to update with the result
  15691. * @param particle is the particle we are computed the direction for
  15692. */
  15693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15694. /**
  15695. * Clones the current emitter and returns a copy of it
  15696. * @returns the new emitter
  15697. */
  15698. clone(): CylinderDirectedParticleEmitter;
  15699. /**
  15700. * Called by the GPUParticleSystem to setup the update shader
  15701. * @param effect defines the update shader
  15702. */
  15703. applyToShader(effect: Effect): void;
  15704. /**
  15705. * Returns a string to use to update the GPU particles update shader
  15706. * @returns a string containng the defines string
  15707. */
  15708. getEffectDefines(): string;
  15709. /**
  15710. * Returns the string "CylinderDirectedParticleEmitter"
  15711. * @returns a string containing the class name
  15712. */
  15713. getClassName(): string;
  15714. /**
  15715. * Serializes the particle system to a JSON object.
  15716. * @returns the JSON object
  15717. */
  15718. serialize(): any;
  15719. /**
  15720. * Parse properties from a JSON object
  15721. * @param serializationObject defines the JSON object
  15722. */
  15723. parse(serializationObject: any): void;
  15724. }
  15725. }
  15726. declare module BABYLON {
  15727. /**
  15728. * Particle emitter emitting particles from the inside of a hemisphere.
  15729. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15730. */
  15731. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15732. /**
  15733. * The radius of the emission hemisphere.
  15734. */
  15735. radius: number;
  15736. /**
  15737. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15738. */
  15739. radiusRange: number;
  15740. /**
  15741. * How much to randomize the particle direction [0-1].
  15742. */
  15743. directionRandomizer: number;
  15744. /**
  15745. * Creates a new instance HemisphericParticleEmitter
  15746. * @param radius the radius of the emission hemisphere (1 by default)
  15747. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15748. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15749. */
  15750. constructor(
  15751. /**
  15752. * The radius of the emission hemisphere.
  15753. */
  15754. radius?: number,
  15755. /**
  15756. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15757. */
  15758. radiusRange?: number,
  15759. /**
  15760. * How much to randomize the particle direction [0-1].
  15761. */
  15762. directionRandomizer?: number);
  15763. /**
  15764. * Called by the particle System when the direction is computed for the created particle.
  15765. * @param worldMatrix is the world matrix of the particle system
  15766. * @param directionToUpdate is the direction vector to update with the result
  15767. * @param particle is the particle we are computed the direction for
  15768. */
  15769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15770. /**
  15771. * Called by the particle System when the position is computed for the created particle.
  15772. * @param worldMatrix is the world matrix of the particle system
  15773. * @param positionToUpdate is the position vector to update with the result
  15774. * @param particle is the particle we are computed the position for
  15775. */
  15776. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15777. /**
  15778. * Clones the current emitter and returns a copy of it
  15779. * @returns the new emitter
  15780. */
  15781. clone(): HemisphericParticleEmitter;
  15782. /**
  15783. * Called by the GPUParticleSystem to setup the update shader
  15784. * @param effect defines the update shader
  15785. */
  15786. applyToShader(effect: Effect): void;
  15787. /**
  15788. * Returns a string to use to update the GPU particles update shader
  15789. * @returns a string containng the defines string
  15790. */
  15791. getEffectDefines(): string;
  15792. /**
  15793. * Returns the string "HemisphericParticleEmitter"
  15794. * @returns a string containing the class name
  15795. */
  15796. getClassName(): string;
  15797. /**
  15798. * Serializes the particle system to a JSON object.
  15799. * @returns the JSON object
  15800. */
  15801. serialize(): any;
  15802. /**
  15803. * Parse properties from a JSON object
  15804. * @param serializationObject defines the JSON object
  15805. */
  15806. parse(serializationObject: any): void;
  15807. }
  15808. }
  15809. declare module BABYLON {
  15810. /**
  15811. * Particle emitter emitting particles from a point.
  15812. * It emits the particles randomly between 2 given directions.
  15813. */
  15814. export class PointParticleEmitter implements IParticleEmitterType {
  15815. /**
  15816. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15817. */
  15818. direction1: Vector3;
  15819. /**
  15820. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15821. */
  15822. direction2: Vector3;
  15823. /**
  15824. * Creates a new instance PointParticleEmitter
  15825. */
  15826. constructor();
  15827. /**
  15828. * Called by the particle System when the direction is computed for the created particle.
  15829. * @param worldMatrix is the world matrix of the particle system
  15830. * @param directionToUpdate is the direction vector to update with the result
  15831. * @param particle is the particle we are computed the direction for
  15832. */
  15833. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15834. /**
  15835. * Called by the particle System when the position is computed for the created particle.
  15836. * @param worldMatrix is the world matrix of the particle system
  15837. * @param positionToUpdate is the position vector to update with the result
  15838. * @param particle is the particle we are computed the position for
  15839. */
  15840. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15841. /**
  15842. * Clones the current emitter and returns a copy of it
  15843. * @returns the new emitter
  15844. */
  15845. clone(): PointParticleEmitter;
  15846. /**
  15847. * Called by the GPUParticleSystem to setup the update shader
  15848. * @param effect defines the update shader
  15849. */
  15850. applyToShader(effect: Effect): void;
  15851. /**
  15852. * Returns a string to use to update the GPU particles update shader
  15853. * @returns a string containng the defines string
  15854. */
  15855. getEffectDefines(): string;
  15856. /**
  15857. * Returns the string "PointParticleEmitter"
  15858. * @returns a string containing the class name
  15859. */
  15860. getClassName(): string;
  15861. /**
  15862. * Serializes the particle system to a JSON object.
  15863. * @returns the JSON object
  15864. */
  15865. serialize(): any;
  15866. /**
  15867. * Parse properties from a JSON object
  15868. * @param serializationObject defines the JSON object
  15869. */
  15870. parse(serializationObject: any): void;
  15871. }
  15872. }
  15873. declare module BABYLON {
  15874. /**
  15875. * Particle emitter emitting particles from the inside of a sphere.
  15876. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15877. */
  15878. export class SphereParticleEmitter implements IParticleEmitterType {
  15879. /**
  15880. * The radius of the emission sphere.
  15881. */
  15882. radius: number;
  15883. /**
  15884. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15885. */
  15886. radiusRange: number;
  15887. /**
  15888. * How much to randomize the particle direction [0-1].
  15889. */
  15890. directionRandomizer: number;
  15891. /**
  15892. * Creates a new instance SphereParticleEmitter
  15893. * @param radius the radius of the emission sphere (1 by default)
  15894. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15895. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15896. */
  15897. constructor(
  15898. /**
  15899. * The radius of the emission sphere.
  15900. */
  15901. radius?: number,
  15902. /**
  15903. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15904. */
  15905. radiusRange?: number,
  15906. /**
  15907. * How much to randomize the particle direction [0-1].
  15908. */
  15909. directionRandomizer?: number);
  15910. /**
  15911. * Called by the particle System when the direction is computed for the created particle.
  15912. * @param worldMatrix is the world matrix of the particle system
  15913. * @param directionToUpdate is the direction vector to update with the result
  15914. * @param particle is the particle we are computed the direction for
  15915. */
  15916. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15917. /**
  15918. * Called by the particle System when the position is computed for the created particle.
  15919. * @param worldMatrix is the world matrix of the particle system
  15920. * @param positionToUpdate is the position vector to update with the result
  15921. * @param particle is the particle we are computed the position for
  15922. */
  15923. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15924. /**
  15925. * Clones the current emitter and returns a copy of it
  15926. * @returns the new emitter
  15927. */
  15928. clone(): SphereParticleEmitter;
  15929. /**
  15930. * Called by the GPUParticleSystem to setup the update shader
  15931. * @param effect defines the update shader
  15932. */
  15933. applyToShader(effect: Effect): void;
  15934. /**
  15935. * Returns a string to use to update the GPU particles update shader
  15936. * @returns a string containng the defines string
  15937. */
  15938. getEffectDefines(): string;
  15939. /**
  15940. * Returns the string "SphereParticleEmitter"
  15941. * @returns a string containing the class name
  15942. */
  15943. getClassName(): string;
  15944. /**
  15945. * Serializes the particle system to a JSON object.
  15946. * @returns the JSON object
  15947. */
  15948. serialize(): any;
  15949. /**
  15950. * Parse properties from a JSON object
  15951. * @param serializationObject defines the JSON object
  15952. */
  15953. parse(serializationObject: any): void;
  15954. }
  15955. /**
  15956. * Particle emitter emitting particles from the inside of a sphere.
  15957. * It emits the particles randomly between two vectors.
  15958. */
  15959. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15960. /**
  15961. * The min limit of the emission direction.
  15962. */
  15963. direction1: Vector3;
  15964. /**
  15965. * The max limit of the emission direction.
  15966. */
  15967. direction2: Vector3;
  15968. /**
  15969. * Creates a new instance SphereDirectedParticleEmitter
  15970. * @param radius the radius of the emission sphere (1 by default)
  15971. * @param direction1 the min limit of the emission direction (up vector by default)
  15972. * @param direction2 the max limit of the emission direction (up vector by default)
  15973. */
  15974. constructor(radius?: number,
  15975. /**
  15976. * The min limit of the emission direction.
  15977. */
  15978. direction1?: Vector3,
  15979. /**
  15980. * The max limit of the emission direction.
  15981. */
  15982. direction2?: Vector3);
  15983. /**
  15984. * Called by the particle System when the direction is computed for the created particle.
  15985. * @param worldMatrix is the world matrix of the particle system
  15986. * @param directionToUpdate is the direction vector to update with the result
  15987. * @param particle is the particle we are computed the direction for
  15988. */
  15989. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15990. /**
  15991. * Clones the current emitter and returns a copy of it
  15992. * @returns the new emitter
  15993. */
  15994. clone(): SphereDirectedParticleEmitter;
  15995. /**
  15996. * Called by the GPUParticleSystem to setup the update shader
  15997. * @param effect defines the update shader
  15998. */
  15999. applyToShader(effect: Effect): void;
  16000. /**
  16001. * Returns a string to use to update the GPU particles update shader
  16002. * @returns a string containng the defines string
  16003. */
  16004. getEffectDefines(): string;
  16005. /**
  16006. * Returns the string "SphereDirectedParticleEmitter"
  16007. * @returns a string containing the class name
  16008. */
  16009. getClassName(): string;
  16010. /**
  16011. * Serializes the particle system to a JSON object.
  16012. * @returns the JSON object
  16013. */
  16014. serialize(): any;
  16015. /**
  16016. * Parse properties from a JSON object
  16017. * @param serializationObject defines the JSON object
  16018. */
  16019. parse(serializationObject: any): void;
  16020. }
  16021. }
  16022. declare module BABYLON {
  16023. /**
  16024. * Interface representing a particle system in Babylon.js.
  16025. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16026. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16027. */
  16028. export interface IParticleSystem {
  16029. /**
  16030. * List of animations used by the particle system.
  16031. */
  16032. animations: Animation[];
  16033. /**
  16034. * The id of the Particle system.
  16035. */
  16036. id: string;
  16037. /**
  16038. * The name of the Particle system.
  16039. */
  16040. name: string;
  16041. /**
  16042. * The emitter represents the Mesh or position we are attaching the particle system to.
  16043. */
  16044. emitter: Nullable<AbstractMesh | Vector3>;
  16045. /**
  16046. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16047. */
  16048. isBillboardBased: boolean;
  16049. /**
  16050. * The rendering group used by the Particle system to chose when to render.
  16051. */
  16052. renderingGroupId: number;
  16053. /**
  16054. * The layer mask we are rendering the particles through.
  16055. */
  16056. layerMask: number;
  16057. /**
  16058. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16059. */
  16060. updateSpeed: number;
  16061. /**
  16062. * The amount of time the particle system is running (depends of the overall update speed).
  16063. */
  16064. targetStopDuration: number;
  16065. /**
  16066. * The texture used to render each particle. (this can be a spritesheet)
  16067. */
  16068. particleTexture: Nullable<Texture>;
  16069. /**
  16070. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16071. */
  16072. blendMode: number;
  16073. /**
  16074. * Minimum life time of emitting particles.
  16075. */
  16076. minLifeTime: number;
  16077. /**
  16078. * Maximum life time of emitting particles.
  16079. */
  16080. maxLifeTime: number;
  16081. /**
  16082. * Minimum Size of emitting particles.
  16083. */
  16084. minSize: number;
  16085. /**
  16086. * Maximum Size of emitting particles.
  16087. */
  16088. maxSize: number;
  16089. /**
  16090. * Minimum scale of emitting particles on X axis.
  16091. */
  16092. minScaleX: number;
  16093. /**
  16094. * Maximum scale of emitting particles on X axis.
  16095. */
  16096. maxScaleX: number;
  16097. /**
  16098. * Minimum scale of emitting particles on Y axis.
  16099. */
  16100. minScaleY: number;
  16101. /**
  16102. * Maximum scale of emitting particles on Y axis.
  16103. */
  16104. maxScaleY: number;
  16105. /**
  16106. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16107. */
  16108. color1: Color4;
  16109. /**
  16110. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16111. */
  16112. color2: Color4;
  16113. /**
  16114. * Color the particle will have at the end of its lifetime.
  16115. */
  16116. colorDead: Color4;
  16117. /**
  16118. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16119. */
  16120. emitRate: number;
  16121. /**
  16122. * You can use gravity if you want to give an orientation to your particles.
  16123. */
  16124. gravity: Vector3;
  16125. /**
  16126. * Minimum power of emitting particles.
  16127. */
  16128. minEmitPower: number;
  16129. /**
  16130. * Maximum power of emitting particles.
  16131. */
  16132. maxEmitPower: number;
  16133. /**
  16134. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16135. */
  16136. minAngularSpeed: number;
  16137. /**
  16138. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16139. */
  16140. maxAngularSpeed: number;
  16141. /**
  16142. * Gets or sets the minimal initial rotation in radians.
  16143. */
  16144. minInitialRotation: number;
  16145. /**
  16146. * Gets or sets the maximal initial rotation in radians.
  16147. */
  16148. maxInitialRotation: number;
  16149. /**
  16150. * The particle emitter type defines the emitter used by the particle system.
  16151. * It can be for example box, sphere, or cone...
  16152. */
  16153. particleEmitterType: Nullable<IParticleEmitterType>;
  16154. /**
  16155. * Defines the delay in milliseconds before starting the system (0 by default)
  16156. */
  16157. startDelay: number;
  16158. /**
  16159. * 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
  16160. */
  16161. preWarmCycles: number;
  16162. /**
  16163. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16164. */
  16165. preWarmStepOffset: number;
  16166. /**
  16167. * 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)
  16168. */
  16169. spriteCellChangeSpeed: number;
  16170. /**
  16171. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16172. */
  16173. startSpriteCellID: number;
  16174. /**
  16175. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16176. */
  16177. endSpriteCellID: number;
  16178. /**
  16179. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16180. */
  16181. spriteCellWidth: number;
  16182. /**
  16183. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16184. */
  16185. spriteCellHeight: number;
  16186. /**
  16187. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16188. */
  16189. spriteRandomStartCell: boolean;
  16190. /**
  16191. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16192. */
  16193. isAnimationSheetEnabled: boolean;
  16194. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16195. translationPivot: Vector2;
  16196. /**
  16197. * Gets or sets a texture used to add random noise to particle positions
  16198. */
  16199. noiseTexture: Nullable<BaseTexture>;
  16200. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16201. noiseStrength: Vector3;
  16202. /**
  16203. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16204. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16205. */
  16206. billboardMode: number;
  16207. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16208. limitVelocityDamping: number;
  16209. /**
  16210. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16211. */
  16212. beginAnimationOnStart: boolean;
  16213. /**
  16214. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16215. */
  16216. beginAnimationFrom: number;
  16217. /**
  16218. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16219. */
  16220. beginAnimationTo: number;
  16221. /**
  16222. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16223. */
  16224. beginAnimationLoop: boolean;
  16225. /**
  16226. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16227. */
  16228. disposeOnStop: boolean;
  16229. /**
  16230. * Gets the maximum number of particles active at the same time.
  16231. * @returns The max number of active particles.
  16232. */
  16233. getCapacity(): number;
  16234. /**
  16235. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16236. * @returns True if it has been started, otherwise false.
  16237. */
  16238. isStarted(): boolean;
  16239. /**
  16240. * Animates the particle system for this frame.
  16241. */
  16242. animate(): void;
  16243. /**
  16244. * Renders the particle system in its current state.
  16245. * @returns the current number of particles
  16246. */
  16247. render(): number;
  16248. /**
  16249. * Dispose the particle system and frees its associated resources.
  16250. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16251. */
  16252. dispose(disposeTexture?: boolean): void;
  16253. /**
  16254. * Clones the particle system.
  16255. * @param name The name of the cloned object
  16256. * @param newEmitter The new emitter to use
  16257. * @returns the cloned particle system
  16258. */
  16259. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16260. /**
  16261. * Serializes the particle system to a JSON object.
  16262. * @returns the JSON object
  16263. */
  16264. serialize(): any;
  16265. /**
  16266. * Rebuild the particle system
  16267. */
  16268. rebuild(): void;
  16269. /**
  16270. * Starts the particle system and begins to emit
  16271. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16272. */
  16273. start(delay?: number): void;
  16274. /**
  16275. * Stops the particle system.
  16276. */
  16277. stop(): void;
  16278. /**
  16279. * Remove all active particles
  16280. */
  16281. reset(): void;
  16282. /**
  16283. * Is this system ready to be used/rendered
  16284. * @return true if the system is ready
  16285. */
  16286. isReady(): boolean;
  16287. /**
  16288. * Adds a new color gradient
  16289. * @param gradient defines the gradient to use (between 0 and 1)
  16290. * @param color1 defines the color to affect to the specified gradient
  16291. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16292. * @returns the current particle system
  16293. */
  16294. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16295. /**
  16296. * Remove a specific color gradient
  16297. * @param gradient defines the gradient to remove
  16298. * @returns the current particle system
  16299. */
  16300. removeColorGradient(gradient: number): IParticleSystem;
  16301. /**
  16302. * Adds a new size gradient
  16303. * @param gradient defines the gradient to use (between 0 and 1)
  16304. * @param factor defines the size factor to affect to the specified gradient
  16305. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16306. * @returns the current particle system
  16307. */
  16308. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16309. /**
  16310. * Remove a specific size gradient
  16311. * @param gradient defines the gradient to remove
  16312. * @returns the current particle system
  16313. */
  16314. removeSizeGradient(gradient: number): IParticleSystem;
  16315. /**
  16316. * Gets the current list of color gradients.
  16317. * You must use addColorGradient and removeColorGradient to udpate this list
  16318. * @returns the list of color gradients
  16319. */
  16320. getColorGradients(): Nullable<Array<ColorGradient>>;
  16321. /**
  16322. * Gets the current list of size gradients.
  16323. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16324. * @returns the list of size gradients
  16325. */
  16326. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16327. /**
  16328. * Gets the current list of angular speed gradients.
  16329. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16330. * @returns the list of angular speed gradients
  16331. */
  16332. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16333. /**
  16334. * Adds a new angular speed gradient
  16335. * @param gradient defines the gradient to use (between 0 and 1)
  16336. * @param factor defines the angular speed to affect to the specified gradient
  16337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16338. * @returns the current particle system
  16339. */
  16340. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16341. /**
  16342. * Remove a specific angular speed gradient
  16343. * @param gradient defines the gradient to remove
  16344. * @returns the current particle system
  16345. */
  16346. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16347. /**
  16348. * Gets the current list of velocity gradients.
  16349. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16350. * @returns the list of velocity gradients
  16351. */
  16352. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16353. /**
  16354. * Adds a new velocity gradient
  16355. * @param gradient defines the gradient to use (between 0 and 1)
  16356. * @param factor defines the velocity to affect to the specified gradient
  16357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16358. * @returns the current particle system
  16359. */
  16360. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16361. /**
  16362. * Remove a specific velocity gradient
  16363. * @param gradient defines the gradient to remove
  16364. * @returns the current particle system
  16365. */
  16366. removeVelocityGradient(gradient: number): IParticleSystem;
  16367. /**
  16368. * Gets the current list of limit velocity gradients.
  16369. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16370. * @returns the list of limit velocity gradients
  16371. */
  16372. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16373. /**
  16374. * Adds a new limit velocity gradient
  16375. * @param gradient defines the gradient to use (between 0 and 1)
  16376. * @param factor defines the limit velocity to affect to the specified gradient
  16377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16378. * @returns the current particle system
  16379. */
  16380. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16381. /**
  16382. * Remove a specific limit velocity gradient
  16383. * @param gradient defines the gradient to remove
  16384. * @returns the current particle system
  16385. */
  16386. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16387. /**
  16388. * Adds a new drag gradient
  16389. * @param gradient defines the gradient to use (between 0 and 1)
  16390. * @param factor defines the drag to affect to the specified gradient
  16391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16392. * @returns the current particle system
  16393. */
  16394. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16395. /**
  16396. * Remove a specific drag gradient
  16397. * @param gradient defines the gradient to remove
  16398. * @returns the current particle system
  16399. */
  16400. removeDragGradient(gradient: number): IParticleSystem;
  16401. /**
  16402. * Gets the current list of drag gradients.
  16403. * You must use addDragGradient and removeDragGradient to udpate this list
  16404. * @returns the list of drag gradients
  16405. */
  16406. getDragGradients(): Nullable<Array<FactorGradient>>;
  16407. /**
  16408. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16409. * @param gradient defines the gradient to use (between 0 and 1)
  16410. * @param factor defines the emit rate to affect to the specified gradient
  16411. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16412. * @returns the current particle system
  16413. */
  16414. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16415. /**
  16416. * Remove a specific emit rate gradient
  16417. * @param gradient defines the gradient to remove
  16418. * @returns the current particle system
  16419. */
  16420. removeEmitRateGradient(gradient: number): IParticleSystem;
  16421. /**
  16422. * Gets the current list of emit rate gradients.
  16423. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16424. * @returns the list of emit rate gradients
  16425. */
  16426. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16427. /**
  16428. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16429. * @param gradient defines the gradient to use (between 0 and 1)
  16430. * @param factor defines the start size to affect to the specified gradient
  16431. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16432. * @returns the current particle system
  16433. */
  16434. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16435. /**
  16436. * Remove a specific start size gradient
  16437. * @param gradient defines the gradient to remove
  16438. * @returns the current particle system
  16439. */
  16440. removeStartSizeGradient(gradient: number): IParticleSystem;
  16441. /**
  16442. * Gets the current list of start size gradients.
  16443. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16444. * @returns the list of start size gradients
  16445. */
  16446. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16447. /**
  16448. * Adds a new life time gradient
  16449. * @param gradient defines the gradient to use (between 0 and 1)
  16450. * @param factor defines the life time factor to affect to the specified gradient
  16451. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16452. * @returns the current particle system
  16453. */
  16454. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16455. /**
  16456. * Remove a specific life time gradient
  16457. * @param gradient defines the gradient to remove
  16458. * @returns the current particle system
  16459. */
  16460. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16461. /**
  16462. * Gets the current list of life time gradients.
  16463. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16464. * @returns the list of life time gradients
  16465. */
  16466. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16467. /**
  16468. * Gets the current list of color gradients.
  16469. * You must use addColorGradient and removeColorGradient to udpate this list
  16470. * @returns the list of color gradients
  16471. */
  16472. getColorGradients(): Nullable<Array<ColorGradient>>;
  16473. /**
  16474. * Adds a new ramp gradient used to remap particle colors
  16475. * @param gradient defines the gradient to use (between 0 and 1)
  16476. * @param color defines the color to affect to the specified gradient
  16477. * @returns the current particle system
  16478. */
  16479. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16480. /**
  16481. * Gets the current list of ramp gradients.
  16482. * You must use addRampGradient and removeRampGradient to udpate this list
  16483. * @returns the list of ramp gradients
  16484. */
  16485. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16486. /** Gets or sets a boolean indicating that ramp gradients must be used
  16487. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16488. */
  16489. useRampGradients: boolean;
  16490. /**
  16491. * Adds a new color remap gradient
  16492. * @param gradient defines the gradient to use (between 0 and 1)
  16493. * @param min defines the color remap minimal range
  16494. * @param max defines the color remap maximal range
  16495. * @returns the current particle system
  16496. */
  16497. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16498. /**
  16499. * Gets the current list of color remap gradients.
  16500. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16501. * @returns the list of color remap gradients
  16502. */
  16503. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16504. /**
  16505. * Adds a new alpha remap gradient
  16506. * @param gradient defines the gradient to use (between 0 and 1)
  16507. * @param min defines the alpha remap minimal range
  16508. * @param max defines the alpha remap maximal range
  16509. * @returns the current particle system
  16510. */
  16511. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16512. /**
  16513. * Gets the current list of alpha remap gradients.
  16514. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16515. * @returns the list of alpha remap gradients
  16516. */
  16517. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16518. /**
  16519. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16520. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16521. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16522. * @returns the emitter
  16523. */
  16524. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16525. /**
  16526. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16527. * @param radius The radius of the hemisphere to emit from
  16528. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16529. * @returns the emitter
  16530. */
  16531. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16532. /**
  16533. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16534. * @param radius The radius of the sphere to emit from
  16535. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16536. * @returns the emitter
  16537. */
  16538. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16539. /**
  16540. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16541. * @param radius The radius of the sphere to emit from
  16542. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16543. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16544. * @returns the emitter
  16545. */
  16546. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16547. /**
  16548. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16549. * @param radius The radius of the emission cylinder
  16550. * @param height The height of the emission cylinder
  16551. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16552. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16553. * @returns the emitter
  16554. */
  16555. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16556. /**
  16557. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16558. * @param radius The radius of the cylinder to emit from
  16559. * @param height The height of the emission cylinder
  16560. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16561. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16562. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16563. * @returns the emitter
  16564. */
  16565. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16566. /**
  16567. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16568. * @param radius The radius of the cone to emit from
  16569. * @param angle The base angle of the cone
  16570. * @returns the emitter
  16571. */
  16572. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16573. /**
  16574. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16575. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16576. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16577. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16578. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16579. * @returns the emitter
  16580. */
  16581. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16582. /**
  16583. * Get hosting scene
  16584. * @returns the scene
  16585. */
  16586. getScene(): Scene;
  16587. }
  16588. }
  16589. declare module BABYLON {
  16590. /**
  16591. * Creates an instance based on a source mesh.
  16592. */
  16593. export class InstancedMesh extends AbstractMesh {
  16594. private _sourceMesh;
  16595. private _currentLOD;
  16596. /** @hidden */
  16597. _indexInSourceMeshInstanceArray: number;
  16598. constructor(name: string, source: Mesh);
  16599. /**
  16600. * Returns the string "InstancedMesh".
  16601. */
  16602. getClassName(): string;
  16603. /** Gets the list of lights affecting that mesh */
  16604. readonly lightSources: Light[];
  16605. _resyncLightSources(): void;
  16606. _resyncLighSource(light: Light): void;
  16607. _removeLightSource(light: Light): void;
  16608. /**
  16609. * If the source mesh receives shadows
  16610. */
  16611. readonly receiveShadows: boolean;
  16612. /**
  16613. * The material of the source mesh
  16614. */
  16615. readonly material: Nullable<Material>;
  16616. /**
  16617. * Visibility of the source mesh
  16618. */
  16619. readonly visibility: number;
  16620. /**
  16621. * Skeleton of the source mesh
  16622. */
  16623. readonly skeleton: Nullable<Skeleton>;
  16624. /**
  16625. * Rendering ground id of the source mesh
  16626. */
  16627. renderingGroupId: number;
  16628. /**
  16629. * Returns the total number of vertices (integer).
  16630. */
  16631. getTotalVertices(): number;
  16632. /**
  16633. * Returns a positive integer : the total number of indices in this mesh geometry.
  16634. * @returns the numner of indices or zero if the mesh has no geometry.
  16635. */
  16636. getTotalIndices(): number;
  16637. /**
  16638. * The source mesh of the instance
  16639. */
  16640. readonly sourceMesh: Mesh;
  16641. /**
  16642. * Is this node ready to be used/rendered
  16643. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16644. * @return {boolean} is it ready
  16645. */
  16646. isReady(completeCheck?: boolean): boolean;
  16647. /**
  16648. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16649. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16650. * @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.
  16651. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16652. */
  16653. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16654. /**
  16655. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16656. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16657. * The `data` are either a numeric array either a Float32Array.
  16658. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16659. * 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).
  16660. * Note that a new underlying VertexBuffer object is created each call.
  16661. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16662. *
  16663. * Possible `kind` values :
  16664. * - VertexBuffer.PositionKind
  16665. * - VertexBuffer.UVKind
  16666. * - VertexBuffer.UV2Kind
  16667. * - VertexBuffer.UV3Kind
  16668. * - VertexBuffer.UV4Kind
  16669. * - VertexBuffer.UV5Kind
  16670. * - VertexBuffer.UV6Kind
  16671. * - VertexBuffer.ColorKind
  16672. * - VertexBuffer.MatricesIndicesKind
  16673. * - VertexBuffer.MatricesIndicesExtraKind
  16674. * - VertexBuffer.MatricesWeightsKind
  16675. * - VertexBuffer.MatricesWeightsExtraKind
  16676. *
  16677. * Returns the Mesh.
  16678. */
  16679. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16680. /**
  16681. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16682. * If the mesh has no geometry, it is simply returned as it is.
  16683. * The `data` are either a numeric array either a Float32Array.
  16684. * No new underlying VertexBuffer object is created.
  16685. * 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.
  16686. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16687. *
  16688. * Possible `kind` values :
  16689. * - VertexBuffer.PositionKind
  16690. * - VertexBuffer.UVKind
  16691. * - VertexBuffer.UV2Kind
  16692. * - VertexBuffer.UV3Kind
  16693. * - VertexBuffer.UV4Kind
  16694. * - VertexBuffer.UV5Kind
  16695. * - VertexBuffer.UV6Kind
  16696. * - VertexBuffer.ColorKind
  16697. * - VertexBuffer.MatricesIndicesKind
  16698. * - VertexBuffer.MatricesIndicesExtraKind
  16699. * - VertexBuffer.MatricesWeightsKind
  16700. * - VertexBuffer.MatricesWeightsExtraKind
  16701. *
  16702. * Returns the Mesh.
  16703. */
  16704. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16705. /**
  16706. * Sets the mesh indices.
  16707. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16708. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16709. * This method creates a new index buffer each call.
  16710. * Returns the Mesh.
  16711. */
  16712. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16713. /**
  16714. * Boolean : True if the mesh owns the requested kind of data.
  16715. */
  16716. isVerticesDataPresent(kind: string): boolean;
  16717. /**
  16718. * Returns an array of indices (IndicesArray).
  16719. */
  16720. getIndices(): Nullable<IndicesArray>;
  16721. readonly _positions: Nullable<Vector3[]>;
  16722. /**
  16723. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16724. * This means the mesh underlying bounding box and sphere are recomputed.
  16725. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16726. * @returns the current mesh
  16727. */
  16728. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16729. /** @hidden */
  16730. _preActivate(): InstancedMesh;
  16731. /** @hidden */
  16732. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16733. /** @hidden */
  16734. _postActivate(): void;
  16735. getWorldMatrix(): Matrix;
  16736. readonly isAnInstance: boolean;
  16737. /**
  16738. * Returns the current associated LOD AbstractMesh.
  16739. */
  16740. getLOD(camera: Camera): AbstractMesh;
  16741. /** @hidden */
  16742. _syncSubMeshes(): InstancedMesh;
  16743. /** @hidden */
  16744. _generatePointsArray(): boolean;
  16745. /**
  16746. * Creates a new InstancedMesh from the current mesh.
  16747. * - name (string) : the cloned mesh name
  16748. * - newParent (optional Node) : the optional Node to parent the clone to.
  16749. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16750. *
  16751. * Returns the clone.
  16752. */
  16753. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16754. /**
  16755. * Disposes the InstancedMesh.
  16756. * Returns nothing.
  16757. */
  16758. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16759. }
  16760. }
  16761. declare module BABYLON {
  16762. /**
  16763. * Defines the options associated with the creation of a shader material.
  16764. */
  16765. export interface IShaderMaterialOptions {
  16766. /**
  16767. * Does the material work in alpha blend mode
  16768. */
  16769. needAlphaBlending: boolean;
  16770. /**
  16771. * Does the material work in alpha test mode
  16772. */
  16773. needAlphaTesting: boolean;
  16774. /**
  16775. * The list of attribute names used in the shader
  16776. */
  16777. attributes: string[];
  16778. /**
  16779. * The list of unifrom names used in the shader
  16780. */
  16781. uniforms: string[];
  16782. /**
  16783. * The list of UBO names used in the shader
  16784. */
  16785. uniformBuffers: string[];
  16786. /**
  16787. * The list of sampler names used in the shader
  16788. */
  16789. samplers: string[];
  16790. /**
  16791. * The list of defines used in the shader
  16792. */
  16793. defines: string[];
  16794. }
  16795. /**
  16796. * 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.
  16797. *
  16798. * This returned material effects how the mesh will look based on the code in the shaders.
  16799. *
  16800. * @see http://doc.babylonjs.com/how_to/shader_material
  16801. */
  16802. export class ShaderMaterial extends Material {
  16803. private _shaderPath;
  16804. private _options;
  16805. private _textures;
  16806. private _textureArrays;
  16807. private _floats;
  16808. private _ints;
  16809. private _floatsArrays;
  16810. private _colors3;
  16811. private _colors3Arrays;
  16812. private _colors4;
  16813. private _vectors2;
  16814. private _vectors3;
  16815. private _vectors4;
  16816. private _matrices;
  16817. private _matrices3x3;
  16818. private _matrices2x2;
  16819. private _vectors2Arrays;
  16820. private _vectors3Arrays;
  16821. private _cachedWorldViewMatrix;
  16822. private _renderId;
  16823. /**
  16824. * Instantiate a new shader material.
  16825. * 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.
  16826. * This returned material effects how the mesh will look based on the code in the shaders.
  16827. * @see http://doc.babylonjs.com/how_to/shader_material
  16828. * @param name Define the name of the material in the scene
  16829. * @param scene Define the scene the material belongs to
  16830. * @param shaderPath Defines the route to the shader code in one of three ways:
  16831. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16832. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16833. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16834. * @param options Define the options used to create the shader
  16835. */
  16836. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16837. /**
  16838. * Gets the options used to compile the shader.
  16839. * They can be modified to trigger a new compilation
  16840. */
  16841. readonly options: IShaderMaterialOptions;
  16842. /**
  16843. * Gets the current class name of the material e.g. "ShaderMaterial"
  16844. * Mainly use in serialization.
  16845. * @returns the class name
  16846. */
  16847. getClassName(): string;
  16848. /**
  16849. * Specifies if the material will require alpha blending
  16850. * @returns a boolean specifying if alpha blending is needed
  16851. */
  16852. needAlphaBlending(): boolean;
  16853. /**
  16854. * Specifies if this material should be rendered in alpha test mode
  16855. * @returns a boolean specifying if an alpha test is needed.
  16856. */
  16857. needAlphaTesting(): boolean;
  16858. private _checkUniform;
  16859. /**
  16860. * Set a texture in the shader.
  16861. * @param name Define the name of the uniform samplers as defined in the shader
  16862. * @param texture Define the texture to bind to this sampler
  16863. * @return the material itself allowing "fluent" like uniform updates
  16864. */
  16865. setTexture(name: string, texture: Texture): ShaderMaterial;
  16866. /**
  16867. * Set a texture array in the shader.
  16868. * @param name Define the name of the uniform sampler array as defined in the shader
  16869. * @param textures Define the list of textures to bind to this sampler
  16870. * @return the material itself allowing "fluent" like uniform updates
  16871. */
  16872. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16873. /**
  16874. * Set a float in the shader.
  16875. * @param name Define the name of the uniform as defined in the shader
  16876. * @param value Define the value to give to the uniform
  16877. * @return the material itself allowing "fluent" like uniform updates
  16878. */
  16879. setFloat(name: string, value: number): ShaderMaterial;
  16880. /**
  16881. * Set a int in the shader.
  16882. * @param name Define the name of the uniform as defined in the shader
  16883. * @param value Define the value to give to the uniform
  16884. * @return the material itself allowing "fluent" like uniform updates
  16885. */
  16886. setInt(name: string, value: number): ShaderMaterial;
  16887. /**
  16888. * Set an array of floats in the shader.
  16889. * @param name Define the name of the uniform as defined in the shader
  16890. * @param value Define the value to give to the uniform
  16891. * @return the material itself allowing "fluent" like uniform updates
  16892. */
  16893. setFloats(name: string, value: number[]): ShaderMaterial;
  16894. /**
  16895. * Set a vec3 in the shader from a Color3.
  16896. * @param name Define the name of the uniform as defined in the shader
  16897. * @param value Define the value to give to the uniform
  16898. * @return the material itself allowing "fluent" like uniform updates
  16899. */
  16900. setColor3(name: string, value: Color3): ShaderMaterial;
  16901. /**
  16902. * Set a vec3 array in the shader from a Color3 array.
  16903. * @param name Define the name of the uniform as defined in the shader
  16904. * @param value Define the value to give to the uniform
  16905. * @return the material itself allowing "fluent" like uniform updates
  16906. */
  16907. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16908. /**
  16909. * Set a vec4 in the shader from a Color4.
  16910. * @param name Define the name of the uniform as defined in the shader
  16911. * @param value Define the value to give to the uniform
  16912. * @return the material itself allowing "fluent" like uniform updates
  16913. */
  16914. setColor4(name: string, value: Color4): ShaderMaterial;
  16915. /**
  16916. * Set a vec2 in the shader from a Vector2.
  16917. * @param name Define the name of the uniform as defined in the shader
  16918. * @param value Define the value to give to the uniform
  16919. * @return the material itself allowing "fluent" like uniform updates
  16920. */
  16921. setVector2(name: string, value: Vector2): ShaderMaterial;
  16922. /**
  16923. * Set a vec3 in the shader from a Vector3.
  16924. * @param name Define the name of the uniform as defined in the shader
  16925. * @param value Define the value to give to the uniform
  16926. * @return the material itself allowing "fluent" like uniform updates
  16927. */
  16928. setVector3(name: string, value: Vector3): ShaderMaterial;
  16929. /**
  16930. * Set a vec4 in the shader from a Vector4.
  16931. * @param name Define the name of the uniform as defined in the shader
  16932. * @param value Define the value to give to the uniform
  16933. * @return the material itself allowing "fluent" like uniform updates
  16934. */
  16935. setVector4(name: string, value: Vector4): ShaderMaterial;
  16936. /**
  16937. * Set a mat4 in the shader from a Matrix.
  16938. * @param name Define the name of the uniform as defined in the shader
  16939. * @param value Define the value to give to the uniform
  16940. * @return the material itself allowing "fluent" like uniform updates
  16941. */
  16942. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16943. /**
  16944. * Set a mat3 in the shader from a Float32Array.
  16945. * @param name Define the name of the uniform as defined in the shader
  16946. * @param value Define the value to give to the uniform
  16947. * @return the material itself allowing "fluent" like uniform updates
  16948. */
  16949. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16950. /**
  16951. * Set a mat2 in the shader from a Float32Array.
  16952. * @param name Define the name of the uniform as defined in the shader
  16953. * @param value Define the value to give to the uniform
  16954. * @return the material itself allowing "fluent" like uniform updates
  16955. */
  16956. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16957. /**
  16958. * Set a vec2 array in the shader from a number array.
  16959. * @param name Define the name of the uniform as defined in the shader
  16960. * @param value Define the value to give to the uniform
  16961. * @return the material itself allowing "fluent" like uniform updates
  16962. */
  16963. setArray2(name: string, value: number[]): ShaderMaterial;
  16964. /**
  16965. * Set a vec3 array in the shader from a number array.
  16966. * @param name Define the name of the uniform as defined in the shader
  16967. * @param value Define the value to give to the uniform
  16968. * @return the material itself allowing "fluent" like uniform updates
  16969. */
  16970. setArray3(name: string, value: number[]): ShaderMaterial;
  16971. private _checkCache;
  16972. /**
  16973. * Specifies that the submesh is ready to be used
  16974. * @param mesh defines the mesh to check
  16975. * @param subMesh defines which submesh to check
  16976. * @param useInstances specifies that instances should be used
  16977. * @returns a boolean indicating that the submesh is ready or not
  16978. */
  16979. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16980. /**
  16981. * Checks if the material is ready to render the requested mesh
  16982. * @param mesh Define the mesh to render
  16983. * @param useInstances Define whether or not the material is used with instances
  16984. * @returns true if ready, otherwise false
  16985. */
  16986. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16987. /**
  16988. * Binds the world matrix to the material
  16989. * @param world defines the world transformation matrix
  16990. */
  16991. bindOnlyWorldMatrix(world: Matrix): void;
  16992. /**
  16993. * Binds the material to the mesh
  16994. * @param world defines the world transformation matrix
  16995. * @param mesh defines the mesh to bind the material to
  16996. */
  16997. bind(world: Matrix, mesh?: Mesh): void;
  16998. /**
  16999. * Gets the active textures from the material
  17000. * @returns an array of textures
  17001. */
  17002. getActiveTextures(): BaseTexture[];
  17003. /**
  17004. * Specifies if the material uses a texture
  17005. * @param texture defines the texture to check against the material
  17006. * @returns a boolean specifying if the material uses the texture
  17007. */
  17008. hasTexture(texture: BaseTexture): boolean;
  17009. /**
  17010. * Makes a duplicate of the material, and gives it a new name
  17011. * @param name defines the new name for the duplicated material
  17012. * @returns the cloned material
  17013. */
  17014. clone(name: string): ShaderMaterial;
  17015. /**
  17016. * Disposes the material
  17017. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17018. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17019. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17020. */
  17021. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17022. /**
  17023. * Serializes this material in a JSON representation
  17024. * @returns the serialized material object
  17025. */
  17026. serialize(): any;
  17027. /**
  17028. * Creates a shader material from parsed shader material data
  17029. * @param source defines the JSON represnetation of the material
  17030. * @param scene defines the hosting scene
  17031. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17032. * @returns a new material
  17033. */
  17034. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17035. }
  17036. }
  17037. declare module BABYLON {
  17038. /** @hidden */
  17039. export var colorPixelShader: {
  17040. name: string;
  17041. shader: string;
  17042. };
  17043. }
  17044. declare module BABYLON {
  17045. /** @hidden */
  17046. export var colorVertexShader: {
  17047. name: string;
  17048. shader: string;
  17049. };
  17050. }
  17051. declare module BABYLON {
  17052. /**
  17053. * Line mesh
  17054. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17055. */
  17056. export class LinesMesh extends Mesh {
  17057. /**
  17058. * If vertex color should be applied to the mesh
  17059. */
  17060. useVertexColor?: boolean | undefined;
  17061. /**
  17062. * If vertex alpha should be applied to the mesh
  17063. */
  17064. useVertexAlpha?: boolean | undefined;
  17065. /**
  17066. * Color of the line (Default: White)
  17067. */
  17068. color: Color3;
  17069. /**
  17070. * Alpha of the line (Default: 1)
  17071. */
  17072. alpha: number;
  17073. /**
  17074. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17075. * This margin is expressed in world space coordinates, so its value may vary.
  17076. * Default value is 0.1
  17077. */
  17078. intersectionThreshold: number;
  17079. private _colorShader;
  17080. /**
  17081. * Creates a new LinesMesh
  17082. * @param name defines the name
  17083. * @param scene defines the hosting scene
  17084. * @param parent defines the parent mesh if any
  17085. * @param source defines the optional source LinesMesh used to clone data from
  17086. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17087. * When false, achieved by calling a clone(), also passing False.
  17088. * This will make creation of children, recursive.
  17089. * @param useVertexColor defines if this LinesMesh supports vertex color
  17090. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17091. */
  17092. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17093. /**
  17094. * If vertex color should be applied to the mesh
  17095. */
  17096. useVertexColor?: boolean | undefined,
  17097. /**
  17098. * If vertex alpha should be applied to the mesh
  17099. */
  17100. useVertexAlpha?: boolean | undefined);
  17101. private _addClipPlaneDefine;
  17102. private _removeClipPlaneDefine;
  17103. isReady(): boolean;
  17104. /**
  17105. * Returns the string "LineMesh"
  17106. */
  17107. getClassName(): string;
  17108. /**
  17109. * @hidden
  17110. */
  17111. /**
  17112. * @hidden
  17113. */
  17114. material: Material;
  17115. /**
  17116. * @hidden
  17117. */
  17118. readonly checkCollisions: boolean;
  17119. /** @hidden */
  17120. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17121. /** @hidden */
  17122. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17123. /**
  17124. * Disposes of the line mesh
  17125. * @param doNotRecurse If children should be disposed
  17126. */
  17127. dispose(doNotRecurse?: boolean): void;
  17128. /**
  17129. * Returns a new LineMesh object cloned from the current one.
  17130. */
  17131. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17132. /**
  17133. * Creates a new InstancedLinesMesh object from the mesh model.
  17134. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17135. * @param name defines the name of the new instance
  17136. * @returns a new InstancedLinesMesh
  17137. */
  17138. createInstance(name: string): InstancedLinesMesh;
  17139. }
  17140. /**
  17141. * Creates an instance based on a source LinesMesh
  17142. */
  17143. export class InstancedLinesMesh extends InstancedMesh {
  17144. /**
  17145. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17146. * This margin is expressed in world space coordinates, so its value may vary.
  17147. * Initilized with the intersectionThreshold value of the source LinesMesh
  17148. */
  17149. intersectionThreshold: number;
  17150. constructor(name: string, source: LinesMesh);
  17151. /**
  17152. * Returns the string "InstancedLinesMesh".
  17153. */
  17154. getClassName(): string;
  17155. }
  17156. }
  17157. declare module BABYLON {
  17158. /** @hidden */
  17159. export var linePixelShader: {
  17160. name: string;
  17161. shader: string;
  17162. };
  17163. }
  17164. declare module BABYLON {
  17165. /** @hidden */
  17166. export var lineVertexShader: {
  17167. name: string;
  17168. shader: string;
  17169. };
  17170. }
  17171. declare module BABYLON {
  17172. interface AbstractMesh {
  17173. /**
  17174. * Gets the edgesRenderer associated with the mesh
  17175. */
  17176. edgesRenderer: Nullable<EdgesRenderer>;
  17177. }
  17178. interface LinesMesh {
  17179. /**
  17180. * Enables the edge rendering mode on the mesh.
  17181. * This mode makes the mesh edges visible
  17182. * @param epsilon defines the maximal distance between two angles to detect a face
  17183. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17184. * @returns the currentAbstractMesh
  17185. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17186. */
  17187. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17188. }
  17189. interface InstancedLinesMesh {
  17190. /**
  17191. * Enables the edge rendering mode on the mesh.
  17192. * This mode makes the mesh edges visible
  17193. * @param epsilon defines the maximal distance between two angles to detect a face
  17194. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17195. * @returns the current InstancedLinesMesh
  17196. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17197. */
  17198. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17199. }
  17200. /**
  17201. * Defines the minimum contract an Edges renderer should follow.
  17202. */
  17203. export interface IEdgesRenderer extends IDisposable {
  17204. /**
  17205. * Gets or sets a boolean indicating if the edgesRenderer is active
  17206. */
  17207. isEnabled: boolean;
  17208. /**
  17209. * Renders the edges of the attached mesh,
  17210. */
  17211. render(): void;
  17212. /**
  17213. * Checks wether or not the edges renderer is ready to render.
  17214. * @return true if ready, otherwise false.
  17215. */
  17216. isReady(): boolean;
  17217. }
  17218. /**
  17219. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17220. */
  17221. export class EdgesRenderer implements IEdgesRenderer {
  17222. /**
  17223. * Define the size of the edges with an orthographic camera
  17224. */
  17225. edgesWidthScalerForOrthographic: number;
  17226. /**
  17227. * Define the size of the edges with a perspective camera
  17228. */
  17229. edgesWidthScalerForPerspective: number;
  17230. protected _source: AbstractMesh;
  17231. protected _linesPositions: number[];
  17232. protected _linesNormals: number[];
  17233. protected _linesIndices: number[];
  17234. protected _epsilon: number;
  17235. protected _indicesCount: number;
  17236. protected _lineShader: ShaderMaterial;
  17237. protected _ib: DataBuffer;
  17238. protected _buffers: {
  17239. [key: string]: Nullable<VertexBuffer>;
  17240. };
  17241. protected _checkVerticesInsteadOfIndices: boolean;
  17242. private _meshRebuildObserver;
  17243. private _meshDisposeObserver;
  17244. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17245. isEnabled: boolean;
  17246. /**
  17247. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17248. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17249. * @param source Mesh used to create edges
  17250. * @param epsilon sum of angles in adjacency to check for edge
  17251. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17252. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17253. */
  17254. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17255. protected _prepareRessources(): void;
  17256. /** @hidden */
  17257. _rebuild(): void;
  17258. /**
  17259. * Releases the required resources for the edges renderer
  17260. */
  17261. dispose(): void;
  17262. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17263. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17264. /**
  17265. * Checks if the pair of p0 and p1 is en edge
  17266. * @param faceIndex
  17267. * @param edge
  17268. * @param faceNormals
  17269. * @param p0
  17270. * @param p1
  17271. * @private
  17272. */
  17273. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17274. /**
  17275. * push line into the position, normal and index buffer
  17276. * @protected
  17277. */
  17278. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17279. /**
  17280. * Generates lines edges from adjacencjes
  17281. * @private
  17282. */
  17283. _generateEdgesLines(): void;
  17284. /**
  17285. * Checks wether or not the edges renderer is ready to render.
  17286. * @return true if ready, otherwise false.
  17287. */
  17288. isReady(): boolean;
  17289. /**
  17290. * Renders the edges of the attached mesh,
  17291. */
  17292. render(): void;
  17293. }
  17294. /**
  17295. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17296. */
  17297. export class LineEdgesRenderer extends EdgesRenderer {
  17298. /**
  17299. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17300. * @param source LineMesh used to generate edges
  17301. * @param epsilon not important (specified angle for edge detection)
  17302. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17303. */
  17304. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17305. /**
  17306. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17307. */
  17308. _generateEdgesLines(): void;
  17309. }
  17310. }
  17311. declare module BABYLON {
  17312. /**
  17313. * This represents the object necessary to create a rendering group.
  17314. * This is exclusively used and created by the rendering manager.
  17315. * To modify the behavior, you use the available helpers in your scene or meshes.
  17316. * @hidden
  17317. */
  17318. export class RenderingGroup {
  17319. index: number;
  17320. private _scene;
  17321. private _opaqueSubMeshes;
  17322. private _transparentSubMeshes;
  17323. private _alphaTestSubMeshes;
  17324. private _depthOnlySubMeshes;
  17325. private _particleSystems;
  17326. private _spriteManagers;
  17327. private _opaqueSortCompareFn;
  17328. private _alphaTestSortCompareFn;
  17329. private _transparentSortCompareFn;
  17330. private _renderOpaque;
  17331. private _renderAlphaTest;
  17332. private _renderTransparent;
  17333. /** @hidden */
  17334. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17335. onBeforeTransparentRendering: () => void;
  17336. /**
  17337. * Set the opaque sort comparison function.
  17338. * If null the sub meshes will be render in the order they were created
  17339. */
  17340. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17341. /**
  17342. * Set the alpha test sort comparison function.
  17343. * If null the sub meshes will be render in the order they were created
  17344. */
  17345. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17346. /**
  17347. * Set the transparent sort comparison function.
  17348. * If null the sub meshes will be render in the order they were created
  17349. */
  17350. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17351. /**
  17352. * Creates a new rendering group.
  17353. * @param index The rendering group index
  17354. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17355. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17356. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17357. */
  17358. 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>);
  17359. /**
  17360. * Render all the sub meshes contained in the group.
  17361. * @param customRenderFunction Used to override the default render behaviour of the group.
  17362. * @returns true if rendered some submeshes.
  17363. */
  17364. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17365. /**
  17366. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17367. * @param subMeshes The submeshes to render
  17368. */
  17369. private renderOpaqueSorted;
  17370. /**
  17371. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17372. * @param subMeshes The submeshes to render
  17373. */
  17374. private renderAlphaTestSorted;
  17375. /**
  17376. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17377. * @param subMeshes The submeshes to render
  17378. */
  17379. private renderTransparentSorted;
  17380. /**
  17381. * Renders the submeshes in a specified order.
  17382. * @param subMeshes The submeshes to sort before render
  17383. * @param sortCompareFn The comparison function use to sort
  17384. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17385. * @param transparent Specifies to activate blending if true
  17386. */
  17387. private static renderSorted;
  17388. /**
  17389. * Renders the submeshes in the order they were dispatched (no sort applied).
  17390. * @param subMeshes The submeshes to render
  17391. */
  17392. private static renderUnsorted;
  17393. /**
  17394. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17395. * are rendered back to front if in the same alpha index.
  17396. *
  17397. * @param a The first submesh
  17398. * @param b The second submesh
  17399. * @returns The result of the comparison
  17400. */
  17401. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17402. /**
  17403. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17404. * are rendered back to front.
  17405. *
  17406. * @param a The first submesh
  17407. * @param b The second submesh
  17408. * @returns The result of the comparison
  17409. */
  17410. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17411. /**
  17412. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17413. * are rendered front to back (prevent overdraw).
  17414. *
  17415. * @param a The first submesh
  17416. * @param b The second submesh
  17417. * @returns The result of the comparison
  17418. */
  17419. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17420. /**
  17421. * Resets the different lists of submeshes to prepare a new frame.
  17422. */
  17423. prepare(): void;
  17424. dispose(): void;
  17425. /**
  17426. * Inserts the submesh in its correct queue depending on its material.
  17427. * @param subMesh The submesh to dispatch
  17428. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17429. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17430. */
  17431. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17432. dispatchSprites(spriteManager: ISpriteManager): void;
  17433. dispatchParticles(particleSystem: IParticleSystem): void;
  17434. private _renderParticles;
  17435. private _renderSprites;
  17436. }
  17437. }
  17438. declare module BABYLON {
  17439. /**
  17440. * Interface describing the different options available in the rendering manager
  17441. * regarding Auto Clear between groups.
  17442. */
  17443. export interface IRenderingManagerAutoClearSetup {
  17444. /**
  17445. * Defines whether or not autoclear is enable.
  17446. */
  17447. autoClear: boolean;
  17448. /**
  17449. * Defines whether or not to autoclear the depth buffer.
  17450. */
  17451. depth: boolean;
  17452. /**
  17453. * Defines whether or not to autoclear the stencil buffer.
  17454. */
  17455. stencil: boolean;
  17456. }
  17457. /**
  17458. * This class is used by the onRenderingGroupObservable
  17459. */
  17460. export class RenderingGroupInfo {
  17461. /**
  17462. * The Scene that being rendered
  17463. */
  17464. scene: Scene;
  17465. /**
  17466. * The camera currently used for the rendering pass
  17467. */
  17468. camera: Nullable<Camera>;
  17469. /**
  17470. * The ID of the renderingGroup being processed
  17471. */
  17472. renderingGroupId: number;
  17473. }
  17474. /**
  17475. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17476. * It is enable to manage the different groups as well as the different necessary sort functions.
  17477. * This should not be used directly aside of the few static configurations
  17478. */
  17479. export class RenderingManager {
  17480. /**
  17481. * The max id used for rendering groups (not included)
  17482. */
  17483. static MAX_RENDERINGGROUPS: number;
  17484. /**
  17485. * The min id used for rendering groups (included)
  17486. */
  17487. static MIN_RENDERINGGROUPS: number;
  17488. /**
  17489. * Used to globally prevent autoclearing scenes.
  17490. */
  17491. static AUTOCLEAR: boolean;
  17492. /**
  17493. * @hidden
  17494. */
  17495. _useSceneAutoClearSetup: boolean;
  17496. private _scene;
  17497. private _renderingGroups;
  17498. private _depthStencilBufferAlreadyCleaned;
  17499. private _autoClearDepthStencil;
  17500. private _customOpaqueSortCompareFn;
  17501. private _customAlphaTestSortCompareFn;
  17502. private _customTransparentSortCompareFn;
  17503. private _renderingGroupInfo;
  17504. /**
  17505. * Instantiates a new rendering group for a particular scene
  17506. * @param scene Defines the scene the groups belongs to
  17507. */
  17508. constructor(scene: Scene);
  17509. private _clearDepthStencilBuffer;
  17510. /**
  17511. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17512. * @hidden
  17513. */
  17514. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17515. /**
  17516. * Resets the different information of the group to prepare a new frame
  17517. * @hidden
  17518. */
  17519. reset(): void;
  17520. /**
  17521. * Dispose and release the group and its associated resources.
  17522. * @hidden
  17523. */
  17524. dispose(): void;
  17525. /**
  17526. * Clear the info related to rendering groups preventing retention points during dispose.
  17527. */
  17528. freeRenderingGroups(): void;
  17529. private _prepareRenderingGroup;
  17530. /**
  17531. * Add a sprite manager to the rendering manager in order to render it this frame.
  17532. * @param spriteManager Define the sprite manager to render
  17533. */
  17534. dispatchSprites(spriteManager: ISpriteManager): void;
  17535. /**
  17536. * Add a particle system to the rendering manager in order to render it this frame.
  17537. * @param particleSystem Define the particle system to render
  17538. */
  17539. dispatchParticles(particleSystem: IParticleSystem): void;
  17540. /**
  17541. * Add a submesh to the manager in order to render it this frame
  17542. * @param subMesh The submesh to dispatch
  17543. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17544. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17545. */
  17546. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17547. /**
  17548. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17549. * This allowed control for front to back rendering or reversly depending of the special needs.
  17550. *
  17551. * @param renderingGroupId The rendering group id corresponding to its index
  17552. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17553. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17554. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17555. */
  17556. 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;
  17557. /**
  17558. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17559. *
  17560. * @param renderingGroupId The rendering group id corresponding to its index
  17561. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17562. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17563. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17564. */
  17565. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17566. /**
  17567. * Gets the current auto clear configuration for one rendering group of the rendering
  17568. * manager.
  17569. * @param index the rendering group index to get the information for
  17570. * @returns The auto clear setup for the requested rendering group
  17571. */
  17572. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17573. }
  17574. }
  17575. declare module BABYLON {
  17576. /**
  17577. * This Helps creating a texture that will be created from a camera in your scene.
  17578. * It is basically a dynamic texture that could be used to create special effects for instance.
  17579. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17580. */
  17581. export class RenderTargetTexture extends Texture {
  17582. isCube: boolean;
  17583. /**
  17584. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17585. */
  17586. static readonly REFRESHRATE_RENDER_ONCE: number;
  17587. /**
  17588. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17589. */
  17590. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17591. /**
  17592. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17593. * the central point of your effect and can save a lot of performances.
  17594. */
  17595. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17596. /**
  17597. * Use this predicate to dynamically define the list of mesh you want to render.
  17598. * If set, the renderList property will be overwritten.
  17599. */
  17600. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17601. private _renderList;
  17602. /**
  17603. * Use this list to define the list of mesh you want to render.
  17604. */
  17605. renderList: Nullable<Array<AbstractMesh>>;
  17606. private _hookArray;
  17607. /**
  17608. * Define if particles should be rendered in your texture.
  17609. */
  17610. renderParticles: boolean;
  17611. /**
  17612. * Define if sprites should be rendered in your texture.
  17613. */
  17614. renderSprites: boolean;
  17615. /**
  17616. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17617. */
  17618. coordinatesMode: number;
  17619. /**
  17620. * Define the camera used to render the texture.
  17621. */
  17622. activeCamera: Nullable<Camera>;
  17623. /**
  17624. * Override the render function of the texture with your own one.
  17625. */
  17626. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17627. /**
  17628. * Define if camera post processes should be use while rendering the texture.
  17629. */
  17630. useCameraPostProcesses: boolean;
  17631. /**
  17632. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17633. */
  17634. ignoreCameraViewport: boolean;
  17635. private _postProcessManager;
  17636. private _postProcesses;
  17637. private _resizeObserver;
  17638. /**
  17639. * An event triggered when the texture is unbind.
  17640. */
  17641. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17642. /**
  17643. * An event triggered when the texture is unbind.
  17644. */
  17645. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17646. private _onAfterUnbindObserver;
  17647. /**
  17648. * Set a after unbind callback in the texture.
  17649. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17650. */
  17651. onAfterUnbind: () => void;
  17652. /**
  17653. * An event triggered before rendering the texture
  17654. */
  17655. onBeforeRenderObservable: Observable<number>;
  17656. private _onBeforeRenderObserver;
  17657. /**
  17658. * Set a before render callback in the texture.
  17659. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17660. */
  17661. onBeforeRender: (faceIndex: number) => void;
  17662. /**
  17663. * An event triggered after rendering the texture
  17664. */
  17665. onAfterRenderObservable: Observable<number>;
  17666. private _onAfterRenderObserver;
  17667. /**
  17668. * Set a after render callback in the texture.
  17669. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17670. */
  17671. onAfterRender: (faceIndex: number) => void;
  17672. /**
  17673. * An event triggered after the texture clear
  17674. */
  17675. onClearObservable: Observable<Engine>;
  17676. private _onClearObserver;
  17677. /**
  17678. * Set a clear callback in the texture.
  17679. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17680. */
  17681. onClear: (Engine: Engine) => void;
  17682. /**
  17683. * Define the clear color of the Render Target if it should be different from the scene.
  17684. */
  17685. clearColor: Color4;
  17686. protected _size: number | {
  17687. width: number;
  17688. height: number;
  17689. };
  17690. protected _initialSizeParameter: number | {
  17691. width: number;
  17692. height: number;
  17693. } | {
  17694. ratio: number;
  17695. };
  17696. protected _sizeRatio: Nullable<number>;
  17697. /** @hidden */
  17698. _generateMipMaps: boolean;
  17699. protected _renderingManager: RenderingManager;
  17700. /** @hidden */
  17701. _waitingRenderList: string[];
  17702. protected _doNotChangeAspectRatio: boolean;
  17703. protected _currentRefreshId: number;
  17704. protected _refreshRate: number;
  17705. protected _textureMatrix: Matrix;
  17706. protected _samples: number;
  17707. protected _renderTargetOptions: RenderTargetCreationOptions;
  17708. /**
  17709. * Gets render target creation options that were used.
  17710. */
  17711. readonly renderTargetOptions: RenderTargetCreationOptions;
  17712. protected _engine: Engine;
  17713. protected _onRatioRescale(): void;
  17714. /**
  17715. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17716. * It must define where the camera used to render the texture is set
  17717. */
  17718. boundingBoxPosition: Vector3;
  17719. private _boundingBoxSize;
  17720. /**
  17721. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17722. * When defined, the cubemap will switch to local mode
  17723. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17724. * @example https://www.babylonjs-playground.com/#RNASML
  17725. */
  17726. boundingBoxSize: Vector3;
  17727. /**
  17728. * In case the RTT has been created with a depth texture, get the associated
  17729. * depth texture.
  17730. * Otherwise, return null.
  17731. */
  17732. depthStencilTexture: Nullable<InternalTexture>;
  17733. /**
  17734. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17735. * or used a shadow, depth texture...
  17736. * @param name The friendly name of the texture
  17737. * @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)
  17738. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17739. * @param generateMipMaps True if mip maps need to be generated after render.
  17740. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17741. * @param type The type of the buffer in the RTT (int, half float, float...)
  17742. * @param isCube True if a cube texture needs to be created
  17743. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17744. * @param generateDepthBuffer True to generate a depth buffer
  17745. * @param generateStencilBuffer True to generate a stencil buffer
  17746. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17747. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17748. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17749. */
  17750. constructor(name: string, size: number | {
  17751. width: number;
  17752. height: number;
  17753. } | {
  17754. ratio: number;
  17755. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17756. /**
  17757. * Creates a depth stencil texture.
  17758. * This is only available in WebGL 2 or with the depth texture extension available.
  17759. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17760. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17761. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17762. */
  17763. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17764. private _processSizeParameter;
  17765. /**
  17766. * Define the number of samples to use in case of MSAA.
  17767. * It defaults to one meaning no MSAA has been enabled.
  17768. */
  17769. samples: number;
  17770. /**
  17771. * Resets the refresh counter of the texture and start bak from scratch.
  17772. * Could be useful to regenerate the texture if it is setup to render only once.
  17773. */
  17774. resetRefreshCounter(): void;
  17775. /**
  17776. * Define the refresh rate of the texture or the rendering frequency.
  17777. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17778. */
  17779. refreshRate: number;
  17780. /**
  17781. * Adds a post process to the render target rendering passes.
  17782. * @param postProcess define the post process to add
  17783. */
  17784. addPostProcess(postProcess: PostProcess): void;
  17785. /**
  17786. * Clear all the post processes attached to the render target
  17787. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17788. */
  17789. clearPostProcesses(dispose?: boolean): void;
  17790. /**
  17791. * Remove one of the post process from the list of attached post processes to the texture
  17792. * @param postProcess define the post process to remove from the list
  17793. */
  17794. removePostProcess(postProcess: PostProcess): void;
  17795. /** @hidden */
  17796. _shouldRender(): boolean;
  17797. /**
  17798. * Gets the actual render size of the texture.
  17799. * @returns the width of the render size
  17800. */
  17801. getRenderSize(): number;
  17802. /**
  17803. * Gets the actual render width of the texture.
  17804. * @returns the width of the render size
  17805. */
  17806. getRenderWidth(): number;
  17807. /**
  17808. * Gets the actual render height of the texture.
  17809. * @returns the height of the render size
  17810. */
  17811. getRenderHeight(): number;
  17812. /**
  17813. * Get if the texture can be rescaled or not.
  17814. */
  17815. readonly canRescale: boolean;
  17816. /**
  17817. * Resize the texture using a ratio.
  17818. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17819. */
  17820. scale(ratio: number): void;
  17821. /**
  17822. * Get the texture reflection matrix used to rotate/transform the reflection.
  17823. * @returns the reflection matrix
  17824. */
  17825. getReflectionTextureMatrix(): Matrix;
  17826. /**
  17827. * Resize the texture to a new desired size.
  17828. * Be carrefull as it will recreate all the data in the new texture.
  17829. * @param size Define the new size. It can be:
  17830. * - a number for squared texture,
  17831. * - an object containing { width: number, height: number }
  17832. * - or an object containing a ratio { ratio: number }
  17833. */
  17834. resize(size: number | {
  17835. width: number;
  17836. height: number;
  17837. } | {
  17838. ratio: number;
  17839. }): void;
  17840. /**
  17841. * Renders all the objects from the render list into the texture.
  17842. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17843. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17844. */
  17845. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17846. private _bestReflectionRenderTargetDimension;
  17847. /**
  17848. * @hidden
  17849. * @param faceIndex face index to bind to if this is a cubetexture
  17850. */
  17851. _bindFrameBuffer(faceIndex?: number): void;
  17852. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17853. private renderToTarget;
  17854. /**
  17855. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17856. * This allowed control for front to back rendering or reversly depending of the special needs.
  17857. *
  17858. * @param renderingGroupId The rendering group id corresponding to its index
  17859. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17860. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17861. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17862. */
  17863. 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;
  17864. /**
  17865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17866. *
  17867. * @param renderingGroupId The rendering group id corresponding to its index
  17868. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17869. */
  17870. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17871. /**
  17872. * Clones the texture.
  17873. * @returns the cloned texture
  17874. */
  17875. clone(): RenderTargetTexture;
  17876. /**
  17877. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17878. * @returns The JSON representation of the texture
  17879. */
  17880. serialize(): any;
  17881. /**
  17882. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17883. */
  17884. disposeFramebufferObjects(): void;
  17885. /**
  17886. * Dispose the texture and release its associated resources.
  17887. */
  17888. dispose(): void;
  17889. /** @hidden */
  17890. _rebuild(): void;
  17891. /**
  17892. * Clear the info related to rendering groups preventing retention point in material dispose.
  17893. */
  17894. freeRenderingGroups(): void;
  17895. /**
  17896. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17897. * @returns the view count
  17898. */
  17899. getViewCount(): number;
  17900. }
  17901. }
  17902. declare module BABYLON {
  17903. /**
  17904. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17905. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17906. * You can then easily use it as a reflectionTexture on a flat surface.
  17907. * In case the surface is not a plane, please consider relying on reflection probes.
  17908. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17909. */
  17910. export class MirrorTexture extends RenderTargetTexture {
  17911. private scene;
  17912. /**
  17913. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17914. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  17915. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17916. */
  17917. mirrorPlane: Plane;
  17918. /**
  17919. * Define the blur ratio used to blur the reflection if needed.
  17920. */
  17921. blurRatio: number;
  17922. /**
  17923. * Define the adaptive blur kernel used to blur the reflection if needed.
  17924. * This will autocompute the closest best match for the `blurKernel`
  17925. */
  17926. adaptiveBlurKernel: number;
  17927. /**
  17928. * Define the blur kernel used to blur the reflection if needed.
  17929. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17930. */
  17931. blurKernel: number;
  17932. /**
  17933. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17934. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17935. */
  17936. blurKernelX: number;
  17937. /**
  17938. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17939. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17940. */
  17941. blurKernelY: number;
  17942. private _autoComputeBlurKernel;
  17943. protected _onRatioRescale(): void;
  17944. private _updateGammaSpace;
  17945. private _imageProcessingConfigChangeObserver;
  17946. private _transformMatrix;
  17947. private _mirrorMatrix;
  17948. private _savedViewMatrix;
  17949. private _blurX;
  17950. private _blurY;
  17951. private _adaptiveBlurKernel;
  17952. private _blurKernelX;
  17953. private _blurKernelY;
  17954. private _blurRatio;
  17955. /**
  17956. * Instantiates a Mirror Texture.
  17957. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17958. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17959. * You can then easily use it as a reflectionTexture on a flat surface.
  17960. * In case the surface is not a plane, please consider relying on reflection probes.
  17961. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17962. * @param name
  17963. * @param size
  17964. * @param scene
  17965. * @param generateMipMaps
  17966. * @param type
  17967. * @param samplingMode
  17968. * @param generateDepthBuffer
  17969. */
  17970. constructor(name: string, size: number | {
  17971. width: number;
  17972. height: number;
  17973. } | {
  17974. ratio: number;
  17975. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17976. private _preparePostProcesses;
  17977. /**
  17978. * Clone the mirror texture.
  17979. * @returns the cloned texture
  17980. */
  17981. clone(): MirrorTexture;
  17982. /**
  17983. * Serialize the texture to a JSON representation you could use in Parse later on
  17984. * @returns the serialized JSON representation
  17985. */
  17986. serialize(): any;
  17987. /**
  17988. * Dispose the texture and release its associated resources.
  17989. */
  17990. dispose(): void;
  17991. }
  17992. }
  17993. declare module BABYLON {
  17994. /**
  17995. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17996. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17997. */
  17998. export class Texture extends BaseTexture {
  17999. /** @hidden */
  18000. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  18001. /** @hidden */
  18002. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  18003. /** @hidden */
  18004. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  18005. /** nearest is mag = nearest and min = nearest and mip = linear */
  18006. static readonly NEAREST_SAMPLINGMODE: number;
  18007. /** nearest is mag = nearest and min = nearest and mip = linear */
  18008. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18009. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18010. static readonly BILINEAR_SAMPLINGMODE: number;
  18011. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18012. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18013. /** Trilinear is mag = linear and min = linear and mip = linear */
  18014. static readonly TRILINEAR_SAMPLINGMODE: number;
  18015. /** Trilinear is mag = linear and min = linear and mip = linear */
  18016. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18017. /** mag = nearest and min = nearest and mip = nearest */
  18018. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18019. /** mag = nearest and min = linear and mip = nearest */
  18020. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18021. /** mag = nearest and min = linear and mip = linear */
  18022. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18023. /** mag = nearest and min = linear and mip = none */
  18024. static readonly NEAREST_LINEAR: number;
  18025. /** mag = nearest and min = nearest and mip = none */
  18026. static readonly NEAREST_NEAREST: number;
  18027. /** mag = linear and min = nearest and mip = nearest */
  18028. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18029. /** mag = linear and min = nearest and mip = linear */
  18030. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18031. /** mag = linear and min = linear and mip = none */
  18032. static readonly LINEAR_LINEAR: number;
  18033. /** mag = linear and min = nearest and mip = none */
  18034. static readonly LINEAR_NEAREST: number;
  18035. /** Explicit coordinates mode */
  18036. static readonly EXPLICIT_MODE: number;
  18037. /** Spherical coordinates mode */
  18038. static readonly SPHERICAL_MODE: number;
  18039. /** Planar coordinates mode */
  18040. static readonly PLANAR_MODE: number;
  18041. /** Cubic coordinates mode */
  18042. static readonly CUBIC_MODE: number;
  18043. /** Projection coordinates mode */
  18044. static readonly PROJECTION_MODE: number;
  18045. /** Inverse Cubic coordinates mode */
  18046. static readonly SKYBOX_MODE: number;
  18047. /** Inverse Cubic coordinates mode */
  18048. static readonly INVCUBIC_MODE: number;
  18049. /** Equirectangular coordinates mode */
  18050. static readonly EQUIRECTANGULAR_MODE: number;
  18051. /** Equirectangular Fixed coordinates mode */
  18052. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18053. /** Equirectangular Fixed Mirrored coordinates mode */
  18054. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18055. /** Texture is not repeating outside of 0..1 UVs */
  18056. static readonly CLAMP_ADDRESSMODE: number;
  18057. /** Texture is repeating outside of 0..1 UVs */
  18058. static readonly WRAP_ADDRESSMODE: number;
  18059. /** Texture is repeating and mirrored */
  18060. static readonly MIRROR_ADDRESSMODE: number;
  18061. /**
  18062. * 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
  18063. */
  18064. static UseSerializedUrlIfAny: boolean;
  18065. /**
  18066. * Define the url of the texture.
  18067. */
  18068. url: Nullable<string>;
  18069. /**
  18070. * Define an offset on the texture to offset the u coordinates of the UVs
  18071. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18072. */
  18073. uOffset: number;
  18074. /**
  18075. * Define an offset on the texture to offset the v coordinates of the UVs
  18076. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18077. */
  18078. vOffset: number;
  18079. /**
  18080. * Define an offset on the texture to scale the u coordinates of the UVs
  18081. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18082. */
  18083. uScale: number;
  18084. /**
  18085. * Define an offset on the texture to scale the v coordinates of the UVs
  18086. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18087. */
  18088. vScale: number;
  18089. /**
  18090. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18091. * @see http://doc.babylonjs.com/how_to/more_materials
  18092. */
  18093. uAng: number;
  18094. /**
  18095. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18096. * @see http://doc.babylonjs.com/how_to/more_materials
  18097. */
  18098. vAng: number;
  18099. /**
  18100. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18101. * @see http://doc.babylonjs.com/how_to/more_materials
  18102. */
  18103. wAng: number;
  18104. /**
  18105. * Defines the center of rotation (U)
  18106. */
  18107. uRotationCenter: number;
  18108. /**
  18109. * Defines the center of rotation (V)
  18110. */
  18111. vRotationCenter: number;
  18112. /**
  18113. * Defines the center of rotation (W)
  18114. */
  18115. wRotationCenter: number;
  18116. /**
  18117. * Are mip maps generated for this texture or not.
  18118. */
  18119. readonly noMipmap: boolean;
  18120. /**
  18121. * List of inspectable custom properties (used by the Inspector)
  18122. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18123. */
  18124. inspectableCustomProperties: Nullable<IInspectable[]>;
  18125. private _noMipmap;
  18126. /** @hidden */
  18127. _invertY: boolean;
  18128. private _rowGenerationMatrix;
  18129. private _cachedTextureMatrix;
  18130. private _projectionModeMatrix;
  18131. private _t0;
  18132. private _t1;
  18133. private _t2;
  18134. private _cachedUOffset;
  18135. private _cachedVOffset;
  18136. private _cachedUScale;
  18137. private _cachedVScale;
  18138. private _cachedUAng;
  18139. private _cachedVAng;
  18140. private _cachedWAng;
  18141. private _cachedProjectionMatrixId;
  18142. private _cachedCoordinatesMode;
  18143. /** @hidden */
  18144. protected _initialSamplingMode: number;
  18145. /** @hidden */
  18146. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18147. private _deleteBuffer;
  18148. protected _format: Nullable<number>;
  18149. private _delayedOnLoad;
  18150. private _delayedOnError;
  18151. /**
  18152. * Observable triggered once the texture has been loaded.
  18153. */
  18154. onLoadObservable: Observable<Texture>;
  18155. protected _isBlocking: boolean;
  18156. /**
  18157. * Is the texture preventing material to render while loading.
  18158. * If false, a default texture will be used instead of the loading one during the preparation step.
  18159. */
  18160. isBlocking: boolean;
  18161. /**
  18162. * Get the current sampling mode associated with the texture.
  18163. */
  18164. readonly samplingMode: number;
  18165. /**
  18166. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18167. */
  18168. readonly invertY: boolean;
  18169. /**
  18170. * Instantiates a new texture.
  18171. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18172. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18173. * @param url define the url of the picture to load as a texture
  18174. * @param scene define the scene the texture will belong to
  18175. * @param noMipmap define if the texture will require mip maps or not
  18176. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18177. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18178. * @param onLoad define a callback triggered when the texture has been loaded
  18179. * @param onError define a callback triggered when an error occurred during the loading session
  18180. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18181. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18182. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18183. */
  18184. 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);
  18185. /**
  18186. * Update the url (and optional buffer) of this texture if url was null during construction.
  18187. * @param url the url of the texture
  18188. * @param buffer the buffer of the texture (defaults to null)
  18189. * @param onLoad callback called when the texture is loaded (defaults to null)
  18190. */
  18191. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18192. /**
  18193. * Finish the loading sequence of a texture flagged as delayed load.
  18194. * @hidden
  18195. */
  18196. delayLoad(): void;
  18197. private _prepareRowForTextureGeneration;
  18198. /**
  18199. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18200. * @returns the transform matrix of the texture.
  18201. */
  18202. getTextureMatrix(): Matrix;
  18203. /**
  18204. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18205. * @returns The reflection texture transform
  18206. */
  18207. getReflectionTextureMatrix(): Matrix;
  18208. /**
  18209. * Clones the texture.
  18210. * @returns the cloned texture
  18211. */
  18212. clone(): Texture;
  18213. /**
  18214. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18215. * @returns The JSON representation of the texture
  18216. */
  18217. serialize(): any;
  18218. /**
  18219. * Get the current class name of the texture useful for serialization or dynamic coding.
  18220. * @returns "Texture"
  18221. */
  18222. getClassName(): string;
  18223. /**
  18224. * Dispose the texture and release its associated resources.
  18225. */
  18226. dispose(): void;
  18227. /**
  18228. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18229. * @param parsedTexture Define the JSON representation of the texture
  18230. * @param scene Define the scene the parsed texture should be instantiated in
  18231. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18232. * @returns The parsed texture if successful
  18233. */
  18234. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18235. /**
  18236. * Creates a texture from its base 64 representation.
  18237. * @param data Define the base64 payload without the data: prefix
  18238. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18239. * @param scene Define the scene the texture should belong to
  18240. * @param noMipmap Forces the texture to not create mip map information if true
  18241. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18242. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18243. * @param onLoad define a callback triggered when the texture has been loaded
  18244. * @param onError define a callback triggered when an error occurred during the loading session
  18245. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18246. * @returns the created texture
  18247. */
  18248. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18249. /**
  18250. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18251. * @param data Define the base64 payload without the data: prefix
  18252. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18253. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18254. * @param scene Define the scene the texture should belong to
  18255. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18256. * @param noMipmap Forces the texture to not create mip map information if true
  18257. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18258. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18259. * @param onLoad define a callback triggered when the texture has been loaded
  18260. * @param onError define a callback triggered when an error occurred during the loading session
  18261. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18262. * @returns the created texture
  18263. */
  18264. 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;
  18265. }
  18266. }
  18267. declare module BABYLON {
  18268. interface Engine {
  18269. /**
  18270. * Creates a raw texture
  18271. * @param data defines the data to store in the texture
  18272. * @param width defines the width of the texture
  18273. * @param height defines the height of the texture
  18274. * @param format defines the format of the data
  18275. * @param generateMipMaps defines if the engine should generate the mip levels
  18276. * @param invertY defines if data must be stored with Y axis inverted
  18277. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18278. * @param compression defines the compression used (null by default)
  18279. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18280. * @returns the raw texture inside an InternalTexture
  18281. */
  18282. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18283. /**
  18284. * Update a raw texture
  18285. * @param texture defines the texture to update
  18286. * @param data defines the data to store in the texture
  18287. * @param format defines the format of the data
  18288. * @param invertY defines if data must be stored with Y axis inverted
  18289. */
  18290. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18291. /**
  18292. * Update a raw texture
  18293. * @param texture defines the texture to update
  18294. * @param data defines the data to store in the texture
  18295. * @param format defines the format of the data
  18296. * @param invertY defines if data must be stored with Y axis inverted
  18297. * @param compression defines the compression used (null by default)
  18298. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18299. */
  18300. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18301. /**
  18302. * Creates a new raw cube texture
  18303. * @param data defines the array of data to use to create each face
  18304. * @param size defines the size of the textures
  18305. * @param format defines the format of the data
  18306. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18307. * @param generateMipMaps defines if the engine should generate the mip levels
  18308. * @param invertY defines if data must be stored with Y axis inverted
  18309. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18310. * @param compression defines the compression used (null by default)
  18311. * @returns the cube texture as an InternalTexture
  18312. */
  18313. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18314. /**
  18315. * Update a raw cube texture
  18316. * @param texture defines the texture to udpdate
  18317. * @param data defines the data to store
  18318. * @param format defines the data format
  18319. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18320. * @param invertY defines if data must be stored with Y axis inverted
  18321. */
  18322. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18323. /**
  18324. * Update a raw cube texture
  18325. * @param texture defines the texture to udpdate
  18326. * @param data defines the data to store
  18327. * @param format defines the data format
  18328. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18329. * @param invertY defines if data must be stored with Y axis inverted
  18330. * @param compression defines the compression used (null by default)
  18331. */
  18332. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18333. /**
  18334. * Update a raw cube texture
  18335. * @param texture defines the texture to udpdate
  18336. * @param data defines the data to store
  18337. * @param format defines the data format
  18338. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18339. * @param invertY defines if data must be stored with Y axis inverted
  18340. * @param compression defines the compression used (null by default)
  18341. * @param level defines which level of the texture to update
  18342. */
  18343. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18344. /**
  18345. * Creates a new raw cube texture from a specified url
  18346. * @param url defines the url where the data is located
  18347. * @param scene defines the current scene
  18348. * @param size defines the size of the textures
  18349. * @param format defines the format of the data
  18350. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18351. * @param noMipmap defines if the engine should avoid generating the mip levels
  18352. * @param callback defines a callback used to extract texture data from loaded data
  18353. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18354. * @param onLoad defines a callback called when texture is loaded
  18355. * @param onError defines a callback called if there is an error
  18356. * @returns the cube texture as an InternalTexture
  18357. */
  18358. 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>): InternalTexture;
  18359. /**
  18360. * Creates a new raw cube texture from a specified url
  18361. * @param url defines the url where the data is located
  18362. * @param scene defines the current scene
  18363. * @param size defines the size of the textures
  18364. * @param format defines the format of the data
  18365. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18366. * @param noMipmap defines if the engine should avoid generating the mip levels
  18367. * @param callback defines a callback used to extract texture data from loaded data
  18368. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18369. * @param onLoad defines a callback called when texture is loaded
  18370. * @param onError defines a callback called if there is an error
  18371. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18372. * @param invertY defines if data must be stored with Y axis inverted
  18373. * @returns the cube texture as an InternalTexture
  18374. */
  18375. 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;
  18376. /**
  18377. * Creates a new raw 3D texture
  18378. * @param data defines the data used to create the texture
  18379. * @param width defines the width of the texture
  18380. * @param height defines the height of the texture
  18381. * @param depth defines the depth of the texture
  18382. * @param format defines the format of the texture
  18383. * @param generateMipMaps defines if the engine must generate mip levels
  18384. * @param invertY defines if data must be stored with Y axis inverted
  18385. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18386. * @param compression defines the compressed used (can be null)
  18387. * @param textureType defines the compressed used (can be null)
  18388. * @returns a new raw 3D texture (stored in an InternalTexture)
  18389. */
  18390. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18391. /**
  18392. * Update a raw 3D texture
  18393. * @param texture defines the texture to update
  18394. * @param data defines the data to store
  18395. * @param format defines the data format
  18396. * @param invertY defines if data must be stored with Y axis inverted
  18397. */
  18398. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18399. /**
  18400. * Update a raw 3D texture
  18401. * @param texture defines the texture to update
  18402. * @param data defines the data to store
  18403. * @param format defines the data format
  18404. * @param invertY defines if data must be stored with Y axis inverted
  18405. * @param compression defines the used compression (can be null)
  18406. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18407. */
  18408. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18409. }
  18410. }
  18411. declare module BABYLON {
  18412. /**
  18413. * Raw texture can help creating a texture directly from an array of data.
  18414. * This can be super useful if you either get the data from an uncompressed source or
  18415. * if you wish to create your texture pixel by pixel.
  18416. */
  18417. export class RawTexture extends Texture {
  18418. /**
  18419. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18420. */
  18421. format: number;
  18422. private _engine;
  18423. /**
  18424. * Instantiates a new RawTexture.
  18425. * Raw texture can help creating a texture directly from an array of data.
  18426. * This can be super useful if you either get the data from an uncompressed source or
  18427. * if you wish to create your texture pixel by pixel.
  18428. * @param data define the array of data to use to create the texture
  18429. * @param width define the width of the texture
  18430. * @param height define the height of the texture
  18431. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18432. * @param scene define the scene the texture belongs to
  18433. * @param generateMipMaps define whether mip maps should be generated or not
  18434. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18435. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18436. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18437. */
  18438. constructor(data: ArrayBufferView, width: number, height: number,
  18439. /**
  18440. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18441. */
  18442. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18443. /**
  18444. * Updates the texture underlying data.
  18445. * @param data Define the new data of the texture
  18446. */
  18447. update(data: ArrayBufferView): void;
  18448. /**
  18449. * Creates a luminance texture from some data.
  18450. * @param data Define the texture data
  18451. * @param width Define the width of the texture
  18452. * @param height Define the height of the texture
  18453. * @param scene Define the scene the texture belongs to
  18454. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18455. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18456. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18457. * @returns the luminance texture
  18458. */
  18459. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18460. /**
  18461. * Creates a luminance alpha texture from some data.
  18462. * @param data Define the texture data
  18463. * @param width Define the width of the texture
  18464. * @param height Define the height of the texture
  18465. * @param scene Define the scene the texture belongs to
  18466. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18467. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18468. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18469. * @returns the luminance alpha texture
  18470. */
  18471. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18472. /**
  18473. * Creates an alpha texture from some data.
  18474. * @param data Define the texture data
  18475. * @param width Define the width of the texture
  18476. * @param height Define the height of the texture
  18477. * @param scene Define the scene the texture belongs to
  18478. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18479. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18480. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18481. * @returns the alpha texture
  18482. */
  18483. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18484. /**
  18485. * Creates a RGB texture from some data.
  18486. * @param data Define the texture data
  18487. * @param width Define the width of the texture
  18488. * @param height Define the height of the texture
  18489. * @param scene Define the scene the texture belongs to
  18490. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18491. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18492. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18493. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18494. * @returns the RGB alpha texture
  18495. */
  18496. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18497. /**
  18498. * Creates a RGBA texture from some data.
  18499. * @param data Define the texture data
  18500. * @param width Define the width of the texture
  18501. * @param height Define the height of the texture
  18502. * @param scene Define the scene the texture belongs to
  18503. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18504. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18505. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18506. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18507. * @returns the RGBA texture
  18508. */
  18509. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18510. /**
  18511. * Creates a R texture from some data.
  18512. * @param data Define the texture data
  18513. * @param width Define the width of the texture
  18514. * @param height Define the height of the texture
  18515. * @param scene Define the scene the texture belongs to
  18516. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18517. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18518. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18519. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18520. * @returns the R texture
  18521. */
  18522. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18523. }
  18524. }
  18525. declare module BABYLON {
  18526. /**
  18527. * Defines a runtime animation
  18528. */
  18529. export class RuntimeAnimation {
  18530. private _events;
  18531. /**
  18532. * The current frame of the runtime animation
  18533. */
  18534. private _currentFrame;
  18535. /**
  18536. * The animation used by the runtime animation
  18537. */
  18538. private _animation;
  18539. /**
  18540. * The target of the runtime animation
  18541. */
  18542. private _target;
  18543. /**
  18544. * The initiating animatable
  18545. */
  18546. private _host;
  18547. /**
  18548. * The original value of the runtime animation
  18549. */
  18550. private _originalValue;
  18551. /**
  18552. * The original blend value of the runtime animation
  18553. */
  18554. private _originalBlendValue;
  18555. /**
  18556. * The offsets cache of the runtime animation
  18557. */
  18558. private _offsetsCache;
  18559. /**
  18560. * The high limits cache of the runtime animation
  18561. */
  18562. private _highLimitsCache;
  18563. /**
  18564. * Specifies if the runtime animation has been stopped
  18565. */
  18566. private _stopped;
  18567. /**
  18568. * The blending factor of the runtime animation
  18569. */
  18570. private _blendingFactor;
  18571. /**
  18572. * The BabylonJS scene
  18573. */
  18574. private _scene;
  18575. /**
  18576. * The current value of the runtime animation
  18577. */
  18578. private _currentValue;
  18579. /** @hidden */
  18580. _animationState: _IAnimationState;
  18581. /**
  18582. * The active target of the runtime animation
  18583. */
  18584. private _activeTargets;
  18585. private _currentActiveTarget;
  18586. private _directTarget;
  18587. /**
  18588. * The target path of the runtime animation
  18589. */
  18590. private _targetPath;
  18591. /**
  18592. * The weight of the runtime animation
  18593. */
  18594. private _weight;
  18595. /**
  18596. * The ratio offset of the runtime animation
  18597. */
  18598. private _ratioOffset;
  18599. /**
  18600. * The previous delay of the runtime animation
  18601. */
  18602. private _previousDelay;
  18603. /**
  18604. * The previous ratio of the runtime animation
  18605. */
  18606. private _previousRatio;
  18607. private _enableBlending;
  18608. private _keys;
  18609. private _minFrame;
  18610. private _maxFrame;
  18611. private _minValue;
  18612. private _maxValue;
  18613. private _targetIsArray;
  18614. /**
  18615. * Gets the current frame of the runtime animation
  18616. */
  18617. readonly currentFrame: number;
  18618. /**
  18619. * Gets the weight of the runtime animation
  18620. */
  18621. readonly weight: number;
  18622. /**
  18623. * Gets the current value of the runtime animation
  18624. */
  18625. readonly currentValue: any;
  18626. /**
  18627. * Gets the target path of the runtime animation
  18628. */
  18629. readonly targetPath: string;
  18630. /**
  18631. * Gets the actual target of the runtime animation
  18632. */
  18633. readonly target: any;
  18634. /** @hidden */
  18635. _onLoop: () => void;
  18636. /**
  18637. * Create a new RuntimeAnimation object
  18638. * @param target defines the target of the animation
  18639. * @param animation defines the source animation object
  18640. * @param scene defines the hosting scene
  18641. * @param host defines the initiating Animatable
  18642. */
  18643. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18644. private _preparePath;
  18645. /**
  18646. * Gets the animation from the runtime animation
  18647. */
  18648. readonly animation: Animation;
  18649. /**
  18650. * Resets the runtime animation to the beginning
  18651. * @param restoreOriginal defines whether to restore the target property to the original value
  18652. */
  18653. reset(restoreOriginal?: boolean): void;
  18654. /**
  18655. * Specifies if the runtime animation is stopped
  18656. * @returns Boolean specifying if the runtime animation is stopped
  18657. */
  18658. isStopped(): boolean;
  18659. /**
  18660. * Disposes of the runtime animation
  18661. */
  18662. dispose(): void;
  18663. /**
  18664. * Apply the interpolated value to the target
  18665. * @param currentValue defines the value computed by the animation
  18666. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18667. */
  18668. setValue(currentValue: any, weight: number): void;
  18669. private _getOriginalValues;
  18670. private _setValue;
  18671. /**
  18672. * Gets the loop pmode of the runtime animation
  18673. * @returns Loop Mode
  18674. */
  18675. private _getCorrectLoopMode;
  18676. /**
  18677. * Move the current animation to a given frame
  18678. * @param frame defines the frame to move to
  18679. */
  18680. goToFrame(frame: number): void;
  18681. /**
  18682. * @hidden Internal use only
  18683. */
  18684. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18685. /**
  18686. * Execute the current animation
  18687. * @param delay defines the delay to add to the current frame
  18688. * @param from defines the lower bound of the animation range
  18689. * @param to defines the upper bound of the animation range
  18690. * @param loop defines if the current animation must loop
  18691. * @param speedRatio defines the current speed ratio
  18692. * @param weight defines the weight of the animation (default is -1 so no weight)
  18693. * @param onLoop optional callback called when animation loops
  18694. * @returns a boolean indicating if the animation is running
  18695. */
  18696. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18697. }
  18698. }
  18699. declare module BABYLON {
  18700. /**
  18701. * Class used to store an actual running animation
  18702. */
  18703. export class Animatable {
  18704. /** defines the target object */
  18705. target: any;
  18706. /** defines the starting frame number (default is 0) */
  18707. fromFrame: number;
  18708. /** defines the ending frame number (default is 100) */
  18709. toFrame: number;
  18710. /** defines if the animation must loop (default is false) */
  18711. loopAnimation: boolean;
  18712. /** defines a callback to call when animation ends if it is not looping */
  18713. onAnimationEnd?: (() => void) | null | undefined;
  18714. /** defines a callback to call when animation loops */
  18715. onAnimationLoop?: (() => void) | null | undefined;
  18716. private _localDelayOffset;
  18717. private _pausedDelay;
  18718. private _runtimeAnimations;
  18719. private _paused;
  18720. private _scene;
  18721. private _speedRatio;
  18722. private _weight;
  18723. private _syncRoot;
  18724. /**
  18725. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18726. * This will only apply for non looping animation (default is true)
  18727. */
  18728. disposeOnEnd: boolean;
  18729. /**
  18730. * Gets a boolean indicating if the animation has started
  18731. */
  18732. animationStarted: boolean;
  18733. /**
  18734. * Observer raised when the animation ends
  18735. */
  18736. onAnimationEndObservable: Observable<Animatable>;
  18737. /**
  18738. * Observer raised when the animation loops
  18739. */
  18740. onAnimationLoopObservable: Observable<Animatable>;
  18741. /**
  18742. * Gets the root Animatable used to synchronize and normalize animations
  18743. */
  18744. readonly syncRoot: Nullable<Animatable>;
  18745. /**
  18746. * Gets the current frame of the first RuntimeAnimation
  18747. * Used to synchronize Animatables
  18748. */
  18749. readonly masterFrame: number;
  18750. /**
  18751. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18752. */
  18753. weight: number;
  18754. /**
  18755. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18756. */
  18757. speedRatio: number;
  18758. /**
  18759. * Creates a new Animatable
  18760. * @param scene defines the hosting scene
  18761. * @param target defines the target object
  18762. * @param fromFrame defines the starting frame number (default is 0)
  18763. * @param toFrame defines the ending frame number (default is 100)
  18764. * @param loopAnimation defines if the animation must loop (default is false)
  18765. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18766. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18767. * @param animations defines a group of animation to add to the new Animatable
  18768. * @param onAnimationLoop defines a callback to call when animation loops
  18769. */
  18770. constructor(scene: Scene,
  18771. /** defines the target object */
  18772. target: any,
  18773. /** defines the starting frame number (default is 0) */
  18774. fromFrame?: number,
  18775. /** defines the ending frame number (default is 100) */
  18776. toFrame?: number,
  18777. /** defines if the animation must loop (default is false) */
  18778. loopAnimation?: boolean, speedRatio?: number,
  18779. /** defines a callback to call when animation ends if it is not looping */
  18780. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18781. /** defines a callback to call when animation loops */
  18782. onAnimationLoop?: (() => void) | null | undefined);
  18783. /**
  18784. * Synchronize and normalize current Animatable with a source Animatable
  18785. * This is useful when using animation weights and when animations are not of the same length
  18786. * @param root defines the root Animatable to synchronize with
  18787. * @returns the current Animatable
  18788. */
  18789. syncWith(root: Animatable): Animatable;
  18790. /**
  18791. * Gets the list of runtime animations
  18792. * @returns an array of RuntimeAnimation
  18793. */
  18794. getAnimations(): RuntimeAnimation[];
  18795. /**
  18796. * Adds more animations to the current animatable
  18797. * @param target defines the target of the animations
  18798. * @param animations defines the new animations to add
  18799. */
  18800. appendAnimations(target: any, animations: Animation[]): void;
  18801. /**
  18802. * Gets the source animation for a specific property
  18803. * @param property defines the propertyu to look for
  18804. * @returns null or the source animation for the given property
  18805. */
  18806. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18807. /**
  18808. * Gets the runtime animation for a specific property
  18809. * @param property defines the propertyu to look for
  18810. * @returns null or the runtime animation for the given property
  18811. */
  18812. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18813. /**
  18814. * Resets the animatable to its original state
  18815. */
  18816. reset(): void;
  18817. /**
  18818. * Allows the animatable to blend with current running animations
  18819. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18820. * @param blendingSpeed defines the blending speed to use
  18821. */
  18822. enableBlending(blendingSpeed: number): void;
  18823. /**
  18824. * Disable animation blending
  18825. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18826. */
  18827. disableBlending(): void;
  18828. /**
  18829. * Jump directly to a given frame
  18830. * @param frame defines the frame to jump to
  18831. */
  18832. goToFrame(frame: number): void;
  18833. /**
  18834. * Pause the animation
  18835. */
  18836. pause(): void;
  18837. /**
  18838. * Restart the animation
  18839. */
  18840. restart(): void;
  18841. private _raiseOnAnimationEnd;
  18842. /**
  18843. * Stop and delete the current animation
  18844. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18845. * @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)
  18846. */
  18847. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18848. /**
  18849. * Wait asynchronously for the animation to end
  18850. * @returns a promise which will be fullfilled when the animation ends
  18851. */
  18852. waitAsync(): Promise<Animatable>;
  18853. /** @hidden */
  18854. _animate(delay: number): boolean;
  18855. }
  18856. interface Scene {
  18857. /** @hidden */
  18858. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18859. /** @hidden */
  18860. _processLateAnimationBindingsForMatrices(holder: {
  18861. totalWeight: number;
  18862. animations: RuntimeAnimation[];
  18863. originalValue: Matrix;
  18864. }): any;
  18865. /** @hidden */
  18866. _processLateAnimationBindingsForQuaternions(holder: {
  18867. totalWeight: number;
  18868. animations: RuntimeAnimation[];
  18869. originalValue: Quaternion;
  18870. }, refQuaternion: Quaternion): Quaternion;
  18871. /** @hidden */
  18872. _processLateAnimationBindings(): void;
  18873. /**
  18874. * Will start the animation sequence of a given target
  18875. * @param target defines the target
  18876. * @param from defines from which frame should animation start
  18877. * @param to defines until which frame should animation run.
  18878. * @param weight defines the weight to apply to the animation (1.0 by default)
  18879. * @param loop defines if the animation loops
  18880. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18881. * @param onAnimationEnd defines the function to be executed when the animation ends
  18882. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18883. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18884. * @param onAnimationLoop defines the callback to call when an animation loops
  18885. * @returns the animatable object created for this animation
  18886. */
  18887. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18888. /**
  18889. * Will start the animation sequence of a given target
  18890. * @param target defines the target
  18891. * @param from defines from which frame should animation start
  18892. * @param to defines until which frame should animation run.
  18893. * @param loop defines if the animation loops
  18894. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18895. * @param onAnimationEnd defines the function to be executed when the animation ends
  18896. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18897. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18898. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18899. * @param onAnimationLoop defines the callback to call when an animation loops
  18900. * @returns the animatable object created for this animation
  18901. */
  18902. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18903. /**
  18904. * Will start the animation sequence of a given target and its hierarchy
  18905. * @param target defines the target
  18906. * @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.
  18907. * @param from defines from which frame should animation start
  18908. * @param to defines until which frame should animation run.
  18909. * @param loop defines if the animation loops
  18910. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18911. * @param onAnimationEnd defines the function to be executed when the animation ends
  18912. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18913. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18914. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18915. * @param onAnimationLoop defines the callback to call when an animation loops
  18916. * @returns the list of created animatables
  18917. */
  18918. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  18919. /**
  18920. * Begin a new animation on a given node
  18921. * @param target defines the target where the animation will take place
  18922. * @param animations defines the list of animations to start
  18923. * @param from defines the initial value
  18924. * @param to defines the final value
  18925. * @param loop defines if you want animation to loop (off by default)
  18926. * @param speedRatio defines the speed ratio to apply to all animations
  18927. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18928. * @param onAnimationLoop defines the callback to call when an animation loops
  18929. * @returns the list of created animatables
  18930. */
  18931. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18932. /**
  18933. * Begin a new animation on a given node and its hierarchy
  18934. * @param target defines the root node where the animation will take place
  18935. * @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.
  18936. * @param animations defines the list of animations to start
  18937. * @param from defines the initial value
  18938. * @param to defines the final value
  18939. * @param loop defines if you want animation to loop (off by default)
  18940. * @param speedRatio defines the speed ratio to apply to all animations
  18941. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18942. * @param onAnimationLoop defines the callback to call when an animation loops
  18943. * @returns the list of animatables created for all nodes
  18944. */
  18945. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18946. /**
  18947. * Gets the animatable associated with a specific target
  18948. * @param target defines the target of the animatable
  18949. * @returns the required animatable if found
  18950. */
  18951. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18952. /**
  18953. * Gets all animatables associated with a given target
  18954. * @param target defines the target to look animatables for
  18955. * @returns an array of Animatables
  18956. */
  18957. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18958. /**
  18959. * Stops and removes all animations that have been applied to the scene
  18960. */
  18961. stopAllAnimations(): void;
  18962. }
  18963. interface Bone {
  18964. /**
  18965. * Copy an animation range from another bone
  18966. * @param source defines the source bone
  18967. * @param rangeName defines the range name to copy
  18968. * @param frameOffset defines the frame offset
  18969. * @param rescaleAsRequired defines if rescaling must be applied if required
  18970. * @param skelDimensionsRatio defines the scaling ratio
  18971. * @returns true if operation was successful
  18972. */
  18973. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18974. }
  18975. }
  18976. declare module BABYLON {
  18977. /**
  18978. * Class used to handle skinning animations
  18979. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18980. */
  18981. export class Skeleton implements IAnimatable {
  18982. /** defines the skeleton name */
  18983. name: string;
  18984. /** defines the skeleton Id */
  18985. id: string;
  18986. /**
  18987. * Defines the list of child bones
  18988. */
  18989. bones: Bone[];
  18990. /**
  18991. * Defines an estimate of the dimension of the skeleton at rest
  18992. */
  18993. dimensionsAtRest: Vector3;
  18994. /**
  18995. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18996. */
  18997. needInitialSkinMatrix: boolean;
  18998. /**
  18999. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19000. */
  19001. overrideMesh: Nullable<AbstractMesh>;
  19002. /**
  19003. * Gets the list of animations attached to this skeleton
  19004. */
  19005. animations: Array<Animation>;
  19006. private _scene;
  19007. private _isDirty;
  19008. private _transformMatrices;
  19009. private _transformMatrixTexture;
  19010. private _meshesWithPoseMatrix;
  19011. private _animatables;
  19012. private _identity;
  19013. private _synchronizedWithMesh;
  19014. private _ranges;
  19015. private _lastAbsoluteTransformsUpdateId;
  19016. private _canUseTextureForBones;
  19017. private _uniqueId;
  19018. /** @hidden */
  19019. _numBonesWithLinkedTransformNode: number;
  19020. /** @hidden */
  19021. _hasWaitingData: Nullable<boolean>;
  19022. /**
  19023. * Specifies if the skeleton should be serialized
  19024. */
  19025. doNotSerialize: boolean;
  19026. private _useTextureToStoreBoneMatrices;
  19027. /**
  19028. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19029. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19030. */
  19031. useTextureToStoreBoneMatrices: boolean;
  19032. private _animationPropertiesOverride;
  19033. /**
  19034. * Gets or sets the animation properties override
  19035. */
  19036. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19037. /**
  19038. * List of inspectable custom properties (used by the Inspector)
  19039. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19040. */
  19041. inspectableCustomProperties: IInspectable[];
  19042. /**
  19043. * An observable triggered before computing the skeleton's matrices
  19044. */
  19045. onBeforeComputeObservable: Observable<Skeleton>;
  19046. /**
  19047. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19048. */
  19049. readonly isUsingTextureForMatrices: boolean;
  19050. /**
  19051. * Gets the unique ID of this skeleton
  19052. */
  19053. readonly uniqueId: number;
  19054. /**
  19055. * Creates a new skeleton
  19056. * @param name defines the skeleton name
  19057. * @param id defines the skeleton Id
  19058. * @param scene defines the hosting scene
  19059. */
  19060. constructor(
  19061. /** defines the skeleton name */
  19062. name: string,
  19063. /** defines the skeleton Id */
  19064. id: string, scene: Scene);
  19065. /**
  19066. * Gets the current object class name.
  19067. * @return the class name
  19068. */
  19069. getClassName(): string;
  19070. /**
  19071. * Returns an array containing the root bones
  19072. * @returns an array containing the root bones
  19073. */
  19074. getChildren(): Array<Bone>;
  19075. /**
  19076. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19077. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19078. * @returns a Float32Array containing matrices data
  19079. */
  19080. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19081. /**
  19082. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19083. * @returns a raw texture containing the data
  19084. */
  19085. getTransformMatrixTexture(): Nullable<RawTexture>;
  19086. /**
  19087. * Gets the current hosting scene
  19088. * @returns a scene object
  19089. */
  19090. getScene(): Scene;
  19091. /**
  19092. * Gets a string representing the current skeleton data
  19093. * @param fullDetails defines a boolean indicating if we want a verbose version
  19094. * @returns a string representing the current skeleton data
  19095. */
  19096. toString(fullDetails?: boolean): string;
  19097. /**
  19098. * Get bone's index searching by name
  19099. * @param name defines bone's name to search for
  19100. * @return the indice of the bone. Returns -1 if not found
  19101. */
  19102. getBoneIndexByName(name: string): number;
  19103. /**
  19104. * Creater a new animation range
  19105. * @param name defines the name of the range
  19106. * @param from defines the start key
  19107. * @param to defines the end key
  19108. */
  19109. createAnimationRange(name: string, from: number, to: number): void;
  19110. /**
  19111. * Delete a specific animation range
  19112. * @param name defines the name of the range
  19113. * @param deleteFrames defines if frames must be removed as well
  19114. */
  19115. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19116. /**
  19117. * Gets a specific animation range
  19118. * @param name defines the name of the range to look for
  19119. * @returns the requested animation range or null if not found
  19120. */
  19121. getAnimationRange(name: string): Nullable<AnimationRange>;
  19122. /**
  19123. * Gets the list of all animation ranges defined on this skeleton
  19124. * @returns an array
  19125. */
  19126. getAnimationRanges(): Nullable<AnimationRange>[];
  19127. /**
  19128. * Copy animation range from a source skeleton.
  19129. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19130. * @param source defines the source skeleton
  19131. * @param name defines the name of the range to copy
  19132. * @param rescaleAsRequired defines if rescaling must be applied if required
  19133. * @returns true if operation was successful
  19134. */
  19135. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19136. /**
  19137. * Forces the skeleton to go to rest pose
  19138. */
  19139. returnToRest(): void;
  19140. private _getHighestAnimationFrame;
  19141. /**
  19142. * Begin a specific animation range
  19143. * @param name defines the name of the range to start
  19144. * @param loop defines if looping must be turned on (false by default)
  19145. * @param speedRatio defines the speed ratio to apply (1 by default)
  19146. * @param onAnimationEnd defines a callback which will be called when animation will end
  19147. * @returns a new animatable
  19148. */
  19149. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19150. /** @hidden */
  19151. _markAsDirty(): void;
  19152. /** @hidden */
  19153. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19154. /** @hidden */
  19155. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19156. private _computeTransformMatrices;
  19157. /**
  19158. * Build all resources required to render a skeleton
  19159. */
  19160. prepare(): void;
  19161. /**
  19162. * Gets the list of animatables currently running for this skeleton
  19163. * @returns an array of animatables
  19164. */
  19165. getAnimatables(): IAnimatable[];
  19166. /**
  19167. * Clone the current skeleton
  19168. * @param name defines the name of the new skeleton
  19169. * @param id defines the id of the new skeleton
  19170. * @returns the new skeleton
  19171. */
  19172. clone(name: string, id: string): Skeleton;
  19173. /**
  19174. * Enable animation blending for this skeleton
  19175. * @param blendingSpeed defines the blending speed to apply
  19176. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19177. */
  19178. enableBlending(blendingSpeed?: number): void;
  19179. /**
  19180. * Releases all resources associated with the current skeleton
  19181. */
  19182. dispose(): void;
  19183. /**
  19184. * Serialize the skeleton in a JSON object
  19185. * @returns a JSON object
  19186. */
  19187. serialize(): any;
  19188. /**
  19189. * Creates a new skeleton from serialized data
  19190. * @param parsedSkeleton defines the serialized data
  19191. * @param scene defines the hosting scene
  19192. * @returns a new skeleton
  19193. */
  19194. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19195. /**
  19196. * Compute all node absolute transforms
  19197. * @param forceUpdate defines if computation must be done even if cache is up to date
  19198. */
  19199. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19200. /**
  19201. * Gets the root pose matrix
  19202. * @returns a matrix
  19203. */
  19204. getPoseMatrix(): Nullable<Matrix>;
  19205. /**
  19206. * Sorts bones per internal index
  19207. */
  19208. sortBones(): void;
  19209. private _sortBones;
  19210. }
  19211. }
  19212. declare module BABYLON {
  19213. /**
  19214. * Defines a target to use with MorphTargetManager
  19215. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19216. */
  19217. export class MorphTarget implements IAnimatable {
  19218. /** defines the name of the target */
  19219. name: string;
  19220. /**
  19221. * Gets or sets the list of animations
  19222. */
  19223. animations: Animation[];
  19224. private _scene;
  19225. private _positions;
  19226. private _normals;
  19227. private _tangents;
  19228. private _influence;
  19229. /**
  19230. * Observable raised when the influence changes
  19231. */
  19232. onInfluenceChanged: Observable<boolean>;
  19233. /** @hidden */
  19234. _onDataLayoutChanged: Observable<void>;
  19235. /**
  19236. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19237. */
  19238. influence: number;
  19239. /**
  19240. * Gets or sets the id of the morph Target
  19241. */
  19242. id: string;
  19243. private _animationPropertiesOverride;
  19244. /**
  19245. * Gets or sets the animation properties override
  19246. */
  19247. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19248. /**
  19249. * Creates a new MorphTarget
  19250. * @param name defines the name of the target
  19251. * @param influence defines the influence to use
  19252. * @param scene defines the scene the morphtarget belongs to
  19253. */
  19254. constructor(
  19255. /** defines the name of the target */
  19256. name: string, influence?: number, scene?: Nullable<Scene>);
  19257. /**
  19258. * Gets a boolean defining if the target contains position data
  19259. */
  19260. readonly hasPositions: boolean;
  19261. /**
  19262. * Gets a boolean defining if the target contains normal data
  19263. */
  19264. readonly hasNormals: boolean;
  19265. /**
  19266. * Gets a boolean defining if the target contains tangent data
  19267. */
  19268. readonly hasTangents: boolean;
  19269. /**
  19270. * Affects position data to this target
  19271. * @param data defines the position data to use
  19272. */
  19273. setPositions(data: Nullable<FloatArray>): void;
  19274. /**
  19275. * Gets the position data stored in this target
  19276. * @returns a FloatArray containing the position data (or null if not present)
  19277. */
  19278. getPositions(): Nullable<FloatArray>;
  19279. /**
  19280. * Affects normal data to this target
  19281. * @param data defines the normal data to use
  19282. */
  19283. setNormals(data: Nullable<FloatArray>): void;
  19284. /**
  19285. * Gets the normal data stored in this target
  19286. * @returns a FloatArray containing the normal data (or null if not present)
  19287. */
  19288. getNormals(): Nullable<FloatArray>;
  19289. /**
  19290. * Affects tangent data to this target
  19291. * @param data defines the tangent data to use
  19292. */
  19293. setTangents(data: Nullable<FloatArray>): void;
  19294. /**
  19295. * Gets the tangent data stored in this target
  19296. * @returns a FloatArray containing the tangent data (or null if not present)
  19297. */
  19298. getTangents(): Nullable<FloatArray>;
  19299. /**
  19300. * Serializes the current target into a Serialization object
  19301. * @returns the serialized object
  19302. */
  19303. serialize(): any;
  19304. /**
  19305. * Returns the string "MorphTarget"
  19306. * @returns "MorphTarget"
  19307. */
  19308. getClassName(): string;
  19309. /**
  19310. * Creates a new target from serialized data
  19311. * @param serializationObject defines the serialized data to use
  19312. * @returns a new MorphTarget
  19313. */
  19314. static Parse(serializationObject: any): MorphTarget;
  19315. /**
  19316. * Creates a MorphTarget from mesh data
  19317. * @param mesh defines the source mesh
  19318. * @param name defines the name to use for the new target
  19319. * @param influence defines the influence to attach to the target
  19320. * @returns a new MorphTarget
  19321. */
  19322. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19323. }
  19324. }
  19325. declare module BABYLON {
  19326. /**
  19327. * This class is used to deform meshes using morphing between different targets
  19328. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19329. */
  19330. export class MorphTargetManager {
  19331. private _targets;
  19332. private _targetInfluenceChangedObservers;
  19333. private _targetDataLayoutChangedObservers;
  19334. private _activeTargets;
  19335. private _scene;
  19336. private _influences;
  19337. private _supportsNormals;
  19338. private _supportsTangents;
  19339. private _vertexCount;
  19340. private _uniqueId;
  19341. private _tempInfluences;
  19342. /**
  19343. * Creates a new MorphTargetManager
  19344. * @param scene defines the current scene
  19345. */
  19346. constructor(scene?: Nullable<Scene>);
  19347. /**
  19348. * Gets the unique ID of this manager
  19349. */
  19350. readonly uniqueId: number;
  19351. /**
  19352. * Gets the number of vertices handled by this manager
  19353. */
  19354. readonly vertexCount: number;
  19355. /**
  19356. * Gets a boolean indicating if this manager supports morphing of normals
  19357. */
  19358. readonly supportsNormals: boolean;
  19359. /**
  19360. * Gets a boolean indicating if this manager supports morphing of tangents
  19361. */
  19362. readonly supportsTangents: boolean;
  19363. /**
  19364. * Gets the number of targets stored in this manager
  19365. */
  19366. readonly numTargets: number;
  19367. /**
  19368. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19369. */
  19370. readonly numInfluencers: number;
  19371. /**
  19372. * Gets the list of influences (one per target)
  19373. */
  19374. readonly influences: Float32Array;
  19375. /**
  19376. * Gets the active target at specified index. An active target is a target with an influence > 0
  19377. * @param index defines the index to check
  19378. * @returns the requested target
  19379. */
  19380. getActiveTarget(index: number): MorphTarget;
  19381. /**
  19382. * Gets the target at specified index
  19383. * @param index defines the index to check
  19384. * @returns the requested target
  19385. */
  19386. getTarget(index: number): MorphTarget;
  19387. /**
  19388. * Add a new target to this manager
  19389. * @param target defines the target to add
  19390. */
  19391. addTarget(target: MorphTarget): void;
  19392. /**
  19393. * Removes a target from the manager
  19394. * @param target defines the target to remove
  19395. */
  19396. removeTarget(target: MorphTarget): void;
  19397. /**
  19398. * Serializes the current manager into a Serialization object
  19399. * @returns the serialized object
  19400. */
  19401. serialize(): any;
  19402. private _syncActiveTargets;
  19403. /**
  19404. * Syncrhonize the targets with all the meshes using this morph target manager
  19405. */
  19406. synchronize(): void;
  19407. /**
  19408. * Creates a new MorphTargetManager from serialized data
  19409. * @param serializationObject defines the serialized data
  19410. * @param scene defines the hosting scene
  19411. * @returns the new MorphTargetManager
  19412. */
  19413. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19414. }
  19415. }
  19416. declare module BABYLON {
  19417. /**
  19418. * Class used to represent a specific level of detail of a mesh
  19419. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19420. */
  19421. export class MeshLODLevel {
  19422. /** Defines the distance where this level should star being displayed */
  19423. distance: number;
  19424. /** Defines the mesh to use to render this level */
  19425. mesh: Nullable<Mesh>;
  19426. /**
  19427. * Creates a new LOD level
  19428. * @param distance defines the distance where this level should star being displayed
  19429. * @param mesh defines the mesh to use to render this level
  19430. */
  19431. constructor(
  19432. /** Defines the distance where this level should star being displayed */
  19433. distance: number,
  19434. /** Defines the mesh to use to render this level */
  19435. mesh: Nullable<Mesh>);
  19436. }
  19437. }
  19438. declare module BABYLON {
  19439. /**
  19440. * Mesh representing the gorund
  19441. */
  19442. export class GroundMesh extends Mesh {
  19443. /** If octree should be generated */
  19444. generateOctree: boolean;
  19445. private _heightQuads;
  19446. /** @hidden */
  19447. _subdivisionsX: number;
  19448. /** @hidden */
  19449. _subdivisionsY: number;
  19450. /** @hidden */
  19451. _width: number;
  19452. /** @hidden */
  19453. _height: number;
  19454. /** @hidden */
  19455. _minX: number;
  19456. /** @hidden */
  19457. _maxX: number;
  19458. /** @hidden */
  19459. _minZ: number;
  19460. /** @hidden */
  19461. _maxZ: number;
  19462. constructor(name: string, scene: Scene);
  19463. /**
  19464. * "GroundMesh"
  19465. * @returns "GroundMesh"
  19466. */
  19467. getClassName(): string;
  19468. /**
  19469. * The minimum of x and y subdivisions
  19470. */
  19471. readonly subdivisions: number;
  19472. /**
  19473. * X subdivisions
  19474. */
  19475. readonly subdivisionsX: number;
  19476. /**
  19477. * Y subdivisions
  19478. */
  19479. readonly subdivisionsY: number;
  19480. /**
  19481. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19482. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19483. * @param chunksCount the number of subdivisions for x and y
  19484. * @param octreeBlocksSize (Default: 32)
  19485. */
  19486. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19487. /**
  19488. * Returns a height (y) value in the Worl system :
  19489. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19490. * @param x x coordinate
  19491. * @param z z coordinate
  19492. * @returns the ground y position if (x, z) are outside the ground surface.
  19493. */
  19494. getHeightAtCoordinates(x: number, z: number): number;
  19495. /**
  19496. * Returns a normalized vector (Vector3) orthogonal to the ground
  19497. * at the ground coordinates (x, z) expressed in the World system.
  19498. * @param x x coordinate
  19499. * @param z z coordinate
  19500. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19501. */
  19502. getNormalAtCoordinates(x: number, z: number): Vector3;
  19503. /**
  19504. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19505. * at the ground coordinates (x, z) expressed in the World system.
  19506. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19507. * @param x x coordinate
  19508. * @param z z coordinate
  19509. * @param ref vector to store the result
  19510. * @returns the GroundMesh.
  19511. */
  19512. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19513. /**
  19514. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19515. * if the ground has been updated.
  19516. * This can be used in the render loop.
  19517. * @returns the GroundMesh.
  19518. */
  19519. updateCoordinateHeights(): GroundMesh;
  19520. private _getFacetAt;
  19521. private _initHeightQuads;
  19522. private _computeHeightQuads;
  19523. /**
  19524. * Serializes this ground mesh
  19525. * @param serializationObject object to write serialization to
  19526. */
  19527. serialize(serializationObject: any): void;
  19528. /**
  19529. * Parses a serialized ground mesh
  19530. * @param parsedMesh the serialized mesh
  19531. * @param scene the scene to create the ground mesh in
  19532. * @returns the created ground mesh
  19533. */
  19534. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19535. }
  19536. }
  19537. declare module BABYLON {
  19538. /**
  19539. * Interface for Physics-Joint data
  19540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19541. */
  19542. export interface PhysicsJointData {
  19543. /**
  19544. * The main pivot of the joint
  19545. */
  19546. mainPivot?: Vector3;
  19547. /**
  19548. * The connected pivot of the joint
  19549. */
  19550. connectedPivot?: Vector3;
  19551. /**
  19552. * The main axis of the joint
  19553. */
  19554. mainAxis?: Vector3;
  19555. /**
  19556. * The connected axis of the joint
  19557. */
  19558. connectedAxis?: Vector3;
  19559. /**
  19560. * The collision of the joint
  19561. */
  19562. collision?: boolean;
  19563. /**
  19564. * Native Oimo/Cannon/Energy data
  19565. */
  19566. nativeParams?: any;
  19567. }
  19568. /**
  19569. * This is a holder class for the physics joint created by the physics plugin
  19570. * It holds a set of functions to control the underlying joint
  19571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19572. */
  19573. export class PhysicsJoint {
  19574. /**
  19575. * The type of the physics joint
  19576. */
  19577. type: number;
  19578. /**
  19579. * The data for the physics joint
  19580. */
  19581. jointData: PhysicsJointData;
  19582. private _physicsJoint;
  19583. protected _physicsPlugin: IPhysicsEnginePlugin;
  19584. /**
  19585. * Initializes the physics joint
  19586. * @param type The type of the physics joint
  19587. * @param jointData The data for the physics joint
  19588. */
  19589. constructor(
  19590. /**
  19591. * The type of the physics joint
  19592. */
  19593. type: number,
  19594. /**
  19595. * The data for the physics joint
  19596. */
  19597. jointData: PhysicsJointData);
  19598. /**
  19599. * Gets the physics joint
  19600. */
  19601. /**
  19602. * Sets the physics joint
  19603. */
  19604. physicsJoint: any;
  19605. /**
  19606. * Sets the physics plugin
  19607. */
  19608. physicsPlugin: IPhysicsEnginePlugin;
  19609. /**
  19610. * Execute a function that is physics-plugin specific.
  19611. * @param {Function} func the function that will be executed.
  19612. * It accepts two parameters: the physics world and the physics joint
  19613. */
  19614. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19615. /**
  19616. * Distance-Joint type
  19617. */
  19618. static DistanceJoint: number;
  19619. /**
  19620. * Hinge-Joint type
  19621. */
  19622. static HingeJoint: number;
  19623. /**
  19624. * Ball-and-Socket joint type
  19625. */
  19626. static BallAndSocketJoint: number;
  19627. /**
  19628. * Wheel-Joint type
  19629. */
  19630. static WheelJoint: number;
  19631. /**
  19632. * Slider-Joint type
  19633. */
  19634. static SliderJoint: number;
  19635. /**
  19636. * Prismatic-Joint type
  19637. */
  19638. static PrismaticJoint: number;
  19639. /**
  19640. * Universal-Joint type
  19641. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19642. */
  19643. static UniversalJoint: number;
  19644. /**
  19645. * Hinge-Joint 2 type
  19646. */
  19647. static Hinge2Joint: number;
  19648. /**
  19649. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19650. */
  19651. static PointToPointJoint: number;
  19652. /**
  19653. * Spring-Joint type
  19654. */
  19655. static SpringJoint: number;
  19656. /**
  19657. * Lock-Joint type
  19658. */
  19659. static LockJoint: number;
  19660. }
  19661. /**
  19662. * A class representing a physics distance joint
  19663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19664. */
  19665. export class DistanceJoint extends PhysicsJoint {
  19666. /**
  19667. *
  19668. * @param jointData The data for the Distance-Joint
  19669. */
  19670. constructor(jointData: DistanceJointData);
  19671. /**
  19672. * Update the predefined distance.
  19673. * @param maxDistance The maximum preferred distance
  19674. * @param minDistance The minimum preferred distance
  19675. */
  19676. updateDistance(maxDistance: number, minDistance?: number): void;
  19677. }
  19678. /**
  19679. * Represents a Motor-Enabled Joint
  19680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19681. */
  19682. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19683. /**
  19684. * Initializes the Motor-Enabled Joint
  19685. * @param type The type of the joint
  19686. * @param jointData The physica joint data for the joint
  19687. */
  19688. constructor(type: number, jointData: PhysicsJointData);
  19689. /**
  19690. * Set the motor values.
  19691. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19692. * @param force the force to apply
  19693. * @param maxForce max force for this motor.
  19694. */
  19695. setMotor(force?: number, maxForce?: number): void;
  19696. /**
  19697. * Set the motor's limits.
  19698. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19699. * @param upperLimit The upper limit of the motor
  19700. * @param lowerLimit The lower limit of the motor
  19701. */
  19702. setLimit(upperLimit: number, lowerLimit?: number): void;
  19703. }
  19704. /**
  19705. * This class represents a single physics Hinge-Joint
  19706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19707. */
  19708. export class HingeJoint extends MotorEnabledJoint {
  19709. /**
  19710. * Initializes the Hinge-Joint
  19711. * @param jointData The joint data for the Hinge-Joint
  19712. */
  19713. constructor(jointData: PhysicsJointData);
  19714. /**
  19715. * Set the motor values.
  19716. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19717. * @param {number} force the force to apply
  19718. * @param {number} maxForce max force for this motor.
  19719. */
  19720. setMotor(force?: number, maxForce?: number): void;
  19721. /**
  19722. * Set the motor's limits.
  19723. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19724. * @param upperLimit The upper limit of the motor
  19725. * @param lowerLimit The lower limit of the motor
  19726. */
  19727. setLimit(upperLimit: number, lowerLimit?: number): void;
  19728. }
  19729. /**
  19730. * This class represents a dual hinge physics joint (same as wheel joint)
  19731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19732. */
  19733. export class Hinge2Joint extends MotorEnabledJoint {
  19734. /**
  19735. * Initializes the Hinge2-Joint
  19736. * @param jointData The joint data for the Hinge2-Joint
  19737. */
  19738. constructor(jointData: PhysicsJointData);
  19739. /**
  19740. * Set the motor values.
  19741. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19742. * @param {number} targetSpeed the speed the motor is to reach
  19743. * @param {number} maxForce max force for this motor.
  19744. * @param {motorIndex} the motor's index, 0 or 1.
  19745. */
  19746. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19747. /**
  19748. * Set the motor limits.
  19749. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19750. * @param {number} upperLimit the upper limit
  19751. * @param {number} lowerLimit lower limit
  19752. * @param {motorIndex} the motor's index, 0 or 1.
  19753. */
  19754. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19755. }
  19756. /**
  19757. * Interface for a motor enabled joint
  19758. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19759. */
  19760. export interface IMotorEnabledJoint {
  19761. /**
  19762. * Physics joint
  19763. */
  19764. physicsJoint: any;
  19765. /**
  19766. * Sets the motor of the motor-enabled joint
  19767. * @param force The force of the motor
  19768. * @param maxForce The maximum force of the motor
  19769. * @param motorIndex The index of the motor
  19770. */
  19771. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19772. /**
  19773. * Sets the limit of the motor
  19774. * @param upperLimit The upper limit of the motor
  19775. * @param lowerLimit The lower limit of the motor
  19776. * @param motorIndex The index of the motor
  19777. */
  19778. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19779. }
  19780. /**
  19781. * Joint data for a Distance-Joint
  19782. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19783. */
  19784. export interface DistanceJointData extends PhysicsJointData {
  19785. /**
  19786. * Max distance the 2 joint objects can be apart
  19787. */
  19788. maxDistance: number;
  19789. }
  19790. /**
  19791. * Joint data from a spring joint
  19792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19793. */
  19794. export interface SpringJointData extends PhysicsJointData {
  19795. /**
  19796. * Length of the spring
  19797. */
  19798. length: number;
  19799. /**
  19800. * Stiffness of the spring
  19801. */
  19802. stiffness: number;
  19803. /**
  19804. * Damping of the spring
  19805. */
  19806. damping: number;
  19807. /** this callback will be called when applying the force to the impostors. */
  19808. forceApplicationCallback: () => void;
  19809. }
  19810. }
  19811. declare module BABYLON {
  19812. /**
  19813. * Holds the data for the raycast result
  19814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19815. */
  19816. export class PhysicsRaycastResult {
  19817. private _hasHit;
  19818. private _hitDistance;
  19819. private _hitNormalWorld;
  19820. private _hitPointWorld;
  19821. private _rayFromWorld;
  19822. private _rayToWorld;
  19823. /**
  19824. * Gets if there was a hit
  19825. */
  19826. readonly hasHit: boolean;
  19827. /**
  19828. * Gets the distance from the hit
  19829. */
  19830. readonly hitDistance: number;
  19831. /**
  19832. * Gets the hit normal/direction in the world
  19833. */
  19834. readonly hitNormalWorld: Vector3;
  19835. /**
  19836. * Gets the hit point in the world
  19837. */
  19838. readonly hitPointWorld: Vector3;
  19839. /**
  19840. * Gets the ray "start point" of the ray in the world
  19841. */
  19842. readonly rayFromWorld: Vector3;
  19843. /**
  19844. * Gets the ray "end point" of the ray in the world
  19845. */
  19846. readonly rayToWorld: Vector3;
  19847. /**
  19848. * Sets the hit data (normal & point in world space)
  19849. * @param hitNormalWorld defines the normal in world space
  19850. * @param hitPointWorld defines the point in world space
  19851. */
  19852. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19853. /**
  19854. * Sets the distance from the start point to the hit point
  19855. * @param distance
  19856. */
  19857. setHitDistance(distance: number): void;
  19858. /**
  19859. * Calculates the distance manually
  19860. */
  19861. calculateHitDistance(): void;
  19862. /**
  19863. * Resets all the values to default
  19864. * @param from The from point on world space
  19865. * @param to The to point on world space
  19866. */
  19867. reset(from?: Vector3, to?: Vector3): void;
  19868. }
  19869. /**
  19870. * Interface for the size containing width and height
  19871. */
  19872. interface IXYZ {
  19873. /**
  19874. * X
  19875. */
  19876. x: number;
  19877. /**
  19878. * Y
  19879. */
  19880. y: number;
  19881. /**
  19882. * Z
  19883. */
  19884. z: number;
  19885. }
  19886. }
  19887. declare module BABYLON {
  19888. /**
  19889. * Interface used to describe a physics joint
  19890. */
  19891. export interface PhysicsImpostorJoint {
  19892. /** Defines the main impostor to which the joint is linked */
  19893. mainImpostor: PhysicsImpostor;
  19894. /** Defines the impostor that is connected to the main impostor using this joint */
  19895. connectedImpostor: PhysicsImpostor;
  19896. /** Defines the joint itself */
  19897. joint: PhysicsJoint;
  19898. }
  19899. /** @hidden */
  19900. export interface IPhysicsEnginePlugin {
  19901. world: any;
  19902. name: string;
  19903. setGravity(gravity: Vector3): void;
  19904. setTimeStep(timeStep: number): void;
  19905. getTimeStep(): number;
  19906. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19907. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19908. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19909. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19910. removePhysicsBody(impostor: PhysicsImpostor): void;
  19911. generateJoint(joint: PhysicsImpostorJoint): void;
  19912. removeJoint(joint: PhysicsImpostorJoint): void;
  19913. isSupported(): boolean;
  19914. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19915. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19916. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19917. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19918. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19919. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19920. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19921. getBodyMass(impostor: PhysicsImpostor): number;
  19922. getBodyFriction(impostor: PhysicsImpostor): number;
  19923. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19924. getBodyRestitution(impostor: PhysicsImpostor): number;
  19925. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19926. getBodyPressure?(impostor: PhysicsImpostor): number;
  19927. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19928. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19929. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19930. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19931. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19932. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19933. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19934. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19935. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19936. sleepBody(impostor: PhysicsImpostor): void;
  19937. wakeUpBody(impostor: PhysicsImpostor): void;
  19938. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19939. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19940. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19941. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19942. getRadius(impostor: PhysicsImpostor): number;
  19943. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19944. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19945. dispose(): void;
  19946. }
  19947. /**
  19948. * Interface used to define a physics engine
  19949. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19950. */
  19951. export interface IPhysicsEngine {
  19952. /**
  19953. * Gets the gravity vector used by the simulation
  19954. */
  19955. gravity: Vector3;
  19956. /**
  19957. * Sets the gravity vector used by the simulation
  19958. * @param gravity defines the gravity vector to use
  19959. */
  19960. setGravity(gravity: Vector3): void;
  19961. /**
  19962. * Set the time step of the physics engine.
  19963. * Default is 1/60.
  19964. * To slow it down, enter 1/600 for example.
  19965. * To speed it up, 1/30
  19966. * @param newTimeStep the new timestep to apply to this world.
  19967. */
  19968. setTimeStep(newTimeStep: number): void;
  19969. /**
  19970. * Get the time step of the physics engine.
  19971. * @returns the current time step
  19972. */
  19973. getTimeStep(): number;
  19974. /**
  19975. * Release all resources
  19976. */
  19977. dispose(): void;
  19978. /**
  19979. * Gets the name of the current physics plugin
  19980. * @returns the name of the plugin
  19981. */
  19982. getPhysicsPluginName(): string;
  19983. /**
  19984. * Adding a new impostor for the impostor tracking.
  19985. * This will be done by the impostor itself.
  19986. * @param impostor the impostor to add
  19987. */
  19988. addImpostor(impostor: PhysicsImpostor): void;
  19989. /**
  19990. * Remove an impostor from the engine.
  19991. * This impostor and its mesh will not longer be updated by the physics engine.
  19992. * @param impostor the impostor to remove
  19993. */
  19994. removeImpostor(impostor: PhysicsImpostor): void;
  19995. /**
  19996. * Add a joint to the physics engine
  19997. * @param mainImpostor defines the main impostor to which the joint is added.
  19998. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19999. * @param joint defines the joint that will connect both impostors.
  20000. */
  20001. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20002. /**
  20003. * Removes a joint from the simulation
  20004. * @param mainImpostor defines the impostor used with the joint
  20005. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20006. * @param joint defines the joint to remove
  20007. */
  20008. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20009. /**
  20010. * Gets the current plugin used to run the simulation
  20011. * @returns current plugin
  20012. */
  20013. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20014. /**
  20015. * Gets the list of physic impostors
  20016. * @returns an array of PhysicsImpostor
  20017. */
  20018. getImpostors(): Array<PhysicsImpostor>;
  20019. /**
  20020. * Gets the impostor for a physics enabled object
  20021. * @param object defines the object impersonated by the impostor
  20022. * @returns the PhysicsImpostor or null if not found
  20023. */
  20024. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20025. /**
  20026. * Gets the impostor for a physics body object
  20027. * @param body defines physics body used by the impostor
  20028. * @returns the PhysicsImpostor or null if not found
  20029. */
  20030. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20031. /**
  20032. * Does a raycast in the physics world
  20033. * @param from when should the ray start?
  20034. * @param to when should the ray end?
  20035. * @returns PhysicsRaycastResult
  20036. */
  20037. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20038. /**
  20039. * Called by the scene. No need to call it.
  20040. * @param delta defines the timespam between frames
  20041. */
  20042. _step(delta: number): void;
  20043. }
  20044. }
  20045. declare module BABYLON {
  20046. /**
  20047. * The interface for the physics imposter parameters
  20048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20049. */
  20050. export interface PhysicsImpostorParameters {
  20051. /**
  20052. * The mass of the physics imposter
  20053. */
  20054. mass: number;
  20055. /**
  20056. * The friction of the physics imposter
  20057. */
  20058. friction?: number;
  20059. /**
  20060. * The coefficient of restitution of the physics imposter
  20061. */
  20062. restitution?: number;
  20063. /**
  20064. * The native options of the physics imposter
  20065. */
  20066. nativeOptions?: any;
  20067. /**
  20068. * Specifies if the parent should be ignored
  20069. */
  20070. ignoreParent?: boolean;
  20071. /**
  20072. * Specifies if bi-directional transformations should be disabled
  20073. */
  20074. disableBidirectionalTransformation?: boolean;
  20075. /**
  20076. * The pressure inside the physics imposter, soft object only
  20077. */
  20078. pressure?: number;
  20079. /**
  20080. * The stiffness the physics imposter, soft object only
  20081. */
  20082. stiffness?: number;
  20083. /**
  20084. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20085. */
  20086. velocityIterations?: number;
  20087. /**
  20088. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20089. */
  20090. positionIterations?: number;
  20091. /**
  20092. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20093. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20094. * Add to fix multiple points
  20095. */
  20096. fixedPoints?: number;
  20097. /**
  20098. * The collision margin around a soft object
  20099. */
  20100. margin?: number;
  20101. /**
  20102. * The collision margin around a soft object
  20103. */
  20104. damping?: number;
  20105. /**
  20106. * The path for a rope based on an extrusion
  20107. */
  20108. path?: any;
  20109. /**
  20110. * The shape of an extrusion used for a rope based on an extrusion
  20111. */
  20112. shape?: any;
  20113. }
  20114. /**
  20115. * Interface for a physics-enabled object
  20116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20117. */
  20118. export interface IPhysicsEnabledObject {
  20119. /**
  20120. * The position of the physics-enabled object
  20121. */
  20122. position: Vector3;
  20123. /**
  20124. * The rotation of the physics-enabled object
  20125. */
  20126. rotationQuaternion: Nullable<Quaternion>;
  20127. /**
  20128. * The scale of the physics-enabled object
  20129. */
  20130. scaling: Vector3;
  20131. /**
  20132. * The rotation of the physics-enabled object
  20133. */
  20134. rotation?: Vector3;
  20135. /**
  20136. * The parent of the physics-enabled object
  20137. */
  20138. parent?: any;
  20139. /**
  20140. * The bounding info of the physics-enabled object
  20141. * @returns The bounding info of the physics-enabled object
  20142. */
  20143. getBoundingInfo(): BoundingInfo;
  20144. /**
  20145. * Computes the world matrix
  20146. * @param force Specifies if the world matrix should be computed by force
  20147. * @returns A world matrix
  20148. */
  20149. computeWorldMatrix(force: boolean): Matrix;
  20150. /**
  20151. * Gets the world matrix
  20152. * @returns A world matrix
  20153. */
  20154. getWorldMatrix?(): Matrix;
  20155. /**
  20156. * Gets the child meshes
  20157. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20158. * @returns An array of abstract meshes
  20159. */
  20160. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20161. /**
  20162. * Gets the vertex data
  20163. * @param kind The type of vertex data
  20164. * @returns A nullable array of numbers, or a float32 array
  20165. */
  20166. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20167. /**
  20168. * Gets the indices from the mesh
  20169. * @returns A nullable array of index arrays
  20170. */
  20171. getIndices?(): Nullable<IndicesArray>;
  20172. /**
  20173. * Gets the scene from the mesh
  20174. * @returns the indices array or null
  20175. */
  20176. getScene?(): Scene;
  20177. /**
  20178. * Gets the absolute position from the mesh
  20179. * @returns the absolute position
  20180. */
  20181. getAbsolutePosition(): Vector3;
  20182. /**
  20183. * Gets the absolute pivot point from the mesh
  20184. * @returns the absolute pivot point
  20185. */
  20186. getAbsolutePivotPoint(): Vector3;
  20187. /**
  20188. * Rotates the mesh
  20189. * @param axis The axis of rotation
  20190. * @param amount The amount of rotation
  20191. * @param space The space of the rotation
  20192. * @returns The rotation transform node
  20193. */
  20194. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20195. /**
  20196. * Translates the mesh
  20197. * @param axis The axis of translation
  20198. * @param distance The distance of translation
  20199. * @param space The space of the translation
  20200. * @returns The transform node
  20201. */
  20202. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20203. /**
  20204. * Sets the absolute position of the mesh
  20205. * @param absolutePosition The absolute position of the mesh
  20206. * @returns The transform node
  20207. */
  20208. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20209. /**
  20210. * Gets the class name of the mesh
  20211. * @returns The class name
  20212. */
  20213. getClassName(): string;
  20214. }
  20215. /**
  20216. * Represents a physics imposter
  20217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20218. */
  20219. export class PhysicsImpostor {
  20220. /**
  20221. * The physics-enabled object used as the physics imposter
  20222. */
  20223. object: IPhysicsEnabledObject;
  20224. /**
  20225. * The type of the physics imposter
  20226. */
  20227. type: number;
  20228. private _options;
  20229. private _scene?;
  20230. /**
  20231. * The default object size of the imposter
  20232. */
  20233. static DEFAULT_OBJECT_SIZE: Vector3;
  20234. /**
  20235. * The identity quaternion of the imposter
  20236. */
  20237. static IDENTITY_QUATERNION: Quaternion;
  20238. /** @hidden */
  20239. _pluginData: any;
  20240. private _physicsEngine;
  20241. private _physicsBody;
  20242. private _bodyUpdateRequired;
  20243. private _onBeforePhysicsStepCallbacks;
  20244. private _onAfterPhysicsStepCallbacks;
  20245. /** @hidden */
  20246. _onPhysicsCollideCallbacks: Array<{
  20247. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20248. otherImpostors: Array<PhysicsImpostor>;
  20249. }>;
  20250. private _deltaPosition;
  20251. private _deltaRotation;
  20252. private _deltaRotationConjugated;
  20253. /** hidden */
  20254. _isFromLine: boolean;
  20255. private _parent;
  20256. private _isDisposed;
  20257. private static _tmpVecs;
  20258. private static _tmpQuat;
  20259. /**
  20260. * Specifies if the physics imposter is disposed
  20261. */
  20262. readonly isDisposed: boolean;
  20263. /**
  20264. * Gets the mass of the physics imposter
  20265. */
  20266. mass: number;
  20267. /**
  20268. * Gets the coefficient of friction
  20269. */
  20270. /**
  20271. * Sets the coefficient of friction
  20272. */
  20273. friction: number;
  20274. /**
  20275. * Gets the coefficient of restitution
  20276. */
  20277. /**
  20278. * Sets the coefficient of restitution
  20279. */
  20280. restitution: number;
  20281. /**
  20282. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20283. */
  20284. /**
  20285. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20286. */
  20287. pressure: number;
  20288. /**
  20289. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20290. */
  20291. /**
  20292. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20293. */
  20294. stiffness: number;
  20295. /**
  20296. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20297. */
  20298. /**
  20299. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20300. */
  20301. velocityIterations: number;
  20302. /**
  20303. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20304. */
  20305. /**
  20306. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20307. */
  20308. positionIterations: number;
  20309. /**
  20310. * The unique id of the physics imposter
  20311. * set by the physics engine when adding this impostor to the array
  20312. */
  20313. uniqueId: number;
  20314. /**
  20315. * @hidden
  20316. */
  20317. soft: boolean;
  20318. /**
  20319. * @hidden
  20320. */
  20321. segments: number;
  20322. private _joints;
  20323. /**
  20324. * Initializes the physics imposter
  20325. * @param object The physics-enabled object used as the physics imposter
  20326. * @param type The type of the physics imposter
  20327. * @param _options The options for the physics imposter
  20328. * @param _scene The Babylon scene
  20329. */
  20330. constructor(
  20331. /**
  20332. * The physics-enabled object used as the physics imposter
  20333. */
  20334. object: IPhysicsEnabledObject,
  20335. /**
  20336. * The type of the physics imposter
  20337. */
  20338. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20339. /**
  20340. * This function will completly initialize this impostor.
  20341. * It will create a new body - but only if this mesh has no parent.
  20342. * If it has, this impostor will not be used other than to define the impostor
  20343. * of the child mesh.
  20344. * @hidden
  20345. */
  20346. _init(): void;
  20347. private _getPhysicsParent;
  20348. /**
  20349. * Should a new body be generated.
  20350. * @returns boolean specifying if body initialization is required
  20351. */
  20352. isBodyInitRequired(): boolean;
  20353. /**
  20354. * Sets the updated scaling
  20355. * @param updated Specifies if the scaling is updated
  20356. */
  20357. setScalingUpdated(): void;
  20358. /**
  20359. * Force a regeneration of this or the parent's impostor's body.
  20360. * Use under cautious - This will remove all joints already implemented.
  20361. */
  20362. forceUpdate(): void;
  20363. /**
  20364. * Gets the body that holds this impostor. Either its own, or its parent.
  20365. */
  20366. /**
  20367. * Set the physics body. Used mainly by the physics engine/plugin
  20368. */
  20369. physicsBody: any;
  20370. /**
  20371. * Get the parent of the physics imposter
  20372. * @returns Physics imposter or null
  20373. */
  20374. /**
  20375. * Sets the parent of the physics imposter
  20376. */
  20377. parent: Nullable<PhysicsImpostor>;
  20378. /**
  20379. * Resets the update flags
  20380. */
  20381. resetUpdateFlags(): void;
  20382. /**
  20383. * Gets the object extend size
  20384. * @returns the object extend size
  20385. */
  20386. getObjectExtendSize(): Vector3;
  20387. /**
  20388. * Gets the object center
  20389. * @returns The object center
  20390. */
  20391. getObjectCenter(): Vector3;
  20392. /**
  20393. * Get a specific parametes from the options parameter
  20394. * @param paramName The object parameter name
  20395. * @returns The object parameter
  20396. */
  20397. getParam(paramName: string): any;
  20398. /**
  20399. * Sets a specific parameter in the options given to the physics plugin
  20400. * @param paramName The parameter name
  20401. * @param value The value of the parameter
  20402. */
  20403. setParam(paramName: string, value: number): void;
  20404. /**
  20405. * Specifically change the body's mass option. Won't recreate the physics body object
  20406. * @param mass The mass of the physics imposter
  20407. */
  20408. setMass(mass: number): void;
  20409. /**
  20410. * Gets the linear velocity
  20411. * @returns linear velocity or null
  20412. */
  20413. getLinearVelocity(): Nullable<Vector3>;
  20414. /**
  20415. * Sets the linear velocity
  20416. * @param velocity linear velocity or null
  20417. */
  20418. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20419. /**
  20420. * Gets the angular velocity
  20421. * @returns angular velocity or null
  20422. */
  20423. getAngularVelocity(): Nullable<Vector3>;
  20424. /**
  20425. * Sets the angular velocity
  20426. * @param velocity The velocity or null
  20427. */
  20428. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20429. /**
  20430. * Execute a function with the physics plugin native code
  20431. * Provide a function the will have two variables - the world object and the physics body object
  20432. * @param func The function to execute with the physics plugin native code
  20433. */
  20434. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20435. /**
  20436. * Register a function that will be executed before the physics world is stepping forward
  20437. * @param func The function to execute before the physics world is stepped forward
  20438. */
  20439. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20440. /**
  20441. * Unregister a function that will be executed before the physics world is stepping forward
  20442. * @param func The function to execute before the physics world is stepped forward
  20443. */
  20444. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20445. /**
  20446. * Register a function that will be executed after the physics step
  20447. * @param func The function to execute after physics step
  20448. */
  20449. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20450. /**
  20451. * Unregisters a function that will be executed after the physics step
  20452. * @param func The function to execute after physics step
  20453. */
  20454. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20455. /**
  20456. * register a function that will be executed when this impostor collides against a different body
  20457. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20458. * @param func Callback that is executed on collision
  20459. */
  20460. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20461. /**
  20462. * Unregisters the physics imposter on contact
  20463. * @param collideAgainst The physics object to collide against
  20464. * @param func Callback to execute on collision
  20465. */
  20466. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20467. private _tmpQuat;
  20468. private _tmpQuat2;
  20469. /**
  20470. * Get the parent rotation
  20471. * @returns The parent rotation
  20472. */
  20473. getParentsRotation(): Quaternion;
  20474. /**
  20475. * this function is executed by the physics engine.
  20476. */
  20477. beforeStep: () => void;
  20478. /**
  20479. * this function is executed by the physics engine
  20480. */
  20481. afterStep: () => void;
  20482. /**
  20483. * Legacy collision detection event support
  20484. */
  20485. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20486. /**
  20487. * event and body object due to cannon's event-based architecture.
  20488. */
  20489. onCollide: (e: {
  20490. body: any;
  20491. }) => void;
  20492. /**
  20493. * Apply a force
  20494. * @param force The force to apply
  20495. * @param contactPoint The contact point for the force
  20496. * @returns The physics imposter
  20497. */
  20498. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20499. /**
  20500. * Apply an impulse
  20501. * @param force The impulse force
  20502. * @param contactPoint The contact point for the impulse force
  20503. * @returns The physics imposter
  20504. */
  20505. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20506. /**
  20507. * A help function to create a joint
  20508. * @param otherImpostor A physics imposter used to create a joint
  20509. * @param jointType The type of joint
  20510. * @param jointData The data for the joint
  20511. * @returns The physics imposter
  20512. */
  20513. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20514. /**
  20515. * Add a joint to this impostor with a different impostor
  20516. * @param otherImpostor A physics imposter used to add a joint
  20517. * @param joint The joint to add
  20518. * @returns The physics imposter
  20519. */
  20520. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20521. /**
  20522. * Add an anchor to a cloth impostor
  20523. * @param otherImpostor rigid impostor to anchor to
  20524. * @param width ratio across width from 0 to 1
  20525. * @param height ratio up height from 0 to 1
  20526. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20527. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20528. * @returns impostor the soft imposter
  20529. */
  20530. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20531. /**
  20532. * Add a hook to a rope impostor
  20533. * @param otherImpostor rigid impostor to anchor to
  20534. * @param length ratio across rope from 0 to 1
  20535. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20536. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20537. * @returns impostor the rope imposter
  20538. */
  20539. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20540. /**
  20541. * Will keep this body still, in a sleep mode.
  20542. * @returns the physics imposter
  20543. */
  20544. sleep(): PhysicsImpostor;
  20545. /**
  20546. * Wake the body up.
  20547. * @returns The physics imposter
  20548. */
  20549. wakeUp(): PhysicsImpostor;
  20550. /**
  20551. * Clones the physics imposter
  20552. * @param newObject The physics imposter clones to this physics-enabled object
  20553. * @returns A nullable physics imposter
  20554. */
  20555. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20556. /**
  20557. * Disposes the physics imposter
  20558. */
  20559. dispose(): void;
  20560. /**
  20561. * Sets the delta position
  20562. * @param position The delta position amount
  20563. */
  20564. setDeltaPosition(position: Vector3): void;
  20565. /**
  20566. * Sets the delta rotation
  20567. * @param rotation The delta rotation amount
  20568. */
  20569. setDeltaRotation(rotation: Quaternion): void;
  20570. /**
  20571. * Gets the box size of the physics imposter and stores the result in the input parameter
  20572. * @param result Stores the box size
  20573. * @returns The physics imposter
  20574. */
  20575. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20576. /**
  20577. * Gets the radius of the physics imposter
  20578. * @returns Radius of the physics imposter
  20579. */
  20580. getRadius(): number;
  20581. /**
  20582. * Sync a bone with this impostor
  20583. * @param bone The bone to sync to the impostor.
  20584. * @param boneMesh The mesh that the bone is influencing.
  20585. * @param jointPivot The pivot of the joint / bone in local space.
  20586. * @param distToJoint Optional distance from the impostor to the joint.
  20587. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20588. */
  20589. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20590. /**
  20591. * Sync impostor to a bone
  20592. * @param bone The bone that the impostor will be synced to.
  20593. * @param boneMesh The mesh that the bone is influencing.
  20594. * @param jointPivot The pivot of the joint / bone in local space.
  20595. * @param distToJoint Optional distance from the impostor to the joint.
  20596. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20597. * @param boneAxis Optional vector3 axis the bone is aligned with
  20598. */
  20599. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20600. /**
  20601. * No-Imposter type
  20602. */
  20603. static NoImpostor: number;
  20604. /**
  20605. * Sphere-Imposter type
  20606. */
  20607. static SphereImpostor: number;
  20608. /**
  20609. * Box-Imposter type
  20610. */
  20611. static BoxImpostor: number;
  20612. /**
  20613. * Plane-Imposter type
  20614. */
  20615. static PlaneImpostor: number;
  20616. /**
  20617. * Mesh-imposter type
  20618. */
  20619. static MeshImpostor: number;
  20620. /**
  20621. * Cylinder-Imposter type
  20622. */
  20623. static CylinderImpostor: number;
  20624. /**
  20625. * Particle-Imposter type
  20626. */
  20627. static ParticleImpostor: number;
  20628. /**
  20629. * Heightmap-Imposter type
  20630. */
  20631. static HeightmapImpostor: number;
  20632. /**
  20633. * ConvexHull-Impostor type (Ammo.js plugin only)
  20634. */
  20635. static ConvexHullImpostor: number;
  20636. /**
  20637. * Rope-Imposter type
  20638. */
  20639. static RopeImpostor: number;
  20640. /**
  20641. * Cloth-Imposter type
  20642. */
  20643. static ClothImpostor: number;
  20644. /**
  20645. * Softbody-Imposter type
  20646. */
  20647. static SoftbodyImpostor: number;
  20648. }
  20649. }
  20650. declare module BABYLON {
  20651. /**
  20652. * @hidden
  20653. **/
  20654. export class _CreationDataStorage {
  20655. closePath?: boolean;
  20656. closeArray?: boolean;
  20657. idx: number[];
  20658. dashSize: number;
  20659. gapSize: number;
  20660. path3D: Path3D;
  20661. pathArray: Vector3[][];
  20662. arc: number;
  20663. radius: number;
  20664. cap: number;
  20665. tessellation: number;
  20666. }
  20667. /**
  20668. * @hidden
  20669. **/
  20670. class _InstanceDataStorage {
  20671. visibleInstances: any;
  20672. batchCache: _InstancesBatch;
  20673. instancesBufferSize: number;
  20674. instancesBuffer: Nullable<Buffer>;
  20675. instancesData: Float32Array;
  20676. overridenInstanceCount: number;
  20677. isFrozen: boolean;
  20678. previousBatch: _InstancesBatch;
  20679. hardwareInstancedRendering: boolean;
  20680. sideOrientation: number;
  20681. }
  20682. /**
  20683. * @hidden
  20684. **/
  20685. export class _InstancesBatch {
  20686. mustReturn: boolean;
  20687. visibleInstances: Nullable<InstancedMesh[]>[];
  20688. renderSelf: boolean[];
  20689. hardwareInstancedRendering: boolean[];
  20690. }
  20691. /**
  20692. * Class used to represent renderable models
  20693. */
  20694. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20695. /**
  20696. * Mesh side orientation : usually the external or front surface
  20697. */
  20698. static readonly FRONTSIDE: number;
  20699. /**
  20700. * Mesh side orientation : usually the internal or back surface
  20701. */
  20702. static readonly BACKSIDE: number;
  20703. /**
  20704. * Mesh side orientation : both internal and external or front and back surfaces
  20705. */
  20706. static readonly DOUBLESIDE: number;
  20707. /**
  20708. * Mesh side orientation : by default, `FRONTSIDE`
  20709. */
  20710. static readonly DEFAULTSIDE: number;
  20711. /**
  20712. * Mesh cap setting : no cap
  20713. */
  20714. static readonly NO_CAP: number;
  20715. /**
  20716. * Mesh cap setting : one cap at the beginning of the mesh
  20717. */
  20718. static readonly CAP_START: number;
  20719. /**
  20720. * Mesh cap setting : one cap at the end of the mesh
  20721. */
  20722. static readonly CAP_END: number;
  20723. /**
  20724. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20725. */
  20726. static readonly CAP_ALL: number;
  20727. /**
  20728. * Mesh pattern setting : no flip or rotate
  20729. */
  20730. static readonly NO_FLIP: number;
  20731. /**
  20732. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  20733. */
  20734. static readonly FLIP_TILE: number;
  20735. /**
  20736. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  20737. */
  20738. static readonly ROTATE_TILE: number;
  20739. /**
  20740. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  20741. */
  20742. static readonly FLIP_ROW: number;
  20743. /**
  20744. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  20745. */
  20746. static readonly ROTATE_ROW: number;
  20747. /**
  20748. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  20749. */
  20750. static readonly FLIP_N_ROTATE_TILE: number;
  20751. /**
  20752. * Mesh pattern setting : rotate pattern and rotate
  20753. */
  20754. static readonly FLIP_N_ROTATE_ROW: number;
  20755. /**
  20756. * Mesh tile positioning : part tiles same on left/right or top/bottom
  20757. */
  20758. static readonly CENTER: number;
  20759. /**
  20760. * Mesh tile positioning : part tiles on left
  20761. */
  20762. static readonly LEFT: number;
  20763. /**
  20764. * Mesh tile positioning : part tiles on right
  20765. */
  20766. static readonly RIGHT: number;
  20767. /**
  20768. * Mesh tile positioning : part tiles on top
  20769. */
  20770. static readonly TOP: number;
  20771. /**
  20772. * Mesh tile positioning : part tiles on bottom
  20773. */
  20774. static readonly BOTTOM: number;
  20775. /**
  20776. * Gets the default side orientation.
  20777. * @param orientation the orientation to value to attempt to get
  20778. * @returns the default orientation
  20779. * @hidden
  20780. */
  20781. static _GetDefaultSideOrientation(orientation?: number): number;
  20782. private _internalMeshDataInfo;
  20783. /**
  20784. * An event triggered before rendering the mesh
  20785. */
  20786. readonly onBeforeRenderObservable: Observable<Mesh>;
  20787. /**
  20788. * An event triggered before binding the mesh
  20789. */
  20790. readonly onBeforeBindObservable: Observable<Mesh>;
  20791. /**
  20792. * An event triggered after rendering the mesh
  20793. */
  20794. readonly onAfterRenderObservable: Observable<Mesh>;
  20795. /**
  20796. * An event triggered before drawing the mesh
  20797. */
  20798. readonly onBeforeDrawObservable: Observable<Mesh>;
  20799. private _onBeforeDrawObserver;
  20800. /**
  20801. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20802. */
  20803. onBeforeDraw: () => void;
  20804. /**
  20805. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20806. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20807. */
  20808. delayLoadState: number;
  20809. /**
  20810. * Gets the list of instances created from this mesh
  20811. * it is not supposed to be modified manually.
  20812. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20813. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20814. */
  20815. instances: InstancedMesh[];
  20816. /**
  20817. * Gets the file containing delay loading data for this mesh
  20818. */
  20819. delayLoadingFile: string;
  20820. /** @hidden */
  20821. _binaryInfo: any;
  20822. /**
  20823. * User defined function used to change how LOD level selection is done
  20824. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20825. */
  20826. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20827. /**
  20828. * Gets or sets the morph target manager
  20829. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20830. */
  20831. morphTargetManager: Nullable<MorphTargetManager>;
  20832. /** @hidden */
  20833. _creationDataStorage: Nullable<_CreationDataStorage>;
  20834. /** @hidden */
  20835. _geometry: Nullable<Geometry>;
  20836. /** @hidden */
  20837. _delayInfo: Array<string>;
  20838. /** @hidden */
  20839. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20840. /** @hidden */
  20841. _instanceDataStorage: _InstanceDataStorage;
  20842. private _effectiveMaterial;
  20843. /** @hidden */
  20844. _shouldGenerateFlatShading: boolean;
  20845. /** @hidden */
  20846. _originalBuilderSideOrientation: number;
  20847. /**
  20848. * Use this property to change the original side orientation defined at construction time
  20849. */
  20850. overrideMaterialSideOrientation: Nullable<number>;
  20851. /**
  20852. * Gets the source mesh (the one used to clone this one from)
  20853. */
  20854. readonly source: Nullable<Mesh>;
  20855. /**
  20856. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20857. */
  20858. isUnIndexed: boolean;
  20859. /**
  20860. * @constructor
  20861. * @param name The value used by scene.getMeshByName() to do a lookup.
  20862. * @param scene The scene to add this mesh to.
  20863. * @param parent The parent of this mesh, if it has one
  20864. * @param source An optional Mesh from which geometry is shared, cloned.
  20865. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20866. * When false, achieved by calling a clone(), also passing False.
  20867. * This will make creation of children, recursive.
  20868. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20869. */
  20870. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20871. /**
  20872. * Gets the class name
  20873. * @returns the string "Mesh".
  20874. */
  20875. getClassName(): string;
  20876. /** @hidden */
  20877. readonly _isMesh: boolean;
  20878. /**
  20879. * Returns a description of this mesh
  20880. * @param fullDetails define if full details about this mesh must be used
  20881. * @returns a descriptive string representing this mesh
  20882. */
  20883. toString(fullDetails?: boolean): string;
  20884. /** @hidden */
  20885. _unBindEffect(): void;
  20886. /**
  20887. * Gets a boolean indicating if this mesh has LOD
  20888. */
  20889. readonly hasLODLevels: boolean;
  20890. /**
  20891. * Gets the list of MeshLODLevel associated with the current mesh
  20892. * @returns an array of MeshLODLevel
  20893. */
  20894. getLODLevels(): MeshLODLevel[];
  20895. private _sortLODLevels;
  20896. /**
  20897. * Add a mesh as LOD level triggered at the given distance.
  20898. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20899. * @param distance The distance from the center of the object to show this level
  20900. * @param mesh The mesh to be added as LOD level (can be null)
  20901. * @return This mesh (for chaining)
  20902. */
  20903. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20904. /**
  20905. * Returns the LOD level mesh at the passed distance or null if not found.
  20906. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20907. * @param distance The distance from the center of the object to show this level
  20908. * @returns a Mesh or `null`
  20909. */
  20910. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20911. /**
  20912. * Remove a mesh from the LOD array
  20913. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20914. * @param mesh defines the mesh to be removed
  20915. * @return This mesh (for chaining)
  20916. */
  20917. removeLODLevel(mesh: Mesh): Mesh;
  20918. /**
  20919. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20920. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20921. * @param camera defines the camera to use to compute distance
  20922. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20923. * @return This mesh (for chaining)
  20924. */
  20925. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20926. /**
  20927. * Gets the mesh internal Geometry object
  20928. */
  20929. readonly geometry: Nullable<Geometry>;
  20930. /**
  20931. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20932. * @returns the total number of vertices
  20933. */
  20934. getTotalVertices(): number;
  20935. /**
  20936. * Returns the content of an associated vertex buffer
  20937. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20938. * - VertexBuffer.PositionKind
  20939. * - VertexBuffer.UVKind
  20940. * - VertexBuffer.UV2Kind
  20941. * - VertexBuffer.UV3Kind
  20942. * - VertexBuffer.UV4Kind
  20943. * - VertexBuffer.UV5Kind
  20944. * - VertexBuffer.UV6Kind
  20945. * - VertexBuffer.ColorKind
  20946. * - VertexBuffer.MatricesIndicesKind
  20947. * - VertexBuffer.MatricesIndicesExtraKind
  20948. * - VertexBuffer.MatricesWeightsKind
  20949. * - VertexBuffer.MatricesWeightsExtraKind
  20950. * @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
  20951. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20952. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20953. */
  20954. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20955. /**
  20956. * Returns the mesh VertexBuffer object from the requested `kind`
  20957. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20958. * - VertexBuffer.PositionKind
  20959. * - VertexBuffer.UVKind
  20960. * - VertexBuffer.UV2Kind
  20961. * - VertexBuffer.UV3Kind
  20962. * - VertexBuffer.UV4Kind
  20963. * - VertexBuffer.UV5Kind
  20964. * - VertexBuffer.UV6Kind
  20965. * - VertexBuffer.ColorKind
  20966. * - VertexBuffer.MatricesIndicesKind
  20967. * - VertexBuffer.MatricesIndicesExtraKind
  20968. * - VertexBuffer.MatricesWeightsKind
  20969. * - VertexBuffer.MatricesWeightsExtraKind
  20970. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20971. */
  20972. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20973. /**
  20974. * Tests if a specific vertex buffer is associated with this mesh
  20975. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20976. * - VertexBuffer.PositionKind
  20977. * - VertexBuffer.UVKind
  20978. * - VertexBuffer.UV2Kind
  20979. * - VertexBuffer.UV3Kind
  20980. * - VertexBuffer.UV4Kind
  20981. * - VertexBuffer.UV5Kind
  20982. * - VertexBuffer.UV6Kind
  20983. * - VertexBuffer.ColorKind
  20984. * - VertexBuffer.MatricesIndicesKind
  20985. * - VertexBuffer.MatricesIndicesExtraKind
  20986. * - VertexBuffer.MatricesWeightsKind
  20987. * - VertexBuffer.MatricesWeightsExtraKind
  20988. * @returns a boolean
  20989. */
  20990. isVerticesDataPresent(kind: string): boolean;
  20991. /**
  20992. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20993. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20994. * - VertexBuffer.PositionKind
  20995. * - VertexBuffer.UVKind
  20996. * - VertexBuffer.UV2Kind
  20997. * - VertexBuffer.UV3Kind
  20998. * - VertexBuffer.UV4Kind
  20999. * - VertexBuffer.UV5Kind
  21000. * - VertexBuffer.UV6Kind
  21001. * - VertexBuffer.ColorKind
  21002. * - VertexBuffer.MatricesIndicesKind
  21003. * - VertexBuffer.MatricesIndicesExtraKind
  21004. * - VertexBuffer.MatricesWeightsKind
  21005. * - VertexBuffer.MatricesWeightsExtraKind
  21006. * @returns a boolean
  21007. */
  21008. isVertexBufferUpdatable(kind: string): boolean;
  21009. /**
  21010. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21011. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21012. * - VertexBuffer.PositionKind
  21013. * - VertexBuffer.UVKind
  21014. * - VertexBuffer.UV2Kind
  21015. * - VertexBuffer.UV3Kind
  21016. * - VertexBuffer.UV4Kind
  21017. * - VertexBuffer.UV5Kind
  21018. * - VertexBuffer.UV6Kind
  21019. * - VertexBuffer.ColorKind
  21020. * - VertexBuffer.MatricesIndicesKind
  21021. * - VertexBuffer.MatricesIndicesExtraKind
  21022. * - VertexBuffer.MatricesWeightsKind
  21023. * - VertexBuffer.MatricesWeightsExtraKind
  21024. * @returns an array of strings
  21025. */
  21026. getVerticesDataKinds(): string[];
  21027. /**
  21028. * Returns a positive integer : the total number of indices in this mesh geometry.
  21029. * @returns the numner of indices or zero if the mesh has no geometry.
  21030. */
  21031. getTotalIndices(): number;
  21032. /**
  21033. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21034. * @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.
  21035. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21036. * @returns the indices array or an empty array if the mesh has no geometry
  21037. */
  21038. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21039. readonly isBlocked: boolean;
  21040. /**
  21041. * Determine if the current mesh is ready to be rendered
  21042. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21043. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21044. * @returns true if all associated assets are ready (material, textures, shaders)
  21045. */
  21046. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21047. /**
  21048. * 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.
  21049. */
  21050. readonly areNormalsFrozen: boolean;
  21051. /**
  21052. * 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.
  21053. * @returns the current mesh
  21054. */
  21055. freezeNormals(): Mesh;
  21056. /**
  21057. * 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
  21058. * @returns the current mesh
  21059. */
  21060. unfreezeNormals(): Mesh;
  21061. /**
  21062. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21063. */
  21064. overridenInstanceCount: number;
  21065. /** @hidden */
  21066. _preActivate(): Mesh;
  21067. /** @hidden */
  21068. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21069. /** @hidden */
  21070. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21071. /**
  21072. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21073. * This means the mesh underlying bounding box and sphere are recomputed.
  21074. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21075. * @returns the current mesh
  21076. */
  21077. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21078. /** @hidden */
  21079. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21080. /**
  21081. * This function will subdivide the mesh into multiple submeshes
  21082. * @param count defines the expected number of submeshes
  21083. */
  21084. subdivide(count: number): void;
  21085. /**
  21086. * Copy a FloatArray into a specific associated vertex buffer
  21087. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21088. * - VertexBuffer.PositionKind
  21089. * - VertexBuffer.UVKind
  21090. * - VertexBuffer.UV2Kind
  21091. * - VertexBuffer.UV3Kind
  21092. * - VertexBuffer.UV4Kind
  21093. * - VertexBuffer.UV5Kind
  21094. * - VertexBuffer.UV6Kind
  21095. * - VertexBuffer.ColorKind
  21096. * - VertexBuffer.MatricesIndicesKind
  21097. * - VertexBuffer.MatricesIndicesExtraKind
  21098. * - VertexBuffer.MatricesWeightsKind
  21099. * - VertexBuffer.MatricesWeightsExtraKind
  21100. * @param data defines the data source
  21101. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21102. * @param stride defines the data stride size (can be null)
  21103. * @returns the current mesh
  21104. */
  21105. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21106. /**
  21107. * Flags an associated vertex buffer as updatable
  21108. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21109. * - VertexBuffer.PositionKind
  21110. * - VertexBuffer.UVKind
  21111. * - VertexBuffer.UV2Kind
  21112. * - VertexBuffer.UV3Kind
  21113. * - VertexBuffer.UV4Kind
  21114. * - VertexBuffer.UV5Kind
  21115. * - VertexBuffer.UV6Kind
  21116. * - VertexBuffer.ColorKind
  21117. * - VertexBuffer.MatricesIndicesKind
  21118. * - VertexBuffer.MatricesIndicesExtraKind
  21119. * - VertexBuffer.MatricesWeightsKind
  21120. * - VertexBuffer.MatricesWeightsExtraKind
  21121. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21122. */
  21123. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21124. /**
  21125. * Sets the mesh global Vertex Buffer
  21126. * @param buffer defines the buffer to use
  21127. * @returns the current mesh
  21128. */
  21129. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21130. /**
  21131. * Update a specific associated vertex buffer
  21132. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21133. * - VertexBuffer.PositionKind
  21134. * - VertexBuffer.UVKind
  21135. * - VertexBuffer.UV2Kind
  21136. * - VertexBuffer.UV3Kind
  21137. * - VertexBuffer.UV4Kind
  21138. * - VertexBuffer.UV5Kind
  21139. * - VertexBuffer.UV6Kind
  21140. * - VertexBuffer.ColorKind
  21141. * - VertexBuffer.MatricesIndicesKind
  21142. * - VertexBuffer.MatricesIndicesExtraKind
  21143. * - VertexBuffer.MatricesWeightsKind
  21144. * - VertexBuffer.MatricesWeightsExtraKind
  21145. * @param data defines the data source
  21146. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21147. * @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)
  21148. * @returns the current mesh
  21149. */
  21150. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21151. /**
  21152. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21153. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21154. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21155. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21156. * @returns the current mesh
  21157. */
  21158. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21159. /**
  21160. * Creates a un-shared specific occurence of the geometry for the mesh.
  21161. * @returns the current mesh
  21162. */
  21163. makeGeometryUnique(): Mesh;
  21164. /**
  21165. * Set the index buffer of this mesh
  21166. * @param indices defines the source data
  21167. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21168. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21169. * @returns the current mesh
  21170. */
  21171. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21172. /**
  21173. * Update the current index buffer
  21174. * @param indices defines the source data
  21175. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21176. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21177. * @returns the current mesh
  21178. */
  21179. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21180. /**
  21181. * Invert the geometry to move from a right handed system to a left handed one.
  21182. * @returns the current mesh
  21183. */
  21184. toLeftHanded(): Mesh;
  21185. /** @hidden */
  21186. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21187. /** @hidden */
  21188. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21189. /**
  21190. * Registers for this mesh a javascript function called just before the rendering process
  21191. * @param func defines the function to call before rendering this mesh
  21192. * @returns the current mesh
  21193. */
  21194. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21195. /**
  21196. * Disposes a previously registered javascript function called before the rendering
  21197. * @param func defines the function to remove
  21198. * @returns the current mesh
  21199. */
  21200. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21201. /**
  21202. * Registers for this mesh a javascript function called just after the rendering is complete
  21203. * @param func defines the function to call after rendering this mesh
  21204. * @returns the current mesh
  21205. */
  21206. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21207. /**
  21208. * Disposes a previously registered javascript function called after the rendering.
  21209. * @param func defines the function to remove
  21210. * @returns the current mesh
  21211. */
  21212. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21213. /** @hidden */
  21214. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21215. /** @hidden */
  21216. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21217. /** @hidden */
  21218. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21219. /** @hidden */
  21220. _freeze(): void;
  21221. /** @hidden */
  21222. _unFreeze(): void;
  21223. /**
  21224. * 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
  21225. * @param subMesh defines the subMesh to render
  21226. * @param enableAlphaMode defines if alpha mode can be changed
  21227. * @returns the current mesh
  21228. */
  21229. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21230. private _onBeforeDraw;
  21231. /**
  21232. * Renormalize the mesh and patch it up if there are no weights
  21233. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21234. * However in the case of zero weights then we set just a single influence to 1.
  21235. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21236. */
  21237. cleanMatrixWeights(): void;
  21238. private normalizeSkinFourWeights;
  21239. private normalizeSkinWeightsAndExtra;
  21240. /**
  21241. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21242. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21243. * the user know there was an issue with importing the mesh
  21244. * @returns a validation object with skinned, valid and report string
  21245. */
  21246. validateSkinning(): {
  21247. skinned: boolean;
  21248. valid: boolean;
  21249. report: string;
  21250. };
  21251. /** @hidden */
  21252. _checkDelayState(): Mesh;
  21253. private _queueLoad;
  21254. /**
  21255. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21256. * A mesh is in the frustum if its bounding box intersects the frustum
  21257. * @param frustumPlanes defines the frustum to test
  21258. * @returns true if the mesh is in the frustum planes
  21259. */
  21260. isInFrustum(frustumPlanes: Plane[]): boolean;
  21261. /**
  21262. * Sets the mesh material by the material or multiMaterial `id` property
  21263. * @param id is a string identifying the material or the multiMaterial
  21264. * @returns the current mesh
  21265. */
  21266. setMaterialByID(id: string): Mesh;
  21267. /**
  21268. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21269. * @returns an array of IAnimatable
  21270. */
  21271. getAnimatables(): IAnimatable[];
  21272. /**
  21273. * Modifies the mesh geometry according to the passed transformation matrix.
  21274. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21275. * The mesh normals are modified using the same transformation.
  21276. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21277. * @param transform defines the transform matrix to use
  21278. * @see http://doc.babylonjs.com/resources/baking_transformations
  21279. * @returns the current mesh
  21280. */
  21281. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21282. /**
  21283. * Modifies the mesh geometry according to its own current World Matrix.
  21284. * The mesh World Matrix is then reset.
  21285. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21286. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21287. * @see http://doc.babylonjs.com/resources/baking_transformations
  21288. * @returns the current mesh
  21289. */
  21290. bakeCurrentTransformIntoVertices(): Mesh;
  21291. /** @hidden */
  21292. readonly _positions: Nullable<Vector3[]>;
  21293. /** @hidden */
  21294. _resetPointsArrayCache(): Mesh;
  21295. /** @hidden */
  21296. _generatePointsArray(): boolean;
  21297. /**
  21298. * Returns a new Mesh object generated from the current mesh properties.
  21299. * This method must not get confused with createInstance()
  21300. * @param name is a string, the name given to the new mesh
  21301. * @param newParent can be any Node object (default `null`)
  21302. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21303. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21304. * @returns a new mesh
  21305. */
  21306. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21307. /**
  21308. * Releases resources associated with this mesh.
  21309. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21310. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21311. */
  21312. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21313. /**
  21314. * Modifies the mesh geometry according to a displacement map.
  21315. * 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.
  21316. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21317. * @param url is a string, the URL from the image file is to be downloaded.
  21318. * @param minHeight is the lower limit of the displacement.
  21319. * @param maxHeight is the upper limit of the displacement.
  21320. * @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.
  21321. * @param uvOffset is an optional vector2 used to offset UV.
  21322. * @param uvScale is an optional vector2 used to scale UV.
  21323. * @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.
  21324. * @returns the Mesh.
  21325. */
  21326. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21327. /**
  21328. * Modifies the mesh geometry according to a displacementMap buffer.
  21329. * 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.
  21330. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21331. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21332. * @param heightMapWidth is the width of the buffer image.
  21333. * @param heightMapHeight is the height of the buffer image.
  21334. * @param minHeight is the lower limit of the displacement.
  21335. * @param maxHeight is the upper limit of the displacement.
  21336. * @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.
  21337. * @param uvOffset is an optional vector2 used to offset UV.
  21338. * @param uvScale is an optional vector2 used to scale UV.
  21339. * @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.
  21340. * @returns the Mesh.
  21341. */
  21342. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21343. /**
  21344. * Modify the mesh to get a flat shading rendering.
  21345. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21346. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21347. * @returns current mesh
  21348. */
  21349. convertToFlatShadedMesh(): Mesh;
  21350. /**
  21351. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21352. * In other words, more vertices, no more indices and a single bigger VBO.
  21353. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21354. * @returns current mesh
  21355. */
  21356. convertToUnIndexedMesh(): Mesh;
  21357. /**
  21358. * Inverses facet orientations.
  21359. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21360. * @param flipNormals will also inverts the normals
  21361. * @returns current mesh
  21362. */
  21363. flipFaces(flipNormals?: boolean): Mesh;
  21364. /**
  21365. * Increase the number of facets and hence vertices in a mesh
  21366. * Vertex normals are interpolated from existing vertex normals
  21367. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21368. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21369. */
  21370. increaseVertices(numberPerEdge: number): void;
  21371. /**
  21372. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21373. * This will undo any application of covertToFlatShadedMesh
  21374. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21375. */
  21376. forceSharedVertices(): void;
  21377. /** @hidden */
  21378. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21379. /** @hidden */
  21380. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21381. /**
  21382. * Creates a new InstancedMesh object from the mesh model.
  21383. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21384. * @param name defines the name of the new instance
  21385. * @returns a new InstancedMesh
  21386. */
  21387. createInstance(name: string): InstancedMesh;
  21388. /**
  21389. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21390. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21391. * @returns the current mesh
  21392. */
  21393. synchronizeInstances(): Mesh;
  21394. /**
  21395. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21396. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21397. * This should be used together with the simplification to avoid disappearing triangles.
  21398. * @param successCallback an optional success callback to be called after the optimization finished.
  21399. * @returns the current mesh
  21400. */
  21401. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21402. /**
  21403. * Serialize current mesh
  21404. * @param serializationObject defines the object which will receive the serialization data
  21405. */
  21406. serialize(serializationObject: any): void;
  21407. /** @hidden */
  21408. _syncGeometryWithMorphTargetManager(): void;
  21409. /** @hidden */
  21410. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21411. /**
  21412. * Returns a new Mesh object parsed from the source provided.
  21413. * @param parsedMesh is the source
  21414. * @param scene defines the hosting scene
  21415. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21416. * @returns a new Mesh
  21417. */
  21418. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21419. /**
  21420. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21421. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21422. * @param name defines the name of the mesh to create
  21423. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21424. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21425. * @param closePath creates a seam between the first and the last points of each path of the path array
  21426. * @param offset is taken in account only if the `pathArray` is containing a single path
  21427. * @param scene defines the hosting scene
  21428. * @param updatable defines if the mesh must be flagged as updatable
  21429. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21430. * @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)
  21431. * @returns a new Mesh
  21432. */
  21433. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21434. /**
  21435. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21436. * @param name defines the name of the mesh to create
  21437. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21438. * @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
  21439. * @param scene defines the hosting scene
  21440. * @param updatable defines if the mesh must be flagged as updatable
  21441. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21442. * @returns a new Mesh
  21443. */
  21444. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21445. /**
  21446. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21447. * @param name defines the name of the mesh to create
  21448. * @param size sets the size (float) of each box side (default 1)
  21449. * @param scene defines the hosting scene
  21450. * @param updatable defines if the mesh must be flagged as updatable
  21451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21452. * @returns a new Mesh
  21453. */
  21454. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21455. /**
  21456. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21457. * @param name defines the name of the mesh to create
  21458. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21459. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21460. * @param scene defines the hosting scene
  21461. * @param updatable defines if the mesh must be flagged as updatable
  21462. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21463. * @returns a new Mesh
  21464. */
  21465. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21466. /**
  21467. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21468. * @param name defines the name of the mesh to create
  21469. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21470. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21471. * @param scene defines the hosting scene
  21472. * @returns a new Mesh
  21473. */
  21474. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21475. /**
  21476. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21477. * @param name defines the name of the mesh to create
  21478. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21479. * @param diameterTop set the top cap diameter (floats, default 1)
  21480. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21481. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21482. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21483. * @param scene defines the hosting scene
  21484. * @param updatable defines if the mesh must be flagged as updatable
  21485. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21486. * @returns a new Mesh
  21487. */
  21488. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21489. /**
  21490. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21491. * @param name defines the name of the mesh to create
  21492. * @param diameter sets the diameter size (float) of the torus (default 1)
  21493. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21494. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21495. * @param scene defines the hosting scene
  21496. * @param updatable defines if the mesh must be flagged as updatable
  21497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21498. * @returns a new Mesh
  21499. */
  21500. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21501. /**
  21502. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21503. * @param name defines the name of the mesh to create
  21504. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21505. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21506. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21507. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21508. * @param p the number of windings on X axis (positive integers, default 2)
  21509. * @param q the number of windings on Y axis (positive integers, default 3)
  21510. * @param scene defines the hosting scene
  21511. * @param updatable defines if the mesh must be flagged as updatable
  21512. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21513. * @returns a new Mesh
  21514. */
  21515. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21516. /**
  21517. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21518. * @param name defines the name of the mesh to create
  21519. * @param points is an array successive Vector3
  21520. * @param scene defines the hosting scene
  21521. * @param updatable defines if the mesh must be flagged as updatable
  21522. * @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).
  21523. * @returns a new Mesh
  21524. */
  21525. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21526. /**
  21527. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21528. * @param name defines the name of the mesh to create
  21529. * @param points is an array successive Vector3
  21530. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21531. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21532. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21533. * @param scene defines the hosting scene
  21534. * @param updatable defines if the mesh must be flagged as updatable
  21535. * @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)
  21536. * @returns a new Mesh
  21537. */
  21538. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21539. /**
  21540. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21541. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21542. * 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.
  21543. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21544. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21545. * Remember you can only change the shape positions, not their number when updating a polygon.
  21546. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21547. * @param name defines the name of the mesh to create
  21548. * @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
  21549. * @param scene defines the hosting scene
  21550. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21551. * @param updatable defines if the mesh must be flagged as updatable
  21552. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21553. * @param earcutInjection can be used to inject your own earcut reference
  21554. * @returns a new Mesh
  21555. */
  21556. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21557. /**
  21558. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21559. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21560. * @param name defines the name of the mesh to create
  21561. * @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
  21562. * @param depth defines the height of extrusion
  21563. * @param scene defines the hosting scene
  21564. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21565. * @param updatable defines if the mesh must be flagged as updatable
  21566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21567. * @param earcutInjection can be used to inject your own earcut reference
  21568. * @returns a new Mesh
  21569. */
  21570. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21571. /**
  21572. * Creates an extruded shape mesh.
  21573. * 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
  21574. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21575. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21576. * @param name defines the name of the mesh to create
  21577. * @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
  21578. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21579. * @param scale is the value to scale the shape
  21580. * @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
  21581. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21582. * @param scene defines the hosting scene
  21583. * @param updatable defines if the mesh must be flagged as updatable
  21584. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21585. * @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)
  21586. * @returns a new Mesh
  21587. */
  21588. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21589. /**
  21590. * Creates an custom extruded shape mesh.
  21591. * The custom extrusion is a parametric shape.
  21592. * It has no predefined shape. Its final shape will depend on the input parameters.
  21593. * Please consider using the same method from the MeshBuilder class instead
  21594. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21595. * @param name defines the name of the mesh to create
  21596. * @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
  21597. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21598. * @param scaleFunction is a custom Javascript function called on each path point
  21599. * @param rotationFunction is a custom Javascript function called on each path point
  21600. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21601. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21602. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21603. * @param scene defines the hosting scene
  21604. * @param updatable defines if the mesh must be flagged as updatable
  21605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21606. * @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)
  21607. * @returns a new Mesh
  21608. */
  21609. 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;
  21610. /**
  21611. * Creates lathe mesh.
  21612. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21613. * Please consider using the same method from the MeshBuilder class instead
  21614. * @param name defines the name of the mesh to create
  21615. * @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
  21616. * @param radius is the radius value of the lathe
  21617. * @param tessellation is the side number of the lathe.
  21618. * @param scene defines the hosting scene
  21619. * @param updatable defines if the mesh must be flagged as updatable
  21620. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21621. * @returns a new Mesh
  21622. */
  21623. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21624. /**
  21625. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21626. * @param name defines the name of the mesh to create
  21627. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21628. * @param scene defines the hosting scene
  21629. * @param updatable defines if the mesh must be flagged as updatable
  21630. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21631. * @returns a new Mesh
  21632. */
  21633. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21634. /**
  21635. * Creates a ground mesh.
  21636. * Please consider using the same method from the MeshBuilder class instead
  21637. * @param name defines the name of the mesh to create
  21638. * @param width set the width of the ground
  21639. * @param height set the height of the ground
  21640. * @param subdivisions sets the number of subdivisions per side
  21641. * @param scene defines the hosting scene
  21642. * @param updatable defines if the mesh must be flagged as updatable
  21643. * @returns a new Mesh
  21644. */
  21645. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21646. /**
  21647. * Creates a tiled ground mesh.
  21648. * Please consider using the same method from the MeshBuilder class instead
  21649. * @param name defines the name of the mesh to create
  21650. * @param xmin set the ground minimum X coordinate
  21651. * @param zmin set the ground minimum Y coordinate
  21652. * @param xmax set the ground maximum X coordinate
  21653. * @param zmax set the ground maximum Z coordinate
  21654. * @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
  21655. * @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
  21656. * @param scene defines the hosting scene
  21657. * @param updatable defines if the mesh must be flagged as updatable
  21658. * @returns a new Mesh
  21659. */
  21660. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21661. w: number;
  21662. h: number;
  21663. }, precision: {
  21664. w: number;
  21665. h: number;
  21666. }, scene: Scene, updatable?: boolean): Mesh;
  21667. /**
  21668. * Creates a ground mesh from a height map.
  21669. * Please consider using the same method from the MeshBuilder class instead
  21670. * @see http://doc.babylonjs.com/babylon101/height_map
  21671. * @param name defines the name of the mesh to create
  21672. * @param url sets the URL of the height map image resource
  21673. * @param width set the ground width size
  21674. * @param height set the ground height size
  21675. * @param subdivisions sets the number of subdivision per side
  21676. * @param minHeight is the minimum altitude on the ground
  21677. * @param maxHeight is the maximum altitude on the ground
  21678. * @param scene defines the hosting scene
  21679. * @param updatable defines if the mesh must be flagged as updatable
  21680. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21681. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21682. * @returns a new Mesh
  21683. */
  21684. 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;
  21685. /**
  21686. * Creates a tube mesh.
  21687. * The tube is a parametric shape.
  21688. * It has no predefined shape. Its final shape will depend on the input parameters.
  21689. * Please consider using the same method from the MeshBuilder class instead
  21690. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21691. * @param name defines the name of the mesh to create
  21692. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21693. * @param radius sets the tube radius size
  21694. * @param tessellation is the number of sides on the tubular surface
  21695. * @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
  21696. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  21697. * @param scene defines the hosting scene
  21698. * @param updatable defines if the mesh must be flagged as updatable
  21699. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21700. * @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)
  21701. * @returns a new Mesh
  21702. */
  21703. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21704. (i: number, distance: number): number;
  21705. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21706. /**
  21707. * Creates a polyhedron mesh.
  21708. * Please consider using the same method from the MeshBuilder class instead.
  21709. * * 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
  21710. * * The parameter `size` (positive float, default 1) sets the polygon size
  21711. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21712. * * 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`
  21713. * * 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
  21714. * * 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)`)
  21715. * * 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
  21716. * * 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
  21717. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21718. * * 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
  21719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21720. * @param name defines the name of the mesh to create
  21721. * @param options defines the options used to create the mesh
  21722. * @param scene defines the hosting scene
  21723. * @returns a new Mesh
  21724. */
  21725. static CreatePolyhedron(name: string, options: {
  21726. type?: number;
  21727. size?: number;
  21728. sizeX?: number;
  21729. sizeY?: number;
  21730. sizeZ?: number;
  21731. custom?: any;
  21732. faceUV?: Vector4[];
  21733. faceColors?: Color4[];
  21734. updatable?: boolean;
  21735. sideOrientation?: number;
  21736. }, scene: Scene): Mesh;
  21737. /**
  21738. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21739. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21740. * * 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`)
  21741. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21742. * * 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
  21743. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21744. * * 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
  21745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21746. * @param name defines the name of the mesh
  21747. * @param options defines the options used to create the mesh
  21748. * @param scene defines the hosting scene
  21749. * @returns a new Mesh
  21750. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21751. */
  21752. static CreateIcoSphere(name: string, options: {
  21753. radius?: number;
  21754. flat?: boolean;
  21755. subdivisions?: number;
  21756. sideOrientation?: number;
  21757. updatable?: boolean;
  21758. }, scene: Scene): Mesh;
  21759. /**
  21760. * Creates a decal mesh.
  21761. * Please consider using the same method from the MeshBuilder class instead.
  21762. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21763. * @param name defines the name of the mesh
  21764. * @param sourceMesh defines the mesh receiving the decal
  21765. * @param position sets the position of the decal in world coordinates
  21766. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21767. * @param size sets the decal scaling
  21768. * @param angle sets the angle to rotate the decal
  21769. * @returns a new Mesh
  21770. */
  21771. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21772. /**
  21773. * Prepare internal position array for software CPU skinning
  21774. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21775. */
  21776. setPositionsForCPUSkinning(): Float32Array;
  21777. /**
  21778. * Prepare internal normal array for software CPU skinning
  21779. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21780. */
  21781. setNormalsForCPUSkinning(): Float32Array;
  21782. /**
  21783. * Updates the vertex buffer by applying transformation from the bones
  21784. * @param skeleton defines the skeleton to apply to current mesh
  21785. * @returns the current mesh
  21786. */
  21787. applySkeleton(skeleton: Skeleton): Mesh;
  21788. /**
  21789. * 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
  21790. * @param meshes defines the list of meshes to scan
  21791. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21792. */
  21793. static MinMax(meshes: AbstractMesh[]): {
  21794. min: Vector3;
  21795. max: Vector3;
  21796. };
  21797. /**
  21798. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21799. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21800. * @returns a vector3
  21801. */
  21802. static Center(meshesOrMinMaxVector: {
  21803. min: Vector3;
  21804. max: Vector3;
  21805. } | AbstractMesh[]): Vector3;
  21806. /**
  21807. * Merge the array of meshes into a single mesh for performance reasons.
  21808. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21809. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21810. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21811. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21812. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21813. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21814. * @returns a new mesh
  21815. */
  21816. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21817. /** @hidden */
  21818. addInstance(instance: InstancedMesh): void;
  21819. /** @hidden */
  21820. removeInstance(instance: InstancedMesh): void;
  21821. }
  21822. }
  21823. declare module BABYLON {
  21824. /**
  21825. * Base class for the main features of a material in Babylon.js
  21826. */
  21827. export class Material implements IAnimatable {
  21828. /**
  21829. * Returns the triangle fill mode
  21830. */
  21831. static readonly TriangleFillMode: number;
  21832. /**
  21833. * Returns the wireframe mode
  21834. */
  21835. static readonly WireFrameFillMode: number;
  21836. /**
  21837. * Returns the point fill mode
  21838. */
  21839. static readonly PointFillMode: number;
  21840. /**
  21841. * Returns the point list draw mode
  21842. */
  21843. static readonly PointListDrawMode: number;
  21844. /**
  21845. * Returns the line list draw mode
  21846. */
  21847. static readonly LineListDrawMode: number;
  21848. /**
  21849. * Returns the line loop draw mode
  21850. */
  21851. static readonly LineLoopDrawMode: number;
  21852. /**
  21853. * Returns the line strip draw mode
  21854. */
  21855. static readonly LineStripDrawMode: number;
  21856. /**
  21857. * Returns the triangle strip draw mode
  21858. */
  21859. static readonly TriangleStripDrawMode: number;
  21860. /**
  21861. * Returns the triangle fan draw mode
  21862. */
  21863. static readonly TriangleFanDrawMode: number;
  21864. /**
  21865. * Stores the clock-wise side orientation
  21866. */
  21867. static readonly ClockWiseSideOrientation: number;
  21868. /**
  21869. * Stores the counter clock-wise side orientation
  21870. */
  21871. static readonly CounterClockWiseSideOrientation: number;
  21872. /**
  21873. * The dirty texture flag value
  21874. */
  21875. static readonly TextureDirtyFlag: number;
  21876. /**
  21877. * The dirty light flag value
  21878. */
  21879. static readonly LightDirtyFlag: number;
  21880. /**
  21881. * The dirty fresnel flag value
  21882. */
  21883. static readonly FresnelDirtyFlag: number;
  21884. /**
  21885. * The dirty attribute flag value
  21886. */
  21887. static readonly AttributesDirtyFlag: number;
  21888. /**
  21889. * The dirty misc flag value
  21890. */
  21891. static readonly MiscDirtyFlag: number;
  21892. /**
  21893. * The all dirty flag value
  21894. */
  21895. static readonly AllDirtyFlag: number;
  21896. /**
  21897. * The ID of the material
  21898. */
  21899. id: string;
  21900. /**
  21901. * Gets or sets the unique id of the material
  21902. */
  21903. uniqueId: number;
  21904. /**
  21905. * The name of the material
  21906. */
  21907. name: string;
  21908. /**
  21909. * Gets or sets user defined metadata
  21910. */
  21911. metadata: any;
  21912. /**
  21913. * For internal use only. Please do not use.
  21914. */
  21915. reservedDataStore: any;
  21916. /**
  21917. * Specifies if the ready state should be checked on each call
  21918. */
  21919. checkReadyOnEveryCall: boolean;
  21920. /**
  21921. * Specifies if the ready state should be checked once
  21922. */
  21923. checkReadyOnlyOnce: boolean;
  21924. /**
  21925. * The state of the material
  21926. */
  21927. state: string;
  21928. /**
  21929. * The alpha value of the material
  21930. */
  21931. protected _alpha: number;
  21932. /**
  21933. * List of inspectable custom properties (used by the Inspector)
  21934. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21935. */
  21936. inspectableCustomProperties: IInspectable[];
  21937. /**
  21938. * Sets the alpha value of the material
  21939. */
  21940. /**
  21941. * Gets the alpha value of the material
  21942. */
  21943. alpha: number;
  21944. /**
  21945. * Specifies if back face culling is enabled
  21946. */
  21947. protected _backFaceCulling: boolean;
  21948. /**
  21949. * Sets the back-face culling state
  21950. */
  21951. /**
  21952. * Gets the back-face culling state
  21953. */
  21954. backFaceCulling: boolean;
  21955. /**
  21956. * Stores the value for side orientation
  21957. */
  21958. sideOrientation: number;
  21959. /**
  21960. * Callback triggered when the material is compiled
  21961. */
  21962. onCompiled: Nullable<(effect: Effect) => void>;
  21963. /**
  21964. * Callback triggered when an error occurs
  21965. */
  21966. onError: Nullable<(effect: Effect, errors: string) => void>;
  21967. /**
  21968. * Callback triggered to get the render target textures
  21969. */
  21970. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21971. /**
  21972. * Gets a boolean indicating that current material needs to register RTT
  21973. */
  21974. readonly hasRenderTargetTextures: boolean;
  21975. /**
  21976. * Specifies if the material should be serialized
  21977. */
  21978. doNotSerialize: boolean;
  21979. /**
  21980. * @hidden
  21981. */
  21982. _storeEffectOnSubMeshes: boolean;
  21983. /**
  21984. * Stores the animations for the material
  21985. */
  21986. animations: Nullable<Array<Animation>>;
  21987. /**
  21988. * An event triggered when the material is disposed
  21989. */
  21990. onDisposeObservable: Observable<Material>;
  21991. /**
  21992. * An observer which watches for dispose events
  21993. */
  21994. private _onDisposeObserver;
  21995. private _onUnBindObservable;
  21996. /**
  21997. * Called during a dispose event
  21998. */
  21999. onDispose: () => void;
  22000. private _onBindObservable;
  22001. /**
  22002. * An event triggered when the material is bound
  22003. */
  22004. readonly onBindObservable: Observable<AbstractMesh>;
  22005. /**
  22006. * An observer which watches for bind events
  22007. */
  22008. private _onBindObserver;
  22009. /**
  22010. * Called during a bind event
  22011. */
  22012. onBind: (Mesh: AbstractMesh) => void;
  22013. /**
  22014. * An event triggered when the material is unbound
  22015. */
  22016. readonly onUnBindObservable: Observable<Material>;
  22017. /**
  22018. * Stores the value of the alpha mode
  22019. */
  22020. private _alphaMode;
  22021. /**
  22022. * Sets the value of the alpha mode.
  22023. *
  22024. * | Value | Type | Description |
  22025. * | --- | --- | --- |
  22026. * | 0 | ALPHA_DISABLE | |
  22027. * | 1 | ALPHA_ADD | |
  22028. * | 2 | ALPHA_COMBINE | |
  22029. * | 3 | ALPHA_SUBTRACT | |
  22030. * | 4 | ALPHA_MULTIPLY | |
  22031. * | 5 | ALPHA_MAXIMIZED | |
  22032. * | 6 | ALPHA_ONEONE | |
  22033. * | 7 | ALPHA_PREMULTIPLIED | |
  22034. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22035. * | 9 | ALPHA_INTERPOLATE | |
  22036. * | 10 | ALPHA_SCREENMODE | |
  22037. *
  22038. */
  22039. /**
  22040. * Gets the value of the alpha mode
  22041. */
  22042. alphaMode: number;
  22043. /**
  22044. * Stores the state of the need depth pre-pass value
  22045. */
  22046. private _needDepthPrePass;
  22047. /**
  22048. * Sets the need depth pre-pass value
  22049. */
  22050. /**
  22051. * Gets the depth pre-pass value
  22052. */
  22053. needDepthPrePass: boolean;
  22054. /**
  22055. * Specifies if depth writing should be disabled
  22056. */
  22057. disableDepthWrite: boolean;
  22058. /**
  22059. * Specifies if depth writing should be forced
  22060. */
  22061. forceDepthWrite: boolean;
  22062. /**
  22063. * Specifies if there should be a separate pass for culling
  22064. */
  22065. separateCullingPass: boolean;
  22066. /**
  22067. * Stores the state specifing if fog should be enabled
  22068. */
  22069. private _fogEnabled;
  22070. /**
  22071. * Sets the state for enabling fog
  22072. */
  22073. /**
  22074. * Gets the value of the fog enabled state
  22075. */
  22076. fogEnabled: boolean;
  22077. /**
  22078. * Stores the size of points
  22079. */
  22080. pointSize: number;
  22081. /**
  22082. * Stores the z offset value
  22083. */
  22084. zOffset: number;
  22085. /**
  22086. * Gets a value specifying if wireframe mode is enabled
  22087. */
  22088. /**
  22089. * Sets the state of wireframe mode
  22090. */
  22091. wireframe: boolean;
  22092. /**
  22093. * Gets the value specifying if point clouds are enabled
  22094. */
  22095. /**
  22096. * Sets the state of point cloud mode
  22097. */
  22098. pointsCloud: boolean;
  22099. /**
  22100. * Gets the material fill mode
  22101. */
  22102. /**
  22103. * Sets the material fill mode
  22104. */
  22105. fillMode: number;
  22106. /**
  22107. * @hidden
  22108. * Stores the effects for the material
  22109. */
  22110. _effect: Nullable<Effect>;
  22111. /**
  22112. * @hidden
  22113. * Specifies if the material was previously ready
  22114. */
  22115. _wasPreviouslyReady: boolean;
  22116. /**
  22117. * Specifies if uniform buffers should be used
  22118. */
  22119. private _useUBO;
  22120. /**
  22121. * Stores a reference to the scene
  22122. */
  22123. private _scene;
  22124. /**
  22125. * Stores the fill mode state
  22126. */
  22127. private _fillMode;
  22128. /**
  22129. * Specifies if the depth write state should be cached
  22130. */
  22131. private _cachedDepthWriteState;
  22132. /**
  22133. * Stores the uniform buffer
  22134. */
  22135. protected _uniformBuffer: UniformBuffer;
  22136. /** @hidden */
  22137. _indexInSceneMaterialArray: number;
  22138. /** @hidden */
  22139. meshMap: Nullable<{
  22140. [id: string]: AbstractMesh | undefined;
  22141. }>;
  22142. /**
  22143. * Creates a material instance
  22144. * @param name defines the name of the material
  22145. * @param scene defines the scene to reference
  22146. * @param doNotAdd specifies if the material should be added to the scene
  22147. */
  22148. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22149. /**
  22150. * Returns a string representation of the current material
  22151. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22152. * @returns a string with material information
  22153. */
  22154. toString(fullDetails?: boolean): string;
  22155. /**
  22156. * Gets the class name of the material
  22157. * @returns a string with the class name of the material
  22158. */
  22159. getClassName(): string;
  22160. /**
  22161. * Specifies if updates for the material been locked
  22162. */
  22163. readonly isFrozen: boolean;
  22164. /**
  22165. * Locks updates for the material
  22166. */
  22167. freeze(): void;
  22168. /**
  22169. * Unlocks updates for the material
  22170. */
  22171. unfreeze(): void;
  22172. /**
  22173. * Specifies if the material is ready to be used
  22174. * @param mesh defines the mesh to check
  22175. * @param useInstances specifies if instances should be used
  22176. * @returns a boolean indicating if the material is ready to be used
  22177. */
  22178. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22179. /**
  22180. * Specifies that the submesh is ready to be used
  22181. * @param mesh defines the mesh to check
  22182. * @param subMesh defines which submesh to check
  22183. * @param useInstances specifies that instances should be used
  22184. * @returns a boolean indicating that the submesh is ready or not
  22185. */
  22186. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22187. /**
  22188. * Returns the material effect
  22189. * @returns the effect associated with the material
  22190. */
  22191. getEffect(): Nullable<Effect>;
  22192. /**
  22193. * Returns the current scene
  22194. * @returns a Scene
  22195. */
  22196. getScene(): Scene;
  22197. /**
  22198. * Specifies if the material will require alpha blending
  22199. * @returns a boolean specifying if alpha blending is needed
  22200. */
  22201. needAlphaBlending(): boolean;
  22202. /**
  22203. * Specifies if the mesh will require alpha blending
  22204. * @param mesh defines the mesh to check
  22205. * @returns a boolean specifying if alpha blending is needed for the mesh
  22206. */
  22207. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22208. /**
  22209. * Specifies if this material should be rendered in alpha test mode
  22210. * @returns a boolean specifying if an alpha test is needed.
  22211. */
  22212. needAlphaTesting(): boolean;
  22213. /**
  22214. * Gets the texture used for the alpha test
  22215. * @returns the texture to use for alpha testing
  22216. */
  22217. getAlphaTestTexture(): Nullable<BaseTexture>;
  22218. /**
  22219. * Marks the material to indicate that it needs to be re-calculated
  22220. */
  22221. markDirty(): void;
  22222. /** @hidden */
  22223. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22224. /**
  22225. * Binds the material to the mesh
  22226. * @param world defines the world transformation matrix
  22227. * @param mesh defines the mesh to bind the material to
  22228. */
  22229. bind(world: Matrix, mesh?: Mesh): void;
  22230. /**
  22231. * Binds the submesh to the material
  22232. * @param world defines the world transformation matrix
  22233. * @param mesh defines the mesh containing the submesh
  22234. * @param subMesh defines the submesh to bind the material to
  22235. */
  22236. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22237. /**
  22238. * Binds the world matrix to the material
  22239. * @param world defines the world transformation matrix
  22240. */
  22241. bindOnlyWorldMatrix(world: Matrix): void;
  22242. /**
  22243. * Binds the scene's uniform buffer to the effect.
  22244. * @param effect defines the effect to bind to the scene uniform buffer
  22245. * @param sceneUbo defines the uniform buffer storing scene data
  22246. */
  22247. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22248. /**
  22249. * Binds the view matrix to the effect
  22250. * @param effect defines the effect to bind the view matrix to
  22251. */
  22252. bindView(effect: Effect): void;
  22253. /**
  22254. * Binds the view projection matrix to the effect
  22255. * @param effect defines the effect to bind the view projection matrix to
  22256. */
  22257. bindViewProjection(effect: Effect): void;
  22258. /**
  22259. * Specifies if material alpha testing should be turned on for the mesh
  22260. * @param mesh defines the mesh to check
  22261. */
  22262. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22263. /**
  22264. * Processes to execute after binding the material to a mesh
  22265. * @param mesh defines the rendered mesh
  22266. */
  22267. protected _afterBind(mesh?: Mesh): void;
  22268. /**
  22269. * Unbinds the material from the mesh
  22270. */
  22271. unbind(): void;
  22272. /**
  22273. * Gets the active textures from the material
  22274. * @returns an array of textures
  22275. */
  22276. getActiveTextures(): BaseTexture[];
  22277. /**
  22278. * Specifies if the material uses a texture
  22279. * @param texture defines the texture to check against the material
  22280. * @returns a boolean specifying if the material uses the texture
  22281. */
  22282. hasTexture(texture: BaseTexture): boolean;
  22283. /**
  22284. * Makes a duplicate of the material, and gives it a new name
  22285. * @param name defines the new name for the duplicated material
  22286. * @returns the cloned material
  22287. */
  22288. clone(name: string): Nullable<Material>;
  22289. /**
  22290. * Gets the meshes bound to the material
  22291. * @returns an array of meshes bound to the material
  22292. */
  22293. getBindedMeshes(): AbstractMesh[];
  22294. /**
  22295. * Force shader compilation
  22296. * @param mesh defines the mesh associated with this material
  22297. * @param onCompiled defines a function to execute once the material is compiled
  22298. * @param options defines the options to configure the compilation
  22299. */
  22300. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22301. clipPlane: boolean;
  22302. }>): void;
  22303. /**
  22304. * Force shader compilation
  22305. * @param mesh defines the mesh that will use this material
  22306. * @param options defines additional options for compiling the shaders
  22307. * @returns a promise that resolves when the compilation completes
  22308. */
  22309. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22310. clipPlane: boolean;
  22311. }>): Promise<void>;
  22312. private static readonly _ImageProcessingDirtyCallBack;
  22313. private static readonly _TextureDirtyCallBack;
  22314. private static readonly _FresnelDirtyCallBack;
  22315. private static readonly _MiscDirtyCallBack;
  22316. private static readonly _LightsDirtyCallBack;
  22317. private static readonly _AttributeDirtyCallBack;
  22318. private static _FresnelAndMiscDirtyCallBack;
  22319. private static _TextureAndMiscDirtyCallBack;
  22320. private static readonly _DirtyCallbackArray;
  22321. private static readonly _RunDirtyCallBacks;
  22322. /**
  22323. * Marks a define in the material to indicate that it needs to be re-computed
  22324. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22325. */
  22326. markAsDirty(flag: number): void;
  22327. /**
  22328. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22329. * @param func defines a function which checks material defines against the submeshes
  22330. */
  22331. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22332. /**
  22333. * Indicates that image processing needs to be re-calculated for all submeshes
  22334. */
  22335. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22336. /**
  22337. * Indicates that textures need to be re-calculated for all submeshes
  22338. */
  22339. protected _markAllSubMeshesAsTexturesDirty(): void;
  22340. /**
  22341. * Indicates that fresnel needs to be re-calculated for all submeshes
  22342. */
  22343. protected _markAllSubMeshesAsFresnelDirty(): void;
  22344. /**
  22345. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22346. */
  22347. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22348. /**
  22349. * Indicates that lights need to be re-calculated for all submeshes
  22350. */
  22351. protected _markAllSubMeshesAsLightsDirty(): void;
  22352. /**
  22353. * Indicates that attributes need to be re-calculated for all submeshes
  22354. */
  22355. protected _markAllSubMeshesAsAttributesDirty(): void;
  22356. /**
  22357. * Indicates that misc needs to be re-calculated for all submeshes
  22358. */
  22359. protected _markAllSubMeshesAsMiscDirty(): void;
  22360. /**
  22361. * Indicates that textures and misc need to be re-calculated for all submeshes
  22362. */
  22363. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22364. /**
  22365. * Disposes the material
  22366. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22367. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22368. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22369. */
  22370. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22371. /** @hidden */
  22372. private releaseVertexArrayObject;
  22373. /**
  22374. * Serializes this material
  22375. * @returns the serialized material object
  22376. */
  22377. serialize(): any;
  22378. /**
  22379. * Creates a material from parsed material data
  22380. * @param parsedMaterial defines parsed material data
  22381. * @param scene defines the hosting scene
  22382. * @param rootUrl defines the root URL to use to load textures
  22383. * @returns a new material
  22384. */
  22385. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22386. }
  22387. }
  22388. declare module BABYLON {
  22389. /**
  22390. * Base class for submeshes
  22391. */
  22392. export class BaseSubMesh {
  22393. /** @hidden */
  22394. _materialDefines: Nullable<MaterialDefines>;
  22395. /** @hidden */
  22396. _materialEffect: Nullable<Effect>;
  22397. /**
  22398. * Gets associated effect
  22399. */
  22400. readonly effect: Nullable<Effect>;
  22401. /**
  22402. * Sets associated effect (effect used to render this submesh)
  22403. * @param effect defines the effect to associate with
  22404. * @param defines defines the set of defines used to compile this effect
  22405. */
  22406. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22407. }
  22408. /**
  22409. * Defines a subdivision inside a mesh
  22410. */
  22411. export class SubMesh extends BaseSubMesh implements ICullable {
  22412. /** the material index to use */
  22413. materialIndex: number;
  22414. /** vertex index start */
  22415. verticesStart: number;
  22416. /** vertices count */
  22417. verticesCount: number;
  22418. /** index start */
  22419. indexStart: number;
  22420. /** indices count */
  22421. indexCount: number;
  22422. /** @hidden */
  22423. _linesIndexCount: number;
  22424. private _mesh;
  22425. private _renderingMesh;
  22426. private _boundingInfo;
  22427. private _linesIndexBuffer;
  22428. /** @hidden */
  22429. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22430. /** @hidden */
  22431. _trianglePlanes: Plane[];
  22432. /** @hidden */
  22433. _lastColliderTransformMatrix: Nullable<Matrix>;
  22434. /** @hidden */
  22435. _renderId: number;
  22436. /** @hidden */
  22437. _alphaIndex: number;
  22438. /** @hidden */
  22439. _distanceToCamera: number;
  22440. /** @hidden */
  22441. _id: number;
  22442. private _currentMaterial;
  22443. /**
  22444. * Add a new submesh to a mesh
  22445. * @param materialIndex defines the material index to use
  22446. * @param verticesStart defines vertex index start
  22447. * @param verticesCount defines vertices count
  22448. * @param indexStart defines index start
  22449. * @param indexCount defines indices count
  22450. * @param mesh defines the parent mesh
  22451. * @param renderingMesh defines an optional rendering mesh
  22452. * @param createBoundingBox defines if bounding box should be created for this submesh
  22453. * @returns the new submesh
  22454. */
  22455. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22456. /**
  22457. * Creates a new submesh
  22458. * @param materialIndex defines the material index to use
  22459. * @param verticesStart defines vertex index start
  22460. * @param verticesCount defines vertices count
  22461. * @param indexStart defines index start
  22462. * @param indexCount defines indices count
  22463. * @param mesh defines the parent mesh
  22464. * @param renderingMesh defines an optional rendering mesh
  22465. * @param createBoundingBox defines if bounding box should be created for this submesh
  22466. */
  22467. constructor(
  22468. /** the material index to use */
  22469. materialIndex: number,
  22470. /** vertex index start */
  22471. verticesStart: number,
  22472. /** vertices count */
  22473. verticesCount: number,
  22474. /** index start */
  22475. indexStart: number,
  22476. /** indices count */
  22477. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22478. /**
  22479. * Returns true if this submesh covers the entire parent mesh
  22480. * @ignorenaming
  22481. */
  22482. readonly IsGlobal: boolean;
  22483. /**
  22484. * Returns the submesh BoudingInfo object
  22485. * @returns current bounding info (or mesh's one if the submesh is global)
  22486. */
  22487. getBoundingInfo(): BoundingInfo;
  22488. /**
  22489. * Sets the submesh BoundingInfo
  22490. * @param boundingInfo defines the new bounding info to use
  22491. * @returns the SubMesh
  22492. */
  22493. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22494. /**
  22495. * Returns the mesh of the current submesh
  22496. * @return the parent mesh
  22497. */
  22498. getMesh(): AbstractMesh;
  22499. /**
  22500. * Returns the rendering mesh of the submesh
  22501. * @returns the rendering mesh (could be different from parent mesh)
  22502. */
  22503. getRenderingMesh(): Mesh;
  22504. /**
  22505. * Returns the submesh material
  22506. * @returns null or the current material
  22507. */
  22508. getMaterial(): Nullable<Material>;
  22509. /**
  22510. * Sets a new updated BoundingInfo object to the submesh
  22511. * @param data defines an optional position array to use to determine the bounding info
  22512. * @returns the SubMesh
  22513. */
  22514. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22515. /** @hidden */
  22516. _checkCollision(collider: Collider): boolean;
  22517. /**
  22518. * Updates the submesh BoundingInfo
  22519. * @param world defines the world matrix to use to update the bounding info
  22520. * @returns the submesh
  22521. */
  22522. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22523. /**
  22524. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22525. * @param frustumPlanes defines the frustum planes
  22526. * @returns true if the submesh is intersecting with the frustum
  22527. */
  22528. isInFrustum(frustumPlanes: Plane[]): boolean;
  22529. /**
  22530. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22531. * @param frustumPlanes defines the frustum planes
  22532. * @returns true if the submesh is inside the frustum
  22533. */
  22534. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22535. /**
  22536. * Renders the submesh
  22537. * @param enableAlphaMode defines if alpha needs to be used
  22538. * @returns the submesh
  22539. */
  22540. render(enableAlphaMode: boolean): SubMesh;
  22541. /**
  22542. * @hidden
  22543. */
  22544. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22545. /**
  22546. * Checks if the submesh intersects with a ray
  22547. * @param ray defines the ray to test
  22548. * @returns true is the passed ray intersects the submesh bounding box
  22549. */
  22550. canIntersects(ray: Ray): boolean;
  22551. /**
  22552. * Intersects current submesh with a ray
  22553. * @param ray defines the ray to test
  22554. * @param positions defines mesh's positions array
  22555. * @param indices defines mesh's indices array
  22556. * @param fastCheck defines if only bounding info should be used
  22557. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22558. * @returns intersection info or null if no intersection
  22559. */
  22560. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22561. /** @hidden */
  22562. private _intersectLines;
  22563. /** @hidden */
  22564. private _intersectUnIndexedLines;
  22565. /** @hidden */
  22566. private _intersectTriangles;
  22567. /** @hidden */
  22568. private _intersectUnIndexedTriangles;
  22569. /** @hidden */
  22570. _rebuild(): void;
  22571. /**
  22572. * Creates a new submesh from the passed mesh
  22573. * @param newMesh defines the new hosting mesh
  22574. * @param newRenderingMesh defines an optional rendering mesh
  22575. * @returns the new submesh
  22576. */
  22577. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22578. /**
  22579. * Release associated resources
  22580. */
  22581. dispose(): void;
  22582. /**
  22583. * Gets the class name
  22584. * @returns the string "SubMesh".
  22585. */
  22586. getClassName(): string;
  22587. /**
  22588. * Creates a new submesh from indices data
  22589. * @param materialIndex the index of the main mesh material
  22590. * @param startIndex the index where to start the copy in the mesh indices array
  22591. * @param indexCount the number of indices to copy then from the startIndex
  22592. * @param mesh the main mesh to create the submesh from
  22593. * @param renderingMesh the optional rendering mesh
  22594. * @returns a new submesh
  22595. */
  22596. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22597. }
  22598. }
  22599. declare module BABYLON {
  22600. /**
  22601. * Class used to store geometry data (vertex buffers + index buffer)
  22602. */
  22603. export class Geometry implements IGetSetVerticesData {
  22604. /**
  22605. * Gets or sets the ID of the geometry
  22606. */
  22607. id: string;
  22608. /**
  22609. * Gets or sets the unique ID of the geometry
  22610. */
  22611. uniqueId: number;
  22612. /**
  22613. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22614. */
  22615. delayLoadState: number;
  22616. /**
  22617. * Gets the file containing the data to load when running in delay load state
  22618. */
  22619. delayLoadingFile: Nullable<string>;
  22620. /**
  22621. * Callback called when the geometry is updated
  22622. */
  22623. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22624. private _scene;
  22625. private _engine;
  22626. private _meshes;
  22627. private _totalVertices;
  22628. /** @hidden */
  22629. _indices: IndicesArray;
  22630. /** @hidden */
  22631. _vertexBuffers: {
  22632. [key: string]: VertexBuffer;
  22633. };
  22634. private _isDisposed;
  22635. private _extend;
  22636. private _boundingBias;
  22637. /** @hidden */
  22638. _delayInfo: Array<string>;
  22639. private _indexBuffer;
  22640. private _indexBufferIsUpdatable;
  22641. /** @hidden */
  22642. _boundingInfo: Nullable<BoundingInfo>;
  22643. /** @hidden */
  22644. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22645. /** @hidden */
  22646. _softwareSkinningFrameId: number;
  22647. private _vertexArrayObjects;
  22648. private _updatable;
  22649. /** @hidden */
  22650. _positions: Nullable<Vector3[]>;
  22651. /**
  22652. * 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
  22653. */
  22654. /**
  22655. * 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
  22656. */
  22657. boundingBias: Vector2;
  22658. /**
  22659. * Static function used to attach a new empty geometry to a mesh
  22660. * @param mesh defines the mesh to attach the geometry to
  22661. * @returns the new Geometry
  22662. */
  22663. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22664. /**
  22665. * Creates a new geometry
  22666. * @param id defines the unique ID
  22667. * @param scene defines the hosting scene
  22668. * @param vertexData defines the VertexData used to get geometry data
  22669. * @param updatable defines if geometry must be updatable (false by default)
  22670. * @param mesh defines the mesh that will be associated with the geometry
  22671. */
  22672. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22673. /**
  22674. * Gets the current extend of the geometry
  22675. */
  22676. readonly extend: {
  22677. minimum: Vector3;
  22678. maximum: Vector3;
  22679. };
  22680. /**
  22681. * Gets the hosting scene
  22682. * @returns the hosting Scene
  22683. */
  22684. getScene(): Scene;
  22685. /**
  22686. * Gets the hosting engine
  22687. * @returns the hosting Engine
  22688. */
  22689. getEngine(): Engine;
  22690. /**
  22691. * Defines if the geometry is ready to use
  22692. * @returns true if the geometry is ready to be used
  22693. */
  22694. isReady(): boolean;
  22695. /**
  22696. * Gets a value indicating that the geometry should not be serialized
  22697. */
  22698. readonly doNotSerialize: boolean;
  22699. /** @hidden */
  22700. _rebuild(): void;
  22701. /**
  22702. * Affects all geometry data in one call
  22703. * @param vertexData defines the geometry data
  22704. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22705. */
  22706. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22707. /**
  22708. * Set specific vertex data
  22709. * @param kind defines the data kind (Position, normal, etc...)
  22710. * @param data defines the vertex data to use
  22711. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22712. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22713. */
  22714. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22715. /**
  22716. * Removes a specific vertex data
  22717. * @param kind defines the data kind (Position, normal, etc...)
  22718. */
  22719. removeVerticesData(kind: string): void;
  22720. /**
  22721. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22722. * @param buffer defines the vertex buffer to use
  22723. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22724. */
  22725. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22726. /**
  22727. * Update a specific vertex buffer
  22728. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22729. * It will do nothing if the buffer is not updatable
  22730. * @param kind defines the data kind (Position, normal, etc...)
  22731. * @param data defines the data to use
  22732. * @param offset defines the offset in the target buffer where to store the data
  22733. * @param useBytes set to true if the offset is in bytes
  22734. */
  22735. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22736. /**
  22737. * Update a specific vertex buffer
  22738. * This function will create a new buffer if the current one is not updatable
  22739. * @param kind defines the data kind (Position, normal, etc...)
  22740. * @param data defines the data to use
  22741. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22742. */
  22743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22744. private _updateBoundingInfo;
  22745. /** @hidden */
  22746. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22747. /**
  22748. * Gets total number of vertices
  22749. * @returns the total number of vertices
  22750. */
  22751. getTotalVertices(): number;
  22752. /**
  22753. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22754. * @param kind defines the data kind (Position, normal, etc...)
  22755. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22756. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22757. * @returns a float array containing vertex data
  22758. */
  22759. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22760. /**
  22761. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22762. * @param kind defines the data kind (Position, normal, etc...)
  22763. * @returns true if the vertex buffer with the specified kind is updatable
  22764. */
  22765. isVertexBufferUpdatable(kind: string): boolean;
  22766. /**
  22767. * Gets a specific vertex buffer
  22768. * @param kind defines the data kind (Position, normal, etc...)
  22769. * @returns a VertexBuffer
  22770. */
  22771. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22772. /**
  22773. * Returns all vertex buffers
  22774. * @return an object holding all vertex buffers indexed by kind
  22775. */
  22776. getVertexBuffers(): Nullable<{
  22777. [key: string]: VertexBuffer;
  22778. }>;
  22779. /**
  22780. * Gets a boolean indicating if specific vertex buffer is present
  22781. * @param kind defines the data kind (Position, normal, etc...)
  22782. * @returns true if data is present
  22783. */
  22784. isVerticesDataPresent(kind: string): boolean;
  22785. /**
  22786. * Gets a list of all attached data kinds (Position, normal, etc...)
  22787. * @returns a list of string containing all kinds
  22788. */
  22789. getVerticesDataKinds(): string[];
  22790. /**
  22791. * Update index buffer
  22792. * @param indices defines the indices to store in the index buffer
  22793. * @param offset defines the offset in the target buffer where to store the data
  22794. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22795. */
  22796. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22797. /**
  22798. * Creates a new index buffer
  22799. * @param indices defines the indices to store in the index buffer
  22800. * @param totalVertices defines the total number of vertices (could be null)
  22801. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22802. */
  22803. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22804. /**
  22805. * Return the total number of indices
  22806. * @returns the total number of indices
  22807. */
  22808. getTotalIndices(): number;
  22809. /**
  22810. * Gets the index buffer array
  22811. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22812. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22813. * @returns the index buffer array
  22814. */
  22815. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22816. /**
  22817. * Gets the index buffer
  22818. * @return the index buffer
  22819. */
  22820. getIndexBuffer(): Nullable<DataBuffer>;
  22821. /** @hidden */
  22822. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22823. /**
  22824. * Release the associated resources for a specific mesh
  22825. * @param mesh defines the source mesh
  22826. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22827. */
  22828. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22829. /**
  22830. * Apply current geometry to a given mesh
  22831. * @param mesh defines the mesh to apply geometry to
  22832. */
  22833. applyToMesh(mesh: Mesh): void;
  22834. private _updateExtend;
  22835. private _applyToMesh;
  22836. private notifyUpdate;
  22837. /**
  22838. * Load the geometry if it was flagged as delay loaded
  22839. * @param scene defines the hosting scene
  22840. * @param onLoaded defines a callback called when the geometry is loaded
  22841. */
  22842. load(scene: Scene, onLoaded?: () => void): void;
  22843. private _queueLoad;
  22844. /**
  22845. * Invert the geometry to move from a right handed system to a left handed one.
  22846. */
  22847. toLeftHanded(): void;
  22848. /** @hidden */
  22849. _resetPointsArrayCache(): void;
  22850. /** @hidden */
  22851. _generatePointsArray(): boolean;
  22852. /**
  22853. * Gets a value indicating if the geometry is disposed
  22854. * @returns true if the geometry was disposed
  22855. */
  22856. isDisposed(): boolean;
  22857. private _disposeVertexArrayObjects;
  22858. /**
  22859. * Free all associated resources
  22860. */
  22861. dispose(): void;
  22862. /**
  22863. * Clone the current geometry into a new geometry
  22864. * @param id defines the unique ID of the new geometry
  22865. * @returns a new geometry object
  22866. */
  22867. copy(id: string): Geometry;
  22868. /**
  22869. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22870. * @return a JSON representation of the current geometry data (without the vertices data)
  22871. */
  22872. serialize(): any;
  22873. private toNumberArray;
  22874. /**
  22875. * Serialize all vertices data into a JSON oject
  22876. * @returns a JSON representation of the current geometry data
  22877. */
  22878. serializeVerticeData(): any;
  22879. /**
  22880. * Extracts a clone of a mesh geometry
  22881. * @param mesh defines the source mesh
  22882. * @param id defines the unique ID of the new geometry object
  22883. * @returns the new geometry object
  22884. */
  22885. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22886. /**
  22887. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22888. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22889. * Be aware Math.random() could cause collisions, but:
  22890. * "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"
  22891. * @returns a string containing a new GUID
  22892. */
  22893. static RandomId(): string;
  22894. /** @hidden */
  22895. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22896. private static _CleanMatricesWeights;
  22897. /**
  22898. * Create a new geometry from persisted data (Using .babylon file format)
  22899. * @param parsedVertexData defines the persisted data
  22900. * @param scene defines the hosting scene
  22901. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22902. * @returns the new geometry object
  22903. */
  22904. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22905. }
  22906. }
  22907. declare module BABYLON {
  22908. /**
  22909. * Define an interface for all classes that will get and set the data on vertices
  22910. */
  22911. export interface IGetSetVerticesData {
  22912. /**
  22913. * Gets a boolean indicating if specific vertex data is present
  22914. * @param kind defines the vertex data kind to use
  22915. * @returns true is data kind is present
  22916. */
  22917. isVerticesDataPresent(kind: string): boolean;
  22918. /**
  22919. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22920. * @param kind defines the data kind (Position, normal, etc...)
  22921. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22922. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22923. * @returns a float array containing vertex data
  22924. */
  22925. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22926. /**
  22927. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22928. * @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.
  22929. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22930. * @returns the indices array or an empty array if the mesh has no geometry
  22931. */
  22932. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22933. /**
  22934. * Set specific vertex data
  22935. * @param kind defines the data kind (Position, normal, etc...)
  22936. * @param data defines the vertex data to use
  22937. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22938. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22939. */
  22940. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22941. /**
  22942. * Update a specific associated vertex buffer
  22943. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22944. * - VertexBuffer.PositionKind
  22945. * - VertexBuffer.UVKind
  22946. * - VertexBuffer.UV2Kind
  22947. * - VertexBuffer.UV3Kind
  22948. * - VertexBuffer.UV4Kind
  22949. * - VertexBuffer.UV5Kind
  22950. * - VertexBuffer.UV6Kind
  22951. * - VertexBuffer.ColorKind
  22952. * - VertexBuffer.MatricesIndicesKind
  22953. * - VertexBuffer.MatricesIndicesExtraKind
  22954. * - VertexBuffer.MatricesWeightsKind
  22955. * - VertexBuffer.MatricesWeightsExtraKind
  22956. * @param data defines the data source
  22957. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22958. * @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)
  22959. */
  22960. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22961. /**
  22962. * Creates a new index buffer
  22963. * @param indices defines the indices to store in the index buffer
  22964. * @param totalVertices defines the total number of vertices (could be null)
  22965. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22966. */
  22967. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22968. }
  22969. /**
  22970. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22971. */
  22972. export class VertexData {
  22973. /**
  22974. * Mesh side orientation : usually the external or front surface
  22975. */
  22976. static readonly FRONTSIDE: number;
  22977. /**
  22978. * Mesh side orientation : usually the internal or back surface
  22979. */
  22980. static readonly BACKSIDE: number;
  22981. /**
  22982. * Mesh side orientation : both internal and external or front and back surfaces
  22983. */
  22984. static readonly DOUBLESIDE: number;
  22985. /**
  22986. * Mesh side orientation : by default, `FRONTSIDE`
  22987. */
  22988. static readonly DEFAULTSIDE: number;
  22989. /**
  22990. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22991. */
  22992. positions: Nullable<FloatArray>;
  22993. /**
  22994. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22995. */
  22996. normals: Nullable<FloatArray>;
  22997. /**
  22998. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22999. */
  23000. tangents: Nullable<FloatArray>;
  23001. /**
  23002. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23003. */
  23004. uvs: Nullable<FloatArray>;
  23005. /**
  23006. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23007. */
  23008. uvs2: Nullable<FloatArray>;
  23009. /**
  23010. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23011. */
  23012. uvs3: Nullable<FloatArray>;
  23013. /**
  23014. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23015. */
  23016. uvs4: Nullable<FloatArray>;
  23017. /**
  23018. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23019. */
  23020. uvs5: Nullable<FloatArray>;
  23021. /**
  23022. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23023. */
  23024. uvs6: Nullable<FloatArray>;
  23025. /**
  23026. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23027. */
  23028. colors: Nullable<FloatArray>;
  23029. /**
  23030. * 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).
  23031. */
  23032. matricesIndices: Nullable<FloatArray>;
  23033. /**
  23034. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23035. */
  23036. matricesWeights: Nullable<FloatArray>;
  23037. /**
  23038. * An array extending the number of possible indices
  23039. */
  23040. matricesIndicesExtra: Nullable<FloatArray>;
  23041. /**
  23042. * An array extending the number of possible weights when the number of indices is extended
  23043. */
  23044. matricesWeightsExtra: Nullable<FloatArray>;
  23045. /**
  23046. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23047. */
  23048. indices: Nullable<IndicesArray>;
  23049. /**
  23050. * Uses the passed data array to set the set the values for the specified kind of data
  23051. * @param data a linear array of floating numbers
  23052. * @param kind the type of data that is being set, eg positions, colors etc
  23053. */
  23054. set(data: FloatArray, kind: string): void;
  23055. /**
  23056. * Associates the vertexData to the passed Mesh.
  23057. * Sets it as updatable or not (default `false`)
  23058. * @param mesh the mesh the vertexData is applied to
  23059. * @param updatable when used and having the value true allows new data to update the vertexData
  23060. * @returns the VertexData
  23061. */
  23062. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23063. /**
  23064. * Associates the vertexData to the passed Geometry.
  23065. * Sets it as updatable or not (default `false`)
  23066. * @param geometry the geometry the vertexData is applied to
  23067. * @param updatable when used and having the value true allows new data to update the vertexData
  23068. * @returns VertexData
  23069. */
  23070. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23071. /**
  23072. * Updates the associated mesh
  23073. * @param mesh the mesh to be updated
  23074. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23075. * @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
  23076. * @returns VertexData
  23077. */
  23078. updateMesh(mesh: Mesh): VertexData;
  23079. /**
  23080. * Updates the associated geometry
  23081. * @param geometry the geometry to be updated
  23082. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23083. * @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
  23084. * @returns VertexData.
  23085. */
  23086. updateGeometry(geometry: Geometry): VertexData;
  23087. private _applyTo;
  23088. private _update;
  23089. /**
  23090. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23091. * @param matrix the transforming matrix
  23092. * @returns the VertexData
  23093. */
  23094. transform(matrix: Matrix): VertexData;
  23095. /**
  23096. * Merges the passed VertexData into the current one
  23097. * @param other the VertexData to be merged into the current one
  23098. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23099. * @returns the modified VertexData
  23100. */
  23101. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23102. private _mergeElement;
  23103. private _validate;
  23104. /**
  23105. * Serializes the VertexData
  23106. * @returns a serialized object
  23107. */
  23108. serialize(): any;
  23109. /**
  23110. * Extracts the vertexData from a mesh
  23111. * @param mesh the mesh from which to extract the VertexData
  23112. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23113. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23114. * @returns the object VertexData associated to the passed mesh
  23115. */
  23116. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23117. /**
  23118. * Extracts the vertexData from the geometry
  23119. * @param geometry the geometry from which to extract the VertexData
  23120. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23121. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23122. * @returns the object VertexData associated to the passed mesh
  23123. */
  23124. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23125. private static _ExtractFrom;
  23126. /**
  23127. * Creates the VertexData for a Ribbon
  23128. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23129. * * pathArray array of paths, each of which an array of successive Vector3
  23130. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23131. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23132. * * 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
  23133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23134. * * 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)
  23135. * * 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)
  23136. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23137. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23138. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23139. * @returns the VertexData of the ribbon
  23140. */
  23141. static CreateRibbon(options: {
  23142. pathArray: Vector3[][];
  23143. closeArray?: boolean;
  23144. closePath?: boolean;
  23145. offset?: number;
  23146. sideOrientation?: number;
  23147. frontUVs?: Vector4;
  23148. backUVs?: Vector4;
  23149. invertUV?: boolean;
  23150. uvs?: Vector2[];
  23151. colors?: Color4[];
  23152. }): VertexData;
  23153. /**
  23154. * Creates the VertexData for a box
  23155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23156. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23157. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23158. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23159. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23160. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23161. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23162. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23163. * * 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)
  23164. * * 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)
  23165. * @returns the VertexData of the box
  23166. */
  23167. static CreateBox(options: {
  23168. size?: number;
  23169. width?: number;
  23170. height?: number;
  23171. depth?: number;
  23172. faceUV?: Vector4[];
  23173. faceColors?: Color4[];
  23174. sideOrientation?: number;
  23175. frontUVs?: Vector4;
  23176. backUVs?: Vector4;
  23177. }): VertexData;
  23178. /**
  23179. * Creates the VertexData for a tiled box
  23180. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23181. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23182. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23183. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23184. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23185. * @returns the VertexData of the box
  23186. */
  23187. static CreateTiledBox(options: {
  23188. pattern?: number;
  23189. width?: number;
  23190. height?: number;
  23191. depth?: number;
  23192. tileSize?: number;
  23193. tileWidth?: number;
  23194. tileHeight?: number;
  23195. alignHorizontal?: number;
  23196. alignVertical?: number;
  23197. faceUV?: Vector4[];
  23198. faceColors?: Color4[];
  23199. sideOrientation?: number;
  23200. }): VertexData;
  23201. /**
  23202. * Creates the VertexData for a tiled plane
  23203. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23204. * * pattern a limited pattern arrangement depending on the number
  23205. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23206. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23207. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23208. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23209. * * 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)
  23210. * * 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)
  23211. * @returns the VertexData of the tiled plane
  23212. */
  23213. static CreateTiledPlane(options: {
  23214. pattern?: number;
  23215. tileSize?: number;
  23216. tileWidth?: number;
  23217. tileHeight?: number;
  23218. size?: number;
  23219. width?: number;
  23220. height?: number;
  23221. alignHorizontal?: number;
  23222. alignVertical?: number;
  23223. sideOrientation?: number;
  23224. frontUVs?: Vector4;
  23225. backUVs?: Vector4;
  23226. }): VertexData;
  23227. /**
  23228. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23229. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23230. * * segments sets the number of horizontal strips optional, default 32
  23231. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23232. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23233. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23234. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23235. * * 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
  23236. * * 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
  23237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23238. * * 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)
  23239. * * 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)
  23240. * @returns the VertexData of the ellipsoid
  23241. */
  23242. static CreateSphere(options: {
  23243. segments?: number;
  23244. diameter?: number;
  23245. diameterX?: number;
  23246. diameterY?: number;
  23247. diameterZ?: number;
  23248. arc?: number;
  23249. slice?: number;
  23250. sideOrientation?: number;
  23251. frontUVs?: Vector4;
  23252. backUVs?: Vector4;
  23253. }): VertexData;
  23254. /**
  23255. * Creates the VertexData for a cylinder, cone or prism
  23256. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23257. * * height sets the height (y direction) of the cylinder, optional, default 2
  23258. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23259. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23260. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23261. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23262. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23263. * * 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
  23264. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23265. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23266. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23267. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23269. * * 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)
  23270. * * 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)
  23271. * @returns the VertexData of the cylinder, cone or prism
  23272. */
  23273. static CreateCylinder(options: {
  23274. height?: number;
  23275. diameterTop?: number;
  23276. diameterBottom?: number;
  23277. diameter?: number;
  23278. tessellation?: number;
  23279. subdivisions?: number;
  23280. arc?: number;
  23281. faceColors?: Color4[];
  23282. faceUV?: Vector4[];
  23283. hasRings?: boolean;
  23284. enclose?: boolean;
  23285. sideOrientation?: number;
  23286. frontUVs?: Vector4;
  23287. backUVs?: Vector4;
  23288. }): VertexData;
  23289. /**
  23290. * Creates the VertexData for a torus
  23291. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23292. * * diameter the diameter of the torus, optional default 1
  23293. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23294. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23296. * * 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)
  23297. * * 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)
  23298. * @returns the VertexData of the torus
  23299. */
  23300. static CreateTorus(options: {
  23301. diameter?: number;
  23302. thickness?: number;
  23303. tessellation?: number;
  23304. sideOrientation?: number;
  23305. frontUVs?: Vector4;
  23306. backUVs?: Vector4;
  23307. }): VertexData;
  23308. /**
  23309. * Creates the VertexData of the LineSystem
  23310. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23311. * - lines an array of lines, each line being an array of successive Vector3
  23312. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23313. * @returns the VertexData of the LineSystem
  23314. */
  23315. static CreateLineSystem(options: {
  23316. lines: Vector3[][];
  23317. colors?: Nullable<Color4[][]>;
  23318. }): VertexData;
  23319. /**
  23320. * Create the VertexData for a DashedLines
  23321. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23322. * - points an array successive Vector3
  23323. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23324. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23325. * - dashNb the intended total number of dashes, optional, default 200
  23326. * @returns the VertexData for the DashedLines
  23327. */
  23328. static CreateDashedLines(options: {
  23329. points: Vector3[];
  23330. dashSize?: number;
  23331. gapSize?: number;
  23332. dashNb?: number;
  23333. }): VertexData;
  23334. /**
  23335. * Creates the VertexData for a Ground
  23336. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23337. * - width the width (x direction) of the ground, optional, default 1
  23338. * - height the height (z direction) of the ground, optional, default 1
  23339. * - subdivisions the number of subdivisions per side, optional, default 1
  23340. * @returns the VertexData of the Ground
  23341. */
  23342. static CreateGround(options: {
  23343. width?: number;
  23344. height?: number;
  23345. subdivisions?: number;
  23346. subdivisionsX?: number;
  23347. subdivisionsY?: number;
  23348. }): VertexData;
  23349. /**
  23350. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23351. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23352. * * xmin the ground minimum X coordinate, optional, default -1
  23353. * * zmin the ground minimum Z coordinate, optional, default -1
  23354. * * xmax the ground maximum X coordinate, optional, default 1
  23355. * * zmax the ground maximum Z coordinate, optional, default 1
  23356. * * 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}
  23357. * * 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}
  23358. * @returns the VertexData of the TiledGround
  23359. */
  23360. static CreateTiledGround(options: {
  23361. xmin: number;
  23362. zmin: number;
  23363. xmax: number;
  23364. zmax: number;
  23365. subdivisions?: {
  23366. w: number;
  23367. h: number;
  23368. };
  23369. precision?: {
  23370. w: number;
  23371. h: number;
  23372. };
  23373. }): VertexData;
  23374. /**
  23375. * Creates the VertexData of the Ground designed from a heightmap
  23376. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23377. * * width the width (x direction) of the ground
  23378. * * height the height (z direction) of the ground
  23379. * * subdivisions the number of subdivisions per side
  23380. * * minHeight the minimum altitude on the ground, optional, default 0
  23381. * * maxHeight the maximum altitude on the ground, optional default 1
  23382. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23383. * * buffer the array holding the image color data
  23384. * * bufferWidth the width of image
  23385. * * bufferHeight the height of image
  23386. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23387. * @returns the VertexData of the Ground designed from a heightmap
  23388. */
  23389. static CreateGroundFromHeightMap(options: {
  23390. width: number;
  23391. height: number;
  23392. subdivisions: number;
  23393. minHeight: number;
  23394. maxHeight: number;
  23395. colorFilter: Color3;
  23396. buffer: Uint8Array;
  23397. bufferWidth: number;
  23398. bufferHeight: number;
  23399. alphaFilter: number;
  23400. }): VertexData;
  23401. /**
  23402. * Creates the VertexData for a Plane
  23403. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23404. * * size sets the width and height of the plane to the value of size, optional default 1
  23405. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23406. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23407. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23408. * * 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)
  23409. * * 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)
  23410. * @returns the VertexData of the box
  23411. */
  23412. static CreatePlane(options: {
  23413. size?: number;
  23414. width?: number;
  23415. height?: number;
  23416. sideOrientation?: number;
  23417. frontUVs?: Vector4;
  23418. backUVs?: Vector4;
  23419. }): VertexData;
  23420. /**
  23421. * Creates the VertexData of the Disc or regular Polygon
  23422. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23423. * * radius the radius of the disc, optional default 0.5
  23424. * * tessellation the number of polygon sides, optional, default 64
  23425. * * 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
  23426. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23427. * * 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)
  23428. * * 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)
  23429. * @returns the VertexData of the box
  23430. */
  23431. static CreateDisc(options: {
  23432. radius?: number;
  23433. tessellation?: number;
  23434. arc?: number;
  23435. sideOrientation?: number;
  23436. frontUVs?: Vector4;
  23437. backUVs?: Vector4;
  23438. }): VertexData;
  23439. /**
  23440. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23441. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23442. * @param polygon a mesh built from polygonTriangulation.build()
  23443. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23444. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23445. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23446. * @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)
  23447. * @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)
  23448. * @returns the VertexData of the Polygon
  23449. */
  23450. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23451. /**
  23452. * Creates the VertexData of the IcoSphere
  23453. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23454. * * radius the radius of the IcoSphere, optional default 1
  23455. * * radiusX allows stretching in the x direction, optional, default radius
  23456. * * radiusY allows stretching in the y direction, optional, default radius
  23457. * * radiusZ allows stretching in the z direction, optional, default radius
  23458. * * flat when true creates a flat shaded mesh, optional, default true
  23459. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23460. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23461. * * 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)
  23462. * * 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)
  23463. * @returns the VertexData of the IcoSphere
  23464. */
  23465. static CreateIcoSphere(options: {
  23466. radius?: number;
  23467. radiusX?: number;
  23468. radiusY?: number;
  23469. radiusZ?: number;
  23470. flat?: boolean;
  23471. subdivisions?: number;
  23472. sideOrientation?: number;
  23473. frontUVs?: Vector4;
  23474. backUVs?: Vector4;
  23475. }): VertexData;
  23476. /**
  23477. * Creates the VertexData for a Polyhedron
  23478. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23479. * * type provided types are:
  23480. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23481. * * 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)
  23482. * * size the size of the IcoSphere, optional default 1
  23483. * * sizeX allows stretching in the x direction, optional, default size
  23484. * * sizeY allows stretching in the y direction, optional, default size
  23485. * * sizeZ allows stretching in the z direction, optional, default size
  23486. * * 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
  23487. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23488. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23489. * * flat when true creates a flat shaded mesh, optional, default true
  23490. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23491. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23492. * * 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)
  23493. * * 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)
  23494. * @returns the VertexData of the Polyhedron
  23495. */
  23496. static CreatePolyhedron(options: {
  23497. type?: number;
  23498. size?: number;
  23499. sizeX?: number;
  23500. sizeY?: number;
  23501. sizeZ?: number;
  23502. custom?: any;
  23503. faceUV?: Vector4[];
  23504. faceColors?: Color4[];
  23505. flat?: boolean;
  23506. sideOrientation?: number;
  23507. frontUVs?: Vector4;
  23508. backUVs?: Vector4;
  23509. }): VertexData;
  23510. /**
  23511. * Creates the VertexData for a TorusKnot
  23512. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23513. * * radius the radius of the torus knot, optional, default 2
  23514. * * tube the thickness of the tube, optional, default 0.5
  23515. * * radialSegments the number of sides on each tube segments, optional, default 32
  23516. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23517. * * p the number of windings around the z axis, optional, default 2
  23518. * * q the number of windings around the x axis, optional, default 3
  23519. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23520. * * 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)
  23521. * * 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)
  23522. * @returns the VertexData of the Torus Knot
  23523. */
  23524. static CreateTorusKnot(options: {
  23525. radius?: number;
  23526. tube?: number;
  23527. radialSegments?: number;
  23528. tubularSegments?: number;
  23529. p?: number;
  23530. q?: number;
  23531. sideOrientation?: number;
  23532. frontUVs?: Vector4;
  23533. backUVs?: Vector4;
  23534. }): VertexData;
  23535. /**
  23536. * Compute normals for given positions and indices
  23537. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23538. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23539. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23540. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23541. * * facetNormals : optional array of facet normals (vector3)
  23542. * * facetPositions : optional array of facet positions (vector3)
  23543. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23544. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23545. * * bInfo : optional bounding info, required for facetPartitioning computation
  23546. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23547. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23548. * * useRightHandedSystem: optional boolean to for right handed system computation
  23549. * * depthSort : optional boolean to enable the facet depth sort computation
  23550. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23551. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23552. */
  23553. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23554. facetNormals?: any;
  23555. facetPositions?: any;
  23556. facetPartitioning?: any;
  23557. ratio?: number;
  23558. bInfo?: any;
  23559. bbSize?: Vector3;
  23560. subDiv?: any;
  23561. useRightHandedSystem?: boolean;
  23562. depthSort?: boolean;
  23563. distanceTo?: Vector3;
  23564. depthSortedFacets?: any;
  23565. }): void;
  23566. /** @hidden */
  23567. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23568. /**
  23569. * Applies VertexData created from the imported parameters to the geometry
  23570. * @param parsedVertexData the parsed data from an imported file
  23571. * @param geometry the geometry to apply the VertexData to
  23572. */
  23573. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23574. }
  23575. }
  23576. declare module BABYLON {
  23577. /**
  23578. * Class containing static functions to help procedurally build meshes
  23579. */
  23580. export class DiscBuilder {
  23581. /**
  23582. * Creates a plane polygonal mesh. By default, this is a disc
  23583. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23584. * * 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
  23585. * * 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
  23586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23587. * * 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
  23588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23589. * @param name defines the name of the mesh
  23590. * @param options defines the options used to create the mesh
  23591. * @param scene defines the hosting scene
  23592. * @returns the plane polygonal mesh
  23593. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23594. */
  23595. static CreateDisc(name: string, options: {
  23596. radius?: number;
  23597. tessellation?: number;
  23598. arc?: number;
  23599. updatable?: boolean;
  23600. sideOrientation?: number;
  23601. frontUVs?: Vector4;
  23602. backUVs?: Vector4;
  23603. }, scene?: Nullable<Scene>): Mesh;
  23604. }
  23605. }
  23606. declare module BABYLON {
  23607. /**
  23608. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23609. *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.
  23610. * The SPS is also a particle system. It provides some methods to manage the particles.
  23611. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23612. *
  23613. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23614. */
  23615. export class SolidParticleSystem implements IDisposable {
  23616. /**
  23617. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23618. * Example : var p = SPS.particles[i];
  23619. */
  23620. particles: SolidParticle[];
  23621. /**
  23622. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23623. */
  23624. nbParticles: number;
  23625. /**
  23626. * If the particles must ever face the camera (default false). Useful for planar particles.
  23627. */
  23628. billboard: boolean;
  23629. /**
  23630. * Recompute normals when adding a shape
  23631. */
  23632. recomputeNormals: boolean;
  23633. /**
  23634. * This a counter ofr your own usage. It's not set by any SPS functions.
  23635. */
  23636. counter: number;
  23637. /**
  23638. * The SPS name. This name is also given to the underlying mesh.
  23639. */
  23640. name: string;
  23641. /**
  23642. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23643. */
  23644. mesh: Mesh;
  23645. /**
  23646. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23647. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23648. */
  23649. vars: any;
  23650. /**
  23651. * This array is populated when the SPS is set as 'pickable'.
  23652. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23653. * Each element of this array is an object `{idx: int, faceId: int}`.
  23654. * `idx` is the picked particle index in the `SPS.particles` array
  23655. * `faceId` is the picked face index counted within this particle.
  23656. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23657. */
  23658. pickedParticles: {
  23659. idx: number;
  23660. faceId: number;
  23661. }[];
  23662. /**
  23663. * This array is populated when `enableDepthSort` is set to true.
  23664. * Each element of this array is an instance of the class DepthSortedParticle.
  23665. */
  23666. depthSortedParticles: DepthSortedParticle[];
  23667. /**
  23668. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23669. * @hidden
  23670. */
  23671. _bSphereOnly: boolean;
  23672. /**
  23673. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23674. * @hidden
  23675. */
  23676. _bSphereRadiusFactor: number;
  23677. private _scene;
  23678. private _positions;
  23679. private _indices;
  23680. private _normals;
  23681. private _colors;
  23682. private _uvs;
  23683. private _indices32;
  23684. private _positions32;
  23685. private _normals32;
  23686. private _fixedNormal32;
  23687. private _colors32;
  23688. private _uvs32;
  23689. private _index;
  23690. private _updatable;
  23691. private _pickable;
  23692. private _isVisibilityBoxLocked;
  23693. private _alwaysVisible;
  23694. private _depthSort;
  23695. private _shapeCounter;
  23696. private _copy;
  23697. private _color;
  23698. private _computeParticleColor;
  23699. private _computeParticleTexture;
  23700. private _computeParticleRotation;
  23701. private _computeParticleVertex;
  23702. private _computeBoundingBox;
  23703. private _depthSortParticles;
  23704. private _camera;
  23705. private _mustUnrotateFixedNormals;
  23706. private _particlesIntersect;
  23707. private _needs32Bits;
  23708. /**
  23709. * Creates a SPS (Solid Particle System) object.
  23710. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23711. * @param scene (Scene) is the scene in which the SPS is added.
  23712. * @param options defines the options of the sps e.g.
  23713. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23714. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23715. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23716. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23717. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23718. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23719. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23720. */
  23721. constructor(name: string, scene: Scene, options?: {
  23722. updatable?: boolean;
  23723. isPickable?: boolean;
  23724. enableDepthSort?: boolean;
  23725. particleIntersection?: boolean;
  23726. boundingSphereOnly?: boolean;
  23727. bSphereRadiusFactor?: number;
  23728. });
  23729. /**
  23730. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23731. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23732. * @returns the created mesh
  23733. */
  23734. buildMesh(): Mesh;
  23735. /**
  23736. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23737. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23738. * Thus the particles generated from `digest()` have their property `position` set yet.
  23739. * @param mesh ( Mesh ) is the mesh to be digested
  23740. * @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
  23741. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23742. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23743. * @returns the current SPS
  23744. */
  23745. digest(mesh: Mesh, options?: {
  23746. facetNb?: number;
  23747. number?: number;
  23748. delta?: number;
  23749. }): SolidParticleSystem;
  23750. private _unrotateFixedNormals;
  23751. private _resetCopy;
  23752. private _meshBuilder;
  23753. private _posToShape;
  23754. private _uvsToShapeUV;
  23755. private _addParticle;
  23756. /**
  23757. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23758. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23759. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23760. * @param nb (positive integer) the number of particles to be created from this model
  23761. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23762. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23763. * @returns the number of shapes in the system
  23764. */
  23765. addShape(mesh: Mesh, nb: number, options?: {
  23766. positionFunction?: any;
  23767. vertexFunction?: any;
  23768. }): number;
  23769. private _rebuildParticle;
  23770. /**
  23771. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23772. * @returns the SPS.
  23773. */
  23774. rebuildMesh(): SolidParticleSystem;
  23775. /**
  23776. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23777. * This method calls `updateParticle()` for each particle of the SPS.
  23778. * For an animated SPS, it is usually called within the render loop.
  23779. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23780. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23781. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23782. * @returns the SPS.
  23783. */
  23784. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23785. /**
  23786. * Disposes the SPS.
  23787. */
  23788. dispose(): void;
  23789. /**
  23790. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23791. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23792. * @returns the SPS.
  23793. */
  23794. refreshVisibleSize(): SolidParticleSystem;
  23795. /**
  23796. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23797. * @param size the size (float) of the visibility box
  23798. * note : this doesn't lock the SPS mesh bounding box.
  23799. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23800. */
  23801. setVisibilityBox(size: number): void;
  23802. /**
  23803. * Gets whether the SPS as always visible or not
  23804. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23805. */
  23806. /**
  23807. * Sets the SPS as always visible or not
  23808. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23809. */
  23810. isAlwaysVisible: boolean;
  23811. /**
  23812. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23813. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23814. */
  23815. /**
  23816. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23817. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23818. */
  23819. isVisibilityBoxLocked: boolean;
  23820. /**
  23821. * Tells to `setParticles()` to compute the particle rotations or not.
  23822. * Default value : true. The SPS is faster when it's set to false.
  23823. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23824. */
  23825. /**
  23826. * Gets if `setParticles()` computes the particle rotations or not.
  23827. * Default value : true. The SPS is faster when it's set to false.
  23828. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23829. */
  23830. computeParticleRotation: boolean;
  23831. /**
  23832. * Tells to `setParticles()` to compute the particle colors or not.
  23833. * Default value : true. The SPS is faster when it's set to false.
  23834. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23835. */
  23836. /**
  23837. * Gets if `setParticles()` computes the particle colors or not.
  23838. * Default value : true. The SPS is faster when it's set to false.
  23839. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23840. */
  23841. computeParticleColor: boolean;
  23842. /**
  23843. * Gets if `setParticles()` computes the particle textures or not.
  23844. * Default value : true. The SPS is faster when it's set to false.
  23845. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23846. */
  23847. computeParticleTexture: boolean;
  23848. /**
  23849. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23850. * Default value : false. The SPS is faster when it's set to false.
  23851. * Note : the particle custom vertex positions aren't stored values.
  23852. */
  23853. /**
  23854. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23855. * Default value : false. The SPS is faster when it's set to false.
  23856. * Note : the particle custom vertex positions aren't stored values.
  23857. */
  23858. computeParticleVertex: boolean;
  23859. /**
  23860. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23861. */
  23862. /**
  23863. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23864. */
  23865. computeBoundingBox: boolean;
  23866. /**
  23867. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23868. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23869. * Default : `true`
  23870. */
  23871. /**
  23872. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23873. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23874. * Default : `true`
  23875. */
  23876. depthSortParticles: boolean;
  23877. /**
  23878. * This function does nothing. It may be overwritten to set all the particle first values.
  23879. * The SPS doesn't call this function, you may have to call it by your own.
  23880. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23881. */
  23882. initParticles(): void;
  23883. /**
  23884. * This function does nothing. It may be overwritten to recycle a particle.
  23885. * The SPS doesn't call this function, you may have to call it by your own.
  23886. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23887. * @param particle The particle to recycle
  23888. * @returns the recycled particle
  23889. */
  23890. recycleParticle(particle: SolidParticle): SolidParticle;
  23891. /**
  23892. * Updates a particle : this function should be overwritten by the user.
  23893. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23894. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23895. * @example : just set a particle position or velocity and recycle conditions
  23896. * @param particle The particle to update
  23897. * @returns the updated particle
  23898. */
  23899. updateParticle(particle: SolidParticle): SolidParticle;
  23900. /**
  23901. * Updates a vertex of a particle : it can be overwritten by the user.
  23902. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23903. * @param particle the current particle
  23904. * @param vertex the current index of the current particle
  23905. * @param pt the index of the current vertex in the particle shape
  23906. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23907. * @example : just set a vertex particle position
  23908. * @returns the updated vertex
  23909. */
  23910. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23911. /**
  23912. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23913. * This does nothing and may be overwritten by the user.
  23914. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23915. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23916. * @param update the boolean update value actually passed to setParticles()
  23917. */
  23918. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23919. /**
  23920. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23921. * This will be passed three parameters.
  23922. * This does nothing and may be overwritten by the user.
  23923. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23924. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23925. * @param update the boolean update value actually passed to setParticles()
  23926. */
  23927. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23928. }
  23929. }
  23930. declare module BABYLON {
  23931. /**
  23932. * Represents one particle of a solid particle system.
  23933. */
  23934. export class SolidParticle {
  23935. /**
  23936. * particle global index
  23937. */
  23938. idx: number;
  23939. /**
  23940. * The color of the particle
  23941. */
  23942. color: Nullable<Color4>;
  23943. /**
  23944. * The world space position of the particle.
  23945. */
  23946. position: Vector3;
  23947. /**
  23948. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23949. */
  23950. rotation: Vector3;
  23951. /**
  23952. * The world space rotation quaternion of the particle.
  23953. */
  23954. rotationQuaternion: Nullable<Quaternion>;
  23955. /**
  23956. * The scaling of the particle.
  23957. */
  23958. scaling: Vector3;
  23959. /**
  23960. * The uvs of the particle.
  23961. */
  23962. uvs: Vector4;
  23963. /**
  23964. * The current speed of the particle.
  23965. */
  23966. velocity: Vector3;
  23967. /**
  23968. * The pivot point in the particle local space.
  23969. */
  23970. pivot: Vector3;
  23971. /**
  23972. * Must the particle be translated from its pivot point in its local space ?
  23973. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23974. * Default : false
  23975. */
  23976. translateFromPivot: boolean;
  23977. /**
  23978. * Is the particle active or not ?
  23979. */
  23980. alive: boolean;
  23981. /**
  23982. * Is the particle visible or not ?
  23983. */
  23984. isVisible: boolean;
  23985. /**
  23986. * Index of this particle in the global "positions" array (Internal use)
  23987. * @hidden
  23988. */
  23989. _pos: number;
  23990. /**
  23991. * @hidden Index of this particle in the global "indices" array (Internal use)
  23992. */
  23993. _ind: number;
  23994. /**
  23995. * @hidden ModelShape of this particle (Internal use)
  23996. */
  23997. _model: ModelShape;
  23998. /**
  23999. * ModelShape id of this particle
  24000. */
  24001. shapeId: number;
  24002. /**
  24003. * Index of the particle in its shape id (Internal use)
  24004. */
  24005. idxInShape: number;
  24006. /**
  24007. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24008. */
  24009. _modelBoundingInfo: BoundingInfo;
  24010. /**
  24011. * @hidden Particle BoundingInfo object (Internal use)
  24012. */
  24013. _boundingInfo: BoundingInfo;
  24014. /**
  24015. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24016. */
  24017. _sps: SolidParticleSystem;
  24018. /**
  24019. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24020. */
  24021. _stillInvisible: boolean;
  24022. /**
  24023. * @hidden Last computed particle rotation matrix
  24024. */
  24025. _rotationMatrix: number[];
  24026. /**
  24027. * Parent particle Id, if any.
  24028. * Default null.
  24029. */
  24030. parentId: Nullable<number>;
  24031. /**
  24032. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24033. * The possible values are :
  24034. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24035. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24036. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24037. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24038. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24039. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24040. * */
  24041. cullingStrategy: number;
  24042. /**
  24043. * @hidden Internal global position in the SPS.
  24044. */
  24045. _globalPosition: Vector3;
  24046. /**
  24047. * Creates a Solid Particle object.
  24048. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24049. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24050. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24051. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24052. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24053. * @param shapeId (integer) is the model shape identifier in the SPS.
  24054. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24055. * @param sps defines the sps it is associated to
  24056. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24057. */
  24058. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24059. /**
  24060. * Legacy support, changed scale to scaling
  24061. */
  24062. /**
  24063. * Legacy support, changed scale to scaling
  24064. */
  24065. scale: Vector3;
  24066. /**
  24067. * Legacy support, changed quaternion to rotationQuaternion
  24068. */
  24069. /**
  24070. * Legacy support, changed quaternion to rotationQuaternion
  24071. */
  24072. quaternion: Nullable<Quaternion>;
  24073. /**
  24074. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24075. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24076. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24077. * @returns true if it intersects
  24078. */
  24079. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24080. /**
  24081. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24082. * A particle is in the frustum if its bounding box intersects the frustum
  24083. * @param frustumPlanes defines the frustum to test
  24084. * @returns true if the particle is in the frustum planes
  24085. */
  24086. isInFrustum(frustumPlanes: Plane[]): boolean;
  24087. /**
  24088. * get the rotation matrix of the particle
  24089. * @hidden
  24090. */
  24091. getRotationMatrix(m: Matrix): void;
  24092. }
  24093. /**
  24094. * Represents the shape of the model used by one particle of a solid particle system.
  24095. * SPS internal tool, don't use it manually.
  24096. */
  24097. export class ModelShape {
  24098. /**
  24099. * The shape id
  24100. * @hidden
  24101. */
  24102. shapeID: number;
  24103. /**
  24104. * flat array of model positions (internal use)
  24105. * @hidden
  24106. */
  24107. _shape: Vector3[];
  24108. /**
  24109. * flat array of model UVs (internal use)
  24110. * @hidden
  24111. */
  24112. _shapeUV: number[];
  24113. /**
  24114. * length of the shape in the model indices array (internal use)
  24115. * @hidden
  24116. */
  24117. _indicesLength: number;
  24118. /**
  24119. * Custom position function (internal use)
  24120. * @hidden
  24121. */
  24122. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24123. /**
  24124. * Custom vertex function (internal use)
  24125. * @hidden
  24126. */
  24127. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24128. /**
  24129. * 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.
  24130. * SPS internal tool, don't use it manually.
  24131. * @hidden
  24132. */
  24133. 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>);
  24134. }
  24135. /**
  24136. * Represents a Depth Sorted Particle in the solid particle system.
  24137. */
  24138. export class DepthSortedParticle {
  24139. /**
  24140. * Index of the particle in the "indices" array
  24141. */
  24142. ind: number;
  24143. /**
  24144. * Length of the particle shape in the "indices" array
  24145. */
  24146. indicesLength: number;
  24147. /**
  24148. * Squared distance from the particle to the camera
  24149. */
  24150. sqDistance: number;
  24151. }
  24152. }
  24153. declare module BABYLON {
  24154. /**
  24155. * @hidden
  24156. */
  24157. export class _MeshCollisionData {
  24158. _checkCollisions: boolean;
  24159. _collisionMask: number;
  24160. _collisionGroup: number;
  24161. _collider: Nullable<Collider>;
  24162. _oldPositionForCollisions: Vector3;
  24163. _diffPositionForCollisions: Vector3;
  24164. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24165. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24166. }
  24167. }
  24168. declare module BABYLON {
  24169. /** @hidden */
  24170. class _FacetDataStorage {
  24171. facetPositions: Vector3[];
  24172. facetNormals: Vector3[];
  24173. facetPartitioning: number[][];
  24174. facetNb: number;
  24175. partitioningSubdivisions: number;
  24176. partitioningBBoxRatio: number;
  24177. facetDataEnabled: boolean;
  24178. facetParameters: any;
  24179. bbSize: Vector3;
  24180. subDiv: {
  24181. max: number;
  24182. X: number;
  24183. Y: number;
  24184. Z: number;
  24185. };
  24186. facetDepthSort: boolean;
  24187. facetDepthSortEnabled: boolean;
  24188. depthSortedIndices: IndicesArray;
  24189. depthSortedFacets: {
  24190. ind: number;
  24191. sqDistance: number;
  24192. }[];
  24193. facetDepthSortFunction: (f1: {
  24194. ind: number;
  24195. sqDistance: number;
  24196. }, f2: {
  24197. ind: number;
  24198. sqDistance: number;
  24199. }) => number;
  24200. facetDepthSortFrom: Vector3;
  24201. facetDepthSortOrigin: Vector3;
  24202. invertedMatrix: Matrix;
  24203. }
  24204. /**
  24205. * @hidden
  24206. **/
  24207. class _InternalAbstractMeshDataInfo {
  24208. _hasVertexAlpha: boolean;
  24209. _useVertexColors: boolean;
  24210. _numBoneInfluencers: number;
  24211. _applyFog: boolean;
  24212. _receiveShadows: boolean;
  24213. _facetData: _FacetDataStorage;
  24214. _visibility: number;
  24215. _skeleton: Nullable<Skeleton>;
  24216. _layerMask: number;
  24217. _computeBonesUsingShaders: boolean;
  24218. _isActive: boolean;
  24219. _onlyForInstances: boolean;
  24220. _isActiveIntermediate: boolean;
  24221. _onlyForInstancesIntermediate: boolean;
  24222. }
  24223. /**
  24224. * Class used to store all common mesh properties
  24225. */
  24226. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24227. /** No occlusion */
  24228. static OCCLUSION_TYPE_NONE: number;
  24229. /** Occlusion set to optimisitic */
  24230. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24231. /** Occlusion set to strict */
  24232. static OCCLUSION_TYPE_STRICT: number;
  24233. /** Use an accurante occlusion algorithm */
  24234. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24235. /** Use a conservative occlusion algorithm */
  24236. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24237. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24238. * Test order :
  24239. * Is the bounding sphere outside the frustum ?
  24240. * If not, are the bounding box vertices outside the frustum ?
  24241. * It not, then the cullable object is in the frustum.
  24242. */
  24243. static readonly CULLINGSTRATEGY_STANDARD: number;
  24244. /** Culling strategy : Bounding Sphere Only.
  24245. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24246. * It's also less accurate than the standard because some not visible objects can still be selected.
  24247. * Test : is the bounding sphere outside the frustum ?
  24248. * If not, then the cullable object is in the frustum.
  24249. */
  24250. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24251. /** Culling strategy : Optimistic Inclusion.
  24252. * This in an inclusion test first, then the standard exclusion test.
  24253. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24254. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  24255. * Anyway, it's as accurate as the standard strategy.
  24256. * Test :
  24257. * Is the cullable object bounding sphere center in the frustum ?
  24258. * If not, apply the default culling strategy.
  24259. */
  24260. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24261. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24262. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24263. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24264. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  24265. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24266. * Test :
  24267. * Is the cullable object bounding sphere center in the frustum ?
  24268. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24269. */
  24270. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24271. /**
  24272. * No billboard
  24273. */
  24274. static readonly BILLBOARDMODE_NONE: number;
  24275. /** Billboard on X axis */
  24276. static readonly BILLBOARDMODE_X: number;
  24277. /** Billboard on Y axis */
  24278. static readonly BILLBOARDMODE_Y: number;
  24279. /** Billboard on Z axis */
  24280. static readonly BILLBOARDMODE_Z: number;
  24281. /** Billboard on all axes */
  24282. static readonly BILLBOARDMODE_ALL: number;
  24283. /** @hidden */
  24284. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  24285. /**
  24286. * The culling strategy to use to check whether the mesh must be rendered or not.
  24287. * This value can be changed at any time and will be used on the next render mesh selection.
  24288. * The possible values are :
  24289. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24290. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24291. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24292. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24293. * Please read each static variable documentation to get details about the culling process.
  24294. * */
  24295. cullingStrategy: number;
  24296. /**
  24297. * Gets the number of facets in the mesh
  24298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24299. */
  24300. readonly facetNb: number;
  24301. /**
  24302. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24304. */
  24305. partitioningSubdivisions: number;
  24306. /**
  24307. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24308. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24310. */
  24311. partitioningBBoxRatio: number;
  24312. /**
  24313. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24314. * Works only for updatable meshes.
  24315. * Doesn't work with multi-materials
  24316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24317. */
  24318. mustDepthSortFacets: boolean;
  24319. /**
  24320. * The location (Vector3) where the facet depth sort must be computed from.
  24321. * By default, the active camera position.
  24322. * Used only when facet depth sort is enabled
  24323. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24324. */
  24325. facetDepthSortFrom: Vector3;
  24326. /**
  24327. * gets a boolean indicating if facetData is enabled
  24328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24329. */
  24330. readonly isFacetDataEnabled: boolean;
  24331. /** @hidden */
  24332. _updateNonUniformScalingState(value: boolean): boolean;
  24333. /**
  24334. * An event triggered when this mesh collides with another one
  24335. */
  24336. onCollideObservable: Observable<AbstractMesh>;
  24337. /** Set a function to call when this mesh collides with another one */
  24338. onCollide: () => void;
  24339. /**
  24340. * An event triggered when the collision's position changes
  24341. */
  24342. onCollisionPositionChangeObservable: Observable<Vector3>;
  24343. /** Set a function to call when the collision's position changes */
  24344. onCollisionPositionChange: () => void;
  24345. /**
  24346. * An event triggered when material is changed
  24347. */
  24348. onMaterialChangedObservable: Observable<AbstractMesh>;
  24349. /**
  24350. * Gets or sets the orientation for POV movement & rotation
  24351. */
  24352. definedFacingForward: boolean;
  24353. /** @hidden */
  24354. _occlusionQuery: Nullable<WebGLQuery>;
  24355. /** @hidden */
  24356. _renderingGroup: Nullable<RenderingGroup>;
  24357. /**
  24358. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24359. */
  24360. /**
  24361. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24362. */
  24363. visibility: number;
  24364. /** Gets or sets the alpha index used to sort transparent meshes
  24365. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24366. */
  24367. alphaIndex: number;
  24368. /**
  24369. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24370. */
  24371. isVisible: boolean;
  24372. /**
  24373. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24374. */
  24375. isPickable: boolean;
  24376. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24377. showSubMeshesBoundingBox: boolean;
  24378. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24379. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24380. */
  24381. isBlocker: boolean;
  24382. /**
  24383. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24384. */
  24385. enablePointerMoveEvents: boolean;
  24386. /**
  24387. * Specifies the rendering group id for this mesh (0 by default)
  24388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24389. */
  24390. renderingGroupId: number;
  24391. private _material;
  24392. /** Gets or sets current material */
  24393. material: Nullable<Material>;
  24394. /**
  24395. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24396. * @see http://doc.babylonjs.com/babylon101/shadows
  24397. */
  24398. receiveShadows: boolean;
  24399. /** Defines color to use when rendering outline */
  24400. outlineColor: Color3;
  24401. /** Define width to use when rendering outline */
  24402. outlineWidth: number;
  24403. /** Defines color to use when rendering overlay */
  24404. overlayColor: Color3;
  24405. /** Defines alpha to use when rendering overlay */
  24406. overlayAlpha: number;
  24407. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24408. hasVertexAlpha: boolean;
  24409. /** 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) */
  24410. useVertexColors: boolean;
  24411. /**
  24412. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24413. */
  24414. computeBonesUsingShaders: boolean;
  24415. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24416. numBoneInfluencers: number;
  24417. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24418. applyFog: boolean;
  24419. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24420. useOctreeForRenderingSelection: boolean;
  24421. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24422. useOctreeForPicking: boolean;
  24423. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24424. useOctreeForCollisions: boolean;
  24425. /**
  24426. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24427. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24428. */
  24429. layerMask: number;
  24430. /**
  24431. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24432. */
  24433. alwaysSelectAsActiveMesh: boolean;
  24434. /**
  24435. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24436. */
  24437. doNotSyncBoundingInfo: boolean;
  24438. /**
  24439. * Gets or sets the current action manager
  24440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24441. */
  24442. actionManager: Nullable<AbstractActionManager>;
  24443. private _meshCollisionData;
  24444. /**
  24445. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24447. */
  24448. ellipsoid: Vector3;
  24449. /**
  24450. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24451. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24452. */
  24453. ellipsoidOffset: Vector3;
  24454. /**
  24455. * Gets or sets a collision mask used to mask collisions (default is -1).
  24456. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24457. */
  24458. collisionMask: number;
  24459. /**
  24460. * Gets or sets the current collision group mask (-1 by default).
  24461. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24462. */
  24463. collisionGroup: number;
  24464. /**
  24465. * Defines edge width used when edgesRenderer is enabled
  24466. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24467. */
  24468. edgesWidth: number;
  24469. /**
  24470. * Defines edge color used when edgesRenderer is enabled
  24471. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24472. */
  24473. edgesColor: Color4;
  24474. /** @hidden */
  24475. _edgesRenderer: Nullable<IEdgesRenderer>;
  24476. /** @hidden */
  24477. _masterMesh: Nullable<AbstractMesh>;
  24478. /** @hidden */
  24479. _boundingInfo: Nullable<BoundingInfo>;
  24480. /** @hidden */
  24481. _renderId: number;
  24482. /**
  24483. * Gets or sets the list of subMeshes
  24484. * @see http://doc.babylonjs.com/how_to/multi_materials
  24485. */
  24486. subMeshes: SubMesh[];
  24487. /** @hidden */
  24488. _intersectionsInProgress: AbstractMesh[];
  24489. /** @hidden */
  24490. _unIndexed: boolean;
  24491. /** @hidden */
  24492. _lightSources: Light[];
  24493. /** Gets the list of lights affecting that mesh */
  24494. readonly lightSources: Light[];
  24495. /** @hidden */
  24496. readonly _positions: Nullable<Vector3[]>;
  24497. /** @hidden */
  24498. _waitingData: {
  24499. lods: Nullable<any>;
  24500. actions: Nullable<any>;
  24501. freezeWorldMatrix: Nullable<boolean>;
  24502. };
  24503. /** @hidden */
  24504. _bonesTransformMatrices: Nullable<Float32Array>;
  24505. /**
  24506. * Gets or sets a skeleton to apply skining transformations
  24507. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24508. */
  24509. skeleton: Nullable<Skeleton>;
  24510. /**
  24511. * An event triggered when the mesh is rebuilt.
  24512. */
  24513. onRebuildObservable: Observable<AbstractMesh>;
  24514. /**
  24515. * Creates a new AbstractMesh
  24516. * @param name defines the name of the mesh
  24517. * @param scene defines the hosting scene
  24518. */
  24519. constructor(name: string, scene?: Nullable<Scene>);
  24520. /**
  24521. * Returns the string "AbstractMesh"
  24522. * @returns "AbstractMesh"
  24523. */
  24524. getClassName(): string;
  24525. /**
  24526. * Gets a string representation of the current mesh
  24527. * @param fullDetails defines a boolean indicating if full details must be included
  24528. * @returns a string representation of the current mesh
  24529. */
  24530. toString(fullDetails?: boolean): string;
  24531. /**
  24532. * @hidden
  24533. */
  24534. protected _getEffectiveParent(): Nullable<Node>;
  24535. /** @hidden */
  24536. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24537. /** @hidden */
  24538. _rebuild(): void;
  24539. /** @hidden */
  24540. _resyncLightSources(): void;
  24541. /** @hidden */
  24542. _resyncLighSource(light: Light): void;
  24543. /** @hidden */
  24544. _unBindEffect(): void;
  24545. /** @hidden */
  24546. _removeLightSource(light: Light): void;
  24547. private _markSubMeshesAsDirty;
  24548. /** @hidden */
  24549. _markSubMeshesAsLightDirty(): void;
  24550. /** @hidden */
  24551. _markSubMeshesAsAttributesDirty(): void;
  24552. /** @hidden */
  24553. _markSubMeshesAsMiscDirty(): void;
  24554. /**
  24555. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24556. */
  24557. scaling: Vector3;
  24558. /**
  24559. * Returns true if the mesh is blocked. Implemented by child classes
  24560. */
  24561. readonly isBlocked: boolean;
  24562. /**
  24563. * Returns the mesh itself by default. Implemented by child classes
  24564. * @param camera defines the camera to use to pick the right LOD level
  24565. * @returns the currentAbstractMesh
  24566. */
  24567. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24568. /**
  24569. * Returns 0 by default. Implemented by child classes
  24570. * @returns an integer
  24571. */
  24572. getTotalVertices(): number;
  24573. /**
  24574. * Returns a positive integer : the total number of indices in this mesh geometry.
  24575. * @returns the numner of indices or zero if the mesh has no geometry.
  24576. */
  24577. getTotalIndices(): number;
  24578. /**
  24579. * Returns null by default. Implemented by child classes
  24580. * @returns null
  24581. */
  24582. getIndices(): Nullable<IndicesArray>;
  24583. /**
  24584. * Returns the array of the requested vertex data kind. Implemented by child classes
  24585. * @param kind defines the vertex data kind to use
  24586. * @returns null
  24587. */
  24588. getVerticesData(kind: string): Nullable<FloatArray>;
  24589. /**
  24590. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24591. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24592. * Note that a new underlying VertexBuffer object is created each call.
  24593. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24594. * @param kind defines vertex data kind:
  24595. * * VertexBuffer.PositionKind
  24596. * * VertexBuffer.UVKind
  24597. * * VertexBuffer.UV2Kind
  24598. * * VertexBuffer.UV3Kind
  24599. * * VertexBuffer.UV4Kind
  24600. * * VertexBuffer.UV5Kind
  24601. * * VertexBuffer.UV6Kind
  24602. * * VertexBuffer.ColorKind
  24603. * * VertexBuffer.MatricesIndicesKind
  24604. * * VertexBuffer.MatricesIndicesExtraKind
  24605. * * VertexBuffer.MatricesWeightsKind
  24606. * * VertexBuffer.MatricesWeightsExtraKind
  24607. * @param data defines the data source
  24608. * @param updatable defines if the data must be flagged as updatable (or static)
  24609. * @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
  24610. * @returns the current mesh
  24611. */
  24612. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24613. /**
  24614. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24615. * If the mesh has no geometry, it is simply returned as it is.
  24616. * @param kind defines vertex data kind:
  24617. * * VertexBuffer.PositionKind
  24618. * * VertexBuffer.UVKind
  24619. * * VertexBuffer.UV2Kind
  24620. * * VertexBuffer.UV3Kind
  24621. * * VertexBuffer.UV4Kind
  24622. * * VertexBuffer.UV5Kind
  24623. * * VertexBuffer.UV6Kind
  24624. * * VertexBuffer.ColorKind
  24625. * * VertexBuffer.MatricesIndicesKind
  24626. * * VertexBuffer.MatricesIndicesExtraKind
  24627. * * VertexBuffer.MatricesWeightsKind
  24628. * * VertexBuffer.MatricesWeightsExtraKind
  24629. * @param data defines the data source
  24630. * @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
  24631. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24632. * @returns the current mesh
  24633. */
  24634. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24635. /**
  24636. * Sets the mesh indices,
  24637. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24638. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24639. * @param totalVertices Defines the total number of vertices
  24640. * @returns the current mesh
  24641. */
  24642. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24643. /**
  24644. * Gets a boolean indicating if specific vertex data is present
  24645. * @param kind defines the vertex data kind to use
  24646. * @returns true is data kind is present
  24647. */
  24648. isVerticesDataPresent(kind: string): boolean;
  24649. /**
  24650. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24651. * @returns a BoundingInfo
  24652. */
  24653. getBoundingInfo(): BoundingInfo;
  24654. /**
  24655. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24656. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24657. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24658. * @returns the current mesh
  24659. */
  24660. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24661. /**
  24662. * Overwrite the current bounding info
  24663. * @param boundingInfo defines the new bounding info
  24664. * @returns the current mesh
  24665. */
  24666. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24667. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24668. readonly useBones: boolean;
  24669. /** @hidden */
  24670. _preActivate(): void;
  24671. /** @hidden */
  24672. _preActivateForIntermediateRendering(renderId: number): void;
  24673. /** @hidden */
  24674. _activate(renderId: number, intermediateRendering: boolean): boolean;
  24675. /** @hidden */
  24676. _postActivate(): void;
  24677. /** @hidden */
  24678. _freeze(): void;
  24679. /** @hidden */
  24680. _unFreeze(): void;
  24681. /**
  24682. * Gets the current world matrix
  24683. * @returns a Matrix
  24684. */
  24685. getWorldMatrix(): Matrix;
  24686. /** @hidden */
  24687. _getWorldMatrixDeterminant(): number;
  24688. /**
  24689. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24690. */
  24691. readonly isAnInstance: boolean;
  24692. /**
  24693. * Perform relative position change from the point of view of behind the front of the mesh.
  24694. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24695. * Supports definition of mesh facing forward or backward
  24696. * @param amountRight defines the distance on the right axis
  24697. * @param amountUp defines the distance on the up axis
  24698. * @param amountForward defines the distance on the forward axis
  24699. * @returns the current mesh
  24700. */
  24701. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24702. /**
  24703. * Calculate relative position change from the point of view of behind the front of the mesh.
  24704. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24705. * Supports definition of mesh facing forward or backward
  24706. * @param amountRight defines the distance on the right axis
  24707. * @param amountUp defines the distance on the up axis
  24708. * @param amountForward defines the distance on the forward axis
  24709. * @returns the new displacement vector
  24710. */
  24711. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24712. /**
  24713. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24714. * Supports definition of mesh facing forward or backward
  24715. * @param flipBack defines the flip
  24716. * @param twirlClockwise defines the twirl
  24717. * @param tiltRight defines the tilt
  24718. * @returns the current mesh
  24719. */
  24720. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24721. /**
  24722. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24723. * Supports definition of mesh facing forward or backward.
  24724. * @param flipBack defines the flip
  24725. * @param twirlClockwise defines the twirl
  24726. * @param tiltRight defines the tilt
  24727. * @returns the new rotation vector
  24728. */
  24729. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24730. /**
  24731. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24732. * This means the mesh underlying bounding box and sphere are recomputed.
  24733. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24734. * @returns the current mesh
  24735. */
  24736. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24737. /** @hidden */
  24738. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24739. /** @hidden */
  24740. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24741. /** @hidden */
  24742. _updateBoundingInfo(): AbstractMesh;
  24743. /** @hidden */
  24744. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24745. /** @hidden */
  24746. protected _afterComputeWorldMatrix(): void;
  24747. /** @hidden */
  24748. readonly _effectiveMesh: AbstractMesh;
  24749. /**
  24750. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24751. * A mesh is in the frustum if its bounding box intersects the frustum
  24752. * @param frustumPlanes defines the frustum to test
  24753. * @returns true if the mesh is in the frustum planes
  24754. */
  24755. isInFrustum(frustumPlanes: Plane[]): boolean;
  24756. /**
  24757. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24758. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24759. * @param frustumPlanes defines the frustum to test
  24760. * @returns true if the mesh is completely in the frustum planes
  24761. */
  24762. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24763. /**
  24764. * True if the mesh intersects another mesh or a SolidParticle object
  24765. * @param mesh defines a target mesh or SolidParticle to test
  24766. * @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)
  24767. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24768. * @returns true if there is an intersection
  24769. */
  24770. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24771. /**
  24772. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24773. * @param point defines the point to test
  24774. * @returns true if there is an intersection
  24775. */
  24776. intersectsPoint(point: Vector3): boolean;
  24777. /**
  24778. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24779. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24780. */
  24781. checkCollisions: boolean;
  24782. /**
  24783. * Gets Collider object used to compute collisions (not physics)
  24784. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24785. */
  24786. readonly collider: Nullable<Collider>;
  24787. /**
  24788. * Move the mesh using collision engine
  24789. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24790. * @param displacement defines the requested displacement vector
  24791. * @returns the current mesh
  24792. */
  24793. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24794. private _onCollisionPositionChange;
  24795. /** @hidden */
  24796. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24797. /** @hidden */
  24798. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24799. /** @hidden */
  24800. _checkCollision(collider: Collider): AbstractMesh;
  24801. /** @hidden */
  24802. _generatePointsArray(): boolean;
  24803. /**
  24804. * Checks if the passed Ray intersects with the mesh
  24805. * @param ray defines the ray to use
  24806. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24807. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24808. * @returns the picking info
  24809. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24810. */
  24811. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24812. /**
  24813. * Clones the current mesh
  24814. * @param name defines the mesh name
  24815. * @param newParent defines the new mesh parent
  24816. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24817. * @returns the new mesh
  24818. */
  24819. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24820. /**
  24821. * Disposes all the submeshes of the current meshnp
  24822. * @returns the current mesh
  24823. */
  24824. releaseSubMeshes(): AbstractMesh;
  24825. /**
  24826. * Releases resources associated with this abstract mesh.
  24827. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24828. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24829. */
  24830. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24831. /**
  24832. * Adds the passed mesh as a child to the current mesh
  24833. * @param mesh defines the child mesh
  24834. * @returns the current mesh
  24835. */
  24836. addChild(mesh: AbstractMesh): AbstractMesh;
  24837. /**
  24838. * Removes the passed mesh from the current mesh children list
  24839. * @param mesh defines the child mesh
  24840. * @returns the current mesh
  24841. */
  24842. removeChild(mesh: AbstractMesh): AbstractMesh;
  24843. /** @hidden */
  24844. private _initFacetData;
  24845. /**
  24846. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24847. * This method can be called within the render loop.
  24848. * 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
  24849. * @returns the current mesh
  24850. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24851. */
  24852. updateFacetData(): AbstractMesh;
  24853. /**
  24854. * Returns the facetLocalNormals array.
  24855. * The normals are expressed in the mesh local spac
  24856. * @returns an array of Vector3
  24857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24858. */
  24859. getFacetLocalNormals(): Vector3[];
  24860. /**
  24861. * Returns the facetLocalPositions array.
  24862. * The facet positions are expressed in the mesh local space
  24863. * @returns an array of Vector3
  24864. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24865. */
  24866. getFacetLocalPositions(): Vector3[];
  24867. /**
  24868. * Returns the facetLocalPartioning array
  24869. * @returns an array of array of numbers
  24870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24871. */
  24872. getFacetLocalPartitioning(): number[][];
  24873. /**
  24874. * Returns the i-th facet position in the world system.
  24875. * This method allocates a new Vector3 per call
  24876. * @param i defines the facet index
  24877. * @returns a new Vector3
  24878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24879. */
  24880. getFacetPosition(i: number): Vector3;
  24881. /**
  24882. * Sets the reference Vector3 with the i-th facet position in the world system
  24883. * @param i defines the facet index
  24884. * @param ref defines the target vector
  24885. * @returns the current mesh
  24886. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24887. */
  24888. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24889. /**
  24890. * Returns the i-th facet normal in the world system.
  24891. * This method allocates a new Vector3 per call
  24892. * @param i defines the facet index
  24893. * @returns a new Vector3
  24894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24895. */
  24896. getFacetNormal(i: number): Vector3;
  24897. /**
  24898. * Sets the reference Vector3 with the i-th facet normal in the world system
  24899. * @param i defines the facet index
  24900. * @param ref defines the target vector
  24901. * @returns the current mesh
  24902. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24903. */
  24904. getFacetNormalToRef(i: number, ref: Vector3): this;
  24905. /**
  24906. * 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)
  24907. * @param x defines x coordinate
  24908. * @param y defines y coordinate
  24909. * @param z defines z coordinate
  24910. * @returns the array of facet indexes
  24911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24912. */
  24913. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24914. /**
  24915. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24916. * @param projected sets as the (x,y,z) world projection on the facet
  24917. * @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
  24918. * @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
  24919. * @param x defines x coordinate
  24920. * @param y defines y coordinate
  24921. * @param z defines z coordinate
  24922. * @returns the face index if found (or null instead)
  24923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24924. */
  24925. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24926. /**
  24927. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24928. * @param projected sets as the (x,y,z) local projection on the facet
  24929. * @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
  24930. * @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
  24931. * @param x defines x coordinate
  24932. * @param y defines y coordinate
  24933. * @param z defines z coordinate
  24934. * @returns the face index if found (or null instead)
  24935. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24936. */
  24937. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24938. /**
  24939. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24940. * @returns the parameters
  24941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24942. */
  24943. getFacetDataParameters(): any;
  24944. /**
  24945. * Disables the feature FacetData and frees the related memory
  24946. * @returns the current mesh
  24947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24948. */
  24949. disableFacetData(): AbstractMesh;
  24950. /**
  24951. * Updates the AbstractMesh indices array
  24952. * @param indices defines the data source
  24953. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24954. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24955. * @returns the current mesh
  24956. */
  24957. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24958. /**
  24959. * Creates new normals data for the mesh
  24960. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24961. * @returns the current mesh
  24962. */
  24963. createNormals(updatable: boolean): AbstractMesh;
  24964. /**
  24965. * Align the mesh with a normal
  24966. * @param normal defines the normal to use
  24967. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24968. * @returns the current mesh
  24969. */
  24970. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24971. /** @hidden */
  24972. _checkOcclusionQuery(): boolean;
  24973. /**
  24974. * Disables the mesh edge rendering mode
  24975. * @returns the currentAbstractMesh
  24976. */
  24977. disableEdgesRendering(): AbstractMesh;
  24978. /**
  24979. * Enables the edge rendering mode on the mesh.
  24980. * This mode makes the mesh edges visible
  24981. * @param epsilon defines the maximal distance between two angles to detect a face
  24982. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  24983. * @returns the currentAbstractMesh
  24984. * @see https://www.babylonjs-playground.com/#19O9TU#0
  24985. */
  24986. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  24987. }
  24988. }
  24989. declare module BABYLON {
  24990. /**
  24991. * Interface used to define ActionEvent
  24992. */
  24993. export interface IActionEvent {
  24994. /** The mesh or sprite that triggered the action */
  24995. source: any;
  24996. /** The X mouse cursor position at the time of the event */
  24997. pointerX: number;
  24998. /** The Y mouse cursor position at the time of the event */
  24999. pointerY: number;
  25000. /** The mesh that is currently pointed at (can be null) */
  25001. meshUnderPointer: Nullable<AbstractMesh>;
  25002. /** the original (browser) event that triggered the ActionEvent */
  25003. sourceEvent?: any;
  25004. /** additional data for the event */
  25005. additionalData?: any;
  25006. }
  25007. /**
  25008. * ActionEvent is the event being sent when an action is triggered.
  25009. */
  25010. export class ActionEvent implements IActionEvent {
  25011. /** The mesh or sprite that triggered the action */
  25012. source: any;
  25013. /** The X mouse cursor position at the time of the event */
  25014. pointerX: number;
  25015. /** The Y mouse cursor position at the time of the event */
  25016. pointerY: number;
  25017. /** The mesh that is currently pointed at (can be null) */
  25018. meshUnderPointer: Nullable<AbstractMesh>;
  25019. /** the original (browser) event that triggered the ActionEvent */
  25020. sourceEvent?: any;
  25021. /** additional data for the event */
  25022. additionalData?: any;
  25023. /**
  25024. * Creates a new ActionEvent
  25025. * @param source The mesh or sprite that triggered the action
  25026. * @param pointerX The X mouse cursor position at the time of the event
  25027. * @param pointerY The Y mouse cursor position at the time of the event
  25028. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25029. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25030. * @param additionalData additional data for the event
  25031. */
  25032. constructor(
  25033. /** The mesh or sprite that triggered the action */
  25034. source: any,
  25035. /** The X mouse cursor position at the time of the event */
  25036. pointerX: number,
  25037. /** The Y mouse cursor position at the time of the event */
  25038. pointerY: number,
  25039. /** The mesh that is currently pointed at (can be null) */
  25040. meshUnderPointer: Nullable<AbstractMesh>,
  25041. /** the original (browser) event that triggered the ActionEvent */
  25042. sourceEvent?: any,
  25043. /** additional data for the event */
  25044. additionalData?: any);
  25045. /**
  25046. * Helper function to auto-create an ActionEvent from a source mesh.
  25047. * @param source The source mesh that triggered the event
  25048. * @param evt The original (browser) event
  25049. * @param additionalData additional data for the event
  25050. * @returns the new ActionEvent
  25051. */
  25052. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25053. /**
  25054. * Helper function to auto-create an ActionEvent from a source sprite
  25055. * @param source The source sprite that triggered the event
  25056. * @param scene Scene associated with the sprite
  25057. * @param evt The original (browser) event
  25058. * @param additionalData additional data for the event
  25059. * @returns the new ActionEvent
  25060. */
  25061. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25062. /**
  25063. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25064. * @param scene the scene where the event occurred
  25065. * @param evt The original (browser) event
  25066. * @returns the new ActionEvent
  25067. */
  25068. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25069. /**
  25070. * Helper function to auto-create an ActionEvent from a primitive
  25071. * @param prim defines the target primitive
  25072. * @param pointerPos defines the pointer position
  25073. * @param evt The original (browser) event
  25074. * @param additionalData additional data for the event
  25075. * @returns the new ActionEvent
  25076. */
  25077. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25078. }
  25079. }
  25080. declare module BABYLON {
  25081. /**
  25082. * Abstract class used to decouple action Manager from scene and meshes.
  25083. * Do not instantiate.
  25084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25085. */
  25086. export abstract class AbstractActionManager implements IDisposable {
  25087. /** Gets the list of active triggers */
  25088. static Triggers: {
  25089. [key: string]: number;
  25090. };
  25091. /** Gets the cursor to use when hovering items */
  25092. hoverCursor: string;
  25093. /** Gets the list of actions */
  25094. actions: IAction[];
  25095. /**
  25096. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25097. */
  25098. isRecursive: boolean;
  25099. /**
  25100. * Releases all associated resources
  25101. */
  25102. abstract dispose(): void;
  25103. /**
  25104. * Does this action manager has pointer triggers
  25105. */
  25106. abstract readonly hasPointerTriggers: boolean;
  25107. /**
  25108. * Does this action manager has pick triggers
  25109. */
  25110. abstract readonly hasPickTriggers: boolean;
  25111. /**
  25112. * Process a specific trigger
  25113. * @param trigger defines the trigger to process
  25114. * @param evt defines the event details to be processed
  25115. */
  25116. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25117. /**
  25118. * Does this action manager handles actions of any of the given triggers
  25119. * @param triggers defines the triggers to be tested
  25120. * @return a boolean indicating whether one (or more) of the triggers is handled
  25121. */
  25122. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25123. /**
  25124. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25125. * speed.
  25126. * @param triggerA defines the trigger to be tested
  25127. * @param triggerB defines the trigger to be tested
  25128. * @return a boolean indicating whether one (or more) of the triggers is handled
  25129. */
  25130. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25131. /**
  25132. * Does this action manager handles actions of a given trigger
  25133. * @param trigger defines the trigger to be tested
  25134. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25135. * @return whether the trigger is handled
  25136. */
  25137. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25138. /**
  25139. * Serialize this manager to a JSON object
  25140. * @param name defines the property name to store this manager
  25141. * @returns a JSON representation of this manager
  25142. */
  25143. abstract serialize(name: string): any;
  25144. /**
  25145. * Registers an action to this action manager
  25146. * @param action defines the action to be registered
  25147. * @return the action amended (prepared) after registration
  25148. */
  25149. abstract registerAction(action: IAction): Nullable<IAction>;
  25150. /**
  25151. * Unregisters an action to this action manager
  25152. * @param action defines the action to be unregistered
  25153. * @return a boolean indicating whether the action has been unregistered
  25154. */
  25155. abstract unregisterAction(action: IAction): Boolean;
  25156. /**
  25157. * Does exist one action manager with at least one trigger
  25158. **/
  25159. static readonly HasTriggers: boolean;
  25160. /**
  25161. * Does exist one action manager with at least one pick trigger
  25162. **/
  25163. static readonly HasPickTriggers: boolean;
  25164. /**
  25165. * Does exist one action manager that handles actions of a given trigger
  25166. * @param trigger defines the trigger to be tested
  25167. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25168. **/
  25169. static HasSpecificTrigger(trigger: number): boolean;
  25170. }
  25171. }
  25172. declare module BABYLON {
  25173. /**
  25174. * Defines how a node can be built from a string name.
  25175. */
  25176. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25177. /**
  25178. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25179. */
  25180. export class Node implements IBehaviorAware<Node> {
  25181. /** @hidden */
  25182. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  25183. private static _NodeConstructors;
  25184. /**
  25185. * Add a new node constructor
  25186. * @param type defines the type name of the node to construct
  25187. * @param constructorFunc defines the constructor function
  25188. */
  25189. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25190. /**
  25191. * Returns a node constructor based on type name
  25192. * @param type defines the type name
  25193. * @param name defines the new node name
  25194. * @param scene defines the hosting scene
  25195. * @param options defines optional options to transmit to constructors
  25196. * @returns the new constructor or null
  25197. */
  25198. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25199. /**
  25200. * Gets or sets the name of the node
  25201. */
  25202. name: string;
  25203. /**
  25204. * Gets or sets the id of the node
  25205. */
  25206. id: string;
  25207. /**
  25208. * Gets or sets the unique id of the node
  25209. */
  25210. uniqueId: number;
  25211. /**
  25212. * Gets or sets a string used to store user defined state for the node
  25213. */
  25214. state: string;
  25215. /**
  25216. * Gets or sets an object used to store user defined information for the node
  25217. */
  25218. metadata: any;
  25219. /**
  25220. * For internal use only. Please do not use.
  25221. */
  25222. reservedDataStore: any;
  25223. /**
  25224. * List of inspectable custom properties (used by the Inspector)
  25225. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25226. */
  25227. inspectableCustomProperties: IInspectable[];
  25228. /**
  25229. * Gets or sets a boolean used to define if the node must be serialized
  25230. */
  25231. doNotSerialize: boolean;
  25232. /** @hidden */
  25233. _isDisposed: boolean;
  25234. /**
  25235. * Gets a list of Animations associated with the node
  25236. */
  25237. animations: Animation[];
  25238. protected _ranges: {
  25239. [name: string]: Nullable<AnimationRange>;
  25240. };
  25241. /**
  25242. * Callback raised when the node is ready to be used
  25243. */
  25244. onReady: Nullable<(node: Node) => void>;
  25245. private _isEnabled;
  25246. private _isParentEnabled;
  25247. private _isReady;
  25248. /** @hidden */
  25249. _currentRenderId: number;
  25250. private _parentUpdateId;
  25251. /** @hidden */
  25252. _childUpdateId: number;
  25253. /** @hidden */
  25254. _waitingParentId: Nullable<string>;
  25255. /** @hidden */
  25256. _scene: Scene;
  25257. /** @hidden */
  25258. _cache: any;
  25259. private _parentNode;
  25260. private _children;
  25261. /** @hidden */
  25262. _worldMatrix: Matrix;
  25263. /** @hidden */
  25264. _worldMatrixDeterminant: number;
  25265. /** @hidden */
  25266. _worldMatrixDeterminantIsDirty: boolean;
  25267. /** @hidden */
  25268. private _sceneRootNodesIndex;
  25269. /**
  25270. * Gets a boolean indicating if the node has been disposed
  25271. * @returns true if the node was disposed
  25272. */
  25273. isDisposed(): boolean;
  25274. /**
  25275. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25276. * @see https://doc.babylonjs.com/how_to/parenting
  25277. */
  25278. parent: Nullable<Node>;
  25279. private addToSceneRootNodes;
  25280. private removeFromSceneRootNodes;
  25281. private _animationPropertiesOverride;
  25282. /**
  25283. * Gets or sets the animation properties override
  25284. */
  25285. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25286. /**
  25287. * Gets a string idenfifying the name of the class
  25288. * @returns "Node" string
  25289. */
  25290. getClassName(): string;
  25291. /** @hidden */
  25292. readonly _isNode: boolean;
  25293. /**
  25294. * An event triggered when the mesh is disposed
  25295. */
  25296. onDisposeObservable: Observable<Node>;
  25297. private _onDisposeObserver;
  25298. /**
  25299. * Sets a callback that will be raised when the node will be disposed
  25300. */
  25301. onDispose: () => void;
  25302. /**
  25303. * Creates a new Node
  25304. * @param name the name and id to be given to this node
  25305. * @param scene the scene this node will be added to
  25306. * @param addToRootNodes the node will be added to scene.rootNodes
  25307. */
  25308. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25309. /**
  25310. * Gets the scene of the node
  25311. * @returns a scene
  25312. */
  25313. getScene(): Scene;
  25314. /**
  25315. * Gets the engine of the node
  25316. * @returns a Engine
  25317. */
  25318. getEngine(): Engine;
  25319. private _behaviors;
  25320. /**
  25321. * Attach a behavior to the node
  25322. * @see http://doc.babylonjs.com/features/behaviour
  25323. * @param behavior defines the behavior to attach
  25324. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25325. * @returns the current Node
  25326. */
  25327. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25328. /**
  25329. * Remove an attached behavior
  25330. * @see http://doc.babylonjs.com/features/behaviour
  25331. * @param behavior defines the behavior to attach
  25332. * @returns the current Node
  25333. */
  25334. removeBehavior(behavior: Behavior<Node>): Node;
  25335. /**
  25336. * Gets the list of attached behaviors
  25337. * @see http://doc.babylonjs.com/features/behaviour
  25338. */
  25339. readonly behaviors: Behavior<Node>[];
  25340. /**
  25341. * Gets an attached behavior by name
  25342. * @param name defines the name of the behavior to look for
  25343. * @see http://doc.babylonjs.com/features/behaviour
  25344. * @returns null if behavior was not found else the requested behavior
  25345. */
  25346. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25347. /**
  25348. * Returns the latest update of the World matrix
  25349. * @returns a Matrix
  25350. */
  25351. getWorldMatrix(): Matrix;
  25352. /** @hidden */
  25353. _getWorldMatrixDeterminant(): number;
  25354. /**
  25355. * Returns directly the latest state of the mesh World matrix.
  25356. * A Matrix is returned.
  25357. */
  25358. readonly worldMatrixFromCache: Matrix;
  25359. /** @hidden */
  25360. _initCache(): void;
  25361. /** @hidden */
  25362. updateCache(force?: boolean): void;
  25363. /** @hidden */
  25364. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25365. /** @hidden */
  25366. _updateCache(ignoreParentClass?: boolean): void;
  25367. /** @hidden */
  25368. _isSynchronized(): boolean;
  25369. /** @hidden */
  25370. _markSyncedWithParent(): void;
  25371. /** @hidden */
  25372. isSynchronizedWithParent(): boolean;
  25373. /** @hidden */
  25374. isSynchronized(): boolean;
  25375. /**
  25376. * Is this node ready to be used/rendered
  25377. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25378. * @return true if the node is ready
  25379. */
  25380. isReady(completeCheck?: boolean): boolean;
  25381. /**
  25382. * Is this node enabled?
  25383. * 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
  25384. * @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
  25385. * @return whether this node (and its parent) is enabled
  25386. */
  25387. isEnabled(checkAncestors?: boolean): boolean;
  25388. /** @hidden */
  25389. protected _syncParentEnabledState(): void;
  25390. /**
  25391. * Set the enabled state of this node
  25392. * @param value defines the new enabled state
  25393. */
  25394. setEnabled(value: boolean): void;
  25395. /**
  25396. * Is this node a descendant of the given node?
  25397. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25398. * @param ancestor defines the parent node to inspect
  25399. * @returns a boolean indicating if this node is a descendant of the given node
  25400. */
  25401. isDescendantOf(ancestor: Node): boolean;
  25402. /** @hidden */
  25403. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25404. /**
  25405. * Will return all nodes that have this node as ascendant
  25406. * @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
  25407. * @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
  25408. * @return all children nodes of all types
  25409. */
  25410. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25411. /**
  25412. * Get all child-meshes of this node
  25413. * @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: false)
  25414. * @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
  25415. * @returns an array of AbstractMesh
  25416. */
  25417. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25418. /**
  25419. * Get all direct children of this node
  25420. * @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
  25421. * @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)
  25422. * @returns an array of Node
  25423. */
  25424. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25425. /** @hidden */
  25426. _setReady(state: boolean): void;
  25427. /**
  25428. * Get an animation by name
  25429. * @param name defines the name of the animation to look for
  25430. * @returns null if not found else the requested animation
  25431. */
  25432. getAnimationByName(name: string): Nullable<Animation>;
  25433. /**
  25434. * Creates an animation range for this node
  25435. * @param name defines the name of the range
  25436. * @param from defines the starting key
  25437. * @param to defines the end key
  25438. */
  25439. createAnimationRange(name: string, from: number, to: number): void;
  25440. /**
  25441. * Delete a specific animation range
  25442. * @param name defines the name of the range to delete
  25443. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25444. */
  25445. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25446. /**
  25447. * Get an animation range by name
  25448. * @param name defines the name of the animation range to look for
  25449. * @returns null if not found else the requested animation range
  25450. */
  25451. getAnimationRange(name: string): Nullable<AnimationRange>;
  25452. /**
  25453. * Gets the list of all animation ranges defined on this node
  25454. * @returns an array
  25455. */
  25456. getAnimationRanges(): Nullable<AnimationRange>[];
  25457. /**
  25458. * Will start the animation sequence
  25459. * @param name defines the range frames for animation sequence
  25460. * @param loop defines if the animation should loop (false by default)
  25461. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25462. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25463. * @returns the object created for this animation. If range does not exist, it will return null
  25464. */
  25465. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25466. /**
  25467. * Serialize animation ranges into a JSON compatible object
  25468. * @returns serialization object
  25469. */
  25470. serializeAnimationRanges(): any;
  25471. /**
  25472. * Computes the world matrix of the node
  25473. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25474. * @returns the world matrix
  25475. */
  25476. computeWorldMatrix(force?: boolean): Matrix;
  25477. /**
  25478. * Releases resources associated with this node.
  25479. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25480. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25481. */
  25482. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25483. /**
  25484. * Parse animation range data from a serialization object and store them into a given node
  25485. * @param node defines where to store the animation ranges
  25486. * @param parsedNode defines the serialization object to read data from
  25487. * @param scene defines the hosting scene
  25488. */
  25489. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25490. /**
  25491. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25492. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25493. * @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
  25494. * @returns the new bounding vectors
  25495. */
  25496. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25497. min: Vector3;
  25498. max: Vector3;
  25499. };
  25500. }
  25501. }
  25502. declare module BABYLON {
  25503. /**
  25504. * @hidden
  25505. */
  25506. export class _IAnimationState {
  25507. key: number;
  25508. repeatCount: number;
  25509. workValue?: any;
  25510. loopMode?: number;
  25511. offsetValue?: any;
  25512. highLimitValue?: any;
  25513. }
  25514. /**
  25515. * Class used to store any kind of animation
  25516. */
  25517. export class Animation {
  25518. /**Name of the animation */
  25519. name: string;
  25520. /**Property to animate */
  25521. targetProperty: string;
  25522. /**The frames per second of the animation */
  25523. framePerSecond: number;
  25524. /**The data type of the animation */
  25525. dataType: number;
  25526. /**The loop mode of the animation */
  25527. loopMode?: number | undefined;
  25528. /**Specifies if blending should be enabled */
  25529. enableBlending?: boolean | undefined;
  25530. /**
  25531. * Use matrix interpolation instead of using direct key value when animating matrices
  25532. */
  25533. static AllowMatricesInterpolation: boolean;
  25534. /**
  25535. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25536. */
  25537. static AllowMatrixDecomposeForInterpolation: boolean;
  25538. /**
  25539. * Stores the key frames of the animation
  25540. */
  25541. private _keys;
  25542. /**
  25543. * Stores the easing function of the animation
  25544. */
  25545. private _easingFunction;
  25546. /**
  25547. * @hidden Internal use only
  25548. */
  25549. _runtimeAnimations: RuntimeAnimation[];
  25550. /**
  25551. * The set of event that will be linked to this animation
  25552. */
  25553. private _events;
  25554. /**
  25555. * Stores an array of target property paths
  25556. */
  25557. targetPropertyPath: string[];
  25558. /**
  25559. * Stores the blending speed of the animation
  25560. */
  25561. blendingSpeed: number;
  25562. /**
  25563. * Stores the animation ranges for the animation
  25564. */
  25565. private _ranges;
  25566. /**
  25567. * @hidden Internal use
  25568. */
  25569. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25570. /**
  25571. * Sets up an animation
  25572. * @param property The property to animate
  25573. * @param animationType The animation type to apply
  25574. * @param framePerSecond The frames per second of the animation
  25575. * @param easingFunction The easing function used in the animation
  25576. * @returns The created animation
  25577. */
  25578. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25579. /**
  25580. * Create and start an animation on a node
  25581. * @param name defines the name of the global animation that will be run on all nodes
  25582. * @param node defines the root node where the animation will take place
  25583. * @param targetProperty defines property to animate
  25584. * @param framePerSecond defines the number of frame per second yo use
  25585. * @param totalFrame defines the number of frames in total
  25586. * @param from defines the initial value
  25587. * @param to defines the final value
  25588. * @param loopMode defines which loop mode you want to use (off by default)
  25589. * @param easingFunction defines the easing function to use (linear by default)
  25590. * @param onAnimationEnd defines the callback to call when animation end
  25591. * @returns the animatable created for this animation
  25592. */
  25593. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25594. /**
  25595. * Create and start an animation on a node and its descendants
  25596. * @param name defines the name of the global animation that will be run on all nodes
  25597. * @param node defines the root node where the animation will take place
  25598. * @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
  25599. * @param targetProperty defines property to animate
  25600. * @param framePerSecond defines the number of frame per second to use
  25601. * @param totalFrame defines the number of frames in total
  25602. * @param from defines the initial value
  25603. * @param to defines the final value
  25604. * @param loopMode defines which loop mode you want to use (off by default)
  25605. * @param easingFunction defines the easing function to use (linear by default)
  25606. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25607. * @returns the list of animatables created for all nodes
  25608. * @example https://www.babylonjs-playground.com/#MH0VLI
  25609. */
  25610. 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[]>;
  25611. /**
  25612. * Creates a new animation, merges it with the existing animations and starts it
  25613. * @param name Name of the animation
  25614. * @param node Node which contains the scene that begins the animations
  25615. * @param targetProperty Specifies which property to animate
  25616. * @param framePerSecond The frames per second of the animation
  25617. * @param totalFrame The total number of frames
  25618. * @param from The frame at the beginning of the animation
  25619. * @param to The frame at the end of the animation
  25620. * @param loopMode Specifies the loop mode of the animation
  25621. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25622. * @param onAnimationEnd Callback to run once the animation is complete
  25623. * @returns Nullable animation
  25624. */
  25625. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25626. /**
  25627. * Transition property of an host to the target Value
  25628. * @param property The property to transition
  25629. * @param targetValue The target Value of the property
  25630. * @param host The object where the property to animate belongs
  25631. * @param scene Scene used to run the animation
  25632. * @param frameRate Framerate (in frame/s) to use
  25633. * @param transition The transition type we want to use
  25634. * @param duration The duration of the animation, in milliseconds
  25635. * @param onAnimationEnd Callback trigger at the end of the animation
  25636. * @returns Nullable animation
  25637. */
  25638. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25639. /**
  25640. * Return the array of runtime animations currently using this animation
  25641. */
  25642. readonly runtimeAnimations: RuntimeAnimation[];
  25643. /**
  25644. * Specifies if any of the runtime animations are currently running
  25645. */
  25646. readonly hasRunningRuntimeAnimations: boolean;
  25647. /**
  25648. * Initializes the animation
  25649. * @param name Name of the animation
  25650. * @param targetProperty Property to animate
  25651. * @param framePerSecond The frames per second of the animation
  25652. * @param dataType The data type of the animation
  25653. * @param loopMode The loop mode of the animation
  25654. * @param enableBlending Specifies if blending should be enabled
  25655. */
  25656. constructor(
  25657. /**Name of the animation */
  25658. name: string,
  25659. /**Property to animate */
  25660. targetProperty: string,
  25661. /**The frames per second of the animation */
  25662. framePerSecond: number,
  25663. /**The data type of the animation */
  25664. dataType: number,
  25665. /**The loop mode of the animation */
  25666. loopMode?: number | undefined,
  25667. /**Specifies if blending should be enabled */
  25668. enableBlending?: boolean | undefined);
  25669. /**
  25670. * Converts the animation to a string
  25671. * @param fullDetails support for multiple levels of logging within scene loading
  25672. * @returns String form of the animation
  25673. */
  25674. toString(fullDetails?: boolean): string;
  25675. /**
  25676. * Add an event to this animation
  25677. * @param event Event to add
  25678. */
  25679. addEvent(event: AnimationEvent): void;
  25680. /**
  25681. * Remove all events found at the given frame
  25682. * @param frame The frame to remove events from
  25683. */
  25684. removeEvents(frame: number): void;
  25685. /**
  25686. * Retrieves all the events from the animation
  25687. * @returns Events from the animation
  25688. */
  25689. getEvents(): AnimationEvent[];
  25690. /**
  25691. * Creates an animation range
  25692. * @param name Name of the animation range
  25693. * @param from Starting frame of the animation range
  25694. * @param to Ending frame of the animation
  25695. */
  25696. createRange(name: string, from: number, to: number): void;
  25697. /**
  25698. * Deletes an animation range by name
  25699. * @param name Name of the animation range to delete
  25700. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25701. */
  25702. deleteRange(name: string, deleteFrames?: boolean): void;
  25703. /**
  25704. * Gets the animation range by name, or null if not defined
  25705. * @param name Name of the animation range
  25706. * @returns Nullable animation range
  25707. */
  25708. getRange(name: string): Nullable<AnimationRange>;
  25709. /**
  25710. * Gets the key frames from the animation
  25711. * @returns The key frames of the animation
  25712. */
  25713. getKeys(): Array<IAnimationKey>;
  25714. /**
  25715. * Gets the highest frame rate of the animation
  25716. * @returns Highest frame rate of the animation
  25717. */
  25718. getHighestFrame(): number;
  25719. /**
  25720. * Gets the easing function of the animation
  25721. * @returns Easing function of the animation
  25722. */
  25723. getEasingFunction(): IEasingFunction;
  25724. /**
  25725. * Sets the easing function of the animation
  25726. * @param easingFunction A custom mathematical formula for animation
  25727. */
  25728. setEasingFunction(easingFunction: EasingFunction): void;
  25729. /**
  25730. * Interpolates a scalar linearly
  25731. * @param startValue Start value of the animation curve
  25732. * @param endValue End value of the animation curve
  25733. * @param gradient Scalar amount to interpolate
  25734. * @returns Interpolated scalar value
  25735. */
  25736. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25737. /**
  25738. * Interpolates a scalar cubically
  25739. * @param startValue Start value of the animation curve
  25740. * @param outTangent End tangent of the animation
  25741. * @param endValue End value of the animation curve
  25742. * @param inTangent Start tangent of the animation curve
  25743. * @param gradient Scalar amount to interpolate
  25744. * @returns Interpolated scalar value
  25745. */
  25746. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25747. /**
  25748. * Interpolates a quaternion using a spherical linear interpolation
  25749. * @param startValue Start value of the animation curve
  25750. * @param endValue End value of the animation curve
  25751. * @param gradient Scalar amount to interpolate
  25752. * @returns Interpolated quaternion value
  25753. */
  25754. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25755. /**
  25756. * Interpolates a quaternion cubically
  25757. * @param startValue Start value of the animation curve
  25758. * @param outTangent End tangent of the animation curve
  25759. * @param endValue End value of the animation curve
  25760. * @param inTangent Start tangent of the animation curve
  25761. * @param gradient Scalar amount to interpolate
  25762. * @returns Interpolated quaternion value
  25763. */
  25764. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25765. /**
  25766. * Interpolates a Vector3 linearl
  25767. * @param startValue Start value of the animation curve
  25768. * @param endValue End value of the animation curve
  25769. * @param gradient Scalar amount to interpolate
  25770. * @returns Interpolated scalar value
  25771. */
  25772. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25773. /**
  25774. * Interpolates a Vector3 cubically
  25775. * @param startValue Start value of the animation curve
  25776. * @param outTangent End tangent of the animation
  25777. * @param endValue End value of the animation curve
  25778. * @param inTangent Start tangent of the animation curve
  25779. * @param gradient Scalar amount to interpolate
  25780. * @returns InterpolatedVector3 value
  25781. */
  25782. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25783. /**
  25784. * Interpolates a Vector2 linearly
  25785. * @param startValue Start value of the animation curve
  25786. * @param endValue End value of the animation curve
  25787. * @param gradient Scalar amount to interpolate
  25788. * @returns Interpolated Vector2 value
  25789. */
  25790. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25791. /**
  25792. * Interpolates a Vector2 cubically
  25793. * @param startValue Start value of the animation curve
  25794. * @param outTangent End tangent of the animation
  25795. * @param endValue End value of the animation curve
  25796. * @param inTangent Start tangent of the animation curve
  25797. * @param gradient Scalar amount to interpolate
  25798. * @returns Interpolated Vector2 value
  25799. */
  25800. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25801. /**
  25802. * Interpolates a size linearly
  25803. * @param startValue Start value of the animation curve
  25804. * @param endValue End value of the animation curve
  25805. * @param gradient Scalar amount to interpolate
  25806. * @returns Interpolated Size value
  25807. */
  25808. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25809. /**
  25810. * Interpolates a Color3 linearly
  25811. * @param startValue Start value of the animation curve
  25812. * @param endValue End value of the animation curve
  25813. * @param gradient Scalar amount to interpolate
  25814. * @returns Interpolated Color3 value
  25815. */
  25816. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25817. /**
  25818. * @hidden Internal use only
  25819. */
  25820. _getKeyValue(value: any): any;
  25821. /**
  25822. * @hidden Internal use only
  25823. */
  25824. _interpolate(currentFrame: number, state: _IAnimationState): any;
  25825. /**
  25826. * Defines the function to use to interpolate matrices
  25827. * @param startValue defines the start matrix
  25828. * @param endValue defines the end matrix
  25829. * @param gradient defines the gradient between both matrices
  25830. * @param result defines an optional target matrix where to store the interpolation
  25831. * @returns the interpolated matrix
  25832. */
  25833. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25834. /**
  25835. * Makes a copy of the animation
  25836. * @returns Cloned animation
  25837. */
  25838. clone(): Animation;
  25839. /**
  25840. * Sets the key frames of the animation
  25841. * @param values The animation key frames to set
  25842. */
  25843. setKeys(values: Array<IAnimationKey>): void;
  25844. /**
  25845. * Serializes the animation to an object
  25846. * @returns Serialized object
  25847. */
  25848. serialize(): any;
  25849. /**
  25850. * Float animation type
  25851. */
  25852. private static _ANIMATIONTYPE_FLOAT;
  25853. /**
  25854. * Vector3 animation type
  25855. */
  25856. private static _ANIMATIONTYPE_VECTOR3;
  25857. /**
  25858. * Quaternion animation type
  25859. */
  25860. private static _ANIMATIONTYPE_QUATERNION;
  25861. /**
  25862. * Matrix animation type
  25863. */
  25864. private static _ANIMATIONTYPE_MATRIX;
  25865. /**
  25866. * Color3 animation type
  25867. */
  25868. private static _ANIMATIONTYPE_COLOR3;
  25869. /**
  25870. * Vector2 animation type
  25871. */
  25872. private static _ANIMATIONTYPE_VECTOR2;
  25873. /**
  25874. * Size animation type
  25875. */
  25876. private static _ANIMATIONTYPE_SIZE;
  25877. /**
  25878. * Relative Loop Mode
  25879. */
  25880. private static _ANIMATIONLOOPMODE_RELATIVE;
  25881. /**
  25882. * Cycle Loop Mode
  25883. */
  25884. private static _ANIMATIONLOOPMODE_CYCLE;
  25885. /**
  25886. * Constant Loop Mode
  25887. */
  25888. private static _ANIMATIONLOOPMODE_CONSTANT;
  25889. /**
  25890. * Get the float animation type
  25891. */
  25892. static readonly ANIMATIONTYPE_FLOAT: number;
  25893. /**
  25894. * Get the Vector3 animation type
  25895. */
  25896. static readonly ANIMATIONTYPE_VECTOR3: number;
  25897. /**
  25898. * Get the Vector2 animation type
  25899. */
  25900. static readonly ANIMATIONTYPE_VECTOR2: number;
  25901. /**
  25902. * Get the Size animation type
  25903. */
  25904. static readonly ANIMATIONTYPE_SIZE: number;
  25905. /**
  25906. * Get the Quaternion animation type
  25907. */
  25908. static readonly ANIMATIONTYPE_QUATERNION: number;
  25909. /**
  25910. * Get the Matrix animation type
  25911. */
  25912. static readonly ANIMATIONTYPE_MATRIX: number;
  25913. /**
  25914. * Get the Color3 animation type
  25915. */
  25916. static readonly ANIMATIONTYPE_COLOR3: number;
  25917. /**
  25918. * Get the Relative Loop Mode
  25919. */
  25920. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25921. /**
  25922. * Get the Cycle Loop Mode
  25923. */
  25924. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25925. /**
  25926. * Get the Constant Loop Mode
  25927. */
  25928. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25929. /** @hidden */
  25930. static _UniversalLerp(left: any, right: any, amount: number): any;
  25931. /**
  25932. * Parses an animation object and creates an animation
  25933. * @param parsedAnimation Parsed animation object
  25934. * @returns Animation object
  25935. */
  25936. static Parse(parsedAnimation: any): Animation;
  25937. /**
  25938. * Appends the serialized animations from the source animations
  25939. * @param source Source containing the animations
  25940. * @param destination Target to store the animations
  25941. */
  25942. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25943. }
  25944. }
  25945. declare module BABYLON {
  25946. /**
  25947. * Base class of all the textures in babylon.
  25948. * It groups all the common properties the materials, post process, lights... might need
  25949. * in order to make a correct use of the texture.
  25950. */
  25951. export class BaseTexture implements IAnimatable {
  25952. /**
  25953. * Default anisotropic filtering level for the application.
  25954. * It is set to 4 as a good tradeoff between perf and quality.
  25955. */
  25956. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25957. /**
  25958. * Gets or sets the unique id of the texture
  25959. */
  25960. uniqueId: number;
  25961. /**
  25962. * Define the name of the texture.
  25963. */
  25964. name: string;
  25965. /**
  25966. * Gets or sets an object used to store user defined information.
  25967. */
  25968. metadata: any;
  25969. /**
  25970. * For internal use only. Please do not use.
  25971. */
  25972. reservedDataStore: any;
  25973. private _hasAlpha;
  25974. /**
  25975. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25976. */
  25977. hasAlpha: boolean;
  25978. /**
  25979. * Defines if the alpha value should be determined via the rgb values.
  25980. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25981. */
  25982. getAlphaFromRGB: boolean;
  25983. /**
  25984. * Intensity or strength of the texture.
  25985. * It is commonly used by materials to fine tune the intensity of the texture
  25986. */
  25987. level: number;
  25988. /**
  25989. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25990. * This is part of the texture as textures usually maps to one uv set.
  25991. */
  25992. coordinatesIndex: number;
  25993. private _coordinatesMode;
  25994. /**
  25995. * How a texture is mapped.
  25996. *
  25997. * | Value | Type | Description |
  25998. * | ----- | ----------------------------------- | ----------- |
  25999. * | 0 | EXPLICIT_MODE | |
  26000. * | 1 | SPHERICAL_MODE | |
  26001. * | 2 | PLANAR_MODE | |
  26002. * | 3 | CUBIC_MODE | |
  26003. * | 4 | PROJECTION_MODE | |
  26004. * | 5 | SKYBOX_MODE | |
  26005. * | 6 | INVCUBIC_MODE | |
  26006. * | 7 | EQUIRECTANGULAR_MODE | |
  26007. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26008. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26009. */
  26010. coordinatesMode: number;
  26011. /**
  26012. * | Value | Type | Description |
  26013. * | ----- | ------------------ | ----------- |
  26014. * | 0 | CLAMP_ADDRESSMODE | |
  26015. * | 1 | WRAP_ADDRESSMODE | |
  26016. * | 2 | MIRROR_ADDRESSMODE | |
  26017. */
  26018. wrapU: number;
  26019. /**
  26020. * | Value | Type | Description |
  26021. * | ----- | ------------------ | ----------- |
  26022. * | 0 | CLAMP_ADDRESSMODE | |
  26023. * | 1 | WRAP_ADDRESSMODE | |
  26024. * | 2 | MIRROR_ADDRESSMODE | |
  26025. */
  26026. wrapV: number;
  26027. /**
  26028. * | Value | Type | Description |
  26029. * | ----- | ------------------ | ----------- |
  26030. * | 0 | CLAMP_ADDRESSMODE | |
  26031. * | 1 | WRAP_ADDRESSMODE | |
  26032. * | 2 | MIRROR_ADDRESSMODE | |
  26033. */
  26034. wrapR: number;
  26035. /**
  26036. * With compliant hardware and browser (supporting anisotropic filtering)
  26037. * this defines the level of anisotropic filtering in the texture.
  26038. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26039. */
  26040. anisotropicFilteringLevel: number;
  26041. /**
  26042. * Define if the texture is a cube texture or if false a 2d texture.
  26043. */
  26044. isCube: boolean;
  26045. /**
  26046. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26047. */
  26048. is3D: boolean;
  26049. /**
  26050. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26051. * HDR texture are usually stored in linear space.
  26052. * This only impacts the PBR and Background materials
  26053. */
  26054. gammaSpace: boolean;
  26055. /**
  26056. * Gets whether or not the texture contains RGBD data.
  26057. */
  26058. readonly isRGBD: boolean;
  26059. /**
  26060. * Is Z inverted in the texture (useful in a cube texture).
  26061. */
  26062. invertZ: boolean;
  26063. /**
  26064. * Are mip maps generated for this texture or not.
  26065. */
  26066. readonly noMipmap: boolean;
  26067. /**
  26068. * @hidden
  26069. */
  26070. lodLevelInAlpha: boolean;
  26071. /**
  26072. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26073. */
  26074. lodGenerationOffset: number;
  26075. /**
  26076. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26077. */
  26078. lodGenerationScale: number;
  26079. /**
  26080. * Define if the texture is a render target.
  26081. */
  26082. isRenderTarget: boolean;
  26083. /**
  26084. * Define the unique id of the texture in the scene.
  26085. */
  26086. readonly uid: string;
  26087. /**
  26088. * Return a string representation of the texture.
  26089. * @returns the texture as a string
  26090. */
  26091. toString(): string;
  26092. /**
  26093. * Get the class name of the texture.
  26094. * @returns "BaseTexture"
  26095. */
  26096. getClassName(): string;
  26097. /**
  26098. * Define the list of animation attached to the texture.
  26099. */
  26100. animations: Animation[];
  26101. /**
  26102. * An event triggered when the texture is disposed.
  26103. */
  26104. onDisposeObservable: Observable<BaseTexture>;
  26105. private _onDisposeObserver;
  26106. /**
  26107. * Callback triggered when the texture has been disposed.
  26108. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26109. */
  26110. onDispose: () => void;
  26111. /**
  26112. * Define the current state of the loading sequence when in delayed load mode.
  26113. */
  26114. delayLoadState: number;
  26115. private _scene;
  26116. /** @hidden */
  26117. _texture: Nullable<InternalTexture>;
  26118. private _uid;
  26119. /**
  26120. * Define if the texture is preventinga material to render or not.
  26121. * If not and the texture is not ready, the engine will use a default black texture instead.
  26122. */
  26123. readonly isBlocking: boolean;
  26124. /**
  26125. * Instantiates a new BaseTexture.
  26126. * Base class of all the textures in babylon.
  26127. * It groups all the common properties the materials, post process, lights... might need
  26128. * in order to make a correct use of the texture.
  26129. * @param scene Define the scene the texture blongs to
  26130. */
  26131. constructor(scene: Nullable<Scene>);
  26132. /**
  26133. * Get the scene the texture belongs to.
  26134. * @returns the scene or null if undefined
  26135. */
  26136. getScene(): Nullable<Scene>;
  26137. /**
  26138. * Get the texture transform matrix used to offset tile the texture for istance.
  26139. * @returns the transformation matrix
  26140. */
  26141. getTextureMatrix(): Matrix;
  26142. /**
  26143. * Get the texture reflection matrix used to rotate/transform the reflection.
  26144. * @returns the reflection matrix
  26145. */
  26146. getReflectionTextureMatrix(): Matrix;
  26147. /**
  26148. * Get the underlying lower level texture from Babylon.
  26149. * @returns the insternal texture
  26150. */
  26151. getInternalTexture(): Nullable<InternalTexture>;
  26152. /**
  26153. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26154. * @returns true if ready or not blocking
  26155. */
  26156. isReadyOrNotBlocking(): boolean;
  26157. /**
  26158. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26159. * @returns true if fully ready
  26160. */
  26161. isReady(): boolean;
  26162. private _cachedSize;
  26163. /**
  26164. * Get the size of the texture.
  26165. * @returns the texture size.
  26166. */
  26167. getSize(): ISize;
  26168. /**
  26169. * Get the base size of the texture.
  26170. * It can be different from the size if the texture has been resized for POT for instance
  26171. * @returns the base size
  26172. */
  26173. getBaseSize(): ISize;
  26174. /**
  26175. * Update the sampling mode of the texture.
  26176. * Default is Trilinear mode.
  26177. *
  26178. * | Value | Type | Description |
  26179. * | ----- | ------------------ | ----------- |
  26180. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26181. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26182. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26183. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26184. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26185. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26186. * | 7 | NEAREST_LINEAR | |
  26187. * | 8 | NEAREST_NEAREST | |
  26188. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26189. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26190. * | 11 | LINEAR_LINEAR | |
  26191. * | 12 | LINEAR_NEAREST | |
  26192. *
  26193. * > _mag_: magnification filter (close to the viewer)
  26194. * > _min_: minification filter (far from the viewer)
  26195. * > _mip_: filter used between mip map levels
  26196. *@param samplingMode Define the new sampling mode of the texture
  26197. */
  26198. updateSamplingMode(samplingMode: number): void;
  26199. /**
  26200. * Scales the texture if is `canRescale()`
  26201. * @param ratio the resize factor we want to use to rescale
  26202. */
  26203. scale(ratio: number): void;
  26204. /**
  26205. * Get if the texture can rescale.
  26206. */
  26207. readonly canRescale: boolean;
  26208. /** @hidden */
  26209. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26210. /** @hidden */
  26211. _rebuild(): void;
  26212. /**
  26213. * Triggers the load sequence in delayed load mode.
  26214. */
  26215. delayLoad(): void;
  26216. /**
  26217. * Clones the texture.
  26218. * @returns the cloned texture
  26219. */
  26220. clone(): Nullable<BaseTexture>;
  26221. /**
  26222. * Get the texture underlying type (INT, FLOAT...)
  26223. */
  26224. readonly textureType: number;
  26225. /**
  26226. * Get the texture underlying format (RGB, RGBA...)
  26227. */
  26228. readonly textureFormat: number;
  26229. /**
  26230. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26231. * This will returns an RGBA array buffer containing either in values (0-255) or
  26232. * float values (0-1) depending of the underlying buffer type.
  26233. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26234. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26235. * @param buffer defines a user defined buffer to fill with data (can be null)
  26236. * @returns The Array buffer containing the pixels data.
  26237. */
  26238. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26239. /**
  26240. * Release and destroy the underlying lower level texture aka internalTexture.
  26241. */
  26242. releaseInternalTexture(): void;
  26243. /**
  26244. * Get the polynomial representation of the texture data.
  26245. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26246. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26247. */
  26248. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26249. /** @hidden */
  26250. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26251. /** @hidden */
  26252. readonly _lodTextureMid: Nullable<BaseTexture>;
  26253. /** @hidden */
  26254. readonly _lodTextureLow: Nullable<BaseTexture>;
  26255. /**
  26256. * Dispose the texture and release its associated resources.
  26257. */
  26258. dispose(): void;
  26259. /**
  26260. * Serialize the texture into a JSON representation that can be parsed later on.
  26261. * @returns the JSON representation of the texture
  26262. */
  26263. serialize(): any;
  26264. /**
  26265. * Helper function to be called back once a list of texture contains only ready textures.
  26266. * @param textures Define the list of textures to wait for
  26267. * @param callback Define the callback triggered once the entire list will be ready
  26268. */
  26269. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26270. }
  26271. }
  26272. declare module BABYLON {
  26273. /**
  26274. * Uniform buffer objects.
  26275. *
  26276. * Handles blocks of uniform on the GPU.
  26277. *
  26278. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26279. *
  26280. * For more information, please refer to :
  26281. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26282. */
  26283. export class UniformBuffer {
  26284. private _engine;
  26285. private _buffer;
  26286. private _data;
  26287. private _bufferData;
  26288. private _dynamic?;
  26289. private _uniformLocations;
  26290. private _uniformSizes;
  26291. private _uniformLocationPointer;
  26292. private _needSync;
  26293. private _noUBO;
  26294. private _currentEffect;
  26295. private static _MAX_UNIFORM_SIZE;
  26296. private static _tempBuffer;
  26297. /**
  26298. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26299. * This is dynamic to allow compat with webgl 1 and 2.
  26300. * You will need to pass the name of the uniform as well as the value.
  26301. */
  26302. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26303. /**
  26304. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26305. * This is dynamic to allow compat with webgl 1 and 2.
  26306. * You will need to pass the name of the uniform as well as the value.
  26307. */
  26308. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26309. /**
  26310. * Lambda to Update a single float in a uniform buffer.
  26311. * This is dynamic to allow compat with webgl 1 and 2.
  26312. * You will need to pass the name of the uniform as well as the value.
  26313. */
  26314. updateFloat: (name: string, x: number) => void;
  26315. /**
  26316. * Lambda to Update a vec2 of float in a uniform buffer.
  26317. * This is dynamic to allow compat with webgl 1 and 2.
  26318. * You will need to pass the name of the uniform as well as the value.
  26319. */
  26320. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26321. /**
  26322. * Lambda to Update a vec3 of float in a uniform buffer.
  26323. * This is dynamic to allow compat with webgl 1 and 2.
  26324. * You will need to pass the name of the uniform as well as the value.
  26325. */
  26326. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26327. /**
  26328. * Lambda to Update a vec4 of float in a uniform buffer.
  26329. * This is dynamic to allow compat with webgl 1 and 2.
  26330. * You will need to pass the name of the uniform as well as the value.
  26331. */
  26332. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26333. /**
  26334. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26335. * This is dynamic to allow compat with webgl 1 and 2.
  26336. * You will need to pass the name of the uniform as well as the value.
  26337. */
  26338. updateMatrix: (name: string, mat: Matrix) => void;
  26339. /**
  26340. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26341. * This is dynamic to allow compat with webgl 1 and 2.
  26342. * You will need to pass the name of the uniform as well as the value.
  26343. */
  26344. updateVector3: (name: string, vector: Vector3) => void;
  26345. /**
  26346. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26347. * This is dynamic to allow compat with webgl 1 and 2.
  26348. * You will need to pass the name of the uniform as well as the value.
  26349. */
  26350. updateVector4: (name: string, vector: Vector4) => void;
  26351. /**
  26352. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26353. * This is dynamic to allow compat with webgl 1 and 2.
  26354. * You will need to pass the name of the uniform as well as the value.
  26355. */
  26356. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26357. /**
  26358. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26359. * This is dynamic to allow compat with webgl 1 and 2.
  26360. * You will need to pass the name of the uniform as well as the value.
  26361. */
  26362. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26363. /**
  26364. * Instantiates a new Uniform buffer objects.
  26365. *
  26366. * Handles blocks of uniform on the GPU.
  26367. *
  26368. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26369. *
  26370. * For more information, please refer to :
  26371. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26372. * @param engine Define the engine the buffer is associated with
  26373. * @param data Define the data contained in the buffer
  26374. * @param dynamic Define if the buffer is updatable
  26375. */
  26376. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26377. /**
  26378. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26379. * or just falling back on setUniformXXX calls.
  26380. */
  26381. readonly useUbo: boolean;
  26382. /**
  26383. * Indicates if the WebGL underlying uniform buffer is in sync
  26384. * with the javascript cache data.
  26385. */
  26386. readonly isSync: boolean;
  26387. /**
  26388. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26389. * Also, a dynamic UniformBuffer will disable cache verification and always
  26390. * update the underlying WebGL uniform buffer to the GPU.
  26391. * @returns if Dynamic, otherwise false
  26392. */
  26393. isDynamic(): boolean;
  26394. /**
  26395. * The data cache on JS side.
  26396. * @returns the underlying data as a float array
  26397. */
  26398. getData(): Float32Array;
  26399. /**
  26400. * The underlying WebGL Uniform buffer.
  26401. * @returns the webgl buffer
  26402. */
  26403. getBuffer(): Nullable<DataBuffer>;
  26404. /**
  26405. * std140 layout specifies how to align data within an UBO structure.
  26406. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26407. * for specs.
  26408. */
  26409. private _fillAlignment;
  26410. /**
  26411. * Adds an uniform in the buffer.
  26412. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26413. * for the layout to be correct !
  26414. * @param name Name of the uniform, as used in the uniform block in the shader.
  26415. * @param size Data size, or data directly.
  26416. */
  26417. addUniform(name: string, size: number | number[]): void;
  26418. /**
  26419. * Adds a Matrix 4x4 to the uniform buffer.
  26420. * @param name Name of the uniform, as used in the uniform block in the shader.
  26421. * @param mat A 4x4 matrix.
  26422. */
  26423. addMatrix(name: string, mat: Matrix): void;
  26424. /**
  26425. * Adds a vec2 to the uniform buffer.
  26426. * @param name Name of the uniform, as used in the uniform block in the shader.
  26427. * @param x Define the x component value of the vec2
  26428. * @param y Define the y component value of the vec2
  26429. */
  26430. addFloat2(name: string, x: number, y: number): void;
  26431. /**
  26432. * Adds a vec3 to the uniform buffer.
  26433. * @param name Name of the uniform, as used in the uniform block in the shader.
  26434. * @param x Define the x component value of the vec3
  26435. * @param y Define the y component value of the vec3
  26436. * @param z Define the z component value of the vec3
  26437. */
  26438. addFloat3(name: string, x: number, y: number, z: number): void;
  26439. /**
  26440. * Adds a vec3 to the uniform buffer.
  26441. * @param name Name of the uniform, as used in the uniform block in the shader.
  26442. * @param color Define the vec3 from a Color
  26443. */
  26444. addColor3(name: string, color: Color3): void;
  26445. /**
  26446. * Adds a vec4 to the uniform buffer.
  26447. * @param name Name of the uniform, as used in the uniform block in the shader.
  26448. * @param color Define the rgb components from a Color
  26449. * @param alpha Define the a component of the vec4
  26450. */
  26451. addColor4(name: string, color: Color3, alpha: number): void;
  26452. /**
  26453. * Adds a vec3 to the uniform buffer.
  26454. * @param name Name of the uniform, as used in the uniform block in the shader.
  26455. * @param vector Define the vec3 components from a Vector
  26456. */
  26457. addVector3(name: string, vector: Vector3): void;
  26458. /**
  26459. * Adds a Matrix 3x3 to the uniform buffer.
  26460. * @param name Name of the uniform, as used in the uniform block in the shader.
  26461. */
  26462. addMatrix3x3(name: string): void;
  26463. /**
  26464. * Adds a Matrix 2x2 to the uniform buffer.
  26465. * @param name Name of the uniform, as used in the uniform block in the shader.
  26466. */
  26467. addMatrix2x2(name: string): void;
  26468. /**
  26469. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26470. */
  26471. create(): void;
  26472. /** @hidden */
  26473. _rebuild(): void;
  26474. /**
  26475. * Updates the WebGL Uniform Buffer on the GPU.
  26476. * If the `dynamic` flag is set to true, no cache comparison is done.
  26477. * Otherwise, the buffer will be updated only if the cache differs.
  26478. */
  26479. update(): void;
  26480. /**
  26481. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26482. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26483. * @param data Define the flattened data
  26484. * @param size Define the size of the data.
  26485. */
  26486. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26487. private _updateMatrix3x3ForUniform;
  26488. private _updateMatrix3x3ForEffect;
  26489. private _updateMatrix2x2ForEffect;
  26490. private _updateMatrix2x2ForUniform;
  26491. private _updateFloatForEffect;
  26492. private _updateFloatForUniform;
  26493. private _updateFloat2ForEffect;
  26494. private _updateFloat2ForUniform;
  26495. private _updateFloat3ForEffect;
  26496. private _updateFloat3ForUniform;
  26497. private _updateFloat4ForEffect;
  26498. private _updateFloat4ForUniform;
  26499. private _updateMatrixForEffect;
  26500. private _updateMatrixForUniform;
  26501. private _updateVector3ForEffect;
  26502. private _updateVector3ForUniform;
  26503. private _updateVector4ForEffect;
  26504. private _updateVector4ForUniform;
  26505. private _updateColor3ForEffect;
  26506. private _updateColor3ForUniform;
  26507. private _updateColor4ForEffect;
  26508. private _updateColor4ForUniform;
  26509. /**
  26510. * Sets a sampler uniform on the effect.
  26511. * @param name Define the name of the sampler.
  26512. * @param texture Define the texture to set in the sampler
  26513. */
  26514. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26515. /**
  26516. * Directly updates the value of the uniform in the cache AND on the GPU.
  26517. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26518. * @param data Define the flattened data
  26519. */
  26520. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26521. /**
  26522. * Binds this uniform buffer to an effect.
  26523. * @param effect Define the effect to bind the buffer to
  26524. * @param name Name of the uniform block in the shader.
  26525. */
  26526. bindToEffect(effect: Effect, name: string): void;
  26527. /**
  26528. * Disposes the uniform buffer.
  26529. */
  26530. dispose(): void;
  26531. }
  26532. }
  26533. declare module BABYLON {
  26534. /**
  26535. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26537. */
  26538. export class Analyser {
  26539. /**
  26540. * Gets or sets the smoothing
  26541. * @ignorenaming
  26542. */
  26543. SMOOTHING: number;
  26544. /**
  26545. * Gets or sets the FFT table size
  26546. * @ignorenaming
  26547. */
  26548. FFT_SIZE: number;
  26549. /**
  26550. * Gets or sets the bar graph amplitude
  26551. * @ignorenaming
  26552. */
  26553. BARGRAPHAMPLITUDE: number;
  26554. /**
  26555. * Gets or sets the position of the debug canvas
  26556. * @ignorenaming
  26557. */
  26558. DEBUGCANVASPOS: {
  26559. x: number;
  26560. y: number;
  26561. };
  26562. /**
  26563. * Gets or sets the debug canvas size
  26564. * @ignorenaming
  26565. */
  26566. DEBUGCANVASSIZE: {
  26567. width: number;
  26568. height: number;
  26569. };
  26570. private _byteFreqs;
  26571. private _byteTime;
  26572. private _floatFreqs;
  26573. private _webAudioAnalyser;
  26574. private _debugCanvas;
  26575. private _debugCanvasContext;
  26576. private _scene;
  26577. private _registerFunc;
  26578. private _audioEngine;
  26579. /**
  26580. * Creates a new analyser
  26581. * @param scene defines hosting scene
  26582. */
  26583. constructor(scene: Scene);
  26584. /**
  26585. * Get the number of data values you will have to play with for the visualization
  26586. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26587. * @returns a number
  26588. */
  26589. getFrequencyBinCount(): number;
  26590. /**
  26591. * Gets the current frequency data as a byte array
  26592. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26593. * @returns a Uint8Array
  26594. */
  26595. getByteFrequencyData(): Uint8Array;
  26596. /**
  26597. * Gets the current waveform as a byte array
  26598. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26599. * @returns a Uint8Array
  26600. */
  26601. getByteTimeDomainData(): Uint8Array;
  26602. /**
  26603. * Gets the current frequency data as a float array
  26604. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26605. * @returns a Float32Array
  26606. */
  26607. getFloatFrequencyData(): Float32Array;
  26608. /**
  26609. * Renders the debug canvas
  26610. */
  26611. drawDebugCanvas(): void;
  26612. /**
  26613. * Stops rendering the debug canvas and removes it
  26614. */
  26615. stopDebugCanvas(): void;
  26616. /**
  26617. * Connects two audio nodes
  26618. * @param inputAudioNode defines first node to connect
  26619. * @param outputAudioNode defines second node to connect
  26620. */
  26621. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26622. /**
  26623. * Releases all associated resources
  26624. */
  26625. dispose(): void;
  26626. }
  26627. }
  26628. declare module BABYLON {
  26629. /**
  26630. * This represents an audio engine and it is responsible
  26631. * to play, synchronize and analyse sounds throughout the application.
  26632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26633. */
  26634. export interface IAudioEngine extends IDisposable {
  26635. /**
  26636. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26637. */
  26638. readonly canUseWebAudio: boolean;
  26639. /**
  26640. * Gets the current AudioContext if available.
  26641. */
  26642. readonly audioContext: Nullable<AudioContext>;
  26643. /**
  26644. * The master gain node defines the global audio volume of your audio engine.
  26645. */
  26646. readonly masterGain: GainNode;
  26647. /**
  26648. * Gets whether or not mp3 are supported by your browser.
  26649. */
  26650. readonly isMP3supported: boolean;
  26651. /**
  26652. * Gets whether or not ogg are supported by your browser.
  26653. */
  26654. readonly isOGGsupported: boolean;
  26655. /**
  26656. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26657. * @ignoreNaming
  26658. */
  26659. WarnedWebAudioUnsupported: boolean;
  26660. /**
  26661. * Defines if the audio engine relies on a custom unlocked button.
  26662. * In this case, the embedded button will not be displayed.
  26663. */
  26664. useCustomUnlockedButton: boolean;
  26665. /**
  26666. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26667. */
  26668. readonly unlocked: boolean;
  26669. /**
  26670. * Event raised when audio has been unlocked on the browser.
  26671. */
  26672. onAudioUnlockedObservable: Observable<AudioEngine>;
  26673. /**
  26674. * Event raised when audio has been locked on the browser.
  26675. */
  26676. onAudioLockedObservable: Observable<AudioEngine>;
  26677. /**
  26678. * Flags the audio engine in Locked state.
  26679. * This happens due to new browser policies preventing audio to autoplay.
  26680. */
  26681. lock(): void;
  26682. /**
  26683. * Unlocks the audio engine once a user action has been done on the dom.
  26684. * This is helpful to resume play once browser policies have been satisfied.
  26685. */
  26686. unlock(): void;
  26687. }
  26688. /**
  26689. * This represents the default audio engine used in babylon.
  26690. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26692. */
  26693. export class AudioEngine implements IAudioEngine {
  26694. private _audioContext;
  26695. private _audioContextInitialized;
  26696. private _muteButton;
  26697. private _hostElement;
  26698. /**
  26699. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26700. */
  26701. canUseWebAudio: boolean;
  26702. /**
  26703. * The master gain node defines the global audio volume of your audio engine.
  26704. */
  26705. masterGain: GainNode;
  26706. /**
  26707. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26708. * @ignoreNaming
  26709. */
  26710. WarnedWebAudioUnsupported: boolean;
  26711. /**
  26712. * Gets whether or not mp3 are supported by your browser.
  26713. */
  26714. isMP3supported: boolean;
  26715. /**
  26716. * Gets whether or not ogg are supported by your browser.
  26717. */
  26718. isOGGsupported: boolean;
  26719. /**
  26720. * Gets whether audio has been unlocked on the device.
  26721. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26722. * a user interaction has happened.
  26723. */
  26724. unlocked: boolean;
  26725. /**
  26726. * Defines if the audio engine relies on a custom unlocked button.
  26727. * In this case, the embedded button will not be displayed.
  26728. */
  26729. useCustomUnlockedButton: boolean;
  26730. /**
  26731. * Event raised when audio has been unlocked on the browser.
  26732. */
  26733. onAudioUnlockedObservable: Observable<AudioEngine>;
  26734. /**
  26735. * Event raised when audio has been locked on the browser.
  26736. */
  26737. onAudioLockedObservable: Observable<AudioEngine>;
  26738. /**
  26739. * Gets the current AudioContext if available.
  26740. */
  26741. readonly audioContext: Nullable<AudioContext>;
  26742. private _connectedAnalyser;
  26743. /**
  26744. * Instantiates a new audio engine.
  26745. *
  26746. * There should be only one per page as some browsers restrict the number
  26747. * of audio contexts you can create.
  26748. * @param hostElement defines the host element where to display the mute icon if necessary
  26749. */
  26750. constructor(hostElement?: Nullable<HTMLElement>);
  26751. /**
  26752. * Flags the audio engine in Locked state.
  26753. * This happens due to new browser policies preventing audio to autoplay.
  26754. */
  26755. lock(): void;
  26756. /**
  26757. * Unlocks the audio engine once a user action has been done on the dom.
  26758. * This is helpful to resume play once browser policies have been satisfied.
  26759. */
  26760. unlock(): void;
  26761. private _resumeAudioContext;
  26762. private _initializeAudioContext;
  26763. private _tryToRun;
  26764. private _triggerRunningState;
  26765. private _triggerSuspendedState;
  26766. private _displayMuteButton;
  26767. private _moveButtonToTopLeft;
  26768. private _onResize;
  26769. private _hideMuteButton;
  26770. /**
  26771. * Destroy and release the resources associated with the audio ccontext.
  26772. */
  26773. dispose(): void;
  26774. /**
  26775. * Gets the global volume sets on the master gain.
  26776. * @returns the global volume if set or -1 otherwise
  26777. */
  26778. getGlobalVolume(): number;
  26779. /**
  26780. * Sets the global volume of your experience (sets on the master gain).
  26781. * @param newVolume Defines the new global volume of the application
  26782. */
  26783. setGlobalVolume(newVolume: number): void;
  26784. /**
  26785. * Connect the audio engine to an audio analyser allowing some amazing
  26786. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26788. * @param analyser The analyser to connect to the engine
  26789. */
  26790. connectToAnalyser(analyser: Analyser): void;
  26791. }
  26792. }
  26793. declare module BABYLON {
  26794. /**
  26795. * Interface used to present a loading screen while loading a scene
  26796. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26797. */
  26798. export interface ILoadingScreen {
  26799. /**
  26800. * Function called to display the loading screen
  26801. */
  26802. displayLoadingUI: () => void;
  26803. /**
  26804. * Function called to hide the loading screen
  26805. */
  26806. hideLoadingUI: () => void;
  26807. /**
  26808. * Gets or sets the color to use for the background
  26809. */
  26810. loadingUIBackgroundColor: string;
  26811. /**
  26812. * Gets or sets the text to display while loading
  26813. */
  26814. loadingUIText: string;
  26815. }
  26816. /**
  26817. * Class used for the default loading screen
  26818. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26819. */
  26820. export class DefaultLoadingScreen implements ILoadingScreen {
  26821. private _renderingCanvas;
  26822. private _loadingText;
  26823. private _loadingDivBackgroundColor;
  26824. private _loadingDiv;
  26825. private _loadingTextDiv;
  26826. /** Gets or sets the logo url to use for the default loading screen */
  26827. static DefaultLogoUrl: string;
  26828. /** Gets or sets the spinner url to use for the default loading screen */
  26829. static DefaultSpinnerUrl: string;
  26830. /**
  26831. * Creates a new default loading screen
  26832. * @param _renderingCanvas defines the canvas used to render the scene
  26833. * @param _loadingText defines the default text to display
  26834. * @param _loadingDivBackgroundColor defines the default background color
  26835. */
  26836. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26837. /**
  26838. * Function called to display the loading screen
  26839. */
  26840. displayLoadingUI(): void;
  26841. /**
  26842. * Function called to hide the loading screen
  26843. */
  26844. hideLoadingUI(): void;
  26845. /**
  26846. * Gets or sets the text to display while loading
  26847. */
  26848. loadingUIText: string;
  26849. /**
  26850. * Gets or sets the color to use for the background
  26851. */
  26852. loadingUIBackgroundColor: string;
  26853. private _resizeLoadingUI;
  26854. }
  26855. }
  26856. declare module BABYLON {
  26857. /** @hidden */
  26858. export class WebGLPipelineContext implements IPipelineContext {
  26859. engine: Engine;
  26860. program: Nullable<WebGLProgram>;
  26861. context?: WebGLRenderingContext;
  26862. vertexShader?: WebGLShader;
  26863. fragmentShader?: WebGLShader;
  26864. isParallelCompiled: boolean;
  26865. onCompiled?: () => void;
  26866. transformFeedback?: WebGLTransformFeedback | null;
  26867. readonly isAsync: boolean;
  26868. readonly isReady: boolean;
  26869. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26870. }
  26871. }
  26872. declare module BABYLON {
  26873. /** @hidden */
  26874. export class WebGLDataBuffer extends DataBuffer {
  26875. private _buffer;
  26876. constructor(resource: WebGLBuffer);
  26877. readonly underlyingResource: any;
  26878. }
  26879. }
  26880. declare module BABYLON {
  26881. /**
  26882. * Settings for finer control over video usage
  26883. */
  26884. export interface VideoTextureSettings {
  26885. /**
  26886. * Applies `autoplay` to video, if specified
  26887. */
  26888. autoPlay?: boolean;
  26889. /**
  26890. * Applies `loop` to video, if specified
  26891. */
  26892. loop?: boolean;
  26893. /**
  26894. * Automatically updates internal texture from video at every frame in the render loop
  26895. */
  26896. autoUpdateTexture: boolean;
  26897. /**
  26898. * Image src displayed during the video loading or until the user interacts with the video.
  26899. */
  26900. poster?: string;
  26901. }
  26902. /**
  26903. * If you want to display a video in your scene, this is the special texture for that.
  26904. * This special texture works similar to other textures, with the exception of a few parameters.
  26905. * @see https://doc.babylonjs.com/how_to/video_texture
  26906. */
  26907. export class VideoTexture extends Texture {
  26908. /**
  26909. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26910. */
  26911. readonly autoUpdateTexture: boolean;
  26912. /**
  26913. * The video instance used by the texture internally
  26914. */
  26915. readonly video: HTMLVideoElement;
  26916. private _onUserActionRequestedObservable;
  26917. /**
  26918. * Event triggerd when a dom action is required by the user to play the video.
  26919. * This happens due to recent changes in browser policies preventing video to auto start.
  26920. */
  26921. readonly onUserActionRequestedObservable: Observable<Texture>;
  26922. private _generateMipMaps;
  26923. private _engine;
  26924. private _stillImageCaptured;
  26925. private _displayingPosterTexture;
  26926. private _settings;
  26927. private _createInternalTextureOnEvent;
  26928. /**
  26929. * Creates a video texture.
  26930. * If you want to display a video in your scene, this is the special texture for that.
  26931. * This special texture works similar to other textures, with the exception of a few parameters.
  26932. * @see https://doc.babylonjs.com/how_to/video_texture
  26933. * @param name optional name, will detect from video source, if not defined
  26934. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26935. * @param scene is obviously the current scene.
  26936. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26937. * @param invertY is false by default but can be used to invert video on Y axis
  26938. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26939. * @param settings allows finer control over video usage
  26940. */
  26941. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26942. private _getName;
  26943. private _getVideo;
  26944. private _createInternalTexture;
  26945. private reset;
  26946. /**
  26947. * @hidden Internal method to initiate `update`.
  26948. */
  26949. _rebuild(): void;
  26950. /**
  26951. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26952. */
  26953. update(): void;
  26954. /**
  26955. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26956. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26957. */
  26958. updateTexture(isVisible: boolean): void;
  26959. protected _updateInternalTexture: () => void;
  26960. /**
  26961. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26962. * @param url New url.
  26963. */
  26964. updateURL(url: string): void;
  26965. /**
  26966. * Dispose the texture and release its associated resources.
  26967. */
  26968. dispose(): void;
  26969. /**
  26970. * Creates a video texture straight from a stream.
  26971. * @param scene Define the scene the texture should be created in
  26972. * @param stream Define the stream the texture should be created from
  26973. * @returns The created video texture as a promise
  26974. */
  26975. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26976. /**
  26977. * Creates a video texture straight from your WebCam video feed.
  26978. * @param scene Define the scene the texture should be created in
  26979. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26980. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26981. * @returns The created video texture as a promise
  26982. */
  26983. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26984. minWidth: number;
  26985. maxWidth: number;
  26986. minHeight: number;
  26987. maxHeight: number;
  26988. deviceId: string;
  26989. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26990. /**
  26991. * Creates a video texture straight from your WebCam video feed.
  26992. * @param scene Define the scene the texture should be created in
  26993. * @param onReady Define a callback to triggered once the texture will be ready
  26994. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26995. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26996. */
  26997. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26998. minWidth: number;
  26999. maxWidth: number;
  27000. minHeight: number;
  27001. maxHeight: number;
  27002. deviceId: string;
  27003. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27004. }
  27005. }
  27006. declare module BABYLON {
  27007. /**
  27008. * Interface for attribute information associated with buffer instanciation
  27009. */
  27010. export class InstancingAttributeInfo {
  27011. /**
  27012. * Index/offset of the attribute in the vertex shader
  27013. */
  27014. index: number;
  27015. /**
  27016. * size of the attribute, 1, 2, 3 or 4
  27017. */
  27018. attributeSize: number;
  27019. /**
  27020. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27021. * default is FLOAT
  27022. */
  27023. attribyteType: number;
  27024. /**
  27025. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27026. */
  27027. normalized: boolean;
  27028. /**
  27029. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27030. */
  27031. offset: number;
  27032. /**
  27033. * Name of the GLSL attribute, for debugging purpose only
  27034. */
  27035. attributeName: string;
  27036. }
  27037. /**
  27038. * Define options used to create a depth texture
  27039. */
  27040. export class DepthTextureCreationOptions {
  27041. /** Specifies whether or not a stencil should be allocated in the texture */
  27042. generateStencil?: boolean;
  27043. /** Specifies whether or not bilinear filtering is enable on the texture */
  27044. bilinearFiltering?: boolean;
  27045. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27046. comparisonFunction?: number;
  27047. /** Specifies if the created texture is a cube texture */
  27048. isCube?: boolean;
  27049. }
  27050. /**
  27051. * Class used to describe the capabilities of the engine relatively to the current browser
  27052. */
  27053. export class EngineCapabilities {
  27054. /** Maximum textures units per fragment shader */
  27055. maxTexturesImageUnits: number;
  27056. /** Maximum texture units per vertex shader */
  27057. maxVertexTextureImageUnits: number;
  27058. /** Maximum textures units in the entire pipeline */
  27059. maxCombinedTexturesImageUnits: number;
  27060. /** Maximum texture size */
  27061. maxTextureSize: number;
  27062. /** Maximum cube texture size */
  27063. maxCubemapTextureSize: number;
  27064. /** Maximum render texture size */
  27065. maxRenderTextureSize: number;
  27066. /** Maximum number of vertex attributes */
  27067. maxVertexAttribs: number;
  27068. /** Maximum number of varyings */
  27069. maxVaryingVectors: number;
  27070. /** Maximum number of uniforms per vertex shader */
  27071. maxVertexUniformVectors: number;
  27072. /** Maximum number of uniforms per fragment shader */
  27073. maxFragmentUniformVectors: number;
  27074. /** Defines if standard derivates (dx/dy) are supported */
  27075. standardDerivatives: boolean;
  27076. /** Defines if s3tc texture compression is supported */
  27077. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27078. /** Defines if pvrtc texture compression is supported */
  27079. pvrtc: any;
  27080. /** Defines if etc1 texture compression is supported */
  27081. etc1: any;
  27082. /** Defines if etc2 texture compression is supported */
  27083. etc2: any;
  27084. /** Defines if astc texture compression is supported */
  27085. astc: any;
  27086. /** Defines if float textures are supported */
  27087. textureFloat: boolean;
  27088. /** Defines if vertex array objects are supported */
  27089. vertexArrayObject: boolean;
  27090. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27091. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27092. /** Gets the maximum level of anisotropy supported */
  27093. maxAnisotropy: number;
  27094. /** Defines if instancing is supported */
  27095. instancedArrays: boolean;
  27096. /** Defines if 32 bits indices are supported */
  27097. uintIndices: boolean;
  27098. /** Defines if high precision shaders are supported */
  27099. highPrecisionShaderSupported: boolean;
  27100. /** Defines if depth reading in the fragment shader is supported */
  27101. fragmentDepthSupported: boolean;
  27102. /** Defines if float texture linear filtering is supported*/
  27103. textureFloatLinearFiltering: boolean;
  27104. /** Defines if rendering to float textures is supported */
  27105. textureFloatRender: boolean;
  27106. /** Defines if half float textures are supported*/
  27107. textureHalfFloat: boolean;
  27108. /** Defines if half float texture linear filtering is supported*/
  27109. textureHalfFloatLinearFiltering: boolean;
  27110. /** Defines if rendering to half float textures is supported */
  27111. textureHalfFloatRender: boolean;
  27112. /** Defines if textureLOD shader command is supported */
  27113. textureLOD: boolean;
  27114. /** Defines if draw buffers extension is supported */
  27115. drawBuffersExtension: boolean;
  27116. /** Defines if depth textures are supported */
  27117. depthTextureExtension: boolean;
  27118. /** Defines if float color buffer are supported */
  27119. colorBufferFloat: boolean;
  27120. /** Gets disjoint timer query extension (null if not supported) */
  27121. timerQuery: EXT_disjoint_timer_query;
  27122. /** Defines if timestamp can be used with timer query */
  27123. canUseTimestampForTimerQuery: boolean;
  27124. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27125. multiview: any;
  27126. /** Function used to let the system compiles shaders in background */
  27127. parallelShaderCompile: {
  27128. COMPLETION_STATUS_KHR: number;
  27129. };
  27130. }
  27131. /** Interface defining initialization parameters for Engine class */
  27132. export interface EngineOptions extends WebGLContextAttributes {
  27133. /**
  27134. * Defines if the engine should no exceed a specified device ratio
  27135. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27136. */
  27137. limitDeviceRatio?: number;
  27138. /**
  27139. * Defines if webvr should be enabled automatically
  27140. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27141. */
  27142. autoEnableWebVR?: boolean;
  27143. /**
  27144. * Defines if webgl2 should be turned off even if supported
  27145. * @see http://doc.babylonjs.com/features/webgl2
  27146. */
  27147. disableWebGL2Support?: boolean;
  27148. /**
  27149. * Defines if webaudio should be initialized as well
  27150. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27151. */
  27152. audioEngine?: boolean;
  27153. /**
  27154. * Defines if animations should run using a deterministic lock step
  27155. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27156. */
  27157. deterministicLockstep?: boolean;
  27158. /** Defines the maximum steps to use with deterministic lock step mode */
  27159. lockstepMaxSteps?: number;
  27160. /**
  27161. * Defines that engine should ignore context lost events
  27162. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27163. */
  27164. doNotHandleContextLost?: boolean;
  27165. /**
  27166. * Defines that engine should ignore modifying touch action attribute and style
  27167. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27168. */
  27169. doNotHandleTouchAction?: boolean;
  27170. /**
  27171. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27172. */
  27173. useHighPrecisionFloats?: boolean;
  27174. }
  27175. /**
  27176. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27177. */
  27178. export class Engine {
  27179. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27180. static ExceptionList: ({
  27181. key: string;
  27182. capture: string;
  27183. captureConstraint: number;
  27184. targets: string[];
  27185. } | {
  27186. key: string;
  27187. capture: null;
  27188. captureConstraint: null;
  27189. targets: string[];
  27190. })[];
  27191. /** Gets the list of created engines */
  27192. static readonly Instances: Engine[];
  27193. /**
  27194. * Gets the latest created engine
  27195. */
  27196. static readonly LastCreatedEngine: Nullable<Engine>;
  27197. /**
  27198. * Gets the latest created scene
  27199. */
  27200. static readonly LastCreatedScene: Nullable<Scene>;
  27201. /**
  27202. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27203. * @param flag defines which part of the materials must be marked as dirty
  27204. * @param predicate defines a predicate used to filter which materials should be affected
  27205. */
  27206. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27207. /**
  27208. * Hidden
  27209. */
  27210. static _TextureLoaders: IInternalTextureLoader[];
  27211. /** Defines that alpha blending is disabled */
  27212. static readonly ALPHA_DISABLE: number;
  27213. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27214. static readonly ALPHA_ADD: number;
  27215. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27216. static readonly ALPHA_COMBINE: number;
  27217. /** Defines that alpha blending to DEST - SRC * DEST */
  27218. static readonly ALPHA_SUBTRACT: number;
  27219. /** Defines that alpha blending to SRC * DEST */
  27220. static readonly ALPHA_MULTIPLY: number;
  27221. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27222. static readonly ALPHA_MAXIMIZED: number;
  27223. /** Defines that alpha blending to SRC + DEST */
  27224. static readonly ALPHA_ONEONE: number;
  27225. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27226. static readonly ALPHA_PREMULTIPLIED: number;
  27227. /**
  27228. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27229. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27230. */
  27231. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27232. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27233. static readonly ALPHA_INTERPOLATE: number;
  27234. /**
  27235. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27236. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27237. */
  27238. static readonly ALPHA_SCREENMODE: number;
  27239. /** Defines that the ressource is not delayed*/
  27240. static readonly DELAYLOADSTATE_NONE: number;
  27241. /** Defines that the ressource was successfully delay loaded */
  27242. static readonly DELAYLOADSTATE_LOADED: number;
  27243. /** Defines that the ressource is currently delay loading */
  27244. static readonly DELAYLOADSTATE_LOADING: number;
  27245. /** Defines that the ressource is delayed and has not started loading */
  27246. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27247. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27248. static readonly NEVER: number;
  27249. /** 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 */
  27250. static readonly ALWAYS: number;
  27251. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27252. static readonly LESS: number;
  27253. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27254. static readonly EQUAL: number;
  27255. /** 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 */
  27256. static readonly LEQUAL: number;
  27257. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27258. static readonly GREATER: number;
  27259. /** 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 */
  27260. static readonly GEQUAL: number;
  27261. /** 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 */
  27262. static readonly NOTEQUAL: number;
  27263. /** Passed to stencilOperation to specify that stencil value must be kept */
  27264. static readonly KEEP: number;
  27265. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27266. static readonly REPLACE: number;
  27267. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27268. static readonly INCR: number;
  27269. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27270. static readonly DECR: number;
  27271. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27272. static readonly INVERT: number;
  27273. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27274. static readonly INCR_WRAP: number;
  27275. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27276. static readonly DECR_WRAP: number;
  27277. /** Texture is not repeating outside of 0..1 UVs */
  27278. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27279. /** Texture is repeating outside of 0..1 UVs */
  27280. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27281. /** Texture is repeating and mirrored */
  27282. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27283. /** ALPHA */
  27284. static readonly TEXTUREFORMAT_ALPHA: number;
  27285. /** LUMINANCE */
  27286. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27287. /** LUMINANCE_ALPHA */
  27288. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27289. /** RGB */
  27290. static readonly TEXTUREFORMAT_RGB: number;
  27291. /** RGBA */
  27292. static readonly TEXTUREFORMAT_RGBA: number;
  27293. /** RED */
  27294. static readonly TEXTUREFORMAT_RED: number;
  27295. /** RED (2nd reference) */
  27296. static readonly TEXTUREFORMAT_R: number;
  27297. /** RG */
  27298. static readonly TEXTUREFORMAT_RG: number;
  27299. /** RED_INTEGER */
  27300. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27301. /** RED_INTEGER (2nd reference) */
  27302. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27303. /** RG_INTEGER */
  27304. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27305. /** RGB_INTEGER */
  27306. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27307. /** RGBA_INTEGER */
  27308. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27309. /** UNSIGNED_BYTE */
  27310. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27311. /** UNSIGNED_BYTE (2nd reference) */
  27312. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27313. /** FLOAT */
  27314. static readonly TEXTURETYPE_FLOAT: number;
  27315. /** HALF_FLOAT */
  27316. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27317. /** BYTE */
  27318. static readonly TEXTURETYPE_BYTE: number;
  27319. /** SHORT */
  27320. static readonly TEXTURETYPE_SHORT: number;
  27321. /** UNSIGNED_SHORT */
  27322. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27323. /** INT */
  27324. static readonly TEXTURETYPE_INT: number;
  27325. /** UNSIGNED_INT */
  27326. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27327. /** UNSIGNED_SHORT_4_4_4_4 */
  27328. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27329. /** UNSIGNED_SHORT_5_5_5_1 */
  27330. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27331. /** UNSIGNED_SHORT_5_6_5 */
  27332. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27333. /** UNSIGNED_INT_2_10_10_10_REV */
  27334. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27335. /** UNSIGNED_INT_24_8 */
  27336. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27337. /** UNSIGNED_INT_10F_11F_11F_REV */
  27338. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27339. /** UNSIGNED_INT_5_9_9_9_REV */
  27340. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27341. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27342. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27343. /** nearest is mag = nearest and min = nearest and mip = linear */
  27344. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27345. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27346. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27347. /** Trilinear is mag = linear and min = linear and mip = linear */
  27348. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27349. /** nearest is mag = nearest and min = nearest and mip = linear */
  27350. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27351. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27352. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27353. /** Trilinear is mag = linear and min = linear and mip = linear */
  27354. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27355. /** mag = nearest and min = nearest and mip = nearest */
  27356. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27357. /** mag = nearest and min = linear and mip = nearest */
  27358. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27359. /** mag = nearest and min = linear and mip = linear */
  27360. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27361. /** mag = nearest and min = linear and mip = none */
  27362. static readonly TEXTURE_NEAREST_LINEAR: number;
  27363. /** mag = nearest and min = nearest and mip = none */
  27364. static readonly TEXTURE_NEAREST_NEAREST: number;
  27365. /** mag = linear and min = nearest and mip = nearest */
  27366. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27367. /** mag = linear and min = nearest and mip = linear */
  27368. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27369. /** mag = linear and min = linear and mip = none */
  27370. static readonly TEXTURE_LINEAR_LINEAR: number;
  27371. /** mag = linear and min = nearest and mip = none */
  27372. static readonly TEXTURE_LINEAR_NEAREST: number;
  27373. /** Explicit coordinates mode */
  27374. static readonly TEXTURE_EXPLICIT_MODE: number;
  27375. /** Spherical coordinates mode */
  27376. static readonly TEXTURE_SPHERICAL_MODE: number;
  27377. /** Planar coordinates mode */
  27378. static readonly TEXTURE_PLANAR_MODE: number;
  27379. /** Cubic coordinates mode */
  27380. static readonly TEXTURE_CUBIC_MODE: number;
  27381. /** Projection coordinates mode */
  27382. static readonly TEXTURE_PROJECTION_MODE: number;
  27383. /** Skybox coordinates mode */
  27384. static readonly TEXTURE_SKYBOX_MODE: number;
  27385. /** Inverse Cubic coordinates mode */
  27386. static readonly TEXTURE_INVCUBIC_MODE: number;
  27387. /** Equirectangular coordinates mode */
  27388. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27389. /** Equirectangular Fixed coordinates mode */
  27390. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27391. /** Equirectangular Fixed Mirrored coordinates mode */
  27392. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27393. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27394. static readonly SCALEMODE_FLOOR: number;
  27395. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27396. static readonly SCALEMODE_NEAREST: number;
  27397. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27398. static readonly SCALEMODE_CEILING: number;
  27399. /**
  27400. * Returns the current npm package of the sdk
  27401. */
  27402. static readonly NpmPackage: string;
  27403. /**
  27404. * Returns the current version of the framework
  27405. */
  27406. static readonly Version: string;
  27407. /**
  27408. * Returns a string describing the current engine
  27409. */
  27410. readonly description: string;
  27411. /**
  27412. * Gets or sets the epsilon value used by collision engine
  27413. */
  27414. static CollisionsEpsilon: number;
  27415. /**
  27416. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27417. */
  27418. static ShadersRepository: string;
  27419. /**
  27420. * Method called to create the default loading screen.
  27421. * This can be overriden in your own app.
  27422. * @param canvas The rendering canvas element
  27423. * @returns The loading screen
  27424. */
  27425. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27426. /**
  27427. * Method called to create the default rescale post process on each engine.
  27428. */
  27429. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27430. /**
  27431. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27432. */
  27433. forcePOTTextures: boolean;
  27434. /**
  27435. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27436. */
  27437. isFullscreen: boolean;
  27438. /**
  27439. * Gets a boolean indicating if the pointer is currently locked
  27440. */
  27441. isPointerLock: boolean;
  27442. /**
  27443. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27444. */
  27445. cullBackFaces: boolean;
  27446. /**
  27447. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27448. */
  27449. renderEvenInBackground: boolean;
  27450. /**
  27451. * Gets or sets a boolean indicating that cache can be kept between frames
  27452. */
  27453. preventCacheWipeBetweenFrames: boolean;
  27454. /**
  27455. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27456. **/
  27457. enableOfflineSupport: boolean;
  27458. /**
  27459. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  27460. **/
  27461. disableManifestCheck: boolean;
  27462. /**
  27463. * Gets the list of created scenes
  27464. */
  27465. scenes: Scene[];
  27466. /**
  27467. * Event raised when a new scene is created
  27468. */
  27469. onNewSceneAddedObservable: Observable<Scene>;
  27470. /**
  27471. * Gets the list of created postprocesses
  27472. */
  27473. postProcesses: PostProcess[];
  27474. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27475. validateShaderPrograms: boolean;
  27476. /**
  27477. * Observable event triggered each time the rendering canvas is resized
  27478. */
  27479. onResizeObservable: Observable<Engine>;
  27480. /**
  27481. * Observable event triggered each time the canvas loses focus
  27482. */
  27483. onCanvasBlurObservable: Observable<Engine>;
  27484. /**
  27485. * Observable event triggered each time the canvas gains focus
  27486. */
  27487. onCanvasFocusObservable: Observable<Engine>;
  27488. /**
  27489. * Observable event triggered each time the canvas receives pointerout event
  27490. */
  27491. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27492. /**
  27493. * Observable event triggered before each texture is initialized
  27494. */
  27495. onBeforeTextureInitObservable: Observable<Texture>;
  27496. /**
  27497. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27498. */
  27499. disableUniformBuffers: boolean;
  27500. /** @hidden */
  27501. _uniformBuffers: UniformBuffer[];
  27502. /**
  27503. * Gets a boolean indicating that the engine supports uniform buffers
  27504. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27505. */
  27506. readonly supportsUniformBuffers: boolean;
  27507. /**
  27508. * Observable raised when the engine begins a new frame
  27509. */
  27510. onBeginFrameObservable: Observable<Engine>;
  27511. /**
  27512. * If set, will be used to request the next animation frame for the render loop
  27513. */
  27514. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27515. /**
  27516. * Observable raised when the engine ends the current frame
  27517. */
  27518. onEndFrameObservable: Observable<Engine>;
  27519. /**
  27520. * Observable raised when the engine is about to compile a shader
  27521. */
  27522. onBeforeShaderCompilationObservable: Observable<Engine>;
  27523. /**
  27524. * Observable raised when the engine has jsut compiled a shader
  27525. */
  27526. onAfterShaderCompilationObservable: Observable<Engine>;
  27527. /** @hidden */
  27528. _gl: WebGLRenderingContext;
  27529. private _renderingCanvas;
  27530. private _windowIsBackground;
  27531. private _webGLVersion;
  27532. protected _highPrecisionShadersAllowed: boolean;
  27533. /** @hidden */
  27534. readonly _shouldUseHighPrecisionShader: boolean;
  27535. /**
  27536. * Gets a boolean indicating that only power of 2 textures are supported
  27537. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27538. */
  27539. readonly needPOTTextures: boolean;
  27540. /** @hidden */
  27541. _badOS: boolean;
  27542. /** @hidden */
  27543. _badDesktopOS: boolean;
  27544. /**
  27545. * Gets the audio engine
  27546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27547. * @ignorenaming
  27548. */
  27549. static audioEngine: IAudioEngine;
  27550. /**
  27551. * Default AudioEngine factory responsible of creating the Audio Engine.
  27552. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27553. */
  27554. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27555. /**
  27556. * Default offline support factory responsible of creating a tool used to store data locally.
  27557. * By default, this will create a Database object if the workload has been embedded.
  27558. */
  27559. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27560. private _onFocus;
  27561. private _onBlur;
  27562. private _onCanvasPointerOut;
  27563. private _onCanvasBlur;
  27564. private _onCanvasFocus;
  27565. private _onFullscreenChange;
  27566. private _onPointerLockChange;
  27567. private _hardwareScalingLevel;
  27568. /** @hidden */
  27569. _caps: EngineCapabilities;
  27570. private _pointerLockRequested;
  27571. private _isStencilEnable;
  27572. private _colorWrite;
  27573. private _loadingScreen;
  27574. /** @hidden */
  27575. _drawCalls: PerfCounter;
  27576. private _glVersion;
  27577. private _glRenderer;
  27578. private _glVendor;
  27579. private _videoTextureSupported;
  27580. private _renderingQueueLaunched;
  27581. private _activeRenderLoops;
  27582. private _deterministicLockstep;
  27583. private _lockstepMaxSteps;
  27584. /**
  27585. * Observable signaled when a context lost event is raised
  27586. */
  27587. onContextLostObservable: Observable<Engine>;
  27588. /**
  27589. * Observable signaled when a context restored event is raised
  27590. */
  27591. onContextRestoredObservable: Observable<Engine>;
  27592. private _onContextLost;
  27593. private _onContextRestored;
  27594. private _contextWasLost;
  27595. /** @hidden */
  27596. _doNotHandleContextLost: boolean;
  27597. /**
  27598. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27599. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27600. */
  27601. doNotHandleContextLost: boolean;
  27602. private _performanceMonitor;
  27603. private _fps;
  27604. private _deltaTime;
  27605. /**
  27606. * Turn this value on if you want to pause FPS computation when in background
  27607. */
  27608. disablePerformanceMonitorInBackground: boolean;
  27609. /**
  27610. * Gets the performance monitor attached to this engine
  27611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27612. */
  27613. readonly performanceMonitor: PerformanceMonitor;
  27614. /**
  27615. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27616. */
  27617. disableVertexArrayObjects: boolean;
  27618. /** @hidden */
  27619. protected _depthCullingState: _DepthCullingState;
  27620. /** @hidden */
  27621. protected _stencilState: _StencilState;
  27622. /** @hidden */
  27623. protected _alphaState: _AlphaState;
  27624. /** @hidden */
  27625. protected _alphaMode: number;
  27626. /** @hidden */
  27627. _internalTexturesCache: InternalTexture[];
  27628. /** @hidden */
  27629. protected _activeChannel: number;
  27630. private _currentTextureChannel;
  27631. /** @hidden */
  27632. protected _boundTexturesCache: {
  27633. [key: string]: Nullable<InternalTexture>;
  27634. };
  27635. /** @hidden */
  27636. protected _currentEffect: Nullable<Effect>;
  27637. /** @hidden */
  27638. protected _currentProgram: Nullable<WebGLProgram>;
  27639. private _compiledEffects;
  27640. private _vertexAttribArraysEnabled;
  27641. /** @hidden */
  27642. protected _cachedViewport: Nullable<Viewport>;
  27643. private _cachedVertexArrayObject;
  27644. /** @hidden */
  27645. protected _cachedVertexBuffers: any;
  27646. /** @hidden */
  27647. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27648. /** @hidden */
  27649. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27650. /** @hidden */
  27651. _currentRenderTarget: Nullable<InternalTexture>;
  27652. private _uintIndicesCurrentlySet;
  27653. private _currentBoundBuffer;
  27654. /** @hidden */
  27655. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27656. private _currentBufferPointers;
  27657. private _currentInstanceLocations;
  27658. private _currentInstanceBuffers;
  27659. private _textureUnits;
  27660. /** @hidden */
  27661. _workingCanvas: Nullable<HTMLCanvasElement>;
  27662. /** @hidden */
  27663. _workingContext: Nullable<CanvasRenderingContext2D>;
  27664. private _rescalePostProcess;
  27665. private _dummyFramebuffer;
  27666. private _externalData;
  27667. /** @hidden */
  27668. _bindedRenderFunction: any;
  27669. private _vaoRecordInProgress;
  27670. private _mustWipeVertexAttributes;
  27671. private _emptyTexture;
  27672. private _emptyCubeTexture;
  27673. private _emptyTexture3D;
  27674. /** @hidden */
  27675. _frameHandler: number;
  27676. private _nextFreeTextureSlots;
  27677. private _maxSimultaneousTextures;
  27678. private _activeRequests;
  27679. private _texturesSupported;
  27680. /** @hidden */
  27681. _textureFormatInUse: Nullable<string>;
  27682. /**
  27683. * Gets the list of texture formats supported
  27684. */
  27685. readonly texturesSupported: Array<string>;
  27686. /**
  27687. * Gets the list of texture formats in use
  27688. */
  27689. readonly textureFormatInUse: Nullable<string>;
  27690. /**
  27691. * Gets the current viewport
  27692. */
  27693. readonly currentViewport: Nullable<Viewport>;
  27694. /**
  27695. * Gets the default empty texture
  27696. */
  27697. readonly emptyTexture: InternalTexture;
  27698. /**
  27699. * Gets the default empty 3D texture
  27700. */
  27701. readonly emptyTexture3D: InternalTexture;
  27702. /**
  27703. * Gets the default empty cube texture
  27704. */
  27705. readonly emptyCubeTexture: InternalTexture;
  27706. /**
  27707. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27708. */
  27709. readonly premultipliedAlpha: boolean;
  27710. /**
  27711. * Creates a new engine
  27712. * @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
  27713. * @param antialias defines enable antialiasing (default: false)
  27714. * @param options defines further options to be sent to the getContext() function
  27715. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27716. */
  27717. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27718. /**
  27719. * Initializes a webVR display and starts listening to display change events
  27720. * The onVRDisplayChangedObservable will be notified upon these changes
  27721. * @returns The onVRDisplayChangedObservable
  27722. */
  27723. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27724. /** @hidden */
  27725. _prepareVRComponent(): void;
  27726. /** @hidden */
  27727. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27728. /** @hidden */
  27729. _submitVRFrame(): void;
  27730. /**
  27731. * Call this function to leave webVR mode
  27732. * Will do nothing if webVR is not supported or if there is no webVR device
  27733. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27734. */
  27735. disableVR(): void;
  27736. /**
  27737. * Gets a boolean indicating that the system is in VR mode and is presenting
  27738. * @returns true if VR mode is engaged
  27739. */
  27740. isVRPresenting(): boolean;
  27741. /** @hidden */
  27742. _requestVRFrame(): void;
  27743. private _disableTouchAction;
  27744. private _rebuildInternalTextures;
  27745. private _rebuildEffects;
  27746. /**
  27747. * Gets a boolean indicating if all created effects are ready
  27748. * @returns true if all effects are ready
  27749. */
  27750. areAllEffectsReady(): boolean;
  27751. private _rebuildBuffers;
  27752. private _initGLContext;
  27753. /**
  27754. * Gets version of the current webGL context
  27755. */
  27756. readonly webGLVersion: number;
  27757. /**
  27758. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27759. */
  27760. readonly isStencilEnable: boolean;
  27761. /** @hidden */
  27762. _prepareWorkingCanvas(): void;
  27763. /**
  27764. * Reset the texture cache to empty state
  27765. */
  27766. resetTextureCache(): void;
  27767. /**
  27768. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27769. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27770. * @returns true if engine is in deterministic lock step mode
  27771. */
  27772. isDeterministicLockStep(): boolean;
  27773. /**
  27774. * Gets the max steps when engine is running in deterministic lock step
  27775. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27776. * @returns the max steps
  27777. */
  27778. getLockstepMaxSteps(): number;
  27779. /**
  27780. * Gets an object containing information about the current webGL context
  27781. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27782. */
  27783. getGlInfo(): {
  27784. vendor: string;
  27785. renderer: string;
  27786. version: string;
  27787. };
  27788. /**
  27789. * Gets current aspect ratio
  27790. * @param camera defines the camera to use to get the aspect ratio
  27791. * @param useScreen defines if screen size must be used (or the current render target if any)
  27792. * @returns a number defining the aspect ratio
  27793. */
  27794. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27795. /**
  27796. * Gets current screen aspect ratio
  27797. * @returns a number defining the aspect ratio
  27798. */
  27799. getScreenAspectRatio(): number;
  27800. /**
  27801. * Gets the current render width
  27802. * @param useScreen defines if screen size must be used (or the current render target if any)
  27803. * @returns a number defining the current render width
  27804. */
  27805. getRenderWidth(useScreen?: boolean): number;
  27806. /**
  27807. * Gets the current render height
  27808. * @param useScreen defines if screen size must be used (or the current render target if any)
  27809. * @returns a number defining the current render height
  27810. */
  27811. getRenderHeight(useScreen?: boolean): number;
  27812. /**
  27813. * Gets the HTML canvas attached with the current webGL context
  27814. * @returns a HTML canvas
  27815. */
  27816. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27817. /**
  27818. * Gets the client rect of the HTML canvas attached with the current webGL context
  27819. * @returns a client rectanglee
  27820. */
  27821. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27822. /**
  27823. * Defines the hardware scaling level.
  27824. * By default the hardware scaling level is computed from the window device ratio.
  27825. * 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.
  27826. * @param level defines the level to use
  27827. */
  27828. setHardwareScalingLevel(level: number): void;
  27829. /**
  27830. * Gets the current hardware scaling level.
  27831. * By default the hardware scaling level is computed from the window device ratio.
  27832. * 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.
  27833. * @returns a number indicating the current hardware scaling level
  27834. */
  27835. getHardwareScalingLevel(): number;
  27836. /**
  27837. * Gets the list of loaded textures
  27838. * @returns an array containing all loaded textures
  27839. */
  27840. getLoadedTexturesCache(): InternalTexture[];
  27841. /**
  27842. * Gets the object containing all engine capabilities
  27843. * @returns the EngineCapabilities object
  27844. */
  27845. getCaps(): EngineCapabilities;
  27846. /**
  27847. * Gets the current depth function
  27848. * @returns a number defining the depth function
  27849. */
  27850. getDepthFunction(): Nullable<number>;
  27851. /**
  27852. * Sets the current depth function
  27853. * @param depthFunc defines the function to use
  27854. */
  27855. setDepthFunction(depthFunc: number): void;
  27856. /**
  27857. * Sets the current depth function to GREATER
  27858. */
  27859. setDepthFunctionToGreater(): void;
  27860. /**
  27861. * Sets the current depth function to GEQUAL
  27862. */
  27863. setDepthFunctionToGreaterOrEqual(): void;
  27864. /**
  27865. * Sets the current depth function to LESS
  27866. */
  27867. setDepthFunctionToLess(): void;
  27868. private _cachedStencilBuffer;
  27869. private _cachedStencilFunction;
  27870. private _cachedStencilMask;
  27871. private _cachedStencilOperationPass;
  27872. private _cachedStencilOperationFail;
  27873. private _cachedStencilOperationDepthFail;
  27874. private _cachedStencilReference;
  27875. /**
  27876. * Caches the the state of the stencil buffer
  27877. */
  27878. cacheStencilState(): void;
  27879. /**
  27880. * Restores the state of the stencil buffer
  27881. */
  27882. restoreStencilState(): void;
  27883. /**
  27884. * Sets the current depth function to LEQUAL
  27885. */
  27886. setDepthFunctionToLessOrEqual(): void;
  27887. /**
  27888. * Gets a boolean indicating if stencil buffer is enabled
  27889. * @returns the current stencil buffer state
  27890. */
  27891. getStencilBuffer(): boolean;
  27892. /**
  27893. * Enable or disable the stencil buffer
  27894. * @param enable defines if the stencil buffer must be enabled or disabled
  27895. */
  27896. setStencilBuffer(enable: boolean): void;
  27897. /**
  27898. * Gets the current stencil mask
  27899. * @returns a number defining the new stencil mask to use
  27900. */
  27901. getStencilMask(): number;
  27902. /**
  27903. * Sets the current stencil mask
  27904. * @param mask defines the new stencil mask to use
  27905. */
  27906. setStencilMask(mask: number): void;
  27907. /**
  27908. * Gets the current stencil function
  27909. * @returns a number defining the stencil function to use
  27910. */
  27911. getStencilFunction(): number;
  27912. /**
  27913. * Gets the current stencil reference value
  27914. * @returns a number defining the stencil reference value to use
  27915. */
  27916. getStencilFunctionReference(): number;
  27917. /**
  27918. * Gets the current stencil mask
  27919. * @returns a number defining the stencil mask to use
  27920. */
  27921. getStencilFunctionMask(): number;
  27922. /**
  27923. * Sets the current stencil function
  27924. * @param stencilFunc defines the new stencil function to use
  27925. */
  27926. setStencilFunction(stencilFunc: number): void;
  27927. /**
  27928. * Sets the current stencil reference
  27929. * @param reference defines the new stencil reference to use
  27930. */
  27931. setStencilFunctionReference(reference: number): void;
  27932. /**
  27933. * Sets the current stencil mask
  27934. * @param mask defines the new stencil mask to use
  27935. */
  27936. setStencilFunctionMask(mask: number): void;
  27937. /**
  27938. * Gets the current stencil operation when stencil fails
  27939. * @returns a number defining stencil operation to use when stencil fails
  27940. */
  27941. getStencilOperationFail(): number;
  27942. /**
  27943. * Gets the current stencil operation when depth fails
  27944. * @returns a number defining stencil operation to use when depth fails
  27945. */
  27946. getStencilOperationDepthFail(): number;
  27947. /**
  27948. * Gets the current stencil operation when stencil passes
  27949. * @returns a number defining stencil operation to use when stencil passes
  27950. */
  27951. getStencilOperationPass(): number;
  27952. /**
  27953. * Sets the stencil operation to use when stencil fails
  27954. * @param operation defines the stencil operation to use when stencil fails
  27955. */
  27956. setStencilOperationFail(operation: number): void;
  27957. /**
  27958. * Sets the stencil operation to use when depth fails
  27959. * @param operation defines the stencil operation to use when depth fails
  27960. */
  27961. setStencilOperationDepthFail(operation: number): void;
  27962. /**
  27963. * Sets the stencil operation to use when stencil passes
  27964. * @param operation defines the stencil operation to use when stencil passes
  27965. */
  27966. setStencilOperationPass(operation: number): void;
  27967. /**
  27968. * Sets a boolean indicating if the dithering state is enabled or disabled
  27969. * @param value defines the dithering state
  27970. */
  27971. setDitheringState(value: boolean): void;
  27972. /**
  27973. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27974. * @param value defines the rasterizer state
  27975. */
  27976. setRasterizerState(value: boolean): void;
  27977. /**
  27978. * stop executing a render loop function and remove it from the execution array
  27979. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27980. */
  27981. stopRenderLoop(renderFunction?: () => void): void;
  27982. /** @hidden */
  27983. _renderLoop(): void;
  27984. /**
  27985. * Register and execute a render loop. The engine can have more than one render function
  27986. * @param renderFunction defines the function to continuously execute
  27987. */
  27988. runRenderLoop(renderFunction: () => void): void;
  27989. /**
  27990. * Toggle full screen mode
  27991. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27992. */
  27993. switchFullscreen(requestPointerLock: boolean): void;
  27994. /**
  27995. * Enters full screen mode
  27996. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27997. */
  27998. enterFullscreen(requestPointerLock: boolean): void;
  27999. /**
  28000. * Exits full screen mode
  28001. */
  28002. exitFullscreen(): void;
  28003. /**
  28004. * Clear the current render buffer or the current render target (if any is set up)
  28005. * @param color defines the color to use
  28006. * @param backBuffer defines if the back buffer must be cleared
  28007. * @param depth defines if the depth buffer must be cleared
  28008. * @param stencil defines if the stencil buffer must be cleared
  28009. */
  28010. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28011. /**
  28012. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28013. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28014. * @param y defines the y-coordinate of the corner of the clear rectangle
  28015. * @param width defines the width of the clear rectangle
  28016. * @param height defines the height of the clear rectangle
  28017. * @param clearColor defines the clear color
  28018. */
  28019. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28020. /**
  28021. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28022. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28023. * @param y defines the y-coordinate of the corner of the clear rectangle
  28024. * @param width defines the width of the clear rectangle
  28025. * @param height defines the height of the clear rectangle
  28026. */
  28027. enableScissor(x: number, y: number, width: number, height: number): void;
  28028. /**
  28029. * Disable previously set scissor test rectangle
  28030. */
  28031. disableScissor(): void;
  28032. private _viewportCached;
  28033. /** @hidden */
  28034. _viewport(x: number, y: number, width: number, height: number): void;
  28035. /**
  28036. * Set the WebGL's viewport
  28037. * @param viewport defines the viewport element to be used
  28038. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28039. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28040. */
  28041. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28042. /**
  28043. * Directly set the WebGL Viewport
  28044. * @param x defines the x coordinate of the viewport (in screen space)
  28045. * @param y defines the y coordinate of the viewport (in screen space)
  28046. * @param width defines the width of the viewport (in screen space)
  28047. * @param height defines the height of the viewport (in screen space)
  28048. * @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
  28049. */
  28050. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28051. /**
  28052. * Begin a new frame
  28053. */
  28054. beginFrame(): void;
  28055. /**
  28056. * Enf the current frame
  28057. */
  28058. endFrame(): void;
  28059. /**
  28060. * Resize the view according to the canvas' size
  28061. */
  28062. resize(): void;
  28063. /**
  28064. * Force a specific size of the canvas
  28065. * @param width defines the new canvas' width
  28066. * @param height defines the new canvas' height
  28067. */
  28068. setSize(width: number, height: number): void;
  28069. /**
  28070. * Binds the frame buffer to the specified texture.
  28071. * @param texture The texture to render to or null for the default canvas
  28072. * @param faceIndex The face of the texture to render to in case of cube texture
  28073. * @param requiredWidth The width of the target to render to
  28074. * @param requiredHeight The height of the target to render to
  28075. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28076. * @param depthStencilTexture The depth stencil texture to use to render
  28077. * @param lodLevel defines le lod level to bind to the frame buffer
  28078. */
  28079. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28080. /** @hidden */
  28081. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28082. /**
  28083. * Unbind the current render target texture from the webGL context
  28084. * @param texture defines the render target texture to unbind
  28085. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28086. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28087. */
  28088. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28089. /**
  28090. * Force the mipmap generation for the given render target texture
  28091. * @param texture defines the render target texture to use
  28092. */
  28093. generateMipMapsForCubemap(texture: InternalTexture): void;
  28094. /**
  28095. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28096. */
  28097. flushFramebuffer(): void;
  28098. /**
  28099. * Unbind the current render target and bind the default framebuffer
  28100. */
  28101. restoreDefaultFramebuffer(): void;
  28102. /**
  28103. * Create an uniform buffer
  28104. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28105. * @param elements defines the content of the uniform buffer
  28106. * @returns the webGL uniform buffer
  28107. */
  28108. createUniformBuffer(elements: FloatArray): DataBuffer;
  28109. /**
  28110. * Create a dynamic uniform buffer
  28111. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28112. * @param elements defines the content of the uniform buffer
  28113. * @returns the webGL uniform buffer
  28114. */
  28115. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28116. /**
  28117. * Update an existing uniform buffer
  28118. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28119. * @param uniformBuffer defines the target uniform buffer
  28120. * @param elements defines the content to update
  28121. * @param offset defines the offset in the uniform buffer where update should start
  28122. * @param count defines the size of the data to update
  28123. */
  28124. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28125. private _resetVertexBufferBinding;
  28126. /**
  28127. * Creates a vertex buffer
  28128. * @param data the data for the vertex buffer
  28129. * @returns the new WebGL static buffer
  28130. */
  28131. createVertexBuffer(data: DataArray): DataBuffer;
  28132. /**
  28133. * Creates a dynamic vertex buffer
  28134. * @param data the data for the dynamic vertex buffer
  28135. * @returns the new WebGL dynamic buffer
  28136. */
  28137. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28138. /**
  28139. * Update a dynamic index buffer
  28140. * @param indexBuffer defines the target index buffer
  28141. * @param indices defines the data to update
  28142. * @param offset defines the offset in the target index buffer where update should start
  28143. */
  28144. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28145. /**
  28146. * Updates a dynamic vertex buffer.
  28147. * @param vertexBuffer the vertex buffer to update
  28148. * @param data the data used to update the vertex buffer
  28149. * @param byteOffset the byte offset of the data
  28150. * @param byteLength the byte length of the data
  28151. */
  28152. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28153. private _resetIndexBufferBinding;
  28154. /**
  28155. * Creates a new index buffer
  28156. * @param indices defines the content of the index buffer
  28157. * @param updatable defines if the index buffer must be updatable
  28158. * @returns a new webGL buffer
  28159. */
  28160. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28161. /**
  28162. * Bind a webGL buffer to the webGL context
  28163. * @param buffer defines the buffer to bind
  28164. */
  28165. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28166. /**
  28167. * Bind an uniform buffer to the current webGL context
  28168. * @param buffer defines the buffer to bind
  28169. */
  28170. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28171. /**
  28172. * Bind a buffer to the current webGL context at a given location
  28173. * @param buffer defines the buffer to bind
  28174. * @param location defines the index where to bind the buffer
  28175. */
  28176. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28177. /**
  28178. * Bind a specific block at a given index in a specific shader program
  28179. * @param pipelineContext defines the pipeline context to use
  28180. * @param blockName defines the block name
  28181. * @param index defines the index where to bind the block
  28182. */
  28183. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28184. private bindIndexBuffer;
  28185. private bindBuffer;
  28186. /**
  28187. * update the bound buffer with the given data
  28188. * @param data defines the data to update
  28189. */
  28190. updateArrayBuffer(data: Float32Array): void;
  28191. private _vertexAttribPointer;
  28192. private _bindIndexBufferWithCache;
  28193. private _bindVertexBuffersAttributes;
  28194. /**
  28195. * Records a vertex array object
  28196. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28197. * @param vertexBuffers defines the list of vertex buffers to store
  28198. * @param indexBuffer defines the index buffer to store
  28199. * @param effect defines the effect to store
  28200. * @returns the new vertex array object
  28201. */
  28202. recordVertexArrayObject(vertexBuffers: {
  28203. [key: string]: VertexBuffer;
  28204. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  28205. /**
  28206. * Bind a specific vertex array object
  28207. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28208. * @param vertexArrayObject defines the vertex array object to bind
  28209. * @param indexBuffer defines the index buffer to bind
  28210. */
  28211. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  28212. /**
  28213. * Bind webGl buffers directly to the webGL context
  28214. * @param vertexBuffer defines the vertex buffer to bind
  28215. * @param indexBuffer defines the index buffer to bind
  28216. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28217. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28218. * @param effect defines the effect associated with the vertex buffer
  28219. */
  28220. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28221. private _unbindVertexArrayObject;
  28222. /**
  28223. * Bind a list of vertex buffers to the webGL context
  28224. * @param vertexBuffers defines the list of vertex buffers to bind
  28225. * @param indexBuffer defines the index buffer to bind
  28226. * @param effect defines the effect associated with the vertex buffers
  28227. */
  28228. bindBuffers(vertexBuffers: {
  28229. [key: string]: Nullable<VertexBuffer>;
  28230. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  28231. /**
  28232. * Unbind all instance attributes
  28233. */
  28234. unbindInstanceAttributes(): void;
  28235. /**
  28236. * Release and free the memory of a vertex array object
  28237. * @param vao defines the vertex array object to delete
  28238. */
  28239. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28240. /** @hidden */
  28241. _releaseBuffer(buffer: DataBuffer): boolean;
  28242. /**
  28243. * Creates a webGL buffer to use with instanciation
  28244. * @param capacity defines the size of the buffer
  28245. * @returns the webGL buffer
  28246. */
  28247. createInstancesBuffer(capacity: number): DataBuffer;
  28248. /**
  28249. * Delete a webGL buffer used with instanciation
  28250. * @param buffer defines the webGL buffer to delete
  28251. */
  28252. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28253. /**
  28254. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28255. * @param instancesBuffer defines the webGL buffer to update and bind
  28256. * @param data defines the data to store in the buffer
  28257. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28258. */
  28259. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28260. /**
  28261. * Apply all cached states (depth, culling, stencil and alpha)
  28262. */
  28263. applyStates(): void;
  28264. /**
  28265. * Send a draw order
  28266. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28267. * @param indexStart defines the starting index
  28268. * @param indexCount defines the number of index to draw
  28269. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28270. */
  28271. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28272. /**
  28273. * Draw a list of points
  28274. * @param verticesStart defines the index of first vertex to draw
  28275. * @param verticesCount defines the count of vertices to draw
  28276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28277. */
  28278. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28279. /**
  28280. * Draw a list of unindexed primitives
  28281. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28282. * @param verticesStart defines the index of first vertex to draw
  28283. * @param verticesCount defines the count of vertices to draw
  28284. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28285. */
  28286. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28287. /**
  28288. * Draw a list of indexed primitives
  28289. * @param fillMode defines the primitive to use
  28290. * @param indexStart defines the starting index
  28291. * @param indexCount defines the number of index to draw
  28292. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28293. */
  28294. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28295. /**
  28296. * Draw a list of unindexed primitives
  28297. * @param fillMode defines the primitive to use
  28298. * @param verticesStart defines the index of first vertex to draw
  28299. * @param verticesCount defines the count of vertices to draw
  28300. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28301. */
  28302. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28303. private _drawMode;
  28304. /** @hidden */
  28305. _releaseEffect(effect: Effect): void;
  28306. /** @hidden */
  28307. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  28308. /**
  28309. * Create a new effect (used to store vertex/fragment shaders)
  28310. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28311. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28312. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28313. * @param samplers defines an array of string used to represent textures
  28314. * @param defines defines the string containing the defines to use to compile the shaders
  28315. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28316. * @param onCompiled defines a function to call when the effect creation is successful
  28317. * @param onError defines a function to call when the effect creation has failed
  28318. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28319. * @returns the new Effect
  28320. */
  28321. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28322. private _compileShader;
  28323. private _compileRawShader;
  28324. /**
  28325. * Directly creates a webGL program
  28326. * @param pipelineContext defines the pipeline context to attach to
  28327. * @param vertexCode defines the vertex shader code to use
  28328. * @param fragmentCode defines the fragment shader code to use
  28329. * @param context defines the webGL context to use (if not set, the current one will be used)
  28330. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28331. * @returns the new webGL program
  28332. */
  28333. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28334. /**
  28335. * Creates a webGL program
  28336. * @param pipelineContext defines the pipeline context to attach to
  28337. * @param vertexCode defines the vertex shader code to use
  28338. * @param fragmentCode defines the fragment shader code to use
  28339. * @param defines defines the string containing the defines to use to compile the shaders
  28340. * @param context defines the webGL context to use (if not set, the current one will be used)
  28341. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28342. * @returns the new webGL program
  28343. */
  28344. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28345. /**
  28346. * Creates a new pipeline context
  28347. * @returns the new pipeline
  28348. */
  28349. createPipelineContext(): WebGLPipelineContext;
  28350. private _createShaderProgram;
  28351. private _finalizePipelineContext;
  28352. /** @hidden */
  28353. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  28354. /** @hidden */
  28355. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  28356. /** @hidden */
  28357. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  28358. /**
  28359. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28360. * @param pipelineContext defines the pipeline context to use
  28361. * @param uniformsNames defines the list of uniform names
  28362. * @returns an array of webGL uniform locations
  28363. */
  28364. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28365. /**
  28366. * Gets the lsit of active attributes for a given webGL program
  28367. * @param pipelineContext defines the pipeline context to use
  28368. * @param attributesNames defines the list of attribute names to get
  28369. * @returns an array of indices indicating the offset of each attribute
  28370. */
  28371. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  28372. /**
  28373. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28374. * @param effect defines the effect to activate
  28375. */
  28376. enableEffect(effect: Nullable<Effect>): void;
  28377. /**
  28378. * Set the value of an uniform to an array of int32
  28379. * @param uniform defines the webGL uniform location where to store the value
  28380. * @param array defines the array of int32 to store
  28381. */
  28382. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28383. /**
  28384. * Set the value of an uniform to an array of int32 (stored as vec2)
  28385. * @param uniform defines the webGL uniform location where to store the value
  28386. * @param array defines the array of int32 to store
  28387. */
  28388. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28389. /**
  28390. * Set the value of an uniform to an array of int32 (stored as vec3)
  28391. * @param uniform defines the webGL uniform location where to store the value
  28392. * @param array defines the array of int32 to store
  28393. */
  28394. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28395. /**
  28396. * Set the value of an uniform to an array of int32 (stored as vec4)
  28397. * @param uniform defines the webGL uniform location where to store the value
  28398. * @param array defines the array of int32 to store
  28399. */
  28400. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28401. /**
  28402. * Set the value of an uniform to an array of float32
  28403. * @param uniform defines the webGL uniform location where to store the value
  28404. * @param array defines the array of float32 to store
  28405. */
  28406. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28407. /**
  28408. * Set the value of an uniform to an array of float32 (stored as vec2)
  28409. * @param uniform defines the webGL uniform location where to store the value
  28410. * @param array defines the array of float32 to store
  28411. */
  28412. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28413. /**
  28414. * Set the value of an uniform to an array of float32 (stored as vec3)
  28415. * @param uniform defines the webGL uniform location where to store the value
  28416. * @param array defines the array of float32 to store
  28417. */
  28418. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28419. /**
  28420. * Set the value of an uniform to an array of float32 (stored as vec4)
  28421. * @param uniform defines the webGL uniform location where to store the value
  28422. * @param array defines the array of float32 to store
  28423. */
  28424. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28425. /**
  28426. * Set the value of an uniform to an array of number
  28427. * @param uniform defines the webGL uniform location where to store the value
  28428. * @param array defines the array of number to store
  28429. */
  28430. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28431. /**
  28432. * Set the value of an uniform to an array of number (stored as vec2)
  28433. * @param uniform defines the webGL uniform location where to store the value
  28434. * @param array defines the array of number to store
  28435. */
  28436. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28437. /**
  28438. * Set the value of an uniform to an array of number (stored as vec3)
  28439. * @param uniform defines the webGL uniform location where to store the value
  28440. * @param array defines the array of number to store
  28441. */
  28442. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28443. /**
  28444. * Set the value of an uniform to an array of number (stored as vec4)
  28445. * @param uniform defines the webGL uniform location where to store the value
  28446. * @param array defines the array of number to store
  28447. */
  28448. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28449. /**
  28450. * Set the value of an uniform to an array of float32 (stored as matrices)
  28451. * @param uniform defines the webGL uniform location where to store the value
  28452. * @param matrices defines the array of float32 to store
  28453. */
  28454. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28455. /**
  28456. * Set the value of an uniform to a matrix
  28457. * @param uniform defines the webGL uniform location where to store the value
  28458. * @param matrix defines the matrix to store
  28459. */
  28460. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28461. /**
  28462. * Set the value of an uniform to a matrix (3x3)
  28463. * @param uniform defines the webGL uniform location where to store the value
  28464. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28465. */
  28466. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28467. /**
  28468. * Set the value of an uniform to a matrix (2x2)
  28469. * @param uniform defines the webGL uniform location where to store the value
  28470. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28471. */
  28472. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28473. /**
  28474. * Set the value of an uniform to a number (int)
  28475. * @param uniform defines the webGL uniform location where to store the value
  28476. * @param value defines the int number to store
  28477. */
  28478. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28479. /**
  28480. * Set the value of an uniform to a number (float)
  28481. * @param uniform defines the webGL uniform location where to store the value
  28482. * @param value defines the float number to store
  28483. */
  28484. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28485. /**
  28486. * Set the value of an uniform to a vec2
  28487. * @param uniform defines the webGL uniform location where to store the value
  28488. * @param x defines the 1st component of the value
  28489. * @param y defines the 2nd component of the value
  28490. */
  28491. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28492. /**
  28493. * Set the value of an uniform to a vec3
  28494. * @param uniform defines the webGL uniform location where to store the value
  28495. * @param x defines the 1st component of the value
  28496. * @param y defines the 2nd component of the value
  28497. * @param z defines the 3rd component of the value
  28498. */
  28499. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28500. /**
  28501. * Set the value of an uniform to a boolean
  28502. * @param uniform defines the webGL uniform location where to store the value
  28503. * @param bool defines the boolean to store
  28504. */
  28505. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28506. /**
  28507. * Set the value of an uniform to a vec4
  28508. * @param uniform defines the webGL uniform location where to store the value
  28509. * @param x defines the 1st component of the value
  28510. * @param y defines the 2nd component of the value
  28511. * @param z defines the 3rd component of the value
  28512. * @param w defines the 4th component of the value
  28513. */
  28514. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28515. /**
  28516. * Set the value of an uniform to a Color3
  28517. * @param uniform defines the webGL uniform location where to store the value
  28518. * @param color3 defines the color to store
  28519. */
  28520. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28521. /**
  28522. * Set the value of an uniform to a Color3 and an alpha value
  28523. * @param uniform defines the webGL uniform location where to store the value
  28524. * @param color3 defines the color to store
  28525. * @param alpha defines the alpha component to store
  28526. */
  28527. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28528. /**
  28529. * Sets a Color4 on a uniform variable
  28530. * @param uniform defines the uniform location
  28531. * @param color4 defines the value to be set
  28532. */
  28533. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28534. /**
  28535. * Set various states to the webGL context
  28536. * @param culling defines backface culling state
  28537. * @param zOffset defines the value to apply to zOffset (0 by default)
  28538. * @param force defines if states must be applied even if cache is up to date
  28539. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28540. */
  28541. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28542. /**
  28543. * Set the z offset to apply to current rendering
  28544. * @param value defines the offset to apply
  28545. */
  28546. setZOffset(value: number): void;
  28547. /**
  28548. * Gets the current value of the zOffset
  28549. * @returns the current zOffset state
  28550. */
  28551. getZOffset(): number;
  28552. /**
  28553. * Enable or disable depth buffering
  28554. * @param enable defines the state to set
  28555. */
  28556. setDepthBuffer(enable: boolean): void;
  28557. /**
  28558. * Gets a boolean indicating if depth writing is enabled
  28559. * @returns the current depth writing state
  28560. */
  28561. getDepthWrite(): boolean;
  28562. /**
  28563. * Enable or disable depth writing
  28564. * @param enable defines the state to set
  28565. */
  28566. setDepthWrite(enable: boolean): void;
  28567. /**
  28568. * Enable or disable color writing
  28569. * @param enable defines the state to set
  28570. */
  28571. setColorWrite(enable: boolean): void;
  28572. /**
  28573. * Gets a boolean indicating if color writing is enabled
  28574. * @returns the current color writing state
  28575. */
  28576. getColorWrite(): boolean;
  28577. /**
  28578. * Sets alpha constants used by some alpha blending modes
  28579. * @param r defines the red component
  28580. * @param g defines the green component
  28581. * @param b defines the blue component
  28582. * @param a defines the alpha component
  28583. */
  28584. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28585. /**
  28586. * Sets the current alpha mode
  28587. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28588. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28589. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28590. */
  28591. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28592. /**
  28593. * Gets the current alpha mode
  28594. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28595. * @returns the current alpha mode
  28596. */
  28597. getAlphaMode(): number;
  28598. /**
  28599. * Clears the list of texture accessible through engine.
  28600. * This can help preventing texture load conflict due to name collision.
  28601. */
  28602. clearInternalTexturesCache(): void;
  28603. /**
  28604. * Force the entire cache to be cleared
  28605. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28606. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28607. */
  28608. wipeCaches(bruteForce?: boolean): void;
  28609. /**
  28610. * Set the compressed texture format to use, based on the formats you have, and the formats
  28611. * supported by the hardware / browser.
  28612. *
  28613. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28614. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28615. * to API arguments needed to compressed textures. This puts the burden on the container
  28616. * generator to house the arcane code for determining these for current & future formats.
  28617. *
  28618. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28619. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28620. *
  28621. * Note: The result of this call is not taken into account when a texture is base64.
  28622. *
  28623. * @param formatsAvailable defines the list of those format families you have created
  28624. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28625. *
  28626. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28627. * @returns The extension selected.
  28628. */
  28629. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28630. /** @hidden */
  28631. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28632. min: number;
  28633. mag: number;
  28634. };
  28635. /** @hidden */
  28636. _createTexture(): WebGLTexture;
  28637. /**
  28638. * Usually called from Texture.ts.
  28639. * Passed information to create a WebGLTexture
  28640. * @param urlArg defines a value which contains one of the following:
  28641. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28642. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28643. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28644. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28645. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  28646. * @param scene needed for loading to the correct scene
  28647. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28648. * @param onLoad optional callback to be called upon successful completion
  28649. * @param onError optional callback to be called upon failure
  28650. * @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
  28651. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28652. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28653. * @param forcedExtension defines the extension to use to pick the right loader
  28654. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28655. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28656. */
  28657. 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;
  28658. private _rescaleTexture;
  28659. private _unpackFlipYCached;
  28660. /**
  28661. * In case you are sharing the context with other applications, it might
  28662. * be interested to not cache the unpack flip y state to ensure a consistent
  28663. * value would be set.
  28664. */
  28665. enableUnpackFlipYCached: boolean;
  28666. /** @hidden */
  28667. _unpackFlipY(value: boolean): void;
  28668. /** @hidden */
  28669. _getUnpackAlignement(): number;
  28670. /**
  28671. * Creates a dynamic texture
  28672. * @param width defines the width of the texture
  28673. * @param height defines the height of the texture
  28674. * @param generateMipMaps defines if the engine should generate the mip levels
  28675. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28676. * @returns the dynamic texture inside an InternalTexture
  28677. */
  28678. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28679. /**
  28680. * Update the sampling mode of a given texture
  28681. * @param samplingMode defines the required sampling mode
  28682. * @param texture defines the texture to update
  28683. */
  28684. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28685. /**
  28686. * Update the content of a dynamic texture
  28687. * @param texture defines the texture to update
  28688. * @param canvas defines the canvas containing the source
  28689. * @param invertY defines if data must be stored with Y axis inverted
  28690. * @param premulAlpha defines if alpha is stored as premultiplied
  28691. * @param format defines the format of the data
  28692. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28693. */
  28694. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28695. /**
  28696. * Update a video texture
  28697. * @param texture defines the texture to update
  28698. * @param video defines the video element to use
  28699. * @param invertY defines if data must be stored with Y axis inverted
  28700. */
  28701. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28702. /**
  28703. * Updates a depth texture Comparison Mode and Function.
  28704. * If the comparison Function is equal to 0, the mode will be set to none.
  28705. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28706. * @param texture The texture to set the comparison function for
  28707. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28708. */
  28709. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28710. /** @hidden */
  28711. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28712. width: number;
  28713. height: number;
  28714. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28715. /**
  28716. * Creates a depth stencil texture.
  28717. * This is only available in WebGL 2 or with the depth texture extension available.
  28718. * @param size The size of face edge in the texture.
  28719. * @param options The options defining the texture.
  28720. * @returns The texture
  28721. */
  28722. createDepthStencilTexture(size: number | {
  28723. width: number;
  28724. height: number;
  28725. }, options: DepthTextureCreationOptions): InternalTexture;
  28726. /**
  28727. * Creates a depth stencil texture.
  28728. * This is only available in WebGL 2 or with the depth texture extension available.
  28729. * @param size The size of face edge in the texture.
  28730. * @param options The options defining the texture.
  28731. * @returns The texture
  28732. */
  28733. private _createDepthStencilTexture;
  28734. /**
  28735. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28736. * @param renderTarget The render target to set the frame buffer for
  28737. */
  28738. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28739. /**
  28740. * Creates a new render target texture
  28741. * @param size defines the size of the texture
  28742. * @param options defines the options used to create the texture
  28743. * @returns a new render target texture stored in an InternalTexture
  28744. */
  28745. createRenderTargetTexture(size: number | {
  28746. width: number;
  28747. height: number;
  28748. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28749. /** @hidden */
  28750. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28751. /**
  28752. * Updates the sample count of a render target texture
  28753. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28754. * @param texture defines the texture to update
  28755. * @param samples defines the sample count to set
  28756. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28757. */
  28758. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28759. /** @hidden */
  28760. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28761. /** @hidden */
  28762. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28763. /** @hidden */
  28764. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28765. /** @hidden */
  28766. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28767. /**
  28768. * @hidden
  28769. */
  28770. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28771. private _prepareWebGLTextureContinuation;
  28772. private _prepareWebGLTexture;
  28773. /** @hidden */
  28774. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28775. /** @hidden */
  28776. _releaseFramebufferObjects(texture: InternalTexture): void;
  28777. /** @hidden */
  28778. _releaseTexture(texture: InternalTexture): void;
  28779. private setProgram;
  28780. private _boundUniforms;
  28781. /**
  28782. * Binds an effect to the webGL context
  28783. * @param effect defines the effect to bind
  28784. */
  28785. bindSamplers(effect: Effect): void;
  28786. private _activateCurrentTexture;
  28787. /** @hidden */
  28788. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28789. /** @hidden */
  28790. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28791. /**
  28792. * Sets a texture to the webGL context from a postprocess
  28793. * @param channel defines the channel to use
  28794. * @param postProcess defines the source postprocess
  28795. */
  28796. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28797. /**
  28798. * Binds the output of the passed in post process to the texture channel specified
  28799. * @param channel The channel the texture should be bound to
  28800. * @param postProcess The post process which's output should be bound
  28801. */
  28802. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28803. /**
  28804. * Unbind all textures from the webGL context
  28805. */
  28806. unbindAllTextures(): void;
  28807. /**
  28808. * Sets a texture to the according uniform.
  28809. * @param channel The texture channel
  28810. * @param uniform The uniform to set
  28811. * @param texture The texture to apply
  28812. */
  28813. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28814. /**
  28815. * Sets a depth stencil texture from a render target to the according uniform.
  28816. * @param channel The texture channel
  28817. * @param uniform The uniform to set
  28818. * @param texture The render target texture containing the depth stencil texture to apply
  28819. */
  28820. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28821. private _bindSamplerUniformToChannel;
  28822. private _getTextureWrapMode;
  28823. private _setTexture;
  28824. /**
  28825. * Sets an array of texture to the webGL context
  28826. * @param channel defines the channel where the texture array must be set
  28827. * @param uniform defines the associated uniform location
  28828. * @param textures defines the array of textures to bind
  28829. */
  28830. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28831. /** @hidden */
  28832. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28833. private _setTextureParameterFloat;
  28834. private _setTextureParameterInteger;
  28835. /**
  28836. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28837. * @param x defines the x coordinate of the rectangle where pixels must be read
  28838. * @param y defines the y coordinate of the rectangle where pixels must be read
  28839. * @param width defines the width of the rectangle where pixels must be read
  28840. * @param height defines the height of the rectangle where pixels must be read
  28841. * @returns a Uint8Array containing RGBA colors
  28842. */
  28843. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28844. /**
  28845. * Add an externaly attached data from its key.
  28846. * This method call will fail and return false, if such key already exists.
  28847. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28848. * @param key the unique key that identifies the data
  28849. * @param data the data object to associate to the key for this Engine instance
  28850. * @return true if no such key were already present and the data was added successfully, false otherwise
  28851. */
  28852. addExternalData<T>(key: string, data: T): boolean;
  28853. /**
  28854. * Get an externaly attached data from its key
  28855. * @param key the unique key that identifies the data
  28856. * @return the associated data, if present (can be null), or undefined if not present
  28857. */
  28858. getExternalData<T>(key: string): T;
  28859. /**
  28860. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28861. * @param key the unique key that identifies the data
  28862. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28863. * @return the associated data, can be null if the factory returned null.
  28864. */
  28865. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28866. /**
  28867. * Remove an externaly attached data from the Engine instance
  28868. * @param key the unique key that identifies the data
  28869. * @return true if the data was successfully removed, false if it doesn't exist
  28870. */
  28871. removeExternalData(key: string): boolean;
  28872. /**
  28873. * Unbind all vertex attributes from the webGL context
  28874. */
  28875. unbindAllAttributes(): void;
  28876. /**
  28877. * 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
  28878. */
  28879. releaseEffects(): void;
  28880. /**
  28881. * Dispose and release all associated resources
  28882. */
  28883. dispose(): void;
  28884. /**
  28885. * Display the loading screen
  28886. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28887. */
  28888. displayLoadingUI(): void;
  28889. /**
  28890. * Hide the loading screen
  28891. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28892. */
  28893. hideLoadingUI(): void;
  28894. /**
  28895. * Gets the current loading screen object
  28896. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28897. */
  28898. /**
  28899. * Sets the current loading screen object
  28900. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28901. */
  28902. loadingScreen: ILoadingScreen;
  28903. /**
  28904. * Sets the current loading screen text
  28905. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28906. */
  28907. loadingUIText: string;
  28908. /**
  28909. * Sets the current loading screen background color
  28910. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28911. */
  28912. loadingUIBackgroundColor: string;
  28913. /**
  28914. * Attach a new callback raised when context lost event is fired
  28915. * @param callback defines the callback to call
  28916. */
  28917. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28918. /**
  28919. * Attach a new callback raised when context restored event is fired
  28920. * @param callback defines the callback to call
  28921. */
  28922. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28923. /**
  28924. * Gets the source code of the vertex shader associated with a specific webGL program
  28925. * @param program defines the program to use
  28926. * @returns a string containing the source code of the vertex shader associated with the program
  28927. */
  28928. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28929. /**
  28930. * Gets the source code of the fragment shader associated with a specific webGL program
  28931. * @param program defines the program to use
  28932. * @returns a string containing the source code of the fragment shader associated with the program
  28933. */
  28934. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28935. /**
  28936. * Get the current error code of the webGL context
  28937. * @returns the error code
  28938. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28939. */
  28940. getError(): number;
  28941. /**
  28942. * Gets the current framerate
  28943. * @returns a number representing the framerate
  28944. */
  28945. getFps(): number;
  28946. /**
  28947. * Gets the time spent between current and previous frame
  28948. * @returns a number representing the delta time in ms
  28949. */
  28950. getDeltaTime(): number;
  28951. private _measureFps;
  28952. /** @hidden */
  28953. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28954. private _canRenderToFloatFramebuffer;
  28955. private _canRenderToHalfFloatFramebuffer;
  28956. private _canRenderToFramebuffer;
  28957. /** @hidden */
  28958. _getWebGLTextureType(type: number): number;
  28959. /** @hidden */
  28960. _getInternalFormat(format: number): number;
  28961. /** @hidden */
  28962. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28963. /** @hidden */
  28964. _getRGBAMultiSampleBufferFormat(type: number): number;
  28965. /** @hidden */
  28966. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28967. /** @hidden */
  28968. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28969. /**
  28970. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28971. * @returns true if the engine can be created
  28972. * @ignorenaming
  28973. */
  28974. static isSupported(): boolean;
  28975. }
  28976. }
  28977. declare module BABYLON {
  28978. /**
  28979. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28980. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28981. */
  28982. export class EffectFallbacks {
  28983. private _defines;
  28984. private _currentRank;
  28985. private _maxRank;
  28986. private _mesh;
  28987. /**
  28988. * Removes the fallback from the bound mesh.
  28989. */
  28990. unBindMesh(): void;
  28991. /**
  28992. * Adds a fallback on the specified property.
  28993. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28994. * @param define The name of the define in the shader
  28995. */
  28996. addFallback(rank: number, define: string): void;
  28997. /**
  28998. * Sets the mesh to use CPU skinning when needing to fallback.
  28999. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29000. * @param mesh The mesh to use the fallbacks.
  29001. */
  29002. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29003. /**
  29004. * Checks to see if more fallbacks are still availible.
  29005. */
  29006. readonly isMoreFallbacks: boolean;
  29007. /**
  29008. * Removes the defines that shoould be removed when falling back.
  29009. * @param currentDefines defines the current define statements for the shader.
  29010. * @param effect defines the current effect we try to compile
  29011. * @returns The resulting defines with defines of the current rank removed.
  29012. */
  29013. reduce(currentDefines: string, effect: Effect): string;
  29014. }
  29015. /**
  29016. * Options to be used when creating an effect.
  29017. */
  29018. export class EffectCreationOptions {
  29019. /**
  29020. * Atrributes that will be used in the shader.
  29021. */
  29022. attributes: string[];
  29023. /**
  29024. * Uniform varible names that will be set in the shader.
  29025. */
  29026. uniformsNames: string[];
  29027. /**
  29028. * Uniform buffer varible names that will be set in the shader.
  29029. */
  29030. uniformBuffersNames: string[];
  29031. /**
  29032. * Sampler texture variable names that will be set in the shader.
  29033. */
  29034. samplers: string[];
  29035. /**
  29036. * Define statements that will be set in the shader.
  29037. */
  29038. defines: any;
  29039. /**
  29040. * Possible fallbacks for this effect to improve performance when needed.
  29041. */
  29042. fallbacks: Nullable<EffectFallbacks>;
  29043. /**
  29044. * Callback that will be called when the shader is compiled.
  29045. */
  29046. onCompiled: Nullable<(effect: Effect) => void>;
  29047. /**
  29048. * Callback that will be called if an error occurs during shader compilation.
  29049. */
  29050. onError: Nullable<(effect: Effect, errors: string) => void>;
  29051. /**
  29052. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29053. */
  29054. indexParameters: any;
  29055. /**
  29056. * Max number of lights that can be used in the shader.
  29057. */
  29058. maxSimultaneousLights: number;
  29059. /**
  29060. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29061. */
  29062. transformFeedbackVaryings: Nullable<string[]>;
  29063. }
  29064. /**
  29065. * Effect containing vertex and fragment shader that can be executed on an object.
  29066. */
  29067. export class Effect implements IDisposable {
  29068. /**
  29069. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29070. */
  29071. static ShadersRepository: string;
  29072. /**
  29073. * Name of the effect.
  29074. */
  29075. name: any;
  29076. /**
  29077. * String container all the define statements that should be set on the shader.
  29078. */
  29079. defines: string;
  29080. /**
  29081. * Callback that will be called when the shader is compiled.
  29082. */
  29083. onCompiled: Nullable<(effect: Effect) => void>;
  29084. /**
  29085. * Callback that will be called if an error occurs during shader compilation.
  29086. */
  29087. onError: Nullable<(effect: Effect, errors: string) => void>;
  29088. /**
  29089. * Callback that will be called when effect is bound.
  29090. */
  29091. onBind: Nullable<(effect: Effect) => void>;
  29092. /**
  29093. * Unique ID of the effect.
  29094. */
  29095. uniqueId: number;
  29096. /**
  29097. * Observable that will be called when the shader is compiled.
  29098. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29099. */
  29100. onCompileObservable: Observable<Effect>;
  29101. /**
  29102. * Observable that will be called if an error occurs during shader compilation.
  29103. */
  29104. onErrorObservable: Observable<Effect>;
  29105. /** @hidden */
  29106. _onBindObservable: Nullable<Observable<Effect>>;
  29107. /**
  29108. * Observable that will be called when effect is bound.
  29109. */
  29110. readonly onBindObservable: Observable<Effect>;
  29111. /** @hidden */
  29112. _bonesComputationForcedToCPU: boolean;
  29113. private static _uniqueIdSeed;
  29114. private _engine;
  29115. private _uniformBuffersNames;
  29116. private _uniformsNames;
  29117. private _samplerList;
  29118. private _samplers;
  29119. private _isReady;
  29120. private _compilationError;
  29121. private _attributesNames;
  29122. private _attributes;
  29123. private _uniforms;
  29124. /**
  29125. * Key for the effect.
  29126. * @hidden
  29127. */
  29128. _key: string;
  29129. private _indexParameters;
  29130. private _fallbacks;
  29131. private _vertexSourceCode;
  29132. private _fragmentSourceCode;
  29133. private _vertexSourceCodeOverride;
  29134. private _fragmentSourceCodeOverride;
  29135. private _transformFeedbackVaryings;
  29136. /**
  29137. * Compiled shader to webGL program.
  29138. * @hidden
  29139. */
  29140. _pipelineContext: Nullable<IPipelineContext>;
  29141. private _valueCache;
  29142. private static _baseCache;
  29143. /**
  29144. * Instantiates an effect.
  29145. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29146. * @param baseName Name of the effect.
  29147. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29148. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29149. * @param samplers List of sampler variables that will be passed to the shader.
  29150. * @param engine Engine to be used to render the effect
  29151. * @param defines Define statements to be added to the shader.
  29152. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29153. * @param onCompiled Callback that will be called when the shader is compiled.
  29154. * @param onError Callback that will be called if an error occurs during shader compilation.
  29155. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29156. */
  29157. 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);
  29158. /**
  29159. * Unique key for this effect
  29160. */
  29161. readonly key: string;
  29162. /**
  29163. * If the effect has been compiled and prepared.
  29164. * @returns if the effect is compiled and prepared.
  29165. */
  29166. isReady(): boolean;
  29167. /**
  29168. * The engine the effect was initialized with.
  29169. * @returns the engine.
  29170. */
  29171. getEngine(): Engine;
  29172. /**
  29173. * The pipeline context for this effect
  29174. * @returns the associated pipeline context
  29175. */
  29176. getPipelineContext(): Nullable<IPipelineContext>;
  29177. /**
  29178. * The set of names of attribute variables for the shader.
  29179. * @returns An array of attribute names.
  29180. */
  29181. getAttributesNames(): string[];
  29182. /**
  29183. * Returns the attribute at the given index.
  29184. * @param index The index of the attribute.
  29185. * @returns The location of the attribute.
  29186. */
  29187. getAttributeLocation(index: number): number;
  29188. /**
  29189. * Returns the attribute based on the name of the variable.
  29190. * @param name of the attribute to look up.
  29191. * @returns the attribute location.
  29192. */
  29193. getAttributeLocationByName(name: string): number;
  29194. /**
  29195. * The number of attributes.
  29196. * @returns the numnber of attributes.
  29197. */
  29198. getAttributesCount(): number;
  29199. /**
  29200. * Gets the index of a uniform variable.
  29201. * @param uniformName of the uniform to look up.
  29202. * @returns the index.
  29203. */
  29204. getUniformIndex(uniformName: string): number;
  29205. /**
  29206. * Returns the attribute based on the name of the variable.
  29207. * @param uniformName of the uniform to look up.
  29208. * @returns the location of the uniform.
  29209. */
  29210. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29211. /**
  29212. * Returns an array of sampler variable names
  29213. * @returns The array of sampler variable neames.
  29214. */
  29215. getSamplers(): string[];
  29216. /**
  29217. * The error from the last compilation.
  29218. * @returns the error string.
  29219. */
  29220. getCompilationError(): string;
  29221. /**
  29222. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29223. * @param func The callback to be used.
  29224. */
  29225. executeWhenCompiled(func: (effect: Effect) => void): void;
  29226. private _checkIsReady;
  29227. /** @hidden */
  29228. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29229. /** @hidden */
  29230. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29231. /** @hidden */
  29232. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29233. private _processShaderConversion;
  29234. private _processIncludes;
  29235. private _processPrecision;
  29236. /**
  29237. * Recompiles the webGL program
  29238. * @param vertexSourceCode The source code for the vertex shader.
  29239. * @param fragmentSourceCode The source code for the fragment shader.
  29240. * @param onCompiled Callback called when completed.
  29241. * @param onError Callback called on error.
  29242. * @hidden
  29243. */
  29244. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29245. /**
  29246. * Prepares the effect
  29247. * @hidden
  29248. */
  29249. _prepareEffect(): void;
  29250. /**
  29251. * Checks if the effect is supported. (Must be called after compilation)
  29252. */
  29253. readonly isSupported: boolean;
  29254. /**
  29255. * Binds a texture to the engine to be used as output of the shader.
  29256. * @param channel Name of the output variable.
  29257. * @param texture Texture to bind.
  29258. * @hidden
  29259. */
  29260. _bindTexture(channel: string, texture: InternalTexture): void;
  29261. /**
  29262. * Sets a texture on the engine to be used in the shader.
  29263. * @param channel Name of the sampler variable.
  29264. * @param texture Texture to set.
  29265. */
  29266. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29267. /**
  29268. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29269. * @param channel Name of the sampler variable.
  29270. * @param texture Texture to set.
  29271. */
  29272. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29273. /**
  29274. * Sets an array of textures on the engine to be used in the shader.
  29275. * @param channel Name of the variable.
  29276. * @param textures Textures to set.
  29277. */
  29278. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29279. /**
  29280. * 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)
  29281. * @param channel Name of the sampler variable.
  29282. * @param postProcess Post process to get the input texture from.
  29283. */
  29284. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29285. /**
  29286. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29287. * 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)
  29288. * @param channel Name of the sampler variable.
  29289. * @param postProcess Post process to get the output texture from.
  29290. */
  29291. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29292. /** @hidden */
  29293. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29294. /** @hidden */
  29295. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29296. /** @hidden */
  29297. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29298. /** @hidden */
  29299. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29300. /**
  29301. * Binds a buffer to a uniform.
  29302. * @param buffer Buffer to bind.
  29303. * @param name Name of the uniform variable to bind to.
  29304. */
  29305. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29306. /**
  29307. * Binds block to a uniform.
  29308. * @param blockName Name of the block to bind.
  29309. * @param index Index to bind.
  29310. */
  29311. bindUniformBlock(blockName: string, index: number): void;
  29312. /**
  29313. * Sets an interger value on a uniform variable.
  29314. * @param uniformName Name of the variable.
  29315. * @param value Value to be set.
  29316. * @returns this effect.
  29317. */
  29318. setInt(uniformName: string, value: number): Effect;
  29319. /**
  29320. * Sets an int array on a uniform variable.
  29321. * @param uniformName Name of the variable.
  29322. * @param array array to be set.
  29323. * @returns this effect.
  29324. */
  29325. setIntArray(uniformName: string, array: Int32Array): Effect;
  29326. /**
  29327. * 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)
  29328. * @param uniformName Name of the variable.
  29329. * @param array array to be set.
  29330. * @returns this effect.
  29331. */
  29332. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29333. /**
  29334. * 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)
  29335. * @param uniformName Name of the variable.
  29336. * @param array array to be set.
  29337. * @returns this effect.
  29338. */
  29339. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29340. /**
  29341. * 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)
  29342. * @param uniformName Name of the variable.
  29343. * @param array array to be set.
  29344. * @returns this effect.
  29345. */
  29346. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29347. /**
  29348. * Sets an float array on a uniform variable.
  29349. * @param uniformName Name of the variable.
  29350. * @param array array to be set.
  29351. * @returns this effect.
  29352. */
  29353. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29354. /**
  29355. * 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)
  29356. * @param uniformName Name of the variable.
  29357. * @param array array to be set.
  29358. * @returns this effect.
  29359. */
  29360. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29361. /**
  29362. * 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)
  29363. * @param uniformName Name of the variable.
  29364. * @param array array to be set.
  29365. * @returns this effect.
  29366. */
  29367. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29368. /**
  29369. * 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)
  29370. * @param uniformName Name of the variable.
  29371. * @param array array to be set.
  29372. * @returns this effect.
  29373. */
  29374. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29375. /**
  29376. * Sets an array on a uniform variable.
  29377. * @param uniformName Name of the variable.
  29378. * @param array array to be set.
  29379. * @returns this effect.
  29380. */
  29381. setArray(uniformName: string, array: number[]): Effect;
  29382. /**
  29383. * 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)
  29384. * @param uniformName Name of the variable.
  29385. * @param array array to be set.
  29386. * @returns this effect.
  29387. */
  29388. setArray2(uniformName: string, array: number[]): Effect;
  29389. /**
  29390. * 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)
  29391. * @param uniformName Name of the variable.
  29392. * @param array array to be set.
  29393. * @returns this effect.
  29394. */
  29395. setArray3(uniformName: string, array: number[]): Effect;
  29396. /**
  29397. * 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)
  29398. * @param uniformName Name of the variable.
  29399. * @param array array to be set.
  29400. * @returns this effect.
  29401. */
  29402. setArray4(uniformName: string, array: number[]): Effect;
  29403. /**
  29404. * Sets matrices on a uniform variable.
  29405. * @param uniformName Name of the variable.
  29406. * @param matrices matrices to be set.
  29407. * @returns this effect.
  29408. */
  29409. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29410. /**
  29411. * Sets matrix on a uniform variable.
  29412. * @param uniformName Name of the variable.
  29413. * @param matrix matrix to be set.
  29414. * @returns this effect.
  29415. */
  29416. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29417. /**
  29418. * 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)
  29419. * @param uniformName Name of the variable.
  29420. * @param matrix matrix to be set.
  29421. * @returns this effect.
  29422. */
  29423. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29424. /**
  29425. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29426. * @param uniformName Name of the variable.
  29427. * @param matrix matrix to be set.
  29428. * @returns this effect.
  29429. */
  29430. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29431. /**
  29432. * Sets a float on a uniform variable.
  29433. * @param uniformName Name of the variable.
  29434. * @param value value to be set.
  29435. * @returns this effect.
  29436. */
  29437. setFloat(uniformName: string, value: number): Effect;
  29438. /**
  29439. * Sets a boolean on a uniform variable.
  29440. * @param uniformName Name of the variable.
  29441. * @param bool value to be set.
  29442. * @returns this effect.
  29443. */
  29444. setBool(uniformName: string, bool: boolean): Effect;
  29445. /**
  29446. * Sets a Vector2 on a uniform variable.
  29447. * @param uniformName Name of the variable.
  29448. * @param vector2 vector2 to be set.
  29449. * @returns this effect.
  29450. */
  29451. setVector2(uniformName: string, vector2: Vector2): Effect;
  29452. /**
  29453. * Sets a float2 on a uniform variable.
  29454. * @param uniformName Name of the variable.
  29455. * @param x First float in float2.
  29456. * @param y Second float in float2.
  29457. * @returns this effect.
  29458. */
  29459. setFloat2(uniformName: string, x: number, y: number): Effect;
  29460. /**
  29461. * Sets a Vector3 on a uniform variable.
  29462. * @param uniformName Name of the variable.
  29463. * @param vector3 Value to be set.
  29464. * @returns this effect.
  29465. */
  29466. setVector3(uniformName: string, vector3: Vector3): Effect;
  29467. /**
  29468. * Sets a float3 on a uniform variable.
  29469. * @param uniformName Name of the variable.
  29470. * @param x First float in float3.
  29471. * @param y Second float in float3.
  29472. * @param z Third float in float3.
  29473. * @returns this effect.
  29474. */
  29475. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29476. /**
  29477. * Sets a Vector4 on a uniform variable.
  29478. * @param uniformName Name of the variable.
  29479. * @param vector4 Value to be set.
  29480. * @returns this effect.
  29481. */
  29482. setVector4(uniformName: string, vector4: Vector4): Effect;
  29483. /**
  29484. * Sets a float4 on a uniform variable.
  29485. * @param uniformName Name of the variable.
  29486. * @param x First float in float4.
  29487. * @param y Second float in float4.
  29488. * @param z Third float in float4.
  29489. * @param w Fourth float in float4.
  29490. * @returns this effect.
  29491. */
  29492. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29493. /**
  29494. * Sets a Color3 on a uniform variable.
  29495. * @param uniformName Name of the variable.
  29496. * @param color3 Value to be set.
  29497. * @returns this effect.
  29498. */
  29499. setColor3(uniformName: string, color3: Color3): Effect;
  29500. /**
  29501. * Sets a Color4 on a uniform variable.
  29502. * @param uniformName Name of the variable.
  29503. * @param color3 Value to be set.
  29504. * @param alpha Alpha value to be set.
  29505. * @returns this effect.
  29506. */
  29507. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29508. /**
  29509. * Sets a Color4 on a uniform variable
  29510. * @param uniformName defines the name of the variable
  29511. * @param color4 defines the value to be set
  29512. * @returns this effect.
  29513. */
  29514. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29515. /** Release all associated resources */
  29516. dispose(): void;
  29517. /**
  29518. * This function will add a new shader to the shader store
  29519. * @param name the name of the shader
  29520. * @param pixelShader optional pixel shader content
  29521. * @param vertexShader optional vertex shader content
  29522. */
  29523. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29524. /**
  29525. * Store of each shader (The can be looked up using effect.key)
  29526. */
  29527. static ShadersStore: {
  29528. [key: string]: string;
  29529. };
  29530. /**
  29531. * Store of each included file for a shader (The can be looked up using effect.key)
  29532. */
  29533. static IncludesShadersStore: {
  29534. [key: string]: string;
  29535. };
  29536. /**
  29537. * Resets the cache of effects.
  29538. */
  29539. static ResetCache(): void;
  29540. }
  29541. }
  29542. declare module BABYLON {
  29543. /**
  29544. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29545. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29546. * 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;
  29547. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29548. */
  29549. export class ColorCurves {
  29550. private _dirty;
  29551. private _tempColor;
  29552. private _globalCurve;
  29553. private _highlightsCurve;
  29554. private _midtonesCurve;
  29555. private _shadowsCurve;
  29556. private _positiveCurve;
  29557. private _negativeCurve;
  29558. private _globalHue;
  29559. private _globalDensity;
  29560. private _globalSaturation;
  29561. private _globalExposure;
  29562. /**
  29563. * Gets the global Hue value.
  29564. * 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).
  29565. */
  29566. /**
  29567. * Sets the global Hue value.
  29568. * 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).
  29569. */
  29570. globalHue: number;
  29571. /**
  29572. * Gets the global Density value.
  29573. * 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.
  29574. * Values less than zero provide a filter of opposite hue.
  29575. */
  29576. /**
  29577. * Sets the global Density value.
  29578. * 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.
  29579. * Values less than zero provide a filter of opposite hue.
  29580. */
  29581. globalDensity: number;
  29582. /**
  29583. * Gets the global Saturation value.
  29584. * 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.
  29585. */
  29586. /**
  29587. * Sets the global Saturation value.
  29588. * 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.
  29589. */
  29590. globalSaturation: number;
  29591. /**
  29592. * Gets the global Exposure value.
  29593. * 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.
  29594. */
  29595. /**
  29596. * Sets the global Exposure value.
  29597. * 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.
  29598. */
  29599. globalExposure: number;
  29600. private _highlightsHue;
  29601. private _highlightsDensity;
  29602. private _highlightsSaturation;
  29603. private _highlightsExposure;
  29604. /**
  29605. * Gets the highlights Hue value.
  29606. * 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).
  29607. */
  29608. /**
  29609. * Sets the highlights Hue value.
  29610. * 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).
  29611. */
  29612. highlightsHue: number;
  29613. /**
  29614. * Gets the highlights Density value.
  29615. * 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.
  29616. * Values less than zero provide a filter of opposite hue.
  29617. */
  29618. /**
  29619. * Sets the highlights Density value.
  29620. * 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.
  29621. * Values less than zero provide a filter of opposite hue.
  29622. */
  29623. highlightsDensity: number;
  29624. /**
  29625. * Gets the highlights Saturation value.
  29626. * 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.
  29627. */
  29628. /**
  29629. * Sets the highlights Saturation value.
  29630. * 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.
  29631. */
  29632. highlightsSaturation: number;
  29633. /**
  29634. * Gets the highlights Exposure value.
  29635. * 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.
  29636. */
  29637. /**
  29638. * Sets the highlights Exposure value.
  29639. * 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.
  29640. */
  29641. highlightsExposure: number;
  29642. private _midtonesHue;
  29643. private _midtonesDensity;
  29644. private _midtonesSaturation;
  29645. private _midtonesExposure;
  29646. /**
  29647. * Gets the midtones Hue value.
  29648. * 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).
  29649. */
  29650. /**
  29651. * Sets the midtones Hue value.
  29652. * 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).
  29653. */
  29654. midtonesHue: number;
  29655. /**
  29656. * Gets the midtones Density value.
  29657. * 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.
  29658. * Values less than zero provide a filter of opposite hue.
  29659. */
  29660. /**
  29661. * Sets the midtones Density value.
  29662. * 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.
  29663. * Values less than zero provide a filter of opposite hue.
  29664. */
  29665. midtonesDensity: number;
  29666. /**
  29667. * Gets the midtones Saturation value.
  29668. * 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.
  29669. */
  29670. /**
  29671. * Sets the midtones Saturation value.
  29672. * 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.
  29673. */
  29674. midtonesSaturation: number;
  29675. /**
  29676. * Gets the midtones Exposure value.
  29677. * 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.
  29678. */
  29679. /**
  29680. * Sets the midtones Exposure value.
  29681. * 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.
  29682. */
  29683. midtonesExposure: number;
  29684. private _shadowsHue;
  29685. private _shadowsDensity;
  29686. private _shadowsSaturation;
  29687. private _shadowsExposure;
  29688. /**
  29689. * Gets the shadows Hue value.
  29690. * 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).
  29691. */
  29692. /**
  29693. * Sets the shadows Hue value.
  29694. * 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).
  29695. */
  29696. shadowsHue: number;
  29697. /**
  29698. * Gets the shadows Density value.
  29699. * 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.
  29700. * Values less than zero provide a filter of opposite hue.
  29701. */
  29702. /**
  29703. * Sets the shadows Density value.
  29704. * 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.
  29705. * Values less than zero provide a filter of opposite hue.
  29706. */
  29707. shadowsDensity: number;
  29708. /**
  29709. * Gets the shadows Saturation value.
  29710. * 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.
  29711. */
  29712. /**
  29713. * Sets the shadows Saturation value.
  29714. * 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.
  29715. */
  29716. shadowsSaturation: number;
  29717. /**
  29718. * Gets the shadows Exposure value.
  29719. * 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.
  29720. */
  29721. /**
  29722. * Sets the shadows Exposure value.
  29723. * 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.
  29724. */
  29725. shadowsExposure: number;
  29726. /**
  29727. * Returns the class name
  29728. * @returns The class name
  29729. */
  29730. getClassName(): string;
  29731. /**
  29732. * Binds the color curves to the shader.
  29733. * @param colorCurves The color curve to bind
  29734. * @param effect The effect to bind to
  29735. * @param positiveUniform The positive uniform shader parameter
  29736. * @param neutralUniform The neutral uniform shader parameter
  29737. * @param negativeUniform The negative uniform shader parameter
  29738. */
  29739. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29740. /**
  29741. * Prepare the list of uniforms associated with the ColorCurves effects.
  29742. * @param uniformsList The list of uniforms used in the effect
  29743. */
  29744. static PrepareUniforms(uniformsList: string[]): void;
  29745. /**
  29746. * Returns color grading data based on a hue, density, saturation and exposure value.
  29747. * @param filterHue The hue of the color filter.
  29748. * @param filterDensity The density of the color filter.
  29749. * @param saturation The saturation.
  29750. * @param exposure The exposure.
  29751. * @param result The result data container.
  29752. */
  29753. private getColorGradingDataToRef;
  29754. /**
  29755. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29756. * @param value The input slider value in range [-100,100].
  29757. * @returns Adjusted value.
  29758. */
  29759. private static applyColorGradingSliderNonlinear;
  29760. /**
  29761. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29762. * @param hue The hue (H) input.
  29763. * @param saturation The saturation (S) input.
  29764. * @param brightness The brightness (B) input.
  29765. * @result An RGBA color represented as Vector4.
  29766. */
  29767. private static fromHSBToRef;
  29768. /**
  29769. * Returns a value clamped between min and max
  29770. * @param value The value to clamp
  29771. * @param min The minimum of value
  29772. * @param max The maximum of value
  29773. * @returns The clamped value.
  29774. */
  29775. private static clamp;
  29776. /**
  29777. * Clones the current color curve instance.
  29778. * @return The cloned curves
  29779. */
  29780. clone(): ColorCurves;
  29781. /**
  29782. * Serializes the current color curve instance to a json representation.
  29783. * @return a JSON representation
  29784. */
  29785. serialize(): any;
  29786. /**
  29787. * Parses the color curve from a json representation.
  29788. * @param source the JSON source to parse
  29789. * @return The parsed curves
  29790. */
  29791. static Parse(source: any): ColorCurves;
  29792. }
  29793. }
  29794. declare module BABYLON {
  29795. /**
  29796. * Interface to follow in your material defines to integrate easily the
  29797. * Image proccessing functions.
  29798. * @hidden
  29799. */
  29800. export interface IImageProcessingConfigurationDefines {
  29801. IMAGEPROCESSING: boolean;
  29802. VIGNETTE: boolean;
  29803. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29804. VIGNETTEBLENDMODEOPAQUE: boolean;
  29805. TONEMAPPING: boolean;
  29806. TONEMAPPING_ACES: boolean;
  29807. CONTRAST: boolean;
  29808. EXPOSURE: boolean;
  29809. COLORCURVES: boolean;
  29810. COLORGRADING: boolean;
  29811. COLORGRADING3D: boolean;
  29812. SAMPLER3DGREENDEPTH: boolean;
  29813. SAMPLER3DBGRMAP: boolean;
  29814. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29815. }
  29816. /**
  29817. * @hidden
  29818. */
  29819. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29820. IMAGEPROCESSING: boolean;
  29821. VIGNETTE: boolean;
  29822. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29823. VIGNETTEBLENDMODEOPAQUE: boolean;
  29824. TONEMAPPING: boolean;
  29825. TONEMAPPING_ACES: boolean;
  29826. CONTRAST: boolean;
  29827. COLORCURVES: boolean;
  29828. COLORGRADING: boolean;
  29829. COLORGRADING3D: boolean;
  29830. SAMPLER3DGREENDEPTH: boolean;
  29831. SAMPLER3DBGRMAP: boolean;
  29832. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29833. EXPOSURE: boolean;
  29834. constructor();
  29835. }
  29836. /**
  29837. * This groups together the common properties used for image processing either in direct forward pass
  29838. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29839. * or not.
  29840. */
  29841. export class ImageProcessingConfiguration {
  29842. /**
  29843. * Default tone mapping applied in BabylonJS.
  29844. */
  29845. static readonly TONEMAPPING_STANDARD: number;
  29846. /**
  29847. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29848. * to other engines rendering to increase portability.
  29849. */
  29850. static readonly TONEMAPPING_ACES: number;
  29851. /**
  29852. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29853. */
  29854. colorCurves: Nullable<ColorCurves>;
  29855. private _colorCurvesEnabled;
  29856. /**
  29857. * Gets wether the color curves effect is enabled.
  29858. */
  29859. /**
  29860. * Sets wether the color curves effect is enabled.
  29861. */
  29862. colorCurvesEnabled: boolean;
  29863. private _colorGradingTexture;
  29864. /**
  29865. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29866. */
  29867. /**
  29868. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29869. */
  29870. colorGradingTexture: Nullable<BaseTexture>;
  29871. private _colorGradingEnabled;
  29872. /**
  29873. * Gets wether the color grading effect is enabled.
  29874. */
  29875. /**
  29876. * Sets wether the color grading effect is enabled.
  29877. */
  29878. colorGradingEnabled: boolean;
  29879. private _colorGradingWithGreenDepth;
  29880. /**
  29881. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29882. */
  29883. /**
  29884. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29885. */
  29886. colorGradingWithGreenDepth: boolean;
  29887. private _colorGradingBGR;
  29888. /**
  29889. * Gets wether the color grading texture contains BGR values.
  29890. */
  29891. /**
  29892. * Sets wether the color grading texture contains BGR values.
  29893. */
  29894. colorGradingBGR: boolean;
  29895. /** @hidden */
  29896. _exposure: number;
  29897. /**
  29898. * Gets the Exposure used in the effect.
  29899. */
  29900. /**
  29901. * Sets the Exposure used in the effect.
  29902. */
  29903. exposure: number;
  29904. private _toneMappingEnabled;
  29905. /**
  29906. * Gets wether the tone mapping effect is enabled.
  29907. */
  29908. /**
  29909. * Sets wether the tone mapping effect is enabled.
  29910. */
  29911. toneMappingEnabled: boolean;
  29912. private _toneMappingType;
  29913. /**
  29914. * Gets the type of tone mapping effect.
  29915. */
  29916. /**
  29917. * Sets the type of tone mapping effect used in BabylonJS.
  29918. */
  29919. toneMappingType: number;
  29920. protected _contrast: number;
  29921. /**
  29922. * Gets the contrast used in the effect.
  29923. */
  29924. /**
  29925. * Sets the contrast used in the effect.
  29926. */
  29927. contrast: number;
  29928. /**
  29929. * Vignette stretch size.
  29930. */
  29931. vignetteStretch: number;
  29932. /**
  29933. * Vignette centre X Offset.
  29934. */
  29935. vignetteCentreX: number;
  29936. /**
  29937. * Vignette centre Y Offset.
  29938. */
  29939. vignetteCentreY: number;
  29940. /**
  29941. * Vignette weight or intensity of the vignette effect.
  29942. */
  29943. vignetteWeight: number;
  29944. /**
  29945. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29946. * if vignetteEnabled is set to true.
  29947. */
  29948. vignetteColor: Color4;
  29949. /**
  29950. * Camera field of view used by the Vignette effect.
  29951. */
  29952. vignetteCameraFov: number;
  29953. private _vignetteBlendMode;
  29954. /**
  29955. * Gets the vignette blend mode allowing different kind of effect.
  29956. */
  29957. /**
  29958. * Sets the vignette blend mode allowing different kind of effect.
  29959. */
  29960. vignetteBlendMode: number;
  29961. private _vignetteEnabled;
  29962. /**
  29963. * Gets wether the vignette effect is enabled.
  29964. */
  29965. /**
  29966. * Sets wether the vignette effect is enabled.
  29967. */
  29968. vignetteEnabled: boolean;
  29969. private _applyByPostProcess;
  29970. /**
  29971. * Gets wether the image processing is applied through a post process or not.
  29972. */
  29973. /**
  29974. * Sets wether the image processing is applied through a post process or not.
  29975. */
  29976. applyByPostProcess: boolean;
  29977. private _isEnabled;
  29978. /**
  29979. * Gets wether the image processing is enabled or not.
  29980. */
  29981. /**
  29982. * Sets wether the image processing is enabled or not.
  29983. */
  29984. isEnabled: boolean;
  29985. /**
  29986. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29987. */
  29988. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29989. /**
  29990. * Method called each time the image processing information changes requires to recompile the effect.
  29991. */
  29992. protected _updateParameters(): void;
  29993. /**
  29994. * Gets the current class name.
  29995. * @return "ImageProcessingConfiguration"
  29996. */
  29997. getClassName(): string;
  29998. /**
  29999. * Prepare the list of uniforms associated with the Image Processing effects.
  30000. * @param uniforms The list of uniforms used in the effect
  30001. * @param defines the list of defines currently in use
  30002. */
  30003. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30004. /**
  30005. * Prepare the list of samplers associated with the Image Processing effects.
  30006. * @param samplersList The list of uniforms used in the effect
  30007. * @param defines the list of defines currently in use
  30008. */
  30009. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30010. /**
  30011. * Prepare the list of defines associated to the shader.
  30012. * @param defines the list of defines to complete
  30013. * @param forPostProcess Define if we are currently in post process mode or not
  30014. */
  30015. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30016. /**
  30017. * Returns true if all the image processing information are ready.
  30018. * @returns True if ready, otherwise, false
  30019. */
  30020. isReady(): boolean;
  30021. /**
  30022. * Binds the image processing to the shader.
  30023. * @param effect The effect to bind to
  30024. * @param aspectRatio Define the current aspect ratio of the effect
  30025. */
  30026. bind(effect: Effect, aspectRatio?: number): void;
  30027. /**
  30028. * Clones the current image processing instance.
  30029. * @return The cloned image processing
  30030. */
  30031. clone(): ImageProcessingConfiguration;
  30032. /**
  30033. * Serializes the current image processing instance to a json representation.
  30034. * @return a JSON representation
  30035. */
  30036. serialize(): any;
  30037. /**
  30038. * Parses the image processing from a json representation.
  30039. * @param source the JSON source to parse
  30040. * @return The parsed image processing
  30041. */
  30042. static Parse(source: any): ImageProcessingConfiguration;
  30043. private static _VIGNETTEMODE_MULTIPLY;
  30044. private static _VIGNETTEMODE_OPAQUE;
  30045. /**
  30046. * Used to apply the vignette as a mix with the pixel color.
  30047. */
  30048. static readonly VIGNETTEMODE_MULTIPLY: number;
  30049. /**
  30050. * Used to apply the vignette as a replacement of the pixel color.
  30051. */
  30052. static readonly VIGNETTEMODE_OPAQUE: number;
  30053. }
  30054. }
  30055. declare module BABYLON {
  30056. /**
  30057. * This represents all the required information to add a fresnel effect on a material:
  30058. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30059. */
  30060. export class FresnelParameters {
  30061. private _isEnabled;
  30062. /**
  30063. * Define if the fresnel effect is enable or not.
  30064. */
  30065. isEnabled: boolean;
  30066. /**
  30067. * Define the color used on edges (grazing angle)
  30068. */
  30069. leftColor: Color3;
  30070. /**
  30071. * Define the color used on center
  30072. */
  30073. rightColor: Color3;
  30074. /**
  30075. * Define bias applied to computed fresnel term
  30076. */
  30077. bias: number;
  30078. /**
  30079. * Defined the power exponent applied to fresnel term
  30080. */
  30081. power: number;
  30082. /**
  30083. * Clones the current fresnel and its valuues
  30084. * @returns a clone fresnel configuration
  30085. */
  30086. clone(): FresnelParameters;
  30087. /**
  30088. * Serializes the current fresnel parameters to a JSON representation.
  30089. * @return the JSON serialization
  30090. */
  30091. serialize(): any;
  30092. /**
  30093. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30094. * @param parsedFresnelParameters Define the JSON representation
  30095. * @returns the parsed parameters
  30096. */
  30097. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30098. }
  30099. }
  30100. declare module BABYLON {
  30101. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30102. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30103. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30104. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30105. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30106. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30107. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30108. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30109. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30110. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30111. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30112. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30113. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30114. /**
  30115. * Decorator used to define property that can be serialized as reference to a camera
  30116. * @param sourceName defines the name of the property to decorate
  30117. */
  30118. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30119. /**
  30120. * Class used to help serialization objects
  30121. */
  30122. export class SerializationHelper {
  30123. /** hidden */
  30124. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30125. /** hidden */
  30126. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30127. /** hidden */
  30128. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30129. /** hidden */
  30130. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30131. /**
  30132. * Appends the serialized animations from the source animations
  30133. * @param source Source containing the animations
  30134. * @param destination Target to store the animations
  30135. */
  30136. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30137. /**
  30138. * Static function used to serialized a specific entity
  30139. * @param entity defines the entity to serialize
  30140. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30141. * @returns a JSON compatible object representing the serialization of the entity
  30142. */
  30143. static Serialize<T>(entity: T, serializationObject?: any): any;
  30144. /**
  30145. * Creates a new entity from a serialization data object
  30146. * @param creationFunction defines a function used to instanciated the new entity
  30147. * @param source defines the source serialization data
  30148. * @param scene defines the hosting scene
  30149. * @param rootUrl defines the root url for resources
  30150. * @returns a new entity
  30151. */
  30152. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30153. /**
  30154. * Clones an object
  30155. * @param creationFunction defines the function used to instanciate the new object
  30156. * @param source defines the source object
  30157. * @returns the cloned object
  30158. */
  30159. static Clone<T>(creationFunction: () => T, source: T): T;
  30160. /**
  30161. * Instanciates a new object based on a source one (some data will be shared between both object)
  30162. * @param creationFunction defines the function used to instanciate the new object
  30163. * @param source defines the source object
  30164. * @returns the new object
  30165. */
  30166. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30167. }
  30168. }
  30169. declare module BABYLON {
  30170. /**
  30171. * This is the base class of all the camera used in the application.
  30172. * @see http://doc.babylonjs.com/features/cameras
  30173. */
  30174. export class Camera extends Node {
  30175. /** @hidden */
  30176. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30177. /**
  30178. * This is the default projection mode used by the cameras.
  30179. * It helps recreating a feeling of perspective and better appreciate depth.
  30180. * This is the best way to simulate real life cameras.
  30181. */
  30182. static readonly PERSPECTIVE_CAMERA: number;
  30183. /**
  30184. * This helps creating camera with an orthographic mode.
  30185. * 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.
  30186. */
  30187. static readonly ORTHOGRAPHIC_CAMERA: number;
  30188. /**
  30189. * This is the default FOV mode for perspective cameras.
  30190. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30191. */
  30192. static readonly FOVMODE_VERTICAL_FIXED: number;
  30193. /**
  30194. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30195. */
  30196. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30197. /**
  30198. * This specifies ther is no need for a camera rig.
  30199. * Basically only one eye is rendered corresponding to the camera.
  30200. */
  30201. static readonly RIG_MODE_NONE: number;
  30202. /**
  30203. * Simulates a camera Rig with one blue eye and one red eye.
  30204. * This can be use with 3d blue and red glasses.
  30205. */
  30206. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30207. /**
  30208. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30209. */
  30210. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30211. /**
  30212. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30213. */
  30214. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30215. /**
  30216. * Defines that both eyes of the camera will be rendered over under each other.
  30217. */
  30218. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30219. /**
  30220. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30221. */
  30222. static readonly RIG_MODE_VR: number;
  30223. /**
  30224. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30225. */
  30226. static readonly RIG_MODE_WEBVR: number;
  30227. /**
  30228. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30229. */
  30230. static readonly RIG_MODE_CUSTOM: number;
  30231. /**
  30232. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30233. */
  30234. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30235. /**
  30236. * Define the input manager associated with the camera.
  30237. */
  30238. inputs: CameraInputsManager<Camera>;
  30239. /** @hidden */
  30240. _position: Vector3;
  30241. /**
  30242. * Define the current local position of the camera in the scene
  30243. */
  30244. position: Vector3;
  30245. /**
  30246. * The vector the camera should consider as up.
  30247. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30248. */
  30249. upVector: Vector3;
  30250. /**
  30251. * Define the current limit on the left side for an orthographic camera
  30252. * In scene unit
  30253. */
  30254. orthoLeft: Nullable<number>;
  30255. /**
  30256. * Define the current limit on the right side for an orthographic camera
  30257. * In scene unit
  30258. */
  30259. orthoRight: Nullable<number>;
  30260. /**
  30261. * Define the current limit on the bottom side for an orthographic camera
  30262. * In scene unit
  30263. */
  30264. orthoBottom: Nullable<number>;
  30265. /**
  30266. * Define the current limit on the top side for an orthographic camera
  30267. * In scene unit
  30268. */
  30269. orthoTop: Nullable<number>;
  30270. /**
  30271. * Field Of View is set in Radians. (default is 0.8)
  30272. */
  30273. fov: number;
  30274. /**
  30275. * Define the minimum distance the camera can see from.
  30276. * This is important to note that the depth buffer are not infinite and the closer it starts
  30277. * the more your scene might encounter depth fighting issue.
  30278. */
  30279. minZ: number;
  30280. /**
  30281. * Define the maximum distance the camera can see to.
  30282. * This is important to note that the depth buffer are not infinite and the further it end
  30283. * the more your scene might encounter depth fighting issue.
  30284. */
  30285. maxZ: number;
  30286. /**
  30287. * Define the default inertia of the camera.
  30288. * This helps giving a smooth feeling to the camera movement.
  30289. */
  30290. inertia: number;
  30291. /**
  30292. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30293. */
  30294. mode: number;
  30295. /**
  30296. * Define wether the camera is intermediate.
  30297. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30298. */
  30299. isIntermediate: boolean;
  30300. /**
  30301. * Define the viewport of the camera.
  30302. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30303. */
  30304. viewport: Viewport;
  30305. /**
  30306. * Restricts the camera to viewing objects with the same layerMask.
  30307. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30308. */
  30309. layerMask: number;
  30310. /**
  30311. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30312. */
  30313. fovMode: number;
  30314. /**
  30315. * Rig mode of the camera.
  30316. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30317. * This is normally controlled byt the camera themselves as internal use.
  30318. */
  30319. cameraRigMode: number;
  30320. /**
  30321. * Defines the distance between both "eyes" in case of a RIG
  30322. */
  30323. interaxialDistance: number;
  30324. /**
  30325. * Defines if stereoscopic rendering is done side by side or over under.
  30326. */
  30327. isStereoscopicSideBySide: boolean;
  30328. /**
  30329. * 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
  30330. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30331. * else in the scene.
  30332. */
  30333. customRenderTargets: RenderTargetTexture[];
  30334. /**
  30335. * When set, the camera will render to this render target instead of the default canvas
  30336. */
  30337. outputRenderTarget: Nullable<RenderTargetTexture>;
  30338. /**
  30339. * Observable triggered when the camera view matrix has changed.
  30340. */
  30341. onViewMatrixChangedObservable: Observable<Camera>;
  30342. /**
  30343. * Observable triggered when the camera Projection matrix has changed.
  30344. */
  30345. onProjectionMatrixChangedObservable: Observable<Camera>;
  30346. /**
  30347. * Observable triggered when the inputs have been processed.
  30348. */
  30349. onAfterCheckInputsObservable: Observable<Camera>;
  30350. /**
  30351. * Observable triggered when reset has been called and applied to the camera.
  30352. */
  30353. onRestoreStateObservable: Observable<Camera>;
  30354. /** @hidden */
  30355. _cameraRigParams: any;
  30356. /** @hidden */
  30357. _rigCameras: Camera[];
  30358. /** @hidden */
  30359. _rigPostProcess: Nullable<PostProcess>;
  30360. protected _webvrViewMatrix: Matrix;
  30361. /** @hidden */
  30362. _skipRendering: boolean;
  30363. /** @hidden */
  30364. _projectionMatrix: Matrix;
  30365. /** @hidden */
  30366. _postProcesses: Nullable<PostProcess>[];
  30367. /** @hidden */
  30368. _activeMeshes: SmartArray<AbstractMesh>;
  30369. protected _globalPosition: Vector3;
  30370. /** hidden */
  30371. _computedViewMatrix: Matrix;
  30372. private _doNotComputeProjectionMatrix;
  30373. private _transformMatrix;
  30374. private _frustumPlanes;
  30375. private _refreshFrustumPlanes;
  30376. private _storedFov;
  30377. private _stateStored;
  30378. /**
  30379. * Instantiates a new camera object.
  30380. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30381. * @see http://doc.babylonjs.com/features/cameras
  30382. * @param name Defines the name of the camera in the scene
  30383. * @param position Defines the position of the camera
  30384. * @param scene Defines the scene the camera belongs too
  30385. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30386. */
  30387. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30388. /**
  30389. * Store current camera state (fov, position, etc..)
  30390. * @returns the camera
  30391. */
  30392. storeState(): Camera;
  30393. /**
  30394. * Restores the camera state values if it has been stored. You must call storeState() first
  30395. */
  30396. protected _restoreStateValues(): boolean;
  30397. /**
  30398. * Restored camera state. You must call storeState() first.
  30399. * @returns true if restored and false otherwise
  30400. */
  30401. restoreState(): boolean;
  30402. /**
  30403. * Gets the class name of the camera.
  30404. * @returns the class name
  30405. */
  30406. getClassName(): string;
  30407. /** @hidden */
  30408. readonly _isCamera: boolean;
  30409. /**
  30410. * Gets a string representation of the camera useful for debug purpose.
  30411. * @param fullDetails Defines that a more verboe level of logging is required
  30412. * @returns the string representation
  30413. */
  30414. toString(fullDetails?: boolean): string;
  30415. /**
  30416. * Gets the current world space position of the camera.
  30417. */
  30418. readonly globalPosition: Vector3;
  30419. /**
  30420. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30421. * @returns the active meshe list
  30422. */
  30423. getActiveMeshes(): SmartArray<AbstractMesh>;
  30424. /**
  30425. * Check wether a mesh is part of the current active mesh list of the camera
  30426. * @param mesh Defines the mesh to check
  30427. * @returns true if active, false otherwise
  30428. */
  30429. isActiveMesh(mesh: Mesh): boolean;
  30430. /**
  30431. * Is this camera ready to be used/rendered
  30432. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30433. * @return true if the camera is ready
  30434. */
  30435. isReady(completeCheck?: boolean): boolean;
  30436. /** @hidden */
  30437. _initCache(): void;
  30438. /** @hidden */
  30439. _updateCache(ignoreParentClass?: boolean): void;
  30440. /** @hidden */
  30441. _isSynchronized(): boolean;
  30442. /** @hidden */
  30443. _isSynchronizedViewMatrix(): boolean;
  30444. /** @hidden */
  30445. _isSynchronizedProjectionMatrix(): boolean;
  30446. /**
  30447. * Attach the input controls to a specific dom element to get the input from.
  30448. * @param element Defines the element the controls should be listened from
  30449. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30450. */
  30451. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30452. /**
  30453. * Detach the current controls from the specified dom element.
  30454. * @param element Defines the element to stop listening the inputs from
  30455. */
  30456. detachControl(element: HTMLElement): void;
  30457. /**
  30458. * Update the camera state according to the different inputs gathered during the frame.
  30459. */
  30460. update(): void;
  30461. /** @hidden */
  30462. _checkInputs(): void;
  30463. /** @hidden */
  30464. readonly rigCameras: Camera[];
  30465. /**
  30466. * Gets the post process used by the rig cameras
  30467. */
  30468. readonly rigPostProcess: Nullable<PostProcess>;
  30469. /**
  30470. * Internal, gets the first post proces.
  30471. * @returns the first post process to be run on this camera.
  30472. */
  30473. _getFirstPostProcess(): Nullable<PostProcess>;
  30474. private _cascadePostProcessesToRigCams;
  30475. /**
  30476. * Attach a post process to the camera.
  30477. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30478. * @param postProcess The post process to attach to the camera
  30479. * @param insertAt The position of the post process in case several of them are in use in the scene
  30480. * @returns the position the post process has been inserted at
  30481. */
  30482. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30483. /**
  30484. * Detach a post process to the camera.
  30485. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30486. * @param postProcess The post process to detach from the camera
  30487. */
  30488. detachPostProcess(postProcess: PostProcess): void;
  30489. /**
  30490. * Gets the current world matrix of the camera
  30491. */
  30492. getWorldMatrix(): Matrix;
  30493. /** @hidden */
  30494. _getViewMatrix(): Matrix;
  30495. /**
  30496. * Gets the current view matrix of the camera.
  30497. * @param force forces the camera to recompute the matrix without looking at the cached state
  30498. * @returns the view matrix
  30499. */
  30500. getViewMatrix(force?: boolean): Matrix;
  30501. /**
  30502. * Freeze the projection matrix.
  30503. * It will prevent the cache check of the camera projection compute and can speed up perf
  30504. * if no parameter of the camera are meant to change
  30505. * @param projection Defines manually a projection if necessary
  30506. */
  30507. freezeProjectionMatrix(projection?: Matrix): void;
  30508. /**
  30509. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30510. */
  30511. unfreezeProjectionMatrix(): void;
  30512. /**
  30513. * Gets the current projection matrix of the camera.
  30514. * @param force forces the camera to recompute the matrix without looking at the cached state
  30515. * @returns the projection matrix
  30516. */
  30517. getProjectionMatrix(force?: boolean): Matrix;
  30518. /**
  30519. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30520. * @returns a Matrix
  30521. */
  30522. getTransformationMatrix(): Matrix;
  30523. private _updateFrustumPlanes;
  30524. /**
  30525. * Checks if a cullable object (mesh...) is in the camera frustum
  30526. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30527. * @param target The object to check
  30528. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30529. * @returns true if the object is in frustum otherwise false
  30530. */
  30531. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30532. /**
  30533. * Checks if a cullable object (mesh...) is in the camera frustum
  30534. * Unlike isInFrustum this cheks the full bounding box
  30535. * @param target The object to check
  30536. * @returns true if the object is in frustum otherwise false
  30537. */
  30538. isCompletelyInFrustum(target: ICullable): boolean;
  30539. /**
  30540. * Gets a ray in the forward direction from the camera.
  30541. * @param length Defines the length of the ray to create
  30542. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30543. * @param origin Defines the start point of the ray which defaults to the camera position
  30544. * @returns the forward ray
  30545. */
  30546. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30547. /**
  30548. * Releases resources associated with this node.
  30549. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30550. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30551. */
  30552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30553. /** @hidden */
  30554. _isLeftCamera: boolean;
  30555. /**
  30556. * Gets the left camera of a rig setup in case of Rigged Camera
  30557. */
  30558. readonly isLeftCamera: boolean;
  30559. /** @hidden */
  30560. _isRightCamera: boolean;
  30561. /**
  30562. * Gets the right camera of a rig setup in case of Rigged Camera
  30563. */
  30564. readonly isRightCamera: boolean;
  30565. /**
  30566. * Gets the left camera of a rig setup in case of Rigged Camera
  30567. */
  30568. readonly leftCamera: Nullable<FreeCamera>;
  30569. /**
  30570. * Gets the right camera of a rig setup in case of Rigged Camera
  30571. */
  30572. readonly rightCamera: Nullable<FreeCamera>;
  30573. /**
  30574. * Gets the left camera target of a rig setup in case of Rigged Camera
  30575. * @returns the target position
  30576. */
  30577. getLeftTarget(): Nullable<Vector3>;
  30578. /**
  30579. * Gets the right camera target of a rig setup in case of Rigged Camera
  30580. * @returns the target position
  30581. */
  30582. getRightTarget(): Nullable<Vector3>;
  30583. /**
  30584. * @hidden
  30585. */
  30586. setCameraRigMode(mode: number, rigParams: any): void;
  30587. /** @hidden */
  30588. static _setStereoscopicRigMode(camera: Camera): void;
  30589. /** @hidden */
  30590. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30591. /** @hidden */
  30592. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30593. /** @hidden */
  30594. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30595. /** @hidden */
  30596. _getVRProjectionMatrix(): Matrix;
  30597. protected _updateCameraRotationMatrix(): void;
  30598. protected _updateWebVRCameraRotationMatrix(): void;
  30599. /**
  30600. * This function MUST be overwritten by the different WebVR cameras available.
  30601. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30602. * @hidden
  30603. */
  30604. _getWebVRProjectionMatrix(): Matrix;
  30605. /**
  30606. * This function MUST be overwritten by the different WebVR cameras available.
  30607. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30608. * @hidden
  30609. */
  30610. _getWebVRViewMatrix(): Matrix;
  30611. /** @hidden */
  30612. setCameraRigParameter(name: string, value: any): void;
  30613. /**
  30614. * needs to be overridden by children so sub has required properties to be copied
  30615. * @hidden
  30616. */
  30617. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30618. /**
  30619. * May need to be overridden by children
  30620. * @hidden
  30621. */
  30622. _updateRigCameras(): void;
  30623. /** @hidden */
  30624. _setupInputs(): void;
  30625. /**
  30626. * Serialiaze the camera setup to a json represention
  30627. * @returns the JSON representation
  30628. */
  30629. serialize(): any;
  30630. /**
  30631. * Clones the current camera.
  30632. * @param name The cloned camera name
  30633. * @returns the cloned camera
  30634. */
  30635. clone(name: string): Camera;
  30636. /**
  30637. * Gets the direction of the camera relative to a given local axis.
  30638. * @param localAxis Defines the reference axis to provide a relative direction.
  30639. * @return the direction
  30640. */
  30641. getDirection(localAxis: Vector3): Vector3;
  30642. /**
  30643. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30644. * @param localAxis Defines the reference axis to provide a relative direction.
  30645. * @param result Defines the vector to store the result in
  30646. */
  30647. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30648. /**
  30649. * Gets a camera constructor for a given camera type
  30650. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30651. * @param name The name of the camera the result will be able to instantiate
  30652. * @param scene The scene the result will construct the camera in
  30653. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30654. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30655. * @returns a factory method to construc the camera
  30656. */
  30657. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30658. /**
  30659. * Compute the world matrix of the camera.
  30660. * @returns the camera workd matrix
  30661. */
  30662. computeWorldMatrix(): Matrix;
  30663. /**
  30664. * Parse a JSON and creates the camera from the parsed information
  30665. * @param parsedCamera The JSON to parse
  30666. * @param scene The scene to instantiate the camera in
  30667. * @returns the newly constructed camera
  30668. */
  30669. static Parse(parsedCamera: any, scene: Scene): Camera;
  30670. }
  30671. }
  30672. declare module BABYLON {
  30673. /**
  30674. * Interface for any object that can request an animation frame
  30675. */
  30676. export interface ICustomAnimationFrameRequester {
  30677. /**
  30678. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30679. */
  30680. renderFunction?: Function;
  30681. /**
  30682. * Called to request the next frame to render to
  30683. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30684. */
  30685. requestAnimationFrame: Function;
  30686. /**
  30687. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30688. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30689. */
  30690. requestID?: number;
  30691. }
  30692. /**
  30693. * Interface containing an array of animations
  30694. */
  30695. export interface IAnimatable {
  30696. /**
  30697. * Array of animations
  30698. */
  30699. animations: Nullable<Array<Animation>>;
  30700. }
  30701. /** Interface used by value gradients (color, factor, ...) */
  30702. export interface IValueGradient {
  30703. /**
  30704. * Gets or sets the gradient value (between 0 and 1)
  30705. */
  30706. gradient: number;
  30707. }
  30708. /** Class used to store color4 gradient */
  30709. export class ColorGradient implements IValueGradient {
  30710. /**
  30711. * Gets or sets the gradient value (between 0 and 1)
  30712. */
  30713. gradient: number;
  30714. /**
  30715. * Gets or sets first associated color
  30716. */
  30717. color1: Color4;
  30718. /**
  30719. * Gets or sets second associated color
  30720. */
  30721. color2?: Color4;
  30722. /**
  30723. * Will get a color picked randomly between color1 and color2.
  30724. * If color2 is undefined then color1 will be used
  30725. * @param result defines the target Color4 to store the result in
  30726. */
  30727. getColorToRef(result: Color4): void;
  30728. }
  30729. /** Class used to store color 3 gradient */
  30730. export class Color3Gradient implements IValueGradient {
  30731. /**
  30732. * Gets or sets the gradient value (between 0 and 1)
  30733. */
  30734. gradient: number;
  30735. /**
  30736. * Gets or sets the associated color
  30737. */
  30738. color: Color3;
  30739. }
  30740. /** Class used to store factor gradient */
  30741. export class FactorGradient implements IValueGradient {
  30742. /**
  30743. * Gets or sets the gradient value (between 0 and 1)
  30744. */
  30745. gradient: number;
  30746. /**
  30747. * Gets or sets first associated factor
  30748. */
  30749. factor1: number;
  30750. /**
  30751. * Gets or sets second associated factor
  30752. */
  30753. factor2?: number;
  30754. /**
  30755. * Will get a number picked randomly between factor1 and factor2.
  30756. * If factor2 is undefined then factor1 will be used
  30757. * @returns the picked number
  30758. */
  30759. getFactor(): number;
  30760. }
  30761. /**
  30762. * @ignore
  30763. * Application error to support additional information when loading a file
  30764. */
  30765. export class LoadFileError extends Error {
  30766. /** defines the optional web request */
  30767. request?: WebRequest | undefined;
  30768. private static _setPrototypeOf;
  30769. /**
  30770. * Creates a new LoadFileError
  30771. * @param message defines the message of the error
  30772. * @param request defines the optional web request
  30773. */
  30774. constructor(message: string,
  30775. /** defines the optional web request */
  30776. request?: WebRequest | undefined);
  30777. }
  30778. /**
  30779. * Class used to define a retry strategy when error happens while loading assets
  30780. */
  30781. export class RetryStrategy {
  30782. /**
  30783. * Function used to defines an exponential back off strategy
  30784. * @param maxRetries defines the maximum number of retries (3 by default)
  30785. * @param baseInterval defines the interval between retries
  30786. * @returns the strategy function to use
  30787. */
  30788. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30789. }
  30790. /**
  30791. * File request interface
  30792. */
  30793. export interface IFileRequest {
  30794. /**
  30795. * Raised when the request is complete (success or error).
  30796. */
  30797. onCompleteObservable: Observable<IFileRequest>;
  30798. /**
  30799. * Aborts the request for a file.
  30800. */
  30801. abort: () => void;
  30802. }
  30803. /**
  30804. * Class containing a set of static utilities functions
  30805. */
  30806. export class Tools {
  30807. /**
  30808. * Gets or sets the base URL to use to load assets
  30809. */
  30810. static BaseUrl: string;
  30811. /**
  30812. * Enable/Disable Custom HTTP Request Headers globally.
  30813. * default = false
  30814. * @see CustomRequestHeaders
  30815. */
  30816. static UseCustomRequestHeaders: boolean;
  30817. /**
  30818. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30819. * i.e. when loading files, where the server/service expects an Authorization header
  30820. */
  30821. static CustomRequestHeaders: {
  30822. [key: string]: string;
  30823. };
  30824. /**
  30825. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30826. */
  30827. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30828. /**
  30829. * Default behaviour for cors in the application.
  30830. * It can be a string if the expected behavior is identical in the entire app.
  30831. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30832. */
  30833. static CorsBehavior: string | ((url: string | string[]) => string);
  30834. /**
  30835. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30836. * @ignorenaming
  30837. */
  30838. static UseFallbackTexture: boolean;
  30839. /**
  30840. * Use this object to register external classes like custom textures or material
  30841. * to allow the laoders to instantiate them
  30842. */
  30843. static RegisteredExternalClasses: {
  30844. [key: string]: Object;
  30845. };
  30846. /**
  30847. * Texture content used if a texture cannot loaded
  30848. * @ignorenaming
  30849. */
  30850. static fallbackTexture: string;
  30851. /**
  30852. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30853. * @param u defines the coordinate on X axis
  30854. * @param v defines the coordinate on Y axis
  30855. * @param width defines the width of the source data
  30856. * @param height defines the height of the source data
  30857. * @param pixels defines the source byte array
  30858. * @param color defines the output color
  30859. */
  30860. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30861. /**
  30862. * Interpolates between a and b via alpha
  30863. * @param a The lower value (returned when alpha = 0)
  30864. * @param b The upper value (returned when alpha = 1)
  30865. * @param alpha The interpolation-factor
  30866. * @return The mixed value
  30867. */
  30868. static Mix(a: number, b: number, alpha: number): number;
  30869. /**
  30870. * Tries to instantiate a new object from a given class name
  30871. * @param className defines the class name to instantiate
  30872. * @returns the new object or null if the system was not able to do the instantiation
  30873. */
  30874. static Instantiate(className: string): any;
  30875. /**
  30876. * Provides a slice function that will work even on IE
  30877. * @param data defines the array to slice
  30878. * @param start defines the start of the data (optional)
  30879. * @param end defines the end of the data (optional)
  30880. * @returns the new sliced array
  30881. */
  30882. static Slice<T>(data: T, start?: number, end?: number): T;
  30883. /**
  30884. * Polyfill for setImmediate
  30885. * @param action defines the action to execute after the current execution block
  30886. */
  30887. static SetImmediate(action: () => void): void;
  30888. /**
  30889. * Function indicating if a number is an exponent of 2
  30890. * @param value defines the value to test
  30891. * @returns true if the value is an exponent of 2
  30892. */
  30893. static IsExponentOfTwo(value: number): boolean;
  30894. private static _tmpFloatArray;
  30895. /**
  30896. * Returns the nearest 32-bit single precision float representation of a Number
  30897. * @param value A Number. If the parameter is of a different type, it will get converted
  30898. * to a number or to NaN if it cannot be converted
  30899. * @returns number
  30900. */
  30901. static FloatRound(value: number): number;
  30902. /**
  30903. * Find the next highest power of two.
  30904. * @param x Number to start search from.
  30905. * @return Next highest power of two.
  30906. */
  30907. static CeilingPOT(x: number): number;
  30908. /**
  30909. * Find the next lowest power of two.
  30910. * @param x Number to start search from.
  30911. * @return Next lowest power of two.
  30912. */
  30913. static FloorPOT(x: number): number;
  30914. /**
  30915. * Find the nearest power of two.
  30916. * @param x Number to start search from.
  30917. * @return Next nearest power of two.
  30918. */
  30919. static NearestPOT(x: number): number;
  30920. /**
  30921. * Get the closest exponent of two
  30922. * @param value defines the value to approximate
  30923. * @param max defines the maximum value to return
  30924. * @param mode defines how to define the closest value
  30925. * @returns closest exponent of two of the given value
  30926. */
  30927. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30928. /**
  30929. * Extracts the filename from a path
  30930. * @param path defines the path to use
  30931. * @returns the filename
  30932. */
  30933. static GetFilename(path: string): string;
  30934. /**
  30935. * Extracts the "folder" part of a path (everything before the filename).
  30936. * @param uri The URI to extract the info from
  30937. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30938. * @returns The "folder" part of the path
  30939. */
  30940. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30941. /**
  30942. * Extracts text content from a DOM element hierarchy
  30943. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30944. */
  30945. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30946. /**
  30947. * Convert an angle in radians to degrees
  30948. * @param angle defines the angle to convert
  30949. * @returns the angle in degrees
  30950. */
  30951. static ToDegrees(angle: number): number;
  30952. /**
  30953. * Convert an angle in degrees to radians
  30954. * @param angle defines the angle to convert
  30955. * @returns the angle in radians
  30956. */
  30957. static ToRadians(angle: number): number;
  30958. /**
  30959. * Encode a buffer to a base64 string
  30960. * @param buffer defines the buffer to encode
  30961. * @returns the encoded string
  30962. */
  30963. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30964. /**
  30965. * Extracts minimum and maximum values from a list of indexed positions
  30966. * @param positions defines the positions to use
  30967. * @param indices defines the indices to the positions
  30968. * @param indexStart defines the start index
  30969. * @param indexCount defines the end index
  30970. * @param bias defines bias value to add to the result
  30971. * @return minimum and maximum values
  30972. */
  30973. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30974. minimum: Vector3;
  30975. maximum: Vector3;
  30976. };
  30977. /**
  30978. * Extracts minimum and maximum values from a list of positions
  30979. * @param positions defines the positions to use
  30980. * @param start defines the start index in the positions array
  30981. * @param count defines the number of positions to handle
  30982. * @param bias defines bias value to add to the result
  30983. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30984. * @return minimum and maximum values
  30985. */
  30986. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30987. minimum: Vector3;
  30988. maximum: Vector3;
  30989. };
  30990. /**
  30991. * Returns an array if obj is not an array
  30992. * @param obj defines the object to evaluate as an array
  30993. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30994. * @returns either obj directly if obj is an array or a new array containing obj
  30995. */
  30996. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30997. /**
  30998. * Gets the pointer prefix to use
  30999. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31000. */
  31001. static GetPointerPrefix(): string;
  31002. /**
  31003. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31004. * @param func - the function to be called
  31005. * @param requester - the object that will request the next frame. Falls back to window.
  31006. * @returns frame number
  31007. */
  31008. static QueueNewFrame(func: () => void, requester?: any): number;
  31009. /**
  31010. * Ask the browser to promote the current element to fullscreen rendering mode
  31011. * @param element defines the DOM element to promote
  31012. */
  31013. static RequestFullscreen(element: HTMLElement): void;
  31014. /**
  31015. * Asks the browser to exit fullscreen mode
  31016. */
  31017. static ExitFullscreen(): void;
  31018. /**
  31019. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31020. * @param url define the url we are trying
  31021. * @param element define the dom element where to configure the cors policy
  31022. */
  31023. static SetCorsBehavior(url: string | string[], element: {
  31024. crossOrigin: string | null;
  31025. }): void;
  31026. /**
  31027. * Removes unwanted characters from an url
  31028. * @param url defines the url to clean
  31029. * @returns the cleaned url
  31030. */
  31031. static CleanUrl(url: string): string;
  31032. /**
  31033. * Gets or sets a function used to pre-process url before using them to load assets
  31034. */
  31035. static PreprocessUrl: (url: string) => string;
  31036. /**
  31037. * Loads an image as an HTMLImageElement.
  31038. * @param input url string, ArrayBuffer, or Blob to load
  31039. * @param onLoad callback called when the image successfully loads
  31040. * @param onError callback called when the image fails to load
  31041. * @param offlineProvider offline provider for caching
  31042. * @returns the HTMLImageElement of the loaded image
  31043. */
  31044. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31045. /**
  31046. * Loads a file
  31047. * @param url url string, ArrayBuffer, or Blob to load
  31048. * @param onSuccess callback called when the file successfully loads
  31049. * @param onProgress callback called while file is loading (if the server supports this mode)
  31050. * @param offlineProvider defines the offline provider for caching
  31051. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31052. * @param onError callback called when the file fails to load
  31053. * @returns a file request object
  31054. */
  31055. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  31056. /**
  31057. * Load a script (identified by an url). When the url returns, the
  31058. * content of this file is added into a new script element, attached to the DOM (body element)
  31059. * @param scriptUrl defines the url of the script to laod
  31060. * @param onSuccess defines the callback called when the script is loaded
  31061. * @param onError defines the callback to call if an error occurs
  31062. * @param scriptId defines the id of the script element
  31063. */
  31064. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31065. /**
  31066. * Load an asynchronous script (identified by an url). When the url returns, the
  31067. * content of this file is added into a new script element, attached to the DOM (body element)
  31068. * @param scriptUrl defines the url of the script to laod
  31069. * @param scriptId defines the id of the script element
  31070. * @returns a promise request object
  31071. */
  31072. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31073. /**
  31074. * Loads a file from a blob
  31075. * @param fileToLoad defines the blob to use
  31076. * @param callback defines the callback to call when data is loaded
  31077. * @param progressCallback defines the callback to call during loading process
  31078. * @returns a file request object
  31079. */
  31080. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31081. /**
  31082. * Loads a file
  31083. * @param fileToLoad defines the file to load
  31084. * @param callback defines the callback to call when data is loaded
  31085. * @param progressCallBack defines the callback to call during loading process
  31086. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31087. * @returns a file request object
  31088. */
  31089. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31090. /**
  31091. * Creates a data url from a given string content
  31092. * @param content defines the content to convert
  31093. * @returns the new data url link
  31094. */
  31095. static FileAsURL(content: string): string;
  31096. /**
  31097. * Format the given number to a specific decimal format
  31098. * @param value defines the number to format
  31099. * @param decimals defines the number of decimals to use
  31100. * @returns the formatted string
  31101. */
  31102. static Format(value: number, decimals?: number): string;
  31103. /**
  31104. * Checks if a given vector is inside a specific range
  31105. * @param v defines the vector to test
  31106. * @param min defines the minimum range
  31107. * @param max defines the maximum range
  31108. */
  31109. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31110. /**
  31111. * Tries to copy an object by duplicating every property
  31112. * @param source defines the source object
  31113. * @param destination defines the target object
  31114. * @param doNotCopyList defines a list of properties to avoid
  31115. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31116. */
  31117. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31118. /**
  31119. * Gets a boolean indicating if the given object has no own property
  31120. * @param obj defines the object to test
  31121. * @returns true if object has no own property
  31122. */
  31123. static IsEmpty(obj: any): boolean;
  31124. /**
  31125. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31126. * @param str Source string
  31127. * @param suffix Suffix to search for in the source string
  31128. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31129. */
  31130. static EndsWith(str: string, suffix: string): boolean;
  31131. /**
  31132. * Function used to register events at window level
  31133. * @param events defines the events to register
  31134. */
  31135. static RegisterTopRootEvents(events: {
  31136. name: string;
  31137. handler: Nullable<(e: FocusEvent) => any>;
  31138. }[]): void;
  31139. /**
  31140. * Function used to unregister events from window level
  31141. * @param events defines the events to unregister
  31142. */
  31143. static UnregisterTopRootEvents(events: {
  31144. name: string;
  31145. handler: Nullable<(e: FocusEvent) => any>;
  31146. }[]): void;
  31147. /**
  31148. * @ignore
  31149. */
  31150. static _ScreenshotCanvas: HTMLCanvasElement;
  31151. /**
  31152. * Dumps the current bound framebuffer
  31153. * @param width defines the rendering width
  31154. * @param height defines the rendering height
  31155. * @param engine defines the hosting engine
  31156. * @param successCallback defines the callback triggered once the data are available
  31157. * @param mimeType defines the mime type of the result
  31158. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31159. */
  31160. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31161. /**
  31162. * Converts the canvas data to blob.
  31163. * This acts as a polyfill for browsers not supporting the to blob function.
  31164. * @param canvas Defines the canvas to extract the data from
  31165. * @param successCallback Defines the callback triggered once the data are available
  31166. * @param mimeType Defines the mime type of the result
  31167. */
  31168. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31169. /**
  31170. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31171. * @param successCallback defines the callback triggered once the data are available
  31172. * @param mimeType defines the mime type of the result
  31173. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31174. */
  31175. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31176. /**
  31177. * Downloads a blob in the browser
  31178. * @param blob defines the blob to download
  31179. * @param fileName defines the name of the downloaded file
  31180. */
  31181. static Download(blob: Blob, fileName: string): void;
  31182. /**
  31183. * Captures a screenshot of the current rendering
  31184. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31185. * @param engine defines the rendering engine
  31186. * @param camera defines the source camera
  31187. * @param size This parameter can be set to a single number or to an object with the
  31188. * following (optional) properties: precision, width, height. If a single number is passed,
  31189. * it will be used for both width and height. If an object is passed, the screenshot size
  31190. * will be derived from the parameters. The precision property is a multiplier allowing
  31191. * rendering at a higher or lower resolution
  31192. * @param successCallback defines the callback receives a single parameter which contains the
  31193. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31194. * src parameter of an <img> to display it
  31195. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31196. * Check your browser for supported MIME types
  31197. */
  31198. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31199. /**
  31200. * Generates an image screenshot from the specified camera.
  31201. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31202. * @param engine The engine to use for rendering
  31203. * @param camera The camera to use for rendering
  31204. * @param size This parameter can be set to a single number or to an object with the
  31205. * following (optional) properties: precision, width, height. If a single number is passed,
  31206. * it will be used for both width and height. If an object is passed, the screenshot size
  31207. * will be derived from the parameters. The precision property is a multiplier allowing
  31208. * rendering at a higher or lower resolution
  31209. * @param successCallback The callback receives a single parameter which contains the
  31210. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31211. * src parameter of an <img> to display it
  31212. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31213. * Check your browser for supported MIME types
  31214. * @param samples Texture samples (default: 1)
  31215. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31216. * @param fileName A name for for the downloaded file.
  31217. */
  31218. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31219. /**
  31220. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31221. * Be aware Math.random() could cause collisions, but:
  31222. * "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"
  31223. * @returns a pseudo random id
  31224. */
  31225. static RandomId(): string;
  31226. /**
  31227. * Test if the given uri is a base64 string
  31228. * @param uri The uri to test
  31229. * @return True if the uri is a base64 string or false otherwise
  31230. */
  31231. static IsBase64(uri: string): boolean;
  31232. /**
  31233. * Decode the given base64 uri.
  31234. * @param uri The uri to decode
  31235. * @return The decoded base64 data.
  31236. */
  31237. static DecodeBase64(uri: string): ArrayBuffer;
  31238. /**
  31239. * Gets the absolute url.
  31240. * @param url the input url
  31241. * @return the absolute url
  31242. */
  31243. static GetAbsoluteUrl(url: string): string;
  31244. /**
  31245. * No log
  31246. */
  31247. static readonly NoneLogLevel: number;
  31248. /**
  31249. * Only message logs
  31250. */
  31251. static readonly MessageLogLevel: number;
  31252. /**
  31253. * Only warning logs
  31254. */
  31255. static readonly WarningLogLevel: number;
  31256. /**
  31257. * Only error logs
  31258. */
  31259. static readonly ErrorLogLevel: number;
  31260. /**
  31261. * All logs
  31262. */
  31263. static readonly AllLogLevel: number;
  31264. /**
  31265. * Gets a value indicating the number of loading errors
  31266. * @ignorenaming
  31267. */
  31268. static readonly errorsCount: number;
  31269. /**
  31270. * Callback called when a new log is added
  31271. */
  31272. static OnNewCacheEntry: (entry: string) => void;
  31273. /**
  31274. * Log a message to the console
  31275. * @param message defines the message to log
  31276. */
  31277. static Log(message: string): void;
  31278. /**
  31279. * Write a warning message to the console
  31280. * @param message defines the message to log
  31281. */
  31282. static Warn(message: string): void;
  31283. /**
  31284. * Write an error message to the console
  31285. * @param message defines the message to log
  31286. */
  31287. static Error(message: string): void;
  31288. /**
  31289. * Gets current log cache (list of logs)
  31290. */
  31291. static readonly LogCache: string;
  31292. /**
  31293. * Clears the log cache
  31294. */
  31295. static ClearLogCache(): void;
  31296. /**
  31297. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31298. */
  31299. static LogLevels: number;
  31300. /**
  31301. * Checks if the loaded document was accessed via `file:`-Protocol.
  31302. * @returns boolean
  31303. */
  31304. static IsFileURL(): boolean;
  31305. /**
  31306. * Checks if the window object exists
  31307. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31308. */
  31309. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31310. /**
  31311. * No performance log
  31312. */
  31313. static readonly PerformanceNoneLogLevel: number;
  31314. /**
  31315. * Use user marks to log performance
  31316. */
  31317. static readonly PerformanceUserMarkLogLevel: number;
  31318. /**
  31319. * Log performance to the console
  31320. */
  31321. static readonly PerformanceConsoleLogLevel: number;
  31322. private static _performance;
  31323. /**
  31324. * Sets the current performance log level
  31325. */
  31326. static PerformanceLogLevel: number;
  31327. private static _StartPerformanceCounterDisabled;
  31328. private static _EndPerformanceCounterDisabled;
  31329. private static _StartUserMark;
  31330. private static _EndUserMark;
  31331. private static _StartPerformanceConsole;
  31332. private static _EndPerformanceConsole;
  31333. /**
  31334. * Starts a performance counter
  31335. */
  31336. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31337. /**
  31338. * Ends a specific performance coutner
  31339. */
  31340. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31341. /**
  31342. * Gets either window.performance.now() if supported or Date.now() else
  31343. */
  31344. static readonly Now: number;
  31345. /**
  31346. * This method will return the name of the class used to create the instance of the given object.
  31347. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31348. * @param object the object to get the class name from
  31349. * @param isType defines if the object is actually a type
  31350. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31351. */
  31352. static GetClassName(object: any, isType?: boolean): string;
  31353. /**
  31354. * Gets the first element of an array satisfying a given predicate
  31355. * @param array defines the array to browse
  31356. * @param predicate defines the predicate to use
  31357. * @returns null if not found or the element
  31358. */
  31359. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31360. /**
  31361. * This method will return the name of the full name of the class, including its owning module (if any).
  31362. * 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).
  31363. * @param object the object to get the class name from
  31364. * @param isType defines if the object is actually a type
  31365. * @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.
  31366. * @ignorenaming
  31367. */
  31368. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31369. /**
  31370. * Returns a promise that resolves after the given amount of time.
  31371. * @param delay Number of milliseconds to delay
  31372. * @returns Promise that resolves after the given amount of time
  31373. */
  31374. static DelayAsync(delay: number): Promise<void>;
  31375. /**
  31376. * Gets the current gradient from an array of IValueGradient
  31377. * @param ratio defines the current ratio to get
  31378. * @param gradients defines the array of IValueGradient
  31379. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31380. */
  31381. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31382. }
  31383. /**
  31384. * This class is used to track a performance counter which is number based.
  31385. * The user has access to many properties which give statistics of different nature.
  31386. *
  31387. * The implementer can track two kinds of Performance Counter: time and count.
  31388. * 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.
  31389. * 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.
  31390. */
  31391. export class PerfCounter {
  31392. /**
  31393. * Gets or sets a global boolean to turn on and off all the counters
  31394. */
  31395. static Enabled: boolean;
  31396. /**
  31397. * Returns the smallest value ever
  31398. */
  31399. readonly min: number;
  31400. /**
  31401. * Returns the biggest value ever
  31402. */
  31403. readonly max: number;
  31404. /**
  31405. * Returns the average value since the performance counter is running
  31406. */
  31407. readonly average: number;
  31408. /**
  31409. * Returns the average value of the last second the counter was monitored
  31410. */
  31411. readonly lastSecAverage: number;
  31412. /**
  31413. * Returns the current value
  31414. */
  31415. readonly current: number;
  31416. /**
  31417. * Gets the accumulated total
  31418. */
  31419. readonly total: number;
  31420. /**
  31421. * Gets the total value count
  31422. */
  31423. readonly count: number;
  31424. /**
  31425. * Creates a new counter
  31426. */
  31427. constructor();
  31428. /**
  31429. * Call this method to start monitoring a new frame.
  31430. * 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.
  31431. */
  31432. fetchNewFrame(): void;
  31433. /**
  31434. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31435. * @param newCount the count value to add to the monitored count
  31436. * @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.
  31437. */
  31438. addCount(newCount: number, fetchResult: boolean): void;
  31439. /**
  31440. * Start monitoring this performance counter
  31441. */
  31442. beginMonitoring(): void;
  31443. /**
  31444. * Compute the time lapsed since the previous beginMonitoring() call.
  31445. * @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
  31446. */
  31447. endMonitoring(newFrame?: boolean): void;
  31448. private _fetchResult;
  31449. private _startMonitoringTime;
  31450. private _min;
  31451. private _max;
  31452. private _average;
  31453. private _current;
  31454. private _totalValueCount;
  31455. private _totalAccumulated;
  31456. private _lastSecAverage;
  31457. private _lastSecAccumulated;
  31458. private _lastSecTime;
  31459. private _lastSecValueCount;
  31460. }
  31461. /**
  31462. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31463. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31464. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31465. * @param name The name of the class, case should be preserved
  31466. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31467. */
  31468. export function className(name: string, module?: string): (target: Object) => void;
  31469. /**
  31470. * An implementation of a loop for asynchronous functions.
  31471. */
  31472. export class AsyncLoop {
  31473. /**
  31474. * Defines the number of iterations for the loop
  31475. */
  31476. iterations: number;
  31477. /**
  31478. * Defines the current index of the loop.
  31479. */
  31480. index: number;
  31481. private _done;
  31482. private _fn;
  31483. private _successCallback;
  31484. /**
  31485. * Constructor.
  31486. * @param iterations the number of iterations.
  31487. * @param func the function to run each iteration
  31488. * @param successCallback the callback that will be called upon succesful execution
  31489. * @param offset starting offset.
  31490. */
  31491. constructor(
  31492. /**
  31493. * Defines the number of iterations for the loop
  31494. */
  31495. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31496. /**
  31497. * Execute the next iteration. Must be called after the last iteration was finished.
  31498. */
  31499. executeNext(): void;
  31500. /**
  31501. * Break the loop and run the success callback.
  31502. */
  31503. breakLoop(): void;
  31504. /**
  31505. * Create and run an async loop.
  31506. * @param iterations the number of iterations.
  31507. * @param fn the function to run each iteration
  31508. * @param successCallback the callback that will be called upon succesful execution
  31509. * @param offset starting offset.
  31510. * @returns the created async loop object
  31511. */
  31512. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31513. /**
  31514. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31515. * @param iterations total number of iterations
  31516. * @param syncedIterations number of synchronous iterations in each async iteration.
  31517. * @param fn the function to call each iteration.
  31518. * @param callback a success call back that will be called when iterating stops.
  31519. * @param breakFunction a break condition (optional)
  31520. * @param timeout timeout settings for the setTimeout function. default - 0.
  31521. * @returns the created async loop object
  31522. */
  31523. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31524. }
  31525. }
  31526. declare module BABYLON {
  31527. /** @hidden */
  31528. export interface ICollisionCoordinator {
  31529. createCollider(): Collider;
  31530. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31531. init(scene: Scene): void;
  31532. }
  31533. /** @hidden */
  31534. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31535. private _scene;
  31536. private _scaledPosition;
  31537. private _scaledVelocity;
  31538. private _finalPosition;
  31539. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31540. createCollider(): Collider;
  31541. init(scene: Scene): void;
  31542. private _collideWithWorld;
  31543. }
  31544. }
  31545. declare module BABYLON {
  31546. /**
  31547. * Class used to manage all inputs for the scene.
  31548. */
  31549. export class InputManager {
  31550. /** The distance in pixel that you have to move to prevent some events */
  31551. static DragMovementThreshold: number;
  31552. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31553. static LongPressDelay: number;
  31554. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31555. static DoubleClickDelay: number;
  31556. /** If you need to check double click without raising a single click at first click, enable this flag */
  31557. static ExclusiveDoubleClickMode: boolean;
  31558. private _wheelEventName;
  31559. private _onPointerMove;
  31560. private _onPointerDown;
  31561. private _onPointerUp;
  31562. private _initClickEvent;
  31563. private _initActionManager;
  31564. private _delayedSimpleClick;
  31565. private _delayedSimpleClickTimeout;
  31566. private _previousDelayedSimpleClickTimeout;
  31567. private _meshPickProceed;
  31568. private _previousButtonPressed;
  31569. private _currentPickResult;
  31570. private _previousPickResult;
  31571. private _totalPointersPressed;
  31572. private _doubleClickOccured;
  31573. private _pointerOverMesh;
  31574. private _pickedDownMesh;
  31575. private _pickedUpMesh;
  31576. private _pointerX;
  31577. private _pointerY;
  31578. private _unTranslatedPointerX;
  31579. private _unTranslatedPointerY;
  31580. private _startingPointerPosition;
  31581. private _previousStartingPointerPosition;
  31582. private _startingPointerTime;
  31583. private _previousStartingPointerTime;
  31584. private _pointerCaptures;
  31585. private _onKeyDown;
  31586. private _onKeyUp;
  31587. private _onCanvasFocusObserver;
  31588. private _onCanvasBlurObserver;
  31589. private _scene;
  31590. /**
  31591. * Creates a new InputManager
  31592. * @param scene defines the hosting scene
  31593. */
  31594. constructor(scene: Scene);
  31595. /**
  31596. * Gets the mesh that is currently under the pointer
  31597. */
  31598. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31599. /**
  31600. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31601. */
  31602. readonly unTranslatedPointer: Vector2;
  31603. /**
  31604. * Gets or sets the current on-screen X position of the pointer
  31605. */
  31606. pointerX: number;
  31607. /**
  31608. * Gets or sets the current on-screen Y position of the pointer
  31609. */
  31610. pointerY: number;
  31611. private _updatePointerPosition;
  31612. private _processPointerMove;
  31613. private _setRayOnPointerInfo;
  31614. private _checkPrePointerObservable;
  31615. /**
  31616. * Use this method to simulate a pointer move on a mesh
  31617. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31618. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31619. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31620. */
  31621. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31622. /**
  31623. * Use this method to simulate a pointer down on a mesh
  31624. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31625. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31626. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31627. */
  31628. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31629. private _processPointerDown;
  31630. /** @hidden */
  31631. _isPointerSwiping(): boolean;
  31632. /**
  31633. * Use this method to simulate a pointer up on a mesh
  31634. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31635. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31636. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31637. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31638. */
  31639. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31640. private _processPointerUp;
  31641. /**
  31642. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31643. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31644. * @returns true if the pointer was captured
  31645. */
  31646. isPointerCaptured(pointerId?: number): boolean;
  31647. /**
  31648. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31649. * @param attachUp defines if you want to attach events to pointerup
  31650. * @param attachDown defines if you want to attach events to pointerdown
  31651. * @param attachMove defines if you want to attach events to pointermove
  31652. */
  31653. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31654. /**
  31655. * Detaches all event handlers
  31656. */
  31657. detachControl(): void;
  31658. /**
  31659. * Force the value of meshUnderPointer
  31660. * @param mesh defines the mesh to use
  31661. */
  31662. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31663. /**
  31664. * Gets the mesh under the pointer
  31665. * @returns a Mesh or null if no mesh is under the pointer
  31666. */
  31667. getPointerOverMesh(): Nullable<AbstractMesh>;
  31668. }
  31669. }
  31670. declare module BABYLON {
  31671. /**
  31672. * This class defines the direct association between an animation and a target
  31673. */
  31674. export class TargetedAnimation {
  31675. /**
  31676. * Animation to perform
  31677. */
  31678. animation: Animation;
  31679. /**
  31680. * Target to animate
  31681. */
  31682. target: any;
  31683. }
  31684. /**
  31685. * Use this class to create coordinated animations on multiple targets
  31686. */
  31687. export class AnimationGroup implements IDisposable {
  31688. /** The name of the animation group */
  31689. name: string;
  31690. private _scene;
  31691. private _targetedAnimations;
  31692. private _animatables;
  31693. private _from;
  31694. private _to;
  31695. private _isStarted;
  31696. private _isPaused;
  31697. private _speedRatio;
  31698. private _loopAnimation;
  31699. /**
  31700. * Gets or sets the unique id of the node
  31701. */
  31702. uniqueId: number;
  31703. /**
  31704. * This observable will notify when one animation have ended
  31705. */
  31706. onAnimationEndObservable: Observable<TargetedAnimation>;
  31707. /**
  31708. * Observer raised when one animation loops
  31709. */
  31710. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31711. /**
  31712. * This observable will notify when all animations have ended.
  31713. */
  31714. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31715. /**
  31716. * This observable will notify when all animations have paused.
  31717. */
  31718. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31719. /**
  31720. * This observable will notify when all animations are playing.
  31721. */
  31722. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31723. /**
  31724. * Gets the first frame
  31725. */
  31726. readonly from: number;
  31727. /**
  31728. * Gets the last frame
  31729. */
  31730. readonly to: number;
  31731. /**
  31732. * Define if the animations are started
  31733. */
  31734. readonly isStarted: boolean;
  31735. /**
  31736. * Gets a value indicating that the current group is playing
  31737. */
  31738. readonly isPlaying: boolean;
  31739. /**
  31740. * Gets or sets the speed ratio to use for all animations
  31741. */
  31742. /**
  31743. * Gets or sets the speed ratio to use for all animations
  31744. */
  31745. speedRatio: number;
  31746. /**
  31747. * Gets or sets if all animations should loop or not
  31748. */
  31749. loopAnimation: boolean;
  31750. /**
  31751. * Gets the targeted animations for this animation group
  31752. */
  31753. readonly targetedAnimations: Array<TargetedAnimation>;
  31754. /**
  31755. * returning the list of animatables controlled by this animation group.
  31756. */
  31757. readonly animatables: Array<Animatable>;
  31758. /**
  31759. * Instantiates a new Animation Group.
  31760. * This helps managing several animations at once.
  31761. * @see http://doc.babylonjs.com/how_to/group
  31762. * @param name Defines the name of the group
  31763. * @param scene Defines the scene the group belongs to
  31764. */
  31765. constructor(
  31766. /** The name of the animation group */
  31767. name: string, scene?: Nullable<Scene>);
  31768. /**
  31769. * Add an animation (with its target) in the group
  31770. * @param animation defines the animation we want to add
  31771. * @param target defines the target of the animation
  31772. * @returns the TargetedAnimation object
  31773. */
  31774. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31775. /**
  31776. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31777. * It can add constant keys at begin or end
  31778. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31779. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31780. * @returns the animation group
  31781. */
  31782. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31783. /**
  31784. * Start all animations on given targets
  31785. * @param loop defines if animations must loop
  31786. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31787. * @param from defines the from key (optional)
  31788. * @param to defines the to key (optional)
  31789. * @returns the current animation group
  31790. */
  31791. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31792. /**
  31793. * Pause all animations
  31794. * @returns the animation group
  31795. */
  31796. pause(): AnimationGroup;
  31797. /**
  31798. * Play all animations to initial state
  31799. * This function will start() the animations if they were not started or will restart() them if they were paused
  31800. * @param loop defines if animations must loop
  31801. * @returns the animation group
  31802. */
  31803. play(loop?: boolean): AnimationGroup;
  31804. /**
  31805. * Reset all animations to initial state
  31806. * @returns the animation group
  31807. */
  31808. reset(): AnimationGroup;
  31809. /**
  31810. * Restart animations from key 0
  31811. * @returns the animation group
  31812. */
  31813. restart(): AnimationGroup;
  31814. /**
  31815. * Stop all animations
  31816. * @returns the animation group
  31817. */
  31818. stop(): AnimationGroup;
  31819. /**
  31820. * Set animation weight for all animatables
  31821. * @param weight defines the weight to use
  31822. * @return the animationGroup
  31823. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31824. */
  31825. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31826. /**
  31827. * Synchronize and normalize all animatables with a source animatable
  31828. * @param root defines the root animatable to synchronize with
  31829. * @return the animationGroup
  31830. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31831. */
  31832. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31833. /**
  31834. * Goes to a specific frame in this animation group
  31835. * @param frame the frame number to go to
  31836. * @return the animationGroup
  31837. */
  31838. goToFrame(frame: number): AnimationGroup;
  31839. /**
  31840. * Dispose all associated resources
  31841. */
  31842. dispose(): void;
  31843. private _checkAnimationGroupEnded;
  31844. /**
  31845. * Clone the current animation group and returns a copy
  31846. * @param newName defines the name of the new group
  31847. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31848. * @returns the new aniamtion group
  31849. */
  31850. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31851. /**
  31852. * Returns a new AnimationGroup object parsed from the source provided.
  31853. * @param parsedAnimationGroup defines the source
  31854. * @param scene defines the scene that will receive the animationGroup
  31855. * @returns a new AnimationGroup
  31856. */
  31857. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31858. /**
  31859. * Returns the string "AnimationGroup"
  31860. * @returns "AnimationGroup"
  31861. */
  31862. getClassName(): string;
  31863. /**
  31864. * Creates a detailled string about the object
  31865. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31866. * @returns a string representing the object
  31867. */
  31868. toString(fullDetails?: boolean): string;
  31869. }
  31870. }
  31871. declare module BABYLON {
  31872. /**
  31873. * Define an interface for all classes that will hold resources
  31874. */
  31875. export interface IDisposable {
  31876. /**
  31877. * Releases all held resources
  31878. */
  31879. dispose(): void;
  31880. }
  31881. /** Interface defining initialization parameters for Scene class */
  31882. export interface SceneOptions {
  31883. /**
  31884. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31885. * It will improve performance when the number of geometries becomes important.
  31886. */
  31887. useGeometryUniqueIdsMap?: boolean;
  31888. /**
  31889. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31890. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31891. */
  31892. useMaterialMeshMap?: boolean;
  31893. /**
  31894. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31895. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31896. */
  31897. useClonedMeshhMap?: boolean;
  31898. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31899. virtual?: boolean;
  31900. }
  31901. /**
  31902. * Represents a scene to be rendered by the engine.
  31903. * @see http://doc.babylonjs.com/features/scene
  31904. */
  31905. export class Scene extends AbstractScene implements IAnimatable {
  31906. private static _uniqueIdCounter;
  31907. /** The fog is deactivated */
  31908. static readonly FOGMODE_NONE: number;
  31909. /** The fog density is following an exponential function */
  31910. static readonly FOGMODE_EXP: number;
  31911. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31912. static readonly FOGMODE_EXP2: number;
  31913. /** The fog density is following a linear function. */
  31914. static readonly FOGMODE_LINEAR: number;
  31915. /**
  31916. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31917. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31918. */
  31919. static MinDeltaTime: number;
  31920. /**
  31921. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31923. */
  31924. static MaxDeltaTime: number;
  31925. /**
  31926. * Factory used to create the default material.
  31927. * @param name The name of the material to create
  31928. * @param scene The scene to create the material for
  31929. * @returns The default material
  31930. */
  31931. static DefaultMaterialFactory(scene: Scene): Material;
  31932. /**
  31933. * Factory used to create the a collision coordinator.
  31934. * @returns The collision coordinator
  31935. */
  31936. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31937. /** @hidden */
  31938. _inputManager: InputManager;
  31939. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31940. cameraToUseForPointers: Nullable<Camera>;
  31941. /** @hidden */
  31942. readonly _isScene: boolean;
  31943. /**
  31944. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31945. */
  31946. autoClear: boolean;
  31947. /**
  31948. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31949. */
  31950. autoClearDepthAndStencil: boolean;
  31951. /**
  31952. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31953. */
  31954. clearColor: Color4;
  31955. /**
  31956. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31957. */
  31958. ambientColor: Color3;
  31959. /**
  31960. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31961. * It should only be one of the following (if not the default embedded one):
  31962. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31963. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31964. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31965. * The material properties need to be setup according to the type of texture in use.
  31966. */
  31967. environmentBRDFTexture: BaseTexture;
  31968. /** @hidden */
  31969. protected _environmentTexture: Nullable<BaseTexture>;
  31970. /**
  31971. * Texture used in all pbr material as the reflection texture.
  31972. * As in the majority of the scene they are the same (exception for multi room and so on),
  31973. * this is easier to reference from here than from all the materials.
  31974. */
  31975. /**
  31976. * Texture used in all pbr material as the reflection texture.
  31977. * As in the majority of the scene they are the same (exception for multi room and so on),
  31978. * this is easier to set here than in all the materials.
  31979. */
  31980. environmentTexture: Nullable<BaseTexture>;
  31981. /** @hidden */
  31982. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31983. /**
  31984. * Default image processing configuration used either in the rendering
  31985. * Forward main pass or through the imageProcessingPostProcess if present.
  31986. * As in the majority of the scene they are the same (exception for multi camera),
  31987. * this is easier to reference from here than from all the materials and post process.
  31988. *
  31989. * No setter as we it is a shared configuration, you can set the values instead.
  31990. */
  31991. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31992. private _forceWireframe;
  31993. /**
  31994. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31995. */
  31996. forceWireframe: boolean;
  31997. private _forcePointsCloud;
  31998. /**
  31999. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32000. */
  32001. forcePointsCloud: boolean;
  32002. /**
  32003. * Gets or sets the active clipplane 1
  32004. */
  32005. clipPlane: Nullable<Plane>;
  32006. /**
  32007. * Gets or sets the active clipplane 2
  32008. */
  32009. clipPlane2: Nullable<Plane>;
  32010. /**
  32011. * Gets or sets the active clipplane 3
  32012. */
  32013. clipPlane3: Nullable<Plane>;
  32014. /**
  32015. * Gets or sets the active clipplane 4
  32016. */
  32017. clipPlane4: Nullable<Plane>;
  32018. /**
  32019. * Gets or sets a boolean indicating if animations are enabled
  32020. */
  32021. animationsEnabled: boolean;
  32022. private _animationPropertiesOverride;
  32023. /**
  32024. * Gets or sets the animation properties override
  32025. */
  32026. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32027. /**
  32028. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32029. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32030. */
  32031. useConstantAnimationDeltaTime: boolean;
  32032. /**
  32033. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32034. * Please note that it requires to run a ray cast through the scene on every frame
  32035. */
  32036. constantlyUpdateMeshUnderPointer: boolean;
  32037. /**
  32038. * Defines the HTML cursor to use when hovering over interactive elements
  32039. */
  32040. hoverCursor: string;
  32041. /**
  32042. * Defines the HTML default cursor to use (empty by default)
  32043. */
  32044. defaultCursor: string;
  32045. /**
  32046. * This is used to call preventDefault() on pointer down
  32047. * in order to block unwanted artifacts like system double clicks
  32048. */
  32049. preventDefaultOnPointerDown: boolean;
  32050. /**
  32051. * This is used to call preventDefault() on pointer up
  32052. * in order to block unwanted artifacts like system double clicks
  32053. */
  32054. preventDefaultOnPointerUp: boolean;
  32055. /**
  32056. * Gets or sets user defined metadata
  32057. */
  32058. metadata: any;
  32059. /**
  32060. * For internal use only. Please do not use.
  32061. */
  32062. reservedDataStore: any;
  32063. /**
  32064. * Gets the name of the plugin used to load this scene (null by default)
  32065. */
  32066. loadingPluginName: string;
  32067. /**
  32068. * Use this array to add regular expressions used to disable offline support for specific urls
  32069. */
  32070. disableOfflineSupportExceptionRules: RegExp[];
  32071. /**
  32072. * An event triggered when the scene is disposed.
  32073. */
  32074. onDisposeObservable: Observable<Scene>;
  32075. private _onDisposeObserver;
  32076. /** Sets a function to be executed when this scene is disposed. */
  32077. onDispose: () => void;
  32078. /**
  32079. * An event triggered before rendering the scene (right after animations and physics)
  32080. */
  32081. onBeforeRenderObservable: Observable<Scene>;
  32082. private _onBeforeRenderObserver;
  32083. /** Sets a function to be executed before rendering this scene */
  32084. beforeRender: Nullable<() => void>;
  32085. /**
  32086. * An event triggered after rendering the scene
  32087. */
  32088. onAfterRenderObservable: Observable<Scene>;
  32089. private _onAfterRenderObserver;
  32090. /** Sets a function to be executed after rendering this scene */
  32091. afterRender: Nullable<() => void>;
  32092. /**
  32093. * An event triggered before animating the scene
  32094. */
  32095. onBeforeAnimationsObservable: Observable<Scene>;
  32096. /**
  32097. * An event triggered after animations processing
  32098. */
  32099. onAfterAnimationsObservable: Observable<Scene>;
  32100. /**
  32101. * An event triggered before draw calls are ready to be sent
  32102. */
  32103. onBeforeDrawPhaseObservable: Observable<Scene>;
  32104. /**
  32105. * An event triggered after draw calls have been sent
  32106. */
  32107. onAfterDrawPhaseObservable: Observable<Scene>;
  32108. /**
  32109. * An event triggered when the scene is ready
  32110. */
  32111. onReadyObservable: Observable<Scene>;
  32112. /**
  32113. * An event triggered before rendering a camera
  32114. */
  32115. onBeforeCameraRenderObservable: Observable<Camera>;
  32116. private _onBeforeCameraRenderObserver;
  32117. /** Sets a function to be executed before rendering a camera*/
  32118. beforeCameraRender: () => void;
  32119. /**
  32120. * An event triggered after rendering a camera
  32121. */
  32122. onAfterCameraRenderObservable: Observable<Camera>;
  32123. private _onAfterCameraRenderObserver;
  32124. /** Sets a function to be executed after rendering a camera*/
  32125. afterCameraRender: () => void;
  32126. /**
  32127. * An event triggered when active meshes evaluation is about to start
  32128. */
  32129. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32130. /**
  32131. * An event triggered when active meshes evaluation is done
  32132. */
  32133. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32134. /**
  32135. * An event triggered when particles rendering is about to start
  32136. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32137. */
  32138. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32139. /**
  32140. * An event triggered when particles rendering is done
  32141. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32142. */
  32143. onAfterParticlesRenderingObservable: Observable<Scene>;
  32144. /**
  32145. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32146. */
  32147. onDataLoadedObservable: Observable<Scene>;
  32148. /**
  32149. * An event triggered when a camera is created
  32150. */
  32151. onNewCameraAddedObservable: Observable<Camera>;
  32152. /**
  32153. * An event triggered when a camera is removed
  32154. */
  32155. onCameraRemovedObservable: Observable<Camera>;
  32156. /**
  32157. * An event triggered when a light is created
  32158. */
  32159. onNewLightAddedObservable: Observable<Light>;
  32160. /**
  32161. * An event triggered when a light is removed
  32162. */
  32163. onLightRemovedObservable: Observable<Light>;
  32164. /**
  32165. * An event triggered when a geometry is created
  32166. */
  32167. onNewGeometryAddedObservable: Observable<Geometry>;
  32168. /**
  32169. * An event triggered when a geometry is removed
  32170. */
  32171. onGeometryRemovedObservable: Observable<Geometry>;
  32172. /**
  32173. * An event triggered when a transform node is created
  32174. */
  32175. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32176. /**
  32177. * An event triggered when a transform node is removed
  32178. */
  32179. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32180. /**
  32181. * An event triggered when a mesh is created
  32182. */
  32183. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32184. /**
  32185. * An event triggered when a mesh is removed
  32186. */
  32187. onMeshRemovedObservable: Observable<AbstractMesh>;
  32188. /**
  32189. * An event triggered when a skeleton is created
  32190. */
  32191. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32192. /**
  32193. * An event triggered when a skeleton is removed
  32194. */
  32195. onSkeletonRemovedObservable: Observable<Skeleton>;
  32196. /**
  32197. * An event triggered when a material is created
  32198. */
  32199. onNewMaterialAddedObservable: Observable<Material>;
  32200. /**
  32201. * An event triggered when a material is removed
  32202. */
  32203. onMaterialRemovedObservable: Observable<Material>;
  32204. /**
  32205. * An event triggered when a texture is created
  32206. */
  32207. onNewTextureAddedObservable: Observable<BaseTexture>;
  32208. /**
  32209. * An event triggered when a texture is removed
  32210. */
  32211. onTextureRemovedObservable: Observable<BaseTexture>;
  32212. /**
  32213. * An event triggered when render targets are about to be rendered
  32214. * Can happen multiple times per frame.
  32215. */
  32216. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32217. /**
  32218. * An event triggered when render targets were rendered.
  32219. * Can happen multiple times per frame.
  32220. */
  32221. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32222. /**
  32223. * An event triggered before calculating deterministic simulation step
  32224. */
  32225. onBeforeStepObservable: Observable<Scene>;
  32226. /**
  32227. * An event triggered after calculating deterministic simulation step
  32228. */
  32229. onAfterStepObservable: Observable<Scene>;
  32230. /**
  32231. * An event triggered when the activeCamera property is updated
  32232. */
  32233. onActiveCameraChanged: Observable<Scene>;
  32234. /**
  32235. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32236. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32237. * 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)
  32238. */
  32239. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32240. /**
  32241. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32242. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32243. * 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)
  32244. */
  32245. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32246. /**
  32247. * This Observable will when a mesh has been imported into the scene.
  32248. */
  32249. onMeshImportedObservable: Observable<AbstractMesh>;
  32250. /**
  32251. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32252. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32253. */
  32254. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32255. /** @hidden */
  32256. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32257. /**
  32258. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32259. */
  32260. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32261. /**
  32262. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32263. */
  32264. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32265. /**
  32266. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32267. */
  32268. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32269. /** Callback called when a pointer move is detected */
  32270. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32271. /** Callback called when a pointer down is detected */
  32272. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32273. /** Callback called when a pointer up is detected */
  32274. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32275. /** Callback called when a pointer pick is detected */
  32276. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32277. /**
  32278. * 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).
  32279. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32280. */
  32281. onPrePointerObservable: Observable<PointerInfoPre>;
  32282. /**
  32283. * Observable event triggered each time an input event is received from the rendering canvas
  32284. */
  32285. onPointerObservable: Observable<PointerInfo>;
  32286. /**
  32287. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32288. */
  32289. readonly unTranslatedPointer: Vector2;
  32290. /**
  32291. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32292. */
  32293. static DragMovementThreshold: number;
  32294. /**
  32295. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32296. */
  32297. static LongPressDelay: number;
  32298. /**
  32299. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32300. */
  32301. static DoubleClickDelay: number;
  32302. /** If you need to check double click without raising a single click at first click, enable this flag */
  32303. static ExclusiveDoubleClickMode: boolean;
  32304. /** @hidden */
  32305. _mirroredCameraPosition: Nullable<Vector3>;
  32306. /**
  32307. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32308. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32309. */
  32310. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32311. /**
  32312. * Observable event triggered each time an keyboard event is received from the hosting window
  32313. */
  32314. onKeyboardObservable: Observable<KeyboardInfo>;
  32315. private _useRightHandedSystem;
  32316. /**
  32317. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32318. */
  32319. useRightHandedSystem: boolean;
  32320. private _timeAccumulator;
  32321. private _currentStepId;
  32322. private _currentInternalStep;
  32323. /**
  32324. * Sets the step Id used by deterministic lock step
  32325. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32326. * @param newStepId defines the step Id
  32327. */
  32328. setStepId(newStepId: number): void;
  32329. /**
  32330. * Gets the step Id used by deterministic lock step
  32331. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32332. * @returns the step Id
  32333. */
  32334. getStepId(): number;
  32335. /**
  32336. * Gets the internal step used by deterministic lock step
  32337. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32338. * @returns the internal step
  32339. */
  32340. getInternalStep(): number;
  32341. private _fogEnabled;
  32342. /**
  32343. * Gets or sets a boolean indicating if fog is enabled on this scene
  32344. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32345. * (Default is true)
  32346. */
  32347. fogEnabled: boolean;
  32348. private _fogMode;
  32349. /**
  32350. * Gets or sets the fog mode to use
  32351. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32352. * | mode | value |
  32353. * | --- | --- |
  32354. * | FOGMODE_NONE | 0 |
  32355. * | FOGMODE_EXP | 1 |
  32356. * | FOGMODE_EXP2 | 2 |
  32357. * | FOGMODE_LINEAR | 3 |
  32358. */
  32359. fogMode: number;
  32360. /**
  32361. * Gets or sets the fog color to use
  32362. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32363. * (Default is Color3(0.2, 0.2, 0.3))
  32364. */
  32365. fogColor: Color3;
  32366. /**
  32367. * Gets or sets the fog density to use
  32368. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32369. * (Default is 0.1)
  32370. */
  32371. fogDensity: number;
  32372. /**
  32373. * Gets or sets the fog start distance to use
  32374. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32375. * (Default is 0)
  32376. */
  32377. fogStart: number;
  32378. /**
  32379. * Gets or sets the fog end distance to use
  32380. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32381. * (Default is 1000)
  32382. */
  32383. fogEnd: number;
  32384. private _shadowsEnabled;
  32385. /**
  32386. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32387. */
  32388. shadowsEnabled: boolean;
  32389. private _lightsEnabled;
  32390. /**
  32391. * Gets or sets a boolean indicating if lights are enabled on this scene
  32392. */
  32393. lightsEnabled: boolean;
  32394. /** All of the active cameras added to this scene. */
  32395. activeCameras: Camera[];
  32396. /** @hidden */
  32397. _activeCamera: Nullable<Camera>;
  32398. /** Gets or sets the current active camera */
  32399. activeCamera: Nullable<Camera>;
  32400. private _defaultMaterial;
  32401. /** The default material used on meshes when no material is affected */
  32402. /** The default material used on meshes when no material is affected */
  32403. defaultMaterial: Material;
  32404. private _texturesEnabled;
  32405. /**
  32406. * Gets or sets a boolean indicating if textures are enabled on this scene
  32407. */
  32408. texturesEnabled: boolean;
  32409. /**
  32410. * Gets or sets a boolean indicating if particles are enabled on this scene
  32411. */
  32412. particlesEnabled: boolean;
  32413. /**
  32414. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32415. */
  32416. spritesEnabled: boolean;
  32417. private _skeletonsEnabled;
  32418. /**
  32419. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32420. */
  32421. skeletonsEnabled: boolean;
  32422. /**
  32423. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32424. */
  32425. lensFlaresEnabled: boolean;
  32426. /**
  32427. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32429. */
  32430. collisionsEnabled: boolean;
  32431. private _collisionCoordinator;
  32432. /** @hidden */
  32433. readonly collisionCoordinator: ICollisionCoordinator;
  32434. /**
  32435. * Defines the gravity applied to this scene (used only for collisions)
  32436. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32437. */
  32438. gravity: Vector3;
  32439. /**
  32440. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32441. */
  32442. postProcessesEnabled: boolean;
  32443. /**
  32444. * The list of postprocesses added to the scene
  32445. */
  32446. postProcesses: PostProcess[];
  32447. /**
  32448. * Gets the current postprocess manager
  32449. */
  32450. postProcessManager: PostProcessManager;
  32451. /**
  32452. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32453. */
  32454. renderTargetsEnabled: boolean;
  32455. /**
  32456. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32457. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32458. */
  32459. dumpNextRenderTargets: boolean;
  32460. /**
  32461. * The list of user defined render targets added to the scene
  32462. */
  32463. customRenderTargets: RenderTargetTexture[];
  32464. /**
  32465. * Defines if texture loading must be delayed
  32466. * If true, textures will only be loaded when they need to be rendered
  32467. */
  32468. useDelayedTextureLoading: boolean;
  32469. /**
  32470. * Gets the list of meshes imported to the scene through SceneLoader
  32471. */
  32472. importedMeshesFiles: String[];
  32473. /**
  32474. * Gets or sets a boolean indicating if probes are enabled on this scene
  32475. */
  32476. probesEnabled: boolean;
  32477. /**
  32478. * Gets or sets the current offline provider to use to store scene data
  32479. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32480. */
  32481. offlineProvider: IOfflineProvider;
  32482. /**
  32483. * Gets or sets the action manager associated with the scene
  32484. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32485. */
  32486. actionManager: AbstractActionManager;
  32487. private _meshesForIntersections;
  32488. /**
  32489. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32490. */
  32491. proceduralTexturesEnabled: boolean;
  32492. private _engine;
  32493. private _totalVertices;
  32494. /** @hidden */
  32495. _activeIndices: PerfCounter;
  32496. /** @hidden */
  32497. _activeParticles: PerfCounter;
  32498. /** @hidden */
  32499. _activeBones: PerfCounter;
  32500. private _animationRatio;
  32501. /** @hidden */
  32502. _animationTimeLast: number;
  32503. /** @hidden */
  32504. _animationTime: number;
  32505. /**
  32506. * Gets or sets a general scale for animation speed
  32507. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32508. */
  32509. animationTimeScale: number;
  32510. /** @hidden */
  32511. _cachedMaterial: Nullable<Material>;
  32512. /** @hidden */
  32513. _cachedEffect: Nullable<Effect>;
  32514. /** @hidden */
  32515. _cachedVisibility: Nullable<number>;
  32516. private _renderId;
  32517. private _frameId;
  32518. private _executeWhenReadyTimeoutId;
  32519. private _intermediateRendering;
  32520. private _viewUpdateFlag;
  32521. private _projectionUpdateFlag;
  32522. /** @hidden */
  32523. _toBeDisposed: Nullable<IDisposable>[];
  32524. private _activeRequests;
  32525. /** @hidden */
  32526. _pendingData: any[];
  32527. private _isDisposed;
  32528. /**
  32529. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32530. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32531. */
  32532. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32533. private _activeMeshes;
  32534. private _processedMaterials;
  32535. private _renderTargets;
  32536. /** @hidden */
  32537. _activeParticleSystems: SmartArray<IParticleSystem>;
  32538. private _activeSkeletons;
  32539. private _softwareSkinnedMeshes;
  32540. private _renderingManager;
  32541. /** @hidden */
  32542. _activeAnimatables: Animatable[];
  32543. private _transformMatrix;
  32544. private _sceneUbo;
  32545. /** @hidden */
  32546. _viewMatrix: Matrix;
  32547. private _projectionMatrix;
  32548. /** @hidden */
  32549. _forcedViewPosition: Nullable<Vector3>;
  32550. /** @hidden */
  32551. _frustumPlanes: Plane[];
  32552. /**
  32553. * Gets the list of frustum planes (built from the active camera)
  32554. */
  32555. readonly frustumPlanes: Plane[];
  32556. /**
  32557. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32558. * This is useful if there are more lights that the maximum simulteanous authorized
  32559. */
  32560. requireLightSorting: boolean;
  32561. /** @hidden */
  32562. readonly useMaterialMeshMap: boolean;
  32563. /** @hidden */
  32564. readonly useClonedMeshhMap: boolean;
  32565. private _externalData;
  32566. private _uid;
  32567. /**
  32568. * @hidden
  32569. * Backing store of defined scene components.
  32570. */
  32571. _components: ISceneComponent[];
  32572. /**
  32573. * @hidden
  32574. * Backing store of defined scene components.
  32575. */
  32576. _serializableComponents: ISceneSerializableComponent[];
  32577. /**
  32578. * List of components to register on the next registration step.
  32579. */
  32580. private _transientComponents;
  32581. /**
  32582. * Registers the transient components if needed.
  32583. */
  32584. private _registerTransientComponents;
  32585. /**
  32586. * @hidden
  32587. * Add a component to the scene.
  32588. * Note that the ccomponent could be registered on th next frame if this is called after
  32589. * the register component stage.
  32590. * @param component Defines the component to add to the scene
  32591. */
  32592. _addComponent(component: ISceneComponent): void;
  32593. /**
  32594. * @hidden
  32595. * Gets a component from the scene.
  32596. * @param name defines the name of the component to retrieve
  32597. * @returns the component or null if not present
  32598. */
  32599. _getComponent(name: string): Nullable<ISceneComponent>;
  32600. /**
  32601. * @hidden
  32602. * Defines the actions happening before camera updates.
  32603. */
  32604. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32605. /**
  32606. * @hidden
  32607. * Defines the actions happening before clear the canvas.
  32608. */
  32609. _beforeClearStage: Stage<SimpleStageAction>;
  32610. /**
  32611. * @hidden
  32612. * Defines the actions when collecting render targets for the frame.
  32613. */
  32614. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32615. /**
  32616. * @hidden
  32617. * Defines the actions happening for one camera in the frame.
  32618. */
  32619. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32620. /**
  32621. * @hidden
  32622. * Defines the actions happening during the per mesh ready checks.
  32623. */
  32624. _isReadyForMeshStage: Stage<MeshStageAction>;
  32625. /**
  32626. * @hidden
  32627. * Defines the actions happening before evaluate active mesh checks.
  32628. */
  32629. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32630. /**
  32631. * @hidden
  32632. * Defines the actions happening during the evaluate sub mesh checks.
  32633. */
  32634. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32635. /**
  32636. * @hidden
  32637. * Defines the actions happening during the active mesh stage.
  32638. */
  32639. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32640. /**
  32641. * @hidden
  32642. * Defines the actions happening during the per camera render target step.
  32643. */
  32644. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32645. /**
  32646. * @hidden
  32647. * Defines the actions happening just before the active camera is drawing.
  32648. */
  32649. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32650. /**
  32651. * @hidden
  32652. * Defines the actions happening just before a render target is drawing.
  32653. */
  32654. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32655. /**
  32656. * @hidden
  32657. * Defines the actions happening just before a rendering group is drawing.
  32658. */
  32659. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32660. /**
  32661. * @hidden
  32662. * Defines the actions happening just before a mesh is drawing.
  32663. */
  32664. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32665. /**
  32666. * @hidden
  32667. * Defines the actions happening just after a mesh has been drawn.
  32668. */
  32669. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32670. /**
  32671. * @hidden
  32672. * Defines the actions happening just after a rendering group has been drawn.
  32673. */
  32674. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32675. /**
  32676. * @hidden
  32677. * Defines the actions happening just after the active camera has been drawn.
  32678. */
  32679. _afterCameraDrawStage: Stage<CameraStageAction>;
  32680. /**
  32681. * @hidden
  32682. * Defines the actions happening just after a render target has been drawn.
  32683. */
  32684. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32685. /**
  32686. * @hidden
  32687. * Defines the actions happening just after rendering all cameras and computing intersections.
  32688. */
  32689. _afterRenderStage: Stage<SimpleStageAction>;
  32690. /**
  32691. * @hidden
  32692. * Defines the actions happening when a pointer move event happens.
  32693. */
  32694. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32695. /**
  32696. * @hidden
  32697. * Defines the actions happening when a pointer down event happens.
  32698. */
  32699. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32700. /**
  32701. * @hidden
  32702. * Defines the actions happening when a pointer up event happens.
  32703. */
  32704. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32705. /**
  32706. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32707. */
  32708. private geometriesByUniqueId;
  32709. /**
  32710. * Creates a new Scene
  32711. * @param engine defines the engine to use to render this scene
  32712. * @param options defines the scene options
  32713. */
  32714. constructor(engine: Engine, options?: SceneOptions);
  32715. /**
  32716. * Gets a string idenfifying the name of the class
  32717. * @returns "Scene" string
  32718. */
  32719. getClassName(): string;
  32720. private _defaultMeshCandidates;
  32721. /**
  32722. * @hidden
  32723. */
  32724. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32725. private _defaultSubMeshCandidates;
  32726. /**
  32727. * @hidden
  32728. */
  32729. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32730. /**
  32731. * Sets the default candidate providers for the scene.
  32732. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32733. * and getCollidingSubMeshCandidates to their default function
  32734. */
  32735. setDefaultCandidateProviders(): void;
  32736. /**
  32737. * Gets the mesh that is currently under the pointer
  32738. */
  32739. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32740. /**
  32741. * Gets or sets the current on-screen X position of the pointer
  32742. */
  32743. pointerX: number;
  32744. /**
  32745. * Gets or sets the current on-screen Y position of the pointer
  32746. */
  32747. pointerY: number;
  32748. /**
  32749. * Gets the cached material (ie. the latest rendered one)
  32750. * @returns the cached material
  32751. */
  32752. getCachedMaterial(): Nullable<Material>;
  32753. /**
  32754. * Gets the cached effect (ie. the latest rendered one)
  32755. * @returns the cached effect
  32756. */
  32757. getCachedEffect(): Nullable<Effect>;
  32758. /**
  32759. * Gets the cached visibility state (ie. the latest rendered one)
  32760. * @returns the cached visibility state
  32761. */
  32762. getCachedVisibility(): Nullable<number>;
  32763. /**
  32764. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32765. * @param material defines the current material
  32766. * @param effect defines the current effect
  32767. * @param visibility defines the current visibility state
  32768. * @returns true if one parameter is not cached
  32769. */
  32770. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32771. /**
  32772. * Gets the engine associated with the scene
  32773. * @returns an Engine
  32774. */
  32775. getEngine(): Engine;
  32776. /**
  32777. * Gets the total number of vertices rendered per frame
  32778. * @returns the total number of vertices rendered per frame
  32779. */
  32780. getTotalVertices(): number;
  32781. /**
  32782. * Gets the performance counter for total vertices
  32783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32784. */
  32785. readonly totalVerticesPerfCounter: PerfCounter;
  32786. /**
  32787. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32788. * @returns the total number of active indices rendered per frame
  32789. */
  32790. getActiveIndices(): number;
  32791. /**
  32792. * Gets the performance counter for active indices
  32793. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32794. */
  32795. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32796. /**
  32797. * Gets the total number of active particles rendered per frame
  32798. * @returns the total number of active particles rendered per frame
  32799. */
  32800. getActiveParticles(): number;
  32801. /**
  32802. * Gets the performance counter for active particles
  32803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32804. */
  32805. readonly activeParticlesPerfCounter: PerfCounter;
  32806. /**
  32807. * Gets the total number of active bones rendered per frame
  32808. * @returns the total number of active bones rendered per frame
  32809. */
  32810. getActiveBones(): number;
  32811. /**
  32812. * Gets the performance counter for active bones
  32813. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32814. */
  32815. readonly activeBonesPerfCounter: PerfCounter;
  32816. /**
  32817. * Gets the array of active meshes
  32818. * @returns an array of AbstractMesh
  32819. */
  32820. getActiveMeshes(): SmartArray<AbstractMesh>;
  32821. /**
  32822. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32823. * @returns a number
  32824. */
  32825. getAnimationRatio(): number;
  32826. /**
  32827. * Gets an unique Id for the current render phase
  32828. * @returns a number
  32829. */
  32830. getRenderId(): number;
  32831. /**
  32832. * Gets an unique Id for the current frame
  32833. * @returns a number
  32834. */
  32835. getFrameId(): number;
  32836. /** Call this function if you want to manually increment the render Id*/
  32837. incrementRenderId(): void;
  32838. private _createUbo;
  32839. /**
  32840. * Use this method to simulate a pointer move on a mesh
  32841. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32842. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32843. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32844. * @returns the current scene
  32845. */
  32846. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32847. /**
  32848. * Use this method to simulate a pointer down on a mesh
  32849. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32850. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32851. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32852. * @returns the current scene
  32853. */
  32854. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32855. /**
  32856. * Use this method to simulate a pointer up on a mesh
  32857. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32858. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32859. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32860. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32861. * @returns the current scene
  32862. */
  32863. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32864. /**
  32865. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32866. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32867. * @returns true if the pointer was captured
  32868. */
  32869. isPointerCaptured(pointerId?: number): boolean;
  32870. /**
  32871. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32872. * @param attachUp defines if you want to attach events to pointerup
  32873. * @param attachDown defines if you want to attach events to pointerdown
  32874. * @param attachMove defines if you want to attach events to pointermove
  32875. */
  32876. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32877. /** Detaches all event handlers*/
  32878. detachControl(): void;
  32879. /**
  32880. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32881. * Delay loaded resources are not taking in account
  32882. * @return true if all required resources are ready
  32883. */
  32884. isReady(): boolean;
  32885. /** Resets all cached information relative to material (including effect and visibility) */
  32886. resetCachedMaterial(): void;
  32887. /**
  32888. * Registers a function to be called before every frame render
  32889. * @param func defines the function to register
  32890. */
  32891. registerBeforeRender(func: () => void): void;
  32892. /**
  32893. * Unregisters a function called before every frame render
  32894. * @param func defines the function to unregister
  32895. */
  32896. unregisterBeforeRender(func: () => void): void;
  32897. /**
  32898. * Registers a function to be called after every frame render
  32899. * @param func defines the function to register
  32900. */
  32901. registerAfterRender(func: () => void): void;
  32902. /**
  32903. * Unregisters a function called after every frame render
  32904. * @param func defines the function to unregister
  32905. */
  32906. unregisterAfterRender(func: () => void): void;
  32907. private _executeOnceBeforeRender;
  32908. /**
  32909. * The provided function will run before render once and will be disposed afterwards.
  32910. * A timeout delay can be provided so that the function will be executed in N ms.
  32911. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32912. * @param func The function to be executed.
  32913. * @param timeout optional delay in ms
  32914. */
  32915. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32916. /** @hidden */
  32917. _addPendingData(data: any): void;
  32918. /** @hidden */
  32919. _removePendingData(data: any): void;
  32920. /**
  32921. * Returns the number of items waiting to be loaded
  32922. * @returns the number of items waiting to be loaded
  32923. */
  32924. getWaitingItemsCount(): number;
  32925. /**
  32926. * Returns a boolean indicating if the scene is still loading data
  32927. */
  32928. readonly isLoading: boolean;
  32929. /**
  32930. * Registers a function to be executed when the scene is ready
  32931. * @param {Function} func - the function to be executed
  32932. */
  32933. executeWhenReady(func: () => void): void;
  32934. /**
  32935. * Returns a promise that resolves when the scene is ready
  32936. * @returns A promise that resolves when the scene is ready
  32937. */
  32938. whenReadyAsync(): Promise<void>;
  32939. /** @hidden */
  32940. _checkIsReady(): void;
  32941. /**
  32942. * Gets all animatable attached to the scene
  32943. */
  32944. readonly animatables: Animatable[];
  32945. /**
  32946. * Resets the last animation time frame.
  32947. * Useful to override when animations start running when loading a scene for the first time.
  32948. */
  32949. resetLastAnimationTimeFrame(): void;
  32950. /**
  32951. * Gets the current view matrix
  32952. * @returns a Matrix
  32953. */
  32954. getViewMatrix(): Matrix;
  32955. /**
  32956. * Gets the current projection matrix
  32957. * @returns a Matrix
  32958. */
  32959. getProjectionMatrix(): Matrix;
  32960. /**
  32961. * Gets the current transform matrix
  32962. * @returns a Matrix made of View * Projection
  32963. */
  32964. getTransformMatrix(): Matrix;
  32965. /**
  32966. * Sets the current transform matrix
  32967. * @param viewL defines the View matrix to use
  32968. * @param projectionL defines the Projection matrix to use
  32969. * @param viewR defines the right View matrix to use (if provided)
  32970. * @param projectionR defines the right Projection matrix to use (if provided)
  32971. */
  32972. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32973. /**
  32974. * Gets the uniform buffer used to store scene data
  32975. * @returns a UniformBuffer
  32976. */
  32977. getSceneUniformBuffer(): UniformBuffer;
  32978. /**
  32979. * Gets an unique (relatively to the current scene) Id
  32980. * @returns an unique number for the scene
  32981. */
  32982. getUniqueId(): number;
  32983. /**
  32984. * Add a mesh to the list of scene's meshes
  32985. * @param newMesh defines the mesh to add
  32986. * @param recursive if all child meshes should also be added to the scene
  32987. */
  32988. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32989. /**
  32990. * Remove a mesh for the list of scene's meshes
  32991. * @param toRemove defines the mesh to remove
  32992. * @param recursive if all child meshes should also be removed from the scene
  32993. * @returns the index where the mesh was in the mesh list
  32994. */
  32995. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32996. /**
  32997. * Add a transform node to the list of scene's transform nodes
  32998. * @param newTransformNode defines the transform node to add
  32999. */
  33000. addTransformNode(newTransformNode: TransformNode): void;
  33001. /**
  33002. * Remove a transform node for the list of scene's transform nodes
  33003. * @param toRemove defines the transform node to remove
  33004. * @returns the index where the transform node was in the transform node list
  33005. */
  33006. removeTransformNode(toRemove: TransformNode): number;
  33007. /**
  33008. * Remove a skeleton for the list of scene's skeletons
  33009. * @param toRemove defines the skeleton to remove
  33010. * @returns the index where the skeleton was in the skeleton list
  33011. */
  33012. removeSkeleton(toRemove: Skeleton): number;
  33013. /**
  33014. * Remove a morph target for the list of scene's morph targets
  33015. * @param toRemove defines the morph target to remove
  33016. * @returns the index where the morph target was in the morph target list
  33017. */
  33018. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33019. /**
  33020. * Remove a light for the list of scene's lights
  33021. * @param toRemove defines the light to remove
  33022. * @returns the index where the light was in the light list
  33023. */
  33024. removeLight(toRemove: Light): number;
  33025. /**
  33026. * Remove a camera for the list of scene's cameras
  33027. * @param toRemove defines the camera to remove
  33028. * @returns the index where the camera was in the camera list
  33029. */
  33030. removeCamera(toRemove: Camera): number;
  33031. /**
  33032. * Remove a particle system for the list of scene's particle systems
  33033. * @param toRemove defines the particle system to remove
  33034. * @returns the index where the particle system was in the particle system list
  33035. */
  33036. removeParticleSystem(toRemove: IParticleSystem): number;
  33037. /**
  33038. * Remove a animation for the list of scene's animations
  33039. * @param toRemove defines the animation to remove
  33040. * @returns the index where the animation was in the animation list
  33041. */
  33042. removeAnimation(toRemove: Animation): number;
  33043. /**
  33044. * Will stop the animation of the given target
  33045. * @param target - the target
  33046. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33047. * @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)
  33048. */
  33049. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33050. /**
  33051. * Removes the given animation group from this scene.
  33052. * @param toRemove The animation group to remove
  33053. * @returns The index of the removed animation group
  33054. */
  33055. removeAnimationGroup(toRemove: AnimationGroup): number;
  33056. /**
  33057. * Removes the given multi-material from this scene.
  33058. * @param toRemove The multi-material to remove
  33059. * @returns The index of the removed multi-material
  33060. */
  33061. removeMultiMaterial(toRemove: MultiMaterial): number;
  33062. /**
  33063. * Removes the given material from this scene.
  33064. * @param toRemove The material to remove
  33065. * @returns The index of the removed material
  33066. */
  33067. removeMaterial(toRemove: Material): number;
  33068. /**
  33069. * Removes the given action manager from this scene.
  33070. * @param toRemove The action manager to remove
  33071. * @returns The index of the removed action manager
  33072. */
  33073. removeActionManager(toRemove: AbstractActionManager): number;
  33074. /**
  33075. * Removes the given texture from this scene.
  33076. * @param toRemove The texture to remove
  33077. * @returns The index of the removed texture
  33078. */
  33079. removeTexture(toRemove: BaseTexture): number;
  33080. /**
  33081. * Adds the given light to this scene
  33082. * @param newLight The light to add
  33083. */
  33084. addLight(newLight: Light): void;
  33085. /**
  33086. * Sorts the list list based on light priorities
  33087. */
  33088. sortLightsByPriority(): void;
  33089. /**
  33090. * Adds the given camera to this scene
  33091. * @param newCamera The camera to add
  33092. */
  33093. addCamera(newCamera: Camera): void;
  33094. /**
  33095. * Adds the given skeleton to this scene
  33096. * @param newSkeleton The skeleton to add
  33097. */
  33098. addSkeleton(newSkeleton: Skeleton): void;
  33099. /**
  33100. * Adds the given particle system to this scene
  33101. * @param newParticleSystem The particle system to add
  33102. */
  33103. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33104. /**
  33105. * Adds the given animation to this scene
  33106. * @param newAnimation The animation to add
  33107. */
  33108. addAnimation(newAnimation: Animation): void;
  33109. /**
  33110. * Adds the given animation group to this scene.
  33111. * @param newAnimationGroup The animation group to add
  33112. */
  33113. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33114. /**
  33115. * Adds the given multi-material to this scene
  33116. * @param newMultiMaterial The multi-material to add
  33117. */
  33118. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33119. /**
  33120. * Adds the given material to this scene
  33121. * @param newMaterial The material to add
  33122. */
  33123. addMaterial(newMaterial: Material): void;
  33124. /**
  33125. * Adds the given morph target to this scene
  33126. * @param newMorphTargetManager The morph target to add
  33127. */
  33128. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33129. /**
  33130. * Adds the given geometry to this scene
  33131. * @param newGeometry The geometry to add
  33132. */
  33133. addGeometry(newGeometry: Geometry): void;
  33134. /**
  33135. * Adds the given action manager to this scene
  33136. * @param newActionManager The action manager to add
  33137. */
  33138. addActionManager(newActionManager: AbstractActionManager): void;
  33139. /**
  33140. * Adds the given texture to this scene.
  33141. * @param newTexture The texture to add
  33142. */
  33143. addTexture(newTexture: BaseTexture): void;
  33144. /**
  33145. * Switch active camera
  33146. * @param newCamera defines the new active camera
  33147. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33148. */
  33149. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33150. /**
  33151. * sets the active camera of the scene using its ID
  33152. * @param id defines the camera's ID
  33153. * @return the new active camera or null if none found.
  33154. */
  33155. setActiveCameraByID(id: string): Nullable<Camera>;
  33156. /**
  33157. * sets the active camera of the scene using its name
  33158. * @param name defines the camera's name
  33159. * @returns the new active camera or null if none found.
  33160. */
  33161. setActiveCameraByName(name: string): Nullable<Camera>;
  33162. /**
  33163. * get an animation group using its name
  33164. * @param name defines the material's name
  33165. * @return the animation group or null if none found.
  33166. */
  33167. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33168. /**
  33169. * Get a material using its unique id
  33170. * @param uniqueId defines the material's unique id
  33171. * @return the material or null if none found.
  33172. */
  33173. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33174. /**
  33175. * get a material using its id
  33176. * @param id defines the material's ID
  33177. * @return the material or null if none found.
  33178. */
  33179. getMaterialByID(id: string): Nullable<Material>;
  33180. /**
  33181. * Gets a material using its name
  33182. * @param name defines the material's name
  33183. * @return the material or null if none found.
  33184. */
  33185. getMaterialByName(name: string): Nullable<Material>;
  33186. /**
  33187. * Gets a camera using its id
  33188. * @param id defines the id to look for
  33189. * @returns the camera or null if not found
  33190. */
  33191. getCameraByID(id: string): Nullable<Camera>;
  33192. /**
  33193. * Gets a camera using its unique id
  33194. * @param uniqueId defines the unique id to look for
  33195. * @returns the camera or null if not found
  33196. */
  33197. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33198. /**
  33199. * Gets a camera using its name
  33200. * @param name defines the camera's name
  33201. * @return the camera or null if none found.
  33202. */
  33203. getCameraByName(name: string): Nullable<Camera>;
  33204. /**
  33205. * Gets a bone using its id
  33206. * @param id defines the bone's id
  33207. * @return the bone or null if not found
  33208. */
  33209. getBoneByID(id: string): Nullable<Bone>;
  33210. /**
  33211. * Gets a bone using its id
  33212. * @param name defines the bone's name
  33213. * @return the bone or null if not found
  33214. */
  33215. getBoneByName(name: string): Nullable<Bone>;
  33216. /**
  33217. * Gets a light node using its name
  33218. * @param name defines the the light's name
  33219. * @return the light or null if none found.
  33220. */
  33221. getLightByName(name: string): Nullable<Light>;
  33222. /**
  33223. * Gets a light node using its id
  33224. * @param id defines the light's id
  33225. * @return the light or null if none found.
  33226. */
  33227. getLightByID(id: string): Nullable<Light>;
  33228. /**
  33229. * Gets a light node using its scene-generated unique ID
  33230. * @param uniqueId defines the light's unique id
  33231. * @return the light or null if none found.
  33232. */
  33233. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33234. /**
  33235. * Gets a particle system by id
  33236. * @param id defines the particle system id
  33237. * @return the corresponding system or null if none found
  33238. */
  33239. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33240. /**
  33241. * Gets a geometry using its ID
  33242. * @param id defines the geometry's id
  33243. * @return the geometry or null if none found.
  33244. */
  33245. getGeometryByID(id: string): Nullable<Geometry>;
  33246. private _getGeometryByUniqueID;
  33247. /**
  33248. * Add a new geometry to this scene
  33249. * @param geometry defines the geometry to be added to the scene.
  33250. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33251. * @return a boolean defining if the geometry was added or not
  33252. */
  33253. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33254. /**
  33255. * Removes an existing geometry
  33256. * @param geometry defines the geometry to be removed from the scene
  33257. * @return a boolean defining if the geometry was removed or not
  33258. */
  33259. removeGeometry(geometry: Geometry): boolean;
  33260. /**
  33261. * Gets the list of geometries attached to the scene
  33262. * @returns an array of Geometry
  33263. */
  33264. getGeometries(): Geometry[];
  33265. /**
  33266. * Gets the first added mesh found of a given ID
  33267. * @param id defines the id to search for
  33268. * @return the mesh found or null if not found at all
  33269. */
  33270. getMeshByID(id: string): Nullable<AbstractMesh>;
  33271. /**
  33272. * Gets a list of meshes using their id
  33273. * @param id defines the id to search for
  33274. * @returns a list of meshes
  33275. */
  33276. getMeshesByID(id: string): Array<AbstractMesh>;
  33277. /**
  33278. * Gets the first added transform node found of a given ID
  33279. * @param id defines the id to search for
  33280. * @return the found transform node or null if not found at all.
  33281. */
  33282. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33283. /**
  33284. * Gets a transform node with its auto-generated unique id
  33285. * @param uniqueId efines the unique id to search for
  33286. * @return the found transform node or null if not found at all.
  33287. */
  33288. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33289. /**
  33290. * Gets a list of transform nodes using their id
  33291. * @param id defines the id to search for
  33292. * @returns a list of transform nodes
  33293. */
  33294. getTransformNodesByID(id: string): Array<TransformNode>;
  33295. /**
  33296. * Gets a mesh with its auto-generated unique id
  33297. * @param uniqueId defines the unique id to search for
  33298. * @return the found mesh or null if not found at all.
  33299. */
  33300. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33301. /**
  33302. * Gets a the last added mesh using a given id
  33303. * @param id defines the id to search for
  33304. * @return the found mesh or null if not found at all.
  33305. */
  33306. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33307. /**
  33308. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33309. * @param id defines the id to search for
  33310. * @return the found node or null if not found at all
  33311. */
  33312. getLastEntryByID(id: string): Nullable<Node>;
  33313. /**
  33314. * Gets a node (Mesh, Camera, Light) using a given id
  33315. * @param id defines the id to search for
  33316. * @return the found node or null if not found at all
  33317. */
  33318. getNodeByID(id: string): Nullable<Node>;
  33319. /**
  33320. * Gets a node (Mesh, Camera, Light) using a given name
  33321. * @param name defines the name to search for
  33322. * @return the found node or null if not found at all.
  33323. */
  33324. getNodeByName(name: string): Nullable<Node>;
  33325. /**
  33326. * Gets a mesh using a given name
  33327. * @param name defines the name to search for
  33328. * @return the found mesh or null if not found at all.
  33329. */
  33330. getMeshByName(name: string): Nullable<AbstractMesh>;
  33331. /**
  33332. * Gets a transform node using a given name
  33333. * @param name defines the name to search for
  33334. * @return the found transform node or null if not found at all.
  33335. */
  33336. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33337. /**
  33338. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33339. * @param id defines the id to search for
  33340. * @return the found skeleton or null if not found at all.
  33341. */
  33342. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33343. /**
  33344. * Gets a skeleton using a given auto generated unique id
  33345. * @param uniqueId defines the unique id to search for
  33346. * @return the found skeleton or null if not found at all.
  33347. */
  33348. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33349. /**
  33350. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33351. * @param id defines the id to search for
  33352. * @return the found skeleton or null if not found at all.
  33353. */
  33354. getSkeletonById(id: string): Nullable<Skeleton>;
  33355. /**
  33356. * Gets a skeleton using a given name
  33357. * @param name defines the name to search for
  33358. * @return the found skeleton or null if not found at all.
  33359. */
  33360. getSkeletonByName(name: string): Nullable<Skeleton>;
  33361. /**
  33362. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33363. * @param id defines the id to search for
  33364. * @return the found morph target manager or null if not found at all.
  33365. */
  33366. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33367. /**
  33368. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33369. * @param id defines the id to search for
  33370. * @return the found morph target or null if not found at all.
  33371. */
  33372. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33373. /**
  33374. * Gets a boolean indicating if the given mesh is active
  33375. * @param mesh defines the mesh to look for
  33376. * @returns true if the mesh is in the active list
  33377. */
  33378. isActiveMesh(mesh: AbstractMesh): boolean;
  33379. /**
  33380. * Return a unique id as a string which can serve as an identifier for the scene
  33381. */
  33382. readonly uid: string;
  33383. /**
  33384. * Add an externaly attached data from its key.
  33385. * This method call will fail and return false, if such key already exists.
  33386. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33387. * @param key the unique key that identifies the data
  33388. * @param data the data object to associate to the key for this Engine instance
  33389. * @return true if no such key were already present and the data was added successfully, false otherwise
  33390. */
  33391. addExternalData<T>(key: string, data: T): boolean;
  33392. /**
  33393. * Get an externaly attached data from its key
  33394. * @param key the unique key that identifies the data
  33395. * @return the associated data, if present (can be null), or undefined if not present
  33396. */
  33397. getExternalData<T>(key: string): Nullable<T>;
  33398. /**
  33399. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33400. * @param key the unique key that identifies the data
  33401. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33402. * @return the associated data, can be null if the factory returned null.
  33403. */
  33404. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33405. /**
  33406. * Remove an externaly attached data from the Engine instance
  33407. * @param key the unique key that identifies the data
  33408. * @return true if the data was successfully removed, false if it doesn't exist
  33409. */
  33410. removeExternalData(key: string): boolean;
  33411. private _evaluateSubMesh;
  33412. /**
  33413. * Clear the processed materials smart array preventing retention point in material dispose.
  33414. */
  33415. freeProcessedMaterials(): void;
  33416. private _preventFreeActiveMeshesAndRenderingGroups;
  33417. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33418. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33419. * when disposing several meshes in a row or a hierarchy of meshes.
  33420. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33421. */
  33422. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33423. /**
  33424. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33425. */
  33426. freeActiveMeshes(): void;
  33427. /**
  33428. * Clear the info related to rendering groups preventing retention points during dispose.
  33429. */
  33430. freeRenderingGroups(): void;
  33431. /** @hidden */
  33432. _isInIntermediateRendering(): boolean;
  33433. /**
  33434. * Lambda returning the list of potentially active meshes.
  33435. */
  33436. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33437. /**
  33438. * Lambda returning the list of potentially active sub meshes.
  33439. */
  33440. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33441. /**
  33442. * Lambda returning the list of potentially intersecting sub meshes.
  33443. */
  33444. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33445. /**
  33446. * Lambda returning the list of potentially colliding sub meshes.
  33447. */
  33448. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33449. private _activeMeshesFrozen;
  33450. /**
  33451. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33452. * @returns the current scene
  33453. */
  33454. freezeActiveMeshes(): Scene;
  33455. /**
  33456. * Use this function to restart evaluating active meshes on every frame
  33457. * @returns the current scene
  33458. */
  33459. unfreezeActiveMeshes(): Scene;
  33460. private _evaluateActiveMeshes;
  33461. private _activeMesh;
  33462. /**
  33463. * Update the transform matrix to update from the current active camera
  33464. * @param force defines a boolean used to force the update even if cache is up to date
  33465. */
  33466. updateTransformMatrix(force?: boolean): void;
  33467. private _bindFrameBuffer;
  33468. /** @hidden */
  33469. _allowPostProcessClearColor: boolean;
  33470. /** @hidden */
  33471. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33472. private _processSubCameras;
  33473. private _checkIntersections;
  33474. /** @hidden */
  33475. _advancePhysicsEngineStep(step: number): void;
  33476. /**
  33477. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33478. */
  33479. getDeterministicFrameTime: () => number;
  33480. /** @hidden */
  33481. _animate(): void;
  33482. /** Execute all animations (for a frame) */
  33483. animate(): void;
  33484. /**
  33485. * Render the scene
  33486. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33487. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33488. */
  33489. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33490. /**
  33491. * Freeze all materials
  33492. * A frozen material will not be updatable but should be faster to render
  33493. */
  33494. freezeMaterials(): void;
  33495. /**
  33496. * Unfreeze all materials
  33497. * A frozen material will not be updatable but should be faster to render
  33498. */
  33499. unfreezeMaterials(): void;
  33500. /**
  33501. * Releases all held ressources
  33502. */
  33503. dispose(): void;
  33504. /**
  33505. * Gets if the scene is already disposed
  33506. */
  33507. readonly isDisposed: boolean;
  33508. /**
  33509. * Call this function to reduce memory footprint of the scene.
  33510. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33511. */
  33512. clearCachedVertexData(): void;
  33513. /**
  33514. * This function will remove the local cached buffer data from texture.
  33515. * It will save memory but will prevent the texture from being rebuilt
  33516. */
  33517. cleanCachedTextureBuffer(): void;
  33518. /**
  33519. * Get the world extend vectors with an optional filter
  33520. *
  33521. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33522. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33523. */
  33524. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33525. min: Vector3;
  33526. max: Vector3;
  33527. };
  33528. /**
  33529. * Creates a ray that can be used to pick in the scene
  33530. * @param x defines the x coordinate of the origin (on-screen)
  33531. * @param y defines the y coordinate of the origin (on-screen)
  33532. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33533. * @param camera defines the camera to use for the picking
  33534. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33535. * @returns a Ray
  33536. */
  33537. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33538. /**
  33539. * Creates a ray that can be used to pick in the scene
  33540. * @param x defines the x coordinate of the origin (on-screen)
  33541. * @param y defines the y coordinate of the origin (on-screen)
  33542. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33543. * @param result defines the ray where to store the picking ray
  33544. * @param camera defines the camera to use for the picking
  33545. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33546. * @returns the current scene
  33547. */
  33548. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33549. /**
  33550. * Creates a ray that can be used to pick in the scene
  33551. * @param x defines the x coordinate of the origin (on-screen)
  33552. * @param y defines the y coordinate of the origin (on-screen)
  33553. * @param camera defines the camera to use for the picking
  33554. * @returns a Ray
  33555. */
  33556. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33557. /**
  33558. * Creates a ray that can be used to pick in the scene
  33559. * @param x defines the x coordinate of the origin (on-screen)
  33560. * @param y defines the y coordinate of the origin (on-screen)
  33561. * @param result defines the ray where to store the picking ray
  33562. * @param camera defines the camera to use for the picking
  33563. * @returns the current scene
  33564. */
  33565. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33566. /** Launch a ray to try to pick a mesh in the scene
  33567. * @param x position on screen
  33568. * @param y position on screen
  33569. * @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
  33570. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33571. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33572. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33573. * @returns a PickingInfo
  33574. */
  33575. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  33576. /** Use the given ray to pick a mesh in the scene
  33577. * @param ray The ray to use to pick meshes
  33578. * @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
  33579. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33580. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33581. * @returns a PickingInfo
  33582. */
  33583. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33584. /**
  33585. * Launch a ray to try to pick a mesh in the scene
  33586. * @param x X position on screen
  33587. * @param y Y position on screen
  33588. * @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
  33589. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33590. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33591. * @returns an array of PickingInfo
  33592. */
  33593. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33594. /**
  33595. * Launch a ray to try to pick a mesh in the scene
  33596. * @param ray Ray to use
  33597. * @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
  33598. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33599. * @returns an array of PickingInfo
  33600. */
  33601. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33602. /**
  33603. * Force the value of meshUnderPointer
  33604. * @param mesh defines the mesh to use
  33605. */
  33606. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33607. /**
  33608. * Gets the mesh under the pointer
  33609. * @returns a Mesh or null if no mesh is under the pointer
  33610. */
  33611. getPointerOverMesh(): Nullable<AbstractMesh>;
  33612. /** @hidden */
  33613. _rebuildGeometries(): void;
  33614. /** @hidden */
  33615. _rebuildTextures(): void;
  33616. private _getByTags;
  33617. /**
  33618. * Get a list of meshes by tags
  33619. * @param tagsQuery defines the tags query to use
  33620. * @param forEach defines a predicate used to filter results
  33621. * @returns an array of Mesh
  33622. */
  33623. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33624. /**
  33625. * Get a list of cameras by tags
  33626. * @param tagsQuery defines the tags query to use
  33627. * @param forEach defines a predicate used to filter results
  33628. * @returns an array of Camera
  33629. */
  33630. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33631. /**
  33632. * Get a list of lights by tags
  33633. * @param tagsQuery defines the tags query to use
  33634. * @param forEach defines a predicate used to filter results
  33635. * @returns an array of Light
  33636. */
  33637. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33638. /**
  33639. * Get a list of materials by tags
  33640. * @param tagsQuery defines the tags query to use
  33641. * @param forEach defines a predicate used to filter results
  33642. * @returns an array of Material
  33643. */
  33644. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33645. /**
  33646. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33647. * This allowed control for front to back rendering or reversly depending of the special needs.
  33648. *
  33649. * @param renderingGroupId The rendering group id corresponding to its index
  33650. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33651. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33652. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33653. */
  33654. 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;
  33655. /**
  33656. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33657. *
  33658. * @param renderingGroupId The rendering group id corresponding to its index
  33659. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33660. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33661. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33662. */
  33663. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33664. /**
  33665. * Gets the current auto clear configuration for one rendering group of the rendering
  33666. * manager.
  33667. * @param index the rendering group index to get the information for
  33668. * @returns The auto clear setup for the requested rendering group
  33669. */
  33670. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33671. private _blockMaterialDirtyMechanism;
  33672. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33673. blockMaterialDirtyMechanism: boolean;
  33674. /**
  33675. * Will flag all materials as dirty to trigger new shader compilation
  33676. * @param flag defines the flag used to specify which material part must be marked as dirty
  33677. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33678. */
  33679. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33680. /** @hidden */
  33681. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33682. /** @hidden */
  33683. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33684. }
  33685. }
  33686. declare module BABYLON {
  33687. /**
  33688. * Set of assets to keep when moving a scene into an asset container.
  33689. */
  33690. export class KeepAssets extends AbstractScene {
  33691. }
  33692. /**
  33693. * Container with a set of assets that can be added or removed from a scene.
  33694. */
  33695. export class AssetContainer extends AbstractScene {
  33696. /**
  33697. * The scene the AssetContainer belongs to.
  33698. */
  33699. scene: Scene;
  33700. /**
  33701. * Instantiates an AssetContainer.
  33702. * @param scene The scene the AssetContainer belongs to.
  33703. */
  33704. constructor(scene: Scene);
  33705. /**
  33706. * Adds all the assets from the container to the scene.
  33707. */
  33708. addAllToScene(): void;
  33709. /**
  33710. * Removes all the assets in the container from the scene
  33711. */
  33712. removeAllFromScene(): void;
  33713. /**
  33714. * Disposes all the assets in the container
  33715. */
  33716. dispose(): void;
  33717. private _moveAssets;
  33718. /**
  33719. * Removes all the assets contained in the scene and adds them to the container.
  33720. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33721. */
  33722. moveAllFromScene(keepAssets?: KeepAssets): void;
  33723. /**
  33724. * 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.
  33725. * @returns the root mesh
  33726. */
  33727. createRootMesh(): Mesh;
  33728. }
  33729. }
  33730. declare module BABYLON {
  33731. /**
  33732. * Defines how the parser contract is defined.
  33733. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33734. */
  33735. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33736. /**
  33737. * Defines how the individual parser contract is defined.
  33738. * These parser can parse an individual asset
  33739. */
  33740. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33741. /**
  33742. * Base class of the scene acting as a container for the different elements composing a scene.
  33743. * This class is dynamically extended by the different components of the scene increasing
  33744. * flexibility and reducing coupling
  33745. */
  33746. export abstract class AbstractScene {
  33747. /**
  33748. * Stores the list of available parsers in the application.
  33749. */
  33750. private static _BabylonFileParsers;
  33751. /**
  33752. * Stores the list of available individual parsers in the application.
  33753. */
  33754. private static _IndividualBabylonFileParsers;
  33755. /**
  33756. * Adds a parser in the list of available ones
  33757. * @param name Defines the name of the parser
  33758. * @param parser Defines the parser to add
  33759. */
  33760. static AddParser(name: string, parser: BabylonFileParser): void;
  33761. /**
  33762. * Gets a general parser from the list of avaialble ones
  33763. * @param name Defines the name of the parser
  33764. * @returns the requested parser or null
  33765. */
  33766. static GetParser(name: string): Nullable<BabylonFileParser>;
  33767. /**
  33768. * Adds n individual parser in the list of available ones
  33769. * @param name Defines the name of the parser
  33770. * @param parser Defines the parser to add
  33771. */
  33772. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33773. /**
  33774. * Gets an individual parser from the list of avaialble ones
  33775. * @param name Defines the name of the parser
  33776. * @returns the requested parser or null
  33777. */
  33778. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33779. /**
  33780. * Parser json data and populate both a scene and its associated container object
  33781. * @param jsonData Defines the data to parse
  33782. * @param scene Defines the scene to parse the data for
  33783. * @param container Defines the container attached to the parsing sequence
  33784. * @param rootUrl Defines the root url of the data
  33785. */
  33786. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33787. /**
  33788. * Gets the list of root nodes (ie. nodes with no parent)
  33789. */
  33790. rootNodes: Node[];
  33791. /** All of the cameras added to this scene
  33792. * @see http://doc.babylonjs.com/babylon101/cameras
  33793. */
  33794. cameras: Camera[];
  33795. /**
  33796. * All of the lights added to this scene
  33797. * @see http://doc.babylonjs.com/babylon101/lights
  33798. */
  33799. lights: Light[];
  33800. /**
  33801. * All of the (abstract) meshes added to this scene
  33802. */
  33803. meshes: AbstractMesh[];
  33804. /**
  33805. * The list of skeletons added to the scene
  33806. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33807. */
  33808. skeletons: Skeleton[];
  33809. /**
  33810. * All of the particle systems added to this scene
  33811. * @see http://doc.babylonjs.com/babylon101/particles
  33812. */
  33813. particleSystems: IParticleSystem[];
  33814. /**
  33815. * Gets a list of Animations associated with the scene
  33816. */
  33817. animations: Animation[];
  33818. /**
  33819. * All of the animation groups added to this scene
  33820. * @see http://doc.babylonjs.com/how_to/group
  33821. */
  33822. animationGroups: AnimationGroup[];
  33823. /**
  33824. * All of the multi-materials added to this scene
  33825. * @see http://doc.babylonjs.com/how_to/multi_materials
  33826. */
  33827. multiMaterials: MultiMaterial[];
  33828. /**
  33829. * All of the materials added to this scene
  33830. * In the context of a Scene, it is not supposed to be modified manually.
  33831. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33832. * Note also that the order of the Material wihin the array is not significant and might change.
  33833. * @see http://doc.babylonjs.com/babylon101/materials
  33834. */
  33835. materials: Material[];
  33836. /**
  33837. * The list of morph target managers added to the scene
  33838. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33839. */
  33840. morphTargetManagers: MorphTargetManager[];
  33841. /**
  33842. * The list of geometries used in the scene.
  33843. */
  33844. geometries: Geometry[];
  33845. /**
  33846. * All of the tranform nodes added to this scene
  33847. * In the context of a Scene, it is not supposed to be modified manually.
  33848. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33849. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33850. * @see http://doc.babylonjs.com/how_to/transformnode
  33851. */
  33852. transformNodes: TransformNode[];
  33853. /**
  33854. * ActionManagers available on the scene.
  33855. */
  33856. actionManagers: AbstractActionManager[];
  33857. /**
  33858. * Textures to keep.
  33859. */
  33860. textures: BaseTexture[];
  33861. /**
  33862. * Environment texture for the scene
  33863. */
  33864. environmentTexture: Nullable<BaseTexture>;
  33865. }
  33866. }
  33867. declare module BABYLON {
  33868. /**
  33869. * Defines a sound that can be played in the application.
  33870. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33871. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33872. */
  33873. export class Sound {
  33874. /**
  33875. * The name of the sound in the scene.
  33876. */
  33877. name: string;
  33878. /**
  33879. * Does the sound autoplay once loaded.
  33880. */
  33881. autoplay: boolean;
  33882. /**
  33883. * Does the sound loop after it finishes playing once.
  33884. */
  33885. loop: boolean;
  33886. /**
  33887. * Does the sound use a custom attenuation curve to simulate the falloff
  33888. * happening when the source gets further away from the camera.
  33889. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33890. */
  33891. useCustomAttenuation: boolean;
  33892. /**
  33893. * The sound track id this sound belongs to.
  33894. */
  33895. soundTrackId: number;
  33896. /**
  33897. * Is this sound currently played.
  33898. */
  33899. isPlaying: boolean;
  33900. /**
  33901. * Is this sound currently paused.
  33902. */
  33903. isPaused: boolean;
  33904. /**
  33905. * Does this sound enables spatial sound.
  33906. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33907. */
  33908. spatialSound: boolean;
  33909. /**
  33910. * Define the reference distance the sound should be heard perfectly.
  33911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33912. */
  33913. refDistance: number;
  33914. /**
  33915. * Define the roll off factor of spatial sounds.
  33916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33917. */
  33918. rolloffFactor: number;
  33919. /**
  33920. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33922. */
  33923. maxDistance: number;
  33924. /**
  33925. * Define the distance attenuation model the sound will follow.
  33926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33927. */
  33928. distanceModel: string;
  33929. /**
  33930. * @hidden
  33931. * Back Compat
  33932. **/
  33933. onended: () => any;
  33934. /**
  33935. * Observable event when the current playing sound finishes.
  33936. */
  33937. onEndedObservable: Observable<Sound>;
  33938. private _panningModel;
  33939. private _playbackRate;
  33940. private _streaming;
  33941. private _startTime;
  33942. private _startOffset;
  33943. private _position;
  33944. /** @hidden */
  33945. _positionInEmitterSpace: boolean;
  33946. private _localDirection;
  33947. private _volume;
  33948. private _isReadyToPlay;
  33949. private _isDirectional;
  33950. private _readyToPlayCallback;
  33951. private _audioBuffer;
  33952. private _soundSource;
  33953. private _streamingSource;
  33954. private _soundPanner;
  33955. private _soundGain;
  33956. private _inputAudioNode;
  33957. private _outputAudioNode;
  33958. private _coneInnerAngle;
  33959. private _coneOuterAngle;
  33960. private _coneOuterGain;
  33961. private _scene;
  33962. private _connectedTransformNode;
  33963. private _customAttenuationFunction;
  33964. private _registerFunc;
  33965. private _isOutputConnected;
  33966. private _htmlAudioElement;
  33967. private _urlType;
  33968. /** @hidden */
  33969. static _SceneComponentInitialization: (scene: Scene) => void;
  33970. /**
  33971. * Create a sound and attach it to a scene
  33972. * @param name Name of your sound
  33973. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33974. * @param scene defines the scene the sound belongs to
  33975. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33976. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33977. */
  33978. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33979. /**
  33980. * Release the sound and its associated resources
  33981. */
  33982. dispose(): void;
  33983. /**
  33984. * Gets if the sounds is ready to be played or not.
  33985. * @returns true if ready, otherwise false
  33986. */
  33987. isReady(): boolean;
  33988. private _soundLoaded;
  33989. /**
  33990. * Sets the data of the sound from an audiobuffer
  33991. * @param audioBuffer The audioBuffer containing the data
  33992. */
  33993. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33994. /**
  33995. * Updates the current sounds options such as maxdistance, loop...
  33996. * @param options A JSON object containing values named as the object properties
  33997. */
  33998. updateOptions(options: any): void;
  33999. private _createSpatialParameters;
  34000. private _updateSpatialParameters;
  34001. /**
  34002. * Switch the panning model to HRTF:
  34003. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34004. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34005. */
  34006. switchPanningModelToHRTF(): void;
  34007. /**
  34008. * Switch the panning model to Equal Power:
  34009. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34010. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34011. */
  34012. switchPanningModelToEqualPower(): void;
  34013. private _switchPanningModel;
  34014. /**
  34015. * Connect this sound to a sound track audio node like gain...
  34016. * @param soundTrackAudioNode the sound track audio node to connect to
  34017. */
  34018. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34019. /**
  34020. * Transform this sound into a directional source
  34021. * @param coneInnerAngle Size of the inner cone in degree
  34022. * @param coneOuterAngle Size of the outer cone in degree
  34023. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34024. */
  34025. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34026. /**
  34027. * Gets or sets the inner angle for the directional cone.
  34028. */
  34029. /**
  34030. * Gets or sets the inner angle for the directional cone.
  34031. */
  34032. directionalConeInnerAngle: number;
  34033. /**
  34034. * Gets or sets the outer angle for the directional cone.
  34035. */
  34036. /**
  34037. * Gets or sets the outer angle for the directional cone.
  34038. */
  34039. directionalConeOuterAngle: number;
  34040. /**
  34041. * Sets the position of the emitter if spatial sound is enabled
  34042. * @param newPosition Defines the new posisiton
  34043. */
  34044. setPosition(newPosition: Vector3): void;
  34045. /**
  34046. * Sets the local direction of the emitter if spatial sound is enabled
  34047. * @param newLocalDirection Defines the new local direction
  34048. */
  34049. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34050. private _updateDirection;
  34051. /** @hidden */
  34052. updateDistanceFromListener(): void;
  34053. /**
  34054. * Sets a new custom attenuation function for the sound.
  34055. * @param callback Defines the function used for the attenuation
  34056. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34057. */
  34058. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34059. /**
  34060. * Play the sound
  34061. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34062. * @param offset (optional) Start the sound setting it at a specific time
  34063. */
  34064. play(time?: number, offset?: number): void;
  34065. private _onended;
  34066. /**
  34067. * Stop the sound
  34068. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34069. */
  34070. stop(time?: number): void;
  34071. /**
  34072. * Put the sound in pause
  34073. */
  34074. pause(): void;
  34075. /**
  34076. * Sets a dedicated volume for this sounds
  34077. * @param newVolume Define the new volume of the sound
  34078. * @param time Define in how long the sound should be at this value
  34079. */
  34080. setVolume(newVolume: number, time?: number): void;
  34081. /**
  34082. * Set the sound play back rate
  34083. * @param newPlaybackRate Define the playback rate the sound should be played at
  34084. */
  34085. setPlaybackRate(newPlaybackRate: number): void;
  34086. /**
  34087. * Gets the volume of the sound.
  34088. * @returns the volume of the sound
  34089. */
  34090. getVolume(): number;
  34091. /**
  34092. * Attach the sound to a dedicated mesh
  34093. * @param transformNode The transform node to connect the sound with
  34094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34095. */
  34096. attachToMesh(transformNode: TransformNode): void;
  34097. /**
  34098. * Detach the sound from the previously attached mesh
  34099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34100. */
  34101. detachFromMesh(): void;
  34102. private _onRegisterAfterWorldMatrixUpdate;
  34103. /**
  34104. * Clone the current sound in the scene.
  34105. * @returns the new sound clone
  34106. */
  34107. clone(): Nullable<Sound>;
  34108. /**
  34109. * Gets the current underlying audio buffer containing the data
  34110. * @returns the audio buffer
  34111. */
  34112. getAudioBuffer(): Nullable<AudioBuffer>;
  34113. /**
  34114. * Serializes the Sound in a JSON representation
  34115. * @returns the JSON representation of the sound
  34116. */
  34117. serialize(): any;
  34118. /**
  34119. * Parse a JSON representation of a sound to innstantiate in a given scene
  34120. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34121. * @param scene Define the scene the new parsed sound should be created in
  34122. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34123. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34124. * @returns the newly parsed sound
  34125. */
  34126. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34127. }
  34128. }
  34129. declare module BABYLON {
  34130. /**
  34131. * This defines an action helpful to play a defined sound on a triggered action.
  34132. */
  34133. export class PlaySoundAction extends Action {
  34134. private _sound;
  34135. /**
  34136. * Instantiate the action
  34137. * @param triggerOptions defines the trigger options
  34138. * @param sound defines the sound to play
  34139. * @param condition defines the trigger related conditions
  34140. */
  34141. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34142. /** @hidden */
  34143. _prepare(): void;
  34144. /**
  34145. * Execute the action and play the sound.
  34146. */
  34147. execute(): void;
  34148. /**
  34149. * Serializes the actions and its related information.
  34150. * @param parent defines the object to serialize in
  34151. * @returns the serialized object
  34152. */
  34153. serialize(parent: any): any;
  34154. }
  34155. /**
  34156. * This defines an action helpful to stop a defined sound on a triggered action.
  34157. */
  34158. export class StopSoundAction extends Action {
  34159. private _sound;
  34160. /**
  34161. * Instantiate the action
  34162. * @param triggerOptions defines the trigger options
  34163. * @param sound defines the sound to stop
  34164. * @param condition defines the trigger related conditions
  34165. */
  34166. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34167. /** @hidden */
  34168. _prepare(): void;
  34169. /**
  34170. * Execute the action and stop the sound.
  34171. */
  34172. execute(): void;
  34173. /**
  34174. * Serializes the actions and its related information.
  34175. * @param parent defines the object to serialize in
  34176. * @returns the serialized object
  34177. */
  34178. serialize(parent: any): any;
  34179. }
  34180. }
  34181. declare module BABYLON {
  34182. /**
  34183. * This defines an action responsible to change the value of a property
  34184. * by interpolating between its current value and the newly set one once triggered.
  34185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34186. */
  34187. export class InterpolateValueAction extends Action {
  34188. /**
  34189. * Defines the path of the property where the value should be interpolated
  34190. */
  34191. propertyPath: string;
  34192. /**
  34193. * Defines the target value at the end of the interpolation.
  34194. */
  34195. value: any;
  34196. /**
  34197. * Defines the time it will take for the property to interpolate to the value.
  34198. */
  34199. duration: number;
  34200. /**
  34201. * Defines if the other scene animations should be stopped when the action has been triggered
  34202. */
  34203. stopOtherAnimations?: boolean;
  34204. /**
  34205. * Defines a callback raised once the interpolation animation has been done.
  34206. */
  34207. onInterpolationDone?: () => void;
  34208. /**
  34209. * Observable triggered once the interpolation animation has been done.
  34210. */
  34211. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34212. private _target;
  34213. private _effectiveTarget;
  34214. private _property;
  34215. /**
  34216. * Instantiate the action
  34217. * @param triggerOptions defines the trigger options
  34218. * @param target defines the object containing the value to interpolate
  34219. * @param propertyPath defines the path to the property in the target object
  34220. * @param value defines the target value at the end of the interpolation
  34221. * @param duration deines the time it will take for the property to interpolate to the value.
  34222. * @param condition defines the trigger related conditions
  34223. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34224. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34225. */
  34226. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34227. /** @hidden */
  34228. _prepare(): void;
  34229. /**
  34230. * Execute the action starts the value interpolation.
  34231. */
  34232. execute(): void;
  34233. /**
  34234. * Serializes the actions and its related information.
  34235. * @param parent defines the object to serialize in
  34236. * @returns the serialized object
  34237. */
  34238. serialize(parent: any): any;
  34239. }
  34240. }
  34241. declare module BABYLON {
  34242. /**
  34243. * Options allowed during the creation of a sound track.
  34244. */
  34245. export interface ISoundTrackOptions {
  34246. /**
  34247. * The volume the sound track should take during creation
  34248. */
  34249. volume?: number;
  34250. /**
  34251. * Define if the sound track is the main sound track of the scene
  34252. */
  34253. mainTrack?: boolean;
  34254. }
  34255. /**
  34256. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34257. * It will be also used in a future release to apply effects on a specific track.
  34258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34259. */
  34260. export class SoundTrack {
  34261. /**
  34262. * The unique identifier of the sound track in the scene.
  34263. */
  34264. id: number;
  34265. /**
  34266. * The list of sounds included in the sound track.
  34267. */
  34268. soundCollection: Array<Sound>;
  34269. private _outputAudioNode;
  34270. private _scene;
  34271. private _isMainTrack;
  34272. private _connectedAnalyser;
  34273. private _options;
  34274. private _isInitialized;
  34275. /**
  34276. * Creates a new sound track.
  34277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34278. * @param scene Define the scene the sound track belongs to
  34279. * @param options
  34280. */
  34281. constructor(scene: Scene, options?: ISoundTrackOptions);
  34282. private _initializeSoundTrackAudioGraph;
  34283. /**
  34284. * Release the sound track and its associated resources
  34285. */
  34286. dispose(): void;
  34287. /**
  34288. * Adds a sound to this sound track
  34289. * @param sound define the cound to add
  34290. * @ignoreNaming
  34291. */
  34292. AddSound(sound: Sound): void;
  34293. /**
  34294. * Removes a sound to this sound track
  34295. * @param sound define the cound to remove
  34296. * @ignoreNaming
  34297. */
  34298. RemoveSound(sound: Sound): void;
  34299. /**
  34300. * Set a global volume for the full sound track.
  34301. * @param newVolume Define the new volume of the sound track
  34302. */
  34303. setVolume(newVolume: number): void;
  34304. /**
  34305. * Switch the panning model to HRTF:
  34306. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34308. */
  34309. switchPanningModelToHRTF(): void;
  34310. /**
  34311. * Switch the panning model to Equal Power:
  34312. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34314. */
  34315. switchPanningModelToEqualPower(): void;
  34316. /**
  34317. * Connect the sound track to an audio analyser allowing some amazing
  34318. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34320. * @param analyser The analyser to connect to the engine
  34321. */
  34322. connectToAnalyser(analyser: Analyser): void;
  34323. }
  34324. }
  34325. declare module BABYLON {
  34326. interface AbstractScene {
  34327. /**
  34328. * The list of sounds used in the scene.
  34329. */
  34330. sounds: Nullable<Array<Sound>>;
  34331. }
  34332. interface Scene {
  34333. /**
  34334. * @hidden
  34335. * Backing field
  34336. */
  34337. _mainSoundTrack: SoundTrack;
  34338. /**
  34339. * The main sound track played by the scene.
  34340. * It cotains your primary collection of sounds.
  34341. */
  34342. mainSoundTrack: SoundTrack;
  34343. /**
  34344. * The list of sound tracks added to the scene
  34345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34346. */
  34347. soundTracks: Nullable<Array<SoundTrack>>;
  34348. /**
  34349. * Gets a sound using a given name
  34350. * @param name defines the name to search for
  34351. * @return the found sound or null if not found at all.
  34352. */
  34353. getSoundByName(name: string): Nullable<Sound>;
  34354. /**
  34355. * Gets or sets if audio support is enabled
  34356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34357. */
  34358. audioEnabled: boolean;
  34359. /**
  34360. * Gets or sets if audio will be output to headphones
  34361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34362. */
  34363. headphone: boolean;
  34364. }
  34365. /**
  34366. * Defines the sound scene component responsible to manage any sounds
  34367. * in a given scene.
  34368. */
  34369. export class AudioSceneComponent implements ISceneSerializableComponent {
  34370. /**
  34371. * The component name helpfull to identify the component in the list of scene components.
  34372. */
  34373. readonly name: string;
  34374. /**
  34375. * The scene the component belongs to.
  34376. */
  34377. scene: Scene;
  34378. private _audioEnabled;
  34379. /**
  34380. * Gets whether audio is enabled or not.
  34381. * Please use related enable/disable method to switch state.
  34382. */
  34383. readonly audioEnabled: boolean;
  34384. private _headphone;
  34385. /**
  34386. * Gets whether audio is outputing to headphone or not.
  34387. * Please use the according Switch methods to change output.
  34388. */
  34389. readonly headphone: boolean;
  34390. /**
  34391. * Creates a new instance of the component for the given scene
  34392. * @param scene Defines the scene to register the component in
  34393. */
  34394. constructor(scene: Scene);
  34395. /**
  34396. * Registers the component in a given scene
  34397. */
  34398. register(): void;
  34399. /**
  34400. * Rebuilds the elements related to this component in case of
  34401. * context lost for instance.
  34402. */
  34403. rebuild(): void;
  34404. /**
  34405. * Serializes the component data to the specified json object
  34406. * @param serializationObject The object to serialize to
  34407. */
  34408. serialize(serializationObject: any): void;
  34409. /**
  34410. * Adds all the element from the container to the scene
  34411. * @param container the container holding the elements
  34412. */
  34413. addFromContainer(container: AbstractScene): void;
  34414. /**
  34415. * Removes all the elements in the container from the scene
  34416. * @param container contains the elements to remove
  34417. * @param dispose if the removed element should be disposed (default: false)
  34418. */
  34419. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34420. /**
  34421. * Disposes the component and the associated ressources.
  34422. */
  34423. dispose(): void;
  34424. /**
  34425. * Disables audio in the associated scene.
  34426. */
  34427. disableAudio(): void;
  34428. /**
  34429. * Enables audio in the associated scene.
  34430. */
  34431. enableAudio(): void;
  34432. /**
  34433. * Switch audio to headphone output.
  34434. */
  34435. switchAudioModeForHeadphones(): void;
  34436. /**
  34437. * Switch audio to normal speakers.
  34438. */
  34439. switchAudioModeForNormalSpeakers(): void;
  34440. private _afterRender;
  34441. }
  34442. }
  34443. declare module BABYLON {
  34444. /**
  34445. * Wraps one or more Sound objects and selects one with random weight for playback.
  34446. */
  34447. export class WeightedSound {
  34448. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34449. loop: boolean;
  34450. private _coneInnerAngle;
  34451. private _coneOuterAngle;
  34452. private _volume;
  34453. /** A Sound is currently playing. */
  34454. isPlaying: boolean;
  34455. /** A Sound is currently paused. */
  34456. isPaused: boolean;
  34457. private _sounds;
  34458. private _weights;
  34459. private _currentIndex?;
  34460. /**
  34461. * Creates a new WeightedSound from the list of sounds given.
  34462. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34463. * @param sounds Array of Sounds that will be selected from.
  34464. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34465. */
  34466. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34467. /**
  34468. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34469. */
  34470. /**
  34471. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34472. */
  34473. directionalConeInnerAngle: number;
  34474. /**
  34475. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34476. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34477. */
  34478. /**
  34479. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34480. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34481. */
  34482. directionalConeOuterAngle: number;
  34483. /**
  34484. * Playback volume.
  34485. */
  34486. /**
  34487. * Playback volume.
  34488. */
  34489. volume: number;
  34490. private _onended;
  34491. /**
  34492. * Suspend playback
  34493. */
  34494. pause(): void;
  34495. /**
  34496. * Stop playback
  34497. */
  34498. stop(): void;
  34499. /**
  34500. * Start playback.
  34501. * @param startOffset Position the clip head at a specific time in seconds.
  34502. */
  34503. play(startOffset?: number): void;
  34504. }
  34505. }
  34506. declare module BABYLON {
  34507. /**
  34508. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34509. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34510. */
  34511. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34512. /**
  34513. * Gets the name of the behavior.
  34514. */
  34515. readonly name: string;
  34516. /**
  34517. * The easing function used by animations
  34518. */
  34519. static EasingFunction: BackEase;
  34520. /**
  34521. * The easing mode used by animations
  34522. */
  34523. static EasingMode: number;
  34524. /**
  34525. * The duration of the animation, in milliseconds
  34526. */
  34527. transitionDuration: number;
  34528. /**
  34529. * Length of the distance animated by the transition when lower radius is reached
  34530. */
  34531. lowerRadiusTransitionRange: number;
  34532. /**
  34533. * Length of the distance animated by the transition when upper radius is reached
  34534. */
  34535. upperRadiusTransitionRange: number;
  34536. private _autoTransitionRange;
  34537. /**
  34538. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34539. */
  34540. /**
  34541. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34542. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34543. */
  34544. autoTransitionRange: boolean;
  34545. private _attachedCamera;
  34546. private _onAfterCheckInputsObserver;
  34547. private _onMeshTargetChangedObserver;
  34548. /**
  34549. * Initializes the behavior.
  34550. */
  34551. init(): void;
  34552. /**
  34553. * Attaches the behavior to its arc rotate camera.
  34554. * @param camera Defines the camera to attach the behavior to
  34555. */
  34556. attach(camera: ArcRotateCamera): void;
  34557. /**
  34558. * Detaches the behavior from its current arc rotate camera.
  34559. */
  34560. detach(): void;
  34561. private _radiusIsAnimating;
  34562. private _radiusBounceTransition;
  34563. private _animatables;
  34564. private _cachedWheelPrecision;
  34565. /**
  34566. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34567. * @param radiusLimit The limit to check against.
  34568. * @return Bool to indicate if at limit.
  34569. */
  34570. private _isRadiusAtLimit;
  34571. /**
  34572. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34573. * @param radiusDelta The delta by which to animate to. Can be negative.
  34574. */
  34575. private _applyBoundRadiusAnimation;
  34576. /**
  34577. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34578. */
  34579. protected _clearAnimationLocks(): void;
  34580. /**
  34581. * Stops and removes all animations that have been applied to the camera
  34582. */
  34583. stopAllAnimations(): void;
  34584. }
  34585. }
  34586. declare module BABYLON {
  34587. /**
  34588. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  34589. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34590. */
  34591. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34592. /**
  34593. * Gets the name of the behavior.
  34594. */
  34595. readonly name: string;
  34596. private _mode;
  34597. private _radiusScale;
  34598. private _positionScale;
  34599. private _defaultElevation;
  34600. private _elevationReturnTime;
  34601. private _elevationReturnWaitTime;
  34602. private _zoomStopsAnimation;
  34603. private _framingTime;
  34604. /**
  34605. * The easing function used by animations
  34606. */
  34607. static EasingFunction: ExponentialEase;
  34608. /**
  34609. * The easing mode used by animations
  34610. */
  34611. static EasingMode: number;
  34612. /**
  34613. * Sets the current mode used by the behavior
  34614. */
  34615. /**
  34616. * Gets current mode used by the behavior.
  34617. */
  34618. mode: number;
  34619. /**
  34620. * Sets the scale applied to the radius (1 by default)
  34621. */
  34622. /**
  34623. * Gets the scale applied to the radius
  34624. */
  34625. radiusScale: number;
  34626. /**
  34627. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34628. */
  34629. /**
  34630. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34631. */
  34632. positionScale: number;
  34633. /**
  34634. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34635. * behaviour is triggered, in radians.
  34636. */
  34637. /**
  34638. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34639. * behaviour is triggered, in radians.
  34640. */
  34641. defaultElevation: number;
  34642. /**
  34643. * Sets the time (in milliseconds) taken to return to the default beta position.
  34644. * Negative value indicates camera should not return to default.
  34645. */
  34646. /**
  34647. * Gets the time (in milliseconds) taken to return to the default beta position.
  34648. * Negative value indicates camera should not return to default.
  34649. */
  34650. elevationReturnTime: number;
  34651. /**
  34652. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34653. */
  34654. /**
  34655. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34656. */
  34657. elevationReturnWaitTime: number;
  34658. /**
  34659. * Sets the flag that indicates if user zooming should stop animation.
  34660. */
  34661. /**
  34662. * Gets the flag that indicates if user zooming should stop animation.
  34663. */
  34664. zoomStopsAnimation: boolean;
  34665. /**
  34666. * Sets the transition time when framing the mesh, in milliseconds
  34667. */
  34668. /**
  34669. * Gets the transition time when framing the mesh, in milliseconds
  34670. */
  34671. framingTime: number;
  34672. /**
  34673. * Define if the behavior should automatically change the configured
  34674. * camera limits and sensibilities.
  34675. */
  34676. autoCorrectCameraLimitsAndSensibility: boolean;
  34677. private _onPrePointerObservableObserver;
  34678. private _onAfterCheckInputsObserver;
  34679. private _onMeshTargetChangedObserver;
  34680. private _attachedCamera;
  34681. private _isPointerDown;
  34682. private _lastInteractionTime;
  34683. /**
  34684. * Initializes the behavior.
  34685. */
  34686. init(): void;
  34687. /**
  34688. * Attaches the behavior to its arc rotate camera.
  34689. * @param camera Defines the camera to attach the behavior to
  34690. */
  34691. attach(camera: ArcRotateCamera): void;
  34692. /**
  34693. * Detaches the behavior from its current arc rotate camera.
  34694. */
  34695. detach(): void;
  34696. private _animatables;
  34697. private _betaIsAnimating;
  34698. private _betaTransition;
  34699. private _radiusTransition;
  34700. private _vectorTransition;
  34701. /**
  34702. * Targets the given mesh and updates zoom level accordingly.
  34703. * @param mesh The mesh to target.
  34704. * @param radius Optional. If a cached radius position already exists, overrides default.
  34705. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34706. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34707. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34708. */
  34709. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34710. /**
  34711. * Targets the given mesh with its children and updates zoom level accordingly.
  34712. * @param mesh The mesh to target.
  34713. * @param radius Optional. If a cached radius position already exists, overrides default.
  34714. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34715. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34716. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34717. */
  34718. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34719. /**
  34720. * Targets the given meshes with their children and updates zoom level accordingly.
  34721. * @param meshes The mesh to target.
  34722. * @param radius Optional. If a cached radius position already exists, overrides default.
  34723. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34724. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34725. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34726. */
  34727. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34728. /**
  34729. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34730. * @param minimumWorld Determines the smaller position of the bounding box extend
  34731. * @param maximumWorld Determines the bigger position of the bounding box extend
  34732. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34733. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34734. */
  34735. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34736. /**
  34737. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34738. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34739. * frustum width.
  34740. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34741. * to fully enclose the mesh in the viewing frustum.
  34742. */
  34743. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34744. /**
  34745. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34746. * is automatically returned to its default position (expected to be above ground plane).
  34747. */
  34748. private _maintainCameraAboveGround;
  34749. /**
  34750. * Returns the frustum slope based on the canvas ratio and camera FOV
  34751. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34752. */
  34753. private _getFrustumSlope;
  34754. /**
  34755. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34756. */
  34757. private _clearAnimationLocks;
  34758. /**
  34759. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34760. */
  34761. private _applyUserInteraction;
  34762. /**
  34763. * Stops and removes all animations that have been applied to the camera
  34764. */
  34765. stopAllAnimations(): void;
  34766. /**
  34767. * Gets a value indicating if the user is moving the camera
  34768. */
  34769. readonly isUserIsMoving: boolean;
  34770. /**
  34771. * The camera can move all the way towards the mesh.
  34772. */
  34773. static IgnoreBoundsSizeMode: number;
  34774. /**
  34775. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34776. */
  34777. static FitFrustumSidesMode: number;
  34778. }
  34779. }
  34780. declare module BABYLON {
  34781. /**
  34782. * Base class for Camera Pointer Inputs.
  34783. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34784. * for example usage.
  34785. */
  34786. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34787. /**
  34788. * Defines the camera the input is attached to.
  34789. */
  34790. abstract camera: Camera;
  34791. /**
  34792. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34793. */
  34794. protected _altKey: boolean;
  34795. protected _ctrlKey: boolean;
  34796. protected _metaKey: boolean;
  34797. protected _shiftKey: boolean;
  34798. /**
  34799. * Which mouse buttons were pressed at time of last mouse event.
  34800. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34801. */
  34802. protected _buttonsPressed: number;
  34803. /**
  34804. * Defines the buttons associated with the input to handle camera move.
  34805. */
  34806. buttons: number[];
  34807. /**
  34808. * Attach the input controls to a specific dom element to get the input from.
  34809. * @param element Defines the element the controls should be listened from
  34810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34811. */
  34812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34813. /**
  34814. * Detach the current controls from the specified dom element.
  34815. * @param element Defines the element to stop listening the inputs from
  34816. */
  34817. detachControl(element: Nullable<HTMLElement>): void;
  34818. /**
  34819. * Gets the class name of the current input.
  34820. * @returns the class name
  34821. */
  34822. getClassName(): string;
  34823. /**
  34824. * Get the friendly name associated with the input class.
  34825. * @returns the input friendly name
  34826. */
  34827. getSimpleName(): string;
  34828. /**
  34829. * Called on pointer POINTERDOUBLETAP event.
  34830. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34831. */
  34832. protected onDoubleTap(type: string): void;
  34833. /**
  34834. * Called on pointer POINTERMOVE event if only a single touch is active.
  34835. * Override this method to provide functionality.
  34836. */
  34837. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34838. /**
  34839. * Called on pointer POINTERMOVE event if multiple touches are active.
  34840. * Override this method to provide functionality.
  34841. */
  34842. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34843. /**
  34844. * Called on JS contextmenu event.
  34845. * Override this method to provide functionality.
  34846. */
  34847. protected onContextMenu(evt: PointerEvent): void;
  34848. /**
  34849. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34850. * press.
  34851. * Override this method to provide functionality.
  34852. */
  34853. protected onButtonDown(evt: PointerEvent): void;
  34854. /**
  34855. * Called each time a new POINTERUP event occurs. Ie, for each button
  34856. * release.
  34857. * Override this method to provide functionality.
  34858. */
  34859. protected onButtonUp(evt: PointerEvent): void;
  34860. /**
  34861. * Called when window becomes inactive.
  34862. * Override this method to provide functionality.
  34863. */
  34864. protected onLostFocus(): void;
  34865. private _pointerInput;
  34866. private _observer;
  34867. private _onLostFocus;
  34868. private pointA;
  34869. private pointB;
  34870. }
  34871. }
  34872. declare module BABYLON {
  34873. /**
  34874. * Manage the pointers inputs to control an arc rotate camera.
  34875. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34876. */
  34877. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34878. /**
  34879. * Defines the camera the input is attached to.
  34880. */
  34881. camera: ArcRotateCamera;
  34882. /**
  34883. * Gets the class name of the current input.
  34884. * @returns the class name
  34885. */
  34886. getClassName(): string;
  34887. /**
  34888. * Defines the buttons associated with the input to handle camera move.
  34889. */
  34890. buttons: number[];
  34891. /**
  34892. * Defines the pointer angular sensibility along the X axis or how fast is
  34893. * the camera rotating.
  34894. */
  34895. angularSensibilityX: number;
  34896. /**
  34897. * Defines the pointer angular sensibility along the Y axis or how fast is
  34898. * the camera rotating.
  34899. */
  34900. angularSensibilityY: number;
  34901. /**
  34902. * Defines the pointer pinch precision or how fast is the camera zooming.
  34903. */
  34904. pinchPrecision: number;
  34905. /**
  34906. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34907. * from 0.
  34908. * It defines the percentage of current camera.radius to use as delta when
  34909. * pinch zoom is used.
  34910. */
  34911. pinchDeltaPercentage: number;
  34912. /**
  34913. * Defines the pointer panning sensibility or how fast is the camera moving.
  34914. */
  34915. panningSensibility: number;
  34916. /**
  34917. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34918. */
  34919. multiTouchPanning: boolean;
  34920. /**
  34921. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34922. * zoom (pinch) through multitouch.
  34923. */
  34924. multiTouchPanAndZoom: boolean;
  34925. /**
  34926. * Revers pinch action direction.
  34927. */
  34928. pinchInwards: boolean;
  34929. private _isPanClick;
  34930. private _twoFingerActivityCount;
  34931. private _isPinching;
  34932. /**
  34933. * Called on pointer POINTERMOVE event if only a single touch is active.
  34934. */
  34935. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34936. /**
  34937. * Called on pointer POINTERDOUBLETAP event.
  34938. */
  34939. protected onDoubleTap(type: string): void;
  34940. /**
  34941. * Called on pointer POINTERMOVE event if multiple touches are active.
  34942. */
  34943. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34944. /**
  34945. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34946. * press.
  34947. */
  34948. protected onButtonDown(evt: PointerEvent): void;
  34949. /**
  34950. * Called each time a new POINTERUP event occurs. Ie, for each button
  34951. * release.
  34952. */
  34953. protected onButtonUp(evt: PointerEvent): void;
  34954. /**
  34955. * Called when window becomes inactive.
  34956. */
  34957. protected onLostFocus(): void;
  34958. }
  34959. }
  34960. declare module BABYLON {
  34961. /**
  34962. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34964. */
  34965. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34966. /**
  34967. * Defines the camera the input is attached to.
  34968. */
  34969. camera: ArcRotateCamera;
  34970. /**
  34971. * Defines the list of key codes associated with the up action (increase alpha)
  34972. */
  34973. keysUp: number[];
  34974. /**
  34975. * Defines the list of key codes associated with the down action (decrease alpha)
  34976. */
  34977. keysDown: number[];
  34978. /**
  34979. * Defines the list of key codes associated with the left action (increase beta)
  34980. */
  34981. keysLeft: number[];
  34982. /**
  34983. * Defines the list of key codes associated with the right action (decrease beta)
  34984. */
  34985. keysRight: number[];
  34986. /**
  34987. * Defines the list of key codes associated with the reset action.
  34988. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34989. */
  34990. keysReset: number[];
  34991. /**
  34992. * Defines the panning sensibility of the inputs.
  34993. * (How fast is the camera paning)
  34994. */
  34995. panningSensibility: number;
  34996. /**
  34997. * Defines the zooming sensibility of the inputs.
  34998. * (How fast is the camera zooming)
  34999. */
  35000. zoomingSensibility: number;
  35001. /**
  35002. * Defines wether maintaining the alt key down switch the movement mode from
  35003. * orientation to zoom.
  35004. */
  35005. useAltToZoom: boolean;
  35006. /**
  35007. * Rotation speed of the camera
  35008. */
  35009. angularSpeed: number;
  35010. private _keys;
  35011. private _ctrlPressed;
  35012. private _altPressed;
  35013. private _onCanvasBlurObserver;
  35014. private _onKeyboardObserver;
  35015. private _engine;
  35016. private _scene;
  35017. /**
  35018. * Attach the input controls to a specific dom element to get the input from.
  35019. * @param element Defines the element the controls should be listened from
  35020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35021. */
  35022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35023. /**
  35024. * Detach the current controls from the specified dom element.
  35025. * @param element Defines the element to stop listening the inputs from
  35026. */
  35027. detachControl(element: Nullable<HTMLElement>): void;
  35028. /**
  35029. * Update the current camera state depending on the inputs that have been used this frame.
  35030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35031. */
  35032. checkInputs(): void;
  35033. /**
  35034. * Gets the class name of the current intput.
  35035. * @returns the class name
  35036. */
  35037. getClassName(): string;
  35038. /**
  35039. * Get the friendly name associated with the input class.
  35040. * @returns the input friendly name
  35041. */
  35042. getSimpleName(): string;
  35043. }
  35044. }
  35045. declare module BABYLON {
  35046. /**
  35047. * Manage the mouse wheel inputs to control an arc rotate camera.
  35048. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35049. */
  35050. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35051. /**
  35052. * Defines the camera the input is attached to.
  35053. */
  35054. camera: ArcRotateCamera;
  35055. /**
  35056. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35057. */
  35058. wheelPrecision: number;
  35059. /**
  35060. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35061. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35062. */
  35063. wheelDeltaPercentage: number;
  35064. private _wheel;
  35065. private _observer;
  35066. private computeDeltaFromMouseWheelLegacyEvent;
  35067. /**
  35068. * Attach the input controls to a specific dom element to get the input from.
  35069. * @param element Defines the element the controls should be listened from
  35070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35071. */
  35072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35073. /**
  35074. * Detach the current controls from the specified dom element.
  35075. * @param element Defines the element to stop listening the inputs from
  35076. */
  35077. detachControl(element: Nullable<HTMLElement>): void;
  35078. /**
  35079. * Gets the class name of the current intput.
  35080. * @returns the class name
  35081. */
  35082. getClassName(): string;
  35083. /**
  35084. * Get the friendly name associated with the input class.
  35085. * @returns the input friendly name
  35086. */
  35087. getSimpleName(): string;
  35088. }
  35089. }
  35090. declare module BABYLON {
  35091. /**
  35092. * Default Inputs manager for the ArcRotateCamera.
  35093. * It groups all the default supported inputs for ease of use.
  35094. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35095. */
  35096. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35097. /**
  35098. * Instantiates a new ArcRotateCameraInputsManager.
  35099. * @param camera Defines the camera the inputs belong to
  35100. */
  35101. constructor(camera: ArcRotateCamera);
  35102. /**
  35103. * Add mouse wheel input support to the input manager.
  35104. * @returns the current input manager
  35105. */
  35106. addMouseWheel(): ArcRotateCameraInputsManager;
  35107. /**
  35108. * Add pointers input support to the input manager.
  35109. * @returns the current input manager
  35110. */
  35111. addPointers(): ArcRotateCameraInputsManager;
  35112. /**
  35113. * Add keyboard input support to the input manager.
  35114. * @returns the current input manager
  35115. */
  35116. addKeyboard(): ArcRotateCameraInputsManager;
  35117. }
  35118. }
  35119. declare module BABYLON {
  35120. /**
  35121. * This represents an orbital type of camera.
  35122. *
  35123. * 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.
  35124. * 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.
  35125. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35126. */
  35127. export class ArcRotateCamera extends TargetCamera {
  35128. /**
  35129. * Defines the rotation angle of the camera along the longitudinal axis.
  35130. */
  35131. alpha: number;
  35132. /**
  35133. * Defines the rotation angle of the camera along the latitudinal axis.
  35134. */
  35135. beta: number;
  35136. /**
  35137. * Defines the radius of the camera from it s target point.
  35138. */
  35139. radius: number;
  35140. protected _target: Vector3;
  35141. protected _targetHost: Nullable<AbstractMesh>;
  35142. /**
  35143. * Defines the target point of the camera.
  35144. * The camera looks towards it form the radius distance.
  35145. */
  35146. target: Vector3;
  35147. /**
  35148. * Define the current local position of the camera in the scene
  35149. */
  35150. position: Vector3;
  35151. protected _upVector: Vector3;
  35152. protected _upToYMatrix: Matrix;
  35153. protected _YToUpMatrix: Matrix;
  35154. /**
  35155. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35156. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35157. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35158. */
  35159. upVector: Vector3;
  35160. /**
  35161. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35162. */
  35163. setMatUp(): void;
  35164. /**
  35165. * Current inertia value on the longitudinal axis.
  35166. * The bigger this number the longer it will take for the camera to stop.
  35167. */
  35168. inertialAlphaOffset: number;
  35169. /**
  35170. * Current inertia value on the latitudinal axis.
  35171. * The bigger this number the longer it will take for the camera to stop.
  35172. */
  35173. inertialBetaOffset: number;
  35174. /**
  35175. * Current inertia value on the radius axis.
  35176. * The bigger this number the longer it will take for the camera to stop.
  35177. */
  35178. inertialRadiusOffset: number;
  35179. /**
  35180. * Minimum allowed angle on the longitudinal axis.
  35181. * This can help limiting how the Camera is able to move in the scene.
  35182. */
  35183. lowerAlphaLimit: Nullable<number>;
  35184. /**
  35185. * Maximum allowed angle on the longitudinal axis.
  35186. * This can help limiting how the Camera is able to move in the scene.
  35187. */
  35188. upperAlphaLimit: Nullable<number>;
  35189. /**
  35190. * Minimum allowed angle on the latitudinal axis.
  35191. * This can help limiting how the Camera is able to move in the scene.
  35192. */
  35193. lowerBetaLimit: number;
  35194. /**
  35195. * Maximum allowed angle on the latitudinal axis.
  35196. * This can help limiting how the Camera is able to move in the scene.
  35197. */
  35198. upperBetaLimit: number;
  35199. /**
  35200. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35201. * This can help limiting how the Camera is able to move in the scene.
  35202. */
  35203. lowerRadiusLimit: Nullable<number>;
  35204. /**
  35205. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35206. * This can help limiting how the Camera is able to move in the scene.
  35207. */
  35208. upperRadiusLimit: Nullable<number>;
  35209. /**
  35210. * Defines the current inertia value used during panning of the camera along the X axis.
  35211. */
  35212. inertialPanningX: number;
  35213. /**
  35214. * Defines the current inertia value used during panning of the camera along the Y axis.
  35215. */
  35216. inertialPanningY: number;
  35217. /**
  35218. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35219. * Basically if your fingers moves away from more than this distance you will be considered
  35220. * in pinch mode.
  35221. */
  35222. pinchToPanMaxDistance: number;
  35223. /**
  35224. * Defines the maximum distance the camera can pan.
  35225. * This could help keeping the cammera always in your scene.
  35226. */
  35227. panningDistanceLimit: Nullable<number>;
  35228. /**
  35229. * Defines the target of the camera before paning.
  35230. */
  35231. panningOriginTarget: Vector3;
  35232. /**
  35233. * Defines the value of the inertia used during panning.
  35234. * 0 would mean stop inertia and one would mean no decelleration at all.
  35235. */
  35236. panningInertia: number;
  35237. /**
  35238. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35239. */
  35240. angularSensibilityX: number;
  35241. /**
  35242. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35243. */
  35244. angularSensibilityY: number;
  35245. /**
  35246. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35247. */
  35248. pinchPrecision: number;
  35249. /**
  35250. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35251. * It will be used instead of pinchDeltaPrecision if different from 0.
  35252. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35253. */
  35254. pinchDeltaPercentage: number;
  35255. /**
  35256. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35257. */
  35258. panningSensibility: number;
  35259. /**
  35260. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35261. */
  35262. keysUp: number[];
  35263. /**
  35264. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35265. */
  35266. keysDown: number[];
  35267. /**
  35268. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35269. */
  35270. keysLeft: number[];
  35271. /**
  35272. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35273. */
  35274. keysRight: number[];
  35275. /**
  35276. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35277. */
  35278. wheelPrecision: number;
  35279. /**
  35280. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35281. * It will be used instead of pinchDeltaPrecision if different from 0.
  35282. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35283. */
  35284. wheelDeltaPercentage: number;
  35285. /**
  35286. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35287. */
  35288. zoomOnFactor: number;
  35289. /**
  35290. * Defines a screen offset for the camera position.
  35291. */
  35292. targetScreenOffset: Vector2;
  35293. /**
  35294. * Allows the camera to be completely reversed.
  35295. * If false the camera can not arrive upside down.
  35296. */
  35297. allowUpsideDown: boolean;
  35298. /**
  35299. * Define if double tap/click is used to restore the previously saved state of the camera.
  35300. */
  35301. useInputToRestoreState: boolean;
  35302. /** @hidden */
  35303. _viewMatrix: Matrix;
  35304. /** @hidden */
  35305. _useCtrlForPanning: boolean;
  35306. /** @hidden */
  35307. _panningMouseButton: number;
  35308. /**
  35309. * Defines the input associated to the camera.
  35310. */
  35311. inputs: ArcRotateCameraInputsManager;
  35312. /** @hidden */
  35313. _reset: () => void;
  35314. /**
  35315. * Defines the allowed panning axis.
  35316. */
  35317. panningAxis: Vector3;
  35318. protected _localDirection: Vector3;
  35319. protected _transformedDirection: Vector3;
  35320. private _bouncingBehavior;
  35321. /**
  35322. * Gets the bouncing behavior of the camera if it has been enabled.
  35323. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35324. */
  35325. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35326. /**
  35327. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35328. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35329. */
  35330. useBouncingBehavior: boolean;
  35331. private _framingBehavior;
  35332. /**
  35333. * Gets the framing behavior of the camera if it has been enabled.
  35334. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35335. */
  35336. readonly framingBehavior: Nullable<FramingBehavior>;
  35337. /**
  35338. * Defines if the framing behavior of the camera is enabled on the camera.
  35339. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35340. */
  35341. useFramingBehavior: boolean;
  35342. private _autoRotationBehavior;
  35343. /**
  35344. * Gets the auto rotation behavior of the camera if it has been enabled.
  35345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35346. */
  35347. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35348. /**
  35349. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35350. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35351. */
  35352. useAutoRotationBehavior: boolean;
  35353. /**
  35354. * Observable triggered when the mesh target has been changed on the camera.
  35355. */
  35356. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35357. /**
  35358. * Event raised when the camera is colliding with a mesh.
  35359. */
  35360. onCollide: (collidedMesh: AbstractMesh) => void;
  35361. /**
  35362. * Defines whether the camera should check collision with the objects oh the scene.
  35363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35364. */
  35365. checkCollisions: boolean;
  35366. /**
  35367. * Defines the collision radius of the camera.
  35368. * This simulates a sphere around the camera.
  35369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35370. */
  35371. collisionRadius: Vector3;
  35372. protected _collider: Collider;
  35373. protected _previousPosition: Vector3;
  35374. protected _collisionVelocity: Vector3;
  35375. protected _newPosition: Vector3;
  35376. protected _previousAlpha: number;
  35377. protected _previousBeta: number;
  35378. protected _previousRadius: number;
  35379. protected _collisionTriggered: boolean;
  35380. protected _targetBoundingCenter: Nullable<Vector3>;
  35381. private _computationVector;
  35382. /**
  35383. * Instantiates a new ArcRotateCamera in a given scene
  35384. * @param name Defines the name of the camera
  35385. * @param alpha Defines the camera rotation along the logitudinal axis
  35386. * @param beta Defines the camera rotation along the latitudinal axis
  35387. * @param radius Defines the camera distance from its target
  35388. * @param target Defines the camera target
  35389. * @param scene Defines the scene the camera belongs to
  35390. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35391. */
  35392. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35393. /** @hidden */
  35394. _initCache(): void;
  35395. /** @hidden */
  35396. _updateCache(ignoreParentClass?: boolean): void;
  35397. protected _getTargetPosition(): Vector3;
  35398. private _storedAlpha;
  35399. private _storedBeta;
  35400. private _storedRadius;
  35401. private _storedTarget;
  35402. /**
  35403. * Stores the current state of the camera (alpha, beta, radius and target)
  35404. * @returns the camera itself
  35405. */
  35406. storeState(): Camera;
  35407. /**
  35408. * @hidden
  35409. * Restored camera state. You must call storeState() first
  35410. */
  35411. _restoreStateValues(): boolean;
  35412. /** @hidden */
  35413. _isSynchronizedViewMatrix(): boolean;
  35414. /**
  35415. * Attached controls to the current camera.
  35416. * @param element Defines the element the controls should be listened from
  35417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35418. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35419. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35420. */
  35421. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35422. /**
  35423. * Detach the current controls from the camera.
  35424. * The camera will stop reacting to inputs.
  35425. * @param element Defines the element to stop listening the inputs from
  35426. */
  35427. detachControl(element: HTMLElement): void;
  35428. /** @hidden */
  35429. _checkInputs(): void;
  35430. protected _checkLimits(): void;
  35431. /**
  35432. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35433. */
  35434. rebuildAnglesAndRadius(): void;
  35435. /**
  35436. * Use a position to define the current camera related information like aplha, beta and radius
  35437. * @param position Defines the position to set the camera at
  35438. */
  35439. setPosition(position: Vector3): void;
  35440. /**
  35441. * Defines the target the camera should look at.
  35442. * This will automatically adapt alpha beta and radius to fit within the new target.
  35443. * @param target Defines the new target as a Vector or a mesh
  35444. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35445. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35446. */
  35447. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35448. /** @hidden */
  35449. _getViewMatrix(): Matrix;
  35450. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35451. /**
  35452. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35453. * @param meshes Defines the mesh to zoom on
  35454. * @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)
  35455. */
  35456. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35457. /**
  35458. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35459. * The target will be changed but the radius
  35460. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35461. * @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)
  35462. */
  35463. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35464. min: Vector3;
  35465. max: Vector3;
  35466. distance: number;
  35467. }, doNotUpdateMaxZ?: boolean): void;
  35468. /**
  35469. * @override
  35470. * Override Camera.createRigCamera
  35471. */
  35472. createRigCamera(name: string, cameraIndex: number): Camera;
  35473. /**
  35474. * @hidden
  35475. * @override
  35476. * Override Camera._updateRigCameras
  35477. */
  35478. _updateRigCameras(): void;
  35479. /**
  35480. * Destroy the camera and release the current resources hold by it.
  35481. */
  35482. dispose(): void;
  35483. /**
  35484. * Gets the current object class name.
  35485. * @return the class name
  35486. */
  35487. getClassName(): string;
  35488. }
  35489. }
  35490. declare module BABYLON {
  35491. /**
  35492. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35493. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35494. */
  35495. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35496. /**
  35497. * Gets the name of the behavior.
  35498. */
  35499. readonly name: string;
  35500. private _zoomStopsAnimation;
  35501. private _idleRotationSpeed;
  35502. private _idleRotationWaitTime;
  35503. private _idleRotationSpinupTime;
  35504. /**
  35505. * Sets the flag that indicates if user zooming should stop animation.
  35506. */
  35507. /**
  35508. * Gets the flag that indicates if user zooming should stop animation.
  35509. */
  35510. zoomStopsAnimation: boolean;
  35511. /**
  35512. * Sets the default speed at which the camera rotates around the model.
  35513. */
  35514. /**
  35515. * Gets the default speed at which the camera rotates around the model.
  35516. */
  35517. idleRotationSpeed: number;
  35518. /**
  35519. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35520. */
  35521. /**
  35522. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35523. */
  35524. idleRotationWaitTime: number;
  35525. /**
  35526. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35527. */
  35528. /**
  35529. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35530. */
  35531. idleRotationSpinupTime: number;
  35532. /**
  35533. * Gets a value indicating if the camera is currently rotating because of this behavior
  35534. */
  35535. readonly rotationInProgress: boolean;
  35536. private _onPrePointerObservableObserver;
  35537. private _onAfterCheckInputsObserver;
  35538. private _attachedCamera;
  35539. private _isPointerDown;
  35540. private _lastFrameTime;
  35541. private _lastInteractionTime;
  35542. private _cameraRotationSpeed;
  35543. /**
  35544. * Initializes the behavior.
  35545. */
  35546. init(): void;
  35547. /**
  35548. * Attaches the behavior to its arc rotate camera.
  35549. * @param camera Defines the camera to attach the behavior to
  35550. */
  35551. attach(camera: ArcRotateCamera): void;
  35552. /**
  35553. * Detaches the behavior from its current arc rotate camera.
  35554. */
  35555. detach(): void;
  35556. /**
  35557. * Returns true if user is scrolling.
  35558. * @return true if user is scrolling.
  35559. */
  35560. private _userIsZooming;
  35561. private _lastFrameRadius;
  35562. private _shouldAnimationStopForInteraction;
  35563. /**
  35564. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35565. */
  35566. private _applyUserInteraction;
  35567. private _userIsMoving;
  35568. }
  35569. }
  35570. declare module BABYLON {
  35571. /**
  35572. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35573. */
  35574. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35575. private ui;
  35576. /**
  35577. * The name of the behavior
  35578. */
  35579. name: string;
  35580. /**
  35581. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35582. */
  35583. distanceAwayFromFace: number;
  35584. /**
  35585. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35586. */
  35587. distanceAwayFromBottomOfFace: number;
  35588. private _faceVectors;
  35589. private _target;
  35590. private _scene;
  35591. private _onRenderObserver;
  35592. private _tmpMatrix;
  35593. private _tmpVector;
  35594. /**
  35595. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35596. * @param ui The transform node that should be attched to the mesh
  35597. */
  35598. constructor(ui: TransformNode);
  35599. /**
  35600. * Initializes the behavior
  35601. */
  35602. init(): void;
  35603. private _closestFace;
  35604. private _zeroVector;
  35605. private _lookAtTmpMatrix;
  35606. private _lookAtToRef;
  35607. /**
  35608. * Attaches the AttachToBoxBehavior to the passed in mesh
  35609. * @param target The mesh that the specified node will be attached to
  35610. */
  35611. attach(target: Mesh): void;
  35612. /**
  35613. * Detaches the behavior from the mesh
  35614. */
  35615. detach(): void;
  35616. }
  35617. }
  35618. declare module BABYLON {
  35619. /**
  35620. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35621. */
  35622. export class FadeInOutBehavior implements Behavior<Mesh> {
  35623. /**
  35624. * Time in milliseconds to delay before fading in (Default: 0)
  35625. */
  35626. delay: number;
  35627. /**
  35628. * Time in milliseconds for the mesh to fade in (Default: 300)
  35629. */
  35630. fadeInTime: number;
  35631. private _millisecondsPerFrame;
  35632. private _hovered;
  35633. private _hoverValue;
  35634. private _ownerNode;
  35635. /**
  35636. * Instatiates the FadeInOutBehavior
  35637. */
  35638. constructor();
  35639. /**
  35640. * The name of the behavior
  35641. */
  35642. readonly name: string;
  35643. /**
  35644. * Initializes the behavior
  35645. */
  35646. init(): void;
  35647. /**
  35648. * Attaches the fade behavior on the passed in mesh
  35649. * @param ownerNode The mesh that will be faded in/out once attached
  35650. */
  35651. attach(ownerNode: Mesh): void;
  35652. /**
  35653. * Detaches the behavior from the mesh
  35654. */
  35655. detach(): void;
  35656. /**
  35657. * Triggers the mesh to begin fading in or out
  35658. * @param value if the object should fade in or out (true to fade in)
  35659. */
  35660. fadeIn(value: boolean): void;
  35661. private _update;
  35662. private _setAllVisibility;
  35663. }
  35664. }
  35665. declare module BABYLON {
  35666. /**
  35667. * Class containing a set of static utilities functions for managing Pivots
  35668. * @hidden
  35669. */
  35670. export class PivotTools {
  35671. private static _PivotCached;
  35672. private static _OldPivotPoint;
  35673. private static _PivotTranslation;
  35674. private static _PivotTmpVector;
  35675. /** @hidden */
  35676. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35677. /** @hidden */
  35678. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35679. }
  35680. }
  35681. declare module BABYLON {
  35682. /**
  35683. * Class containing static functions to help procedurally build meshes
  35684. */
  35685. export class PlaneBuilder {
  35686. /**
  35687. * Creates a plane mesh
  35688. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35689. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35690. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35692. * * 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
  35693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35694. * @param name defines the name of the mesh
  35695. * @param options defines the options used to create the mesh
  35696. * @param scene defines the hosting scene
  35697. * @returns the plane mesh
  35698. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35699. */
  35700. static CreatePlane(name: string, options: {
  35701. size?: number;
  35702. width?: number;
  35703. height?: number;
  35704. sideOrientation?: number;
  35705. frontUVs?: Vector4;
  35706. backUVs?: Vector4;
  35707. updatable?: boolean;
  35708. sourcePlane?: Plane;
  35709. }, scene?: Nullable<Scene>): Mesh;
  35710. }
  35711. }
  35712. declare module BABYLON {
  35713. /**
  35714. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35715. */
  35716. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35717. private static _AnyMouseID;
  35718. private _attachedNode;
  35719. private _dragPlane;
  35720. private _scene;
  35721. private _pointerObserver;
  35722. private _beforeRenderObserver;
  35723. private static _planeScene;
  35724. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35725. /**
  35726. * 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)
  35727. */
  35728. maxDragAngle: number;
  35729. /**
  35730. * @hidden
  35731. */
  35732. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35733. /**
  35734. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35735. */
  35736. currentDraggingPointerID: number;
  35737. /**
  35738. * The last position where the pointer hit the drag plane in world space
  35739. */
  35740. lastDragPosition: Vector3;
  35741. /**
  35742. * If the behavior is currently in a dragging state
  35743. */
  35744. dragging: boolean;
  35745. /**
  35746. * 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)
  35747. */
  35748. dragDeltaRatio: number;
  35749. /**
  35750. * If the drag plane orientation should be updated during the dragging (Default: true)
  35751. */
  35752. updateDragPlane: boolean;
  35753. private _debugMode;
  35754. private _moving;
  35755. /**
  35756. * Fires each time the attached mesh is dragged with the pointer
  35757. * * delta between last drag position and current drag position in world space
  35758. * * dragDistance along the drag axis
  35759. * * dragPlaneNormal normal of the current drag plane used during the drag
  35760. * * dragPlanePoint in world space where the drag intersects the drag plane
  35761. */
  35762. onDragObservable: Observable<{
  35763. delta: Vector3;
  35764. dragPlanePoint: Vector3;
  35765. dragPlaneNormal: Vector3;
  35766. dragDistance: number;
  35767. pointerId: number;
  35768. }>;
  35769. /**
  35770. * Fires each time a drag begins (eg. mouse down on mesh)
  35771. */
  35772. onDragStartObservable: Observable<{
  35773. dragPlanePoint: Vector3;
  35774. pointerId: number;
  35775. }>;
  35776. /**
  35777. * Fires each time a drag ends (eg. mouse release after drag)
  35778. */
  35779. onDragEndObservable: Observable<{
  35780. dragPlanePoint: Vector3;
  35781. pointerId: number;
  35782. }>;
  35783. /**
  35784. * If the attached mesh should be moved when dragged
  35785. */
  35786. moveAttached: boolean;
  35787. /**
  35788. * If the drag behavior will react to drag events (Default: true)
  35789. */
  35790. enabled: boolean;
  35791. /**
  35792. * If camera controls should be detached during the drag
  35793. */
  35794. detachCameraControls: boolean;
  35795. /**
  35796. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35797. */
  35798. useObjectOrienationForDragging: boolean;
  35799. private _options;
  35800. /**
  35801. * Creates a pointer drag behavior that can be attached to a mesh
  35802. * @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)
  35803. */
  35804. constructor(options?: {
  35805. dragAxis?: Vector3;
  35806. dragPlaneNormal?: Vector3;
  35807. });
  35808. /**
  35809. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35810. */
  35811. validateDrag: (targetPosition: Vector3) => boolean;
  35812. /**
  35813. * The name of the behavior
  35814. */
  35815. readonly name: string;
  35816. /**
  35817. * Initializes the behavior
  35818. */
  35819. init(): void;
  35820. private _tmpVector;
  35821. private _alternatePickedPoint;
  35822. private _worldDragAxis;
  35823. private _targetPosition;
  35824. private _attachedElement;
  35825. /**
  35826. * Attaches the drag behavior the passed in mesh
  35827. * @param ownerNode The mesh that will be dragged around once attached
  35828. */
  35829. attach(ownerNode: AbstractMesh): void;
  35830. /**
  35831. * Force relase the drag action by code.
  35832. */
  35833. releaseDrag(): void;
  35834. private _startDragRay;
  35835. private _lastPointerRay;
  35836. /**
  35837. * Simulates the start of a pointer drag event on the behavior
  35838. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35839. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35840. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35841. */
  35842. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35843. private _startDrag;
  35844. private _dragDelta;
  35845. private _moveDrag;
  35846. private _pickWithRayOnDragPlane;
  35847. private _pointA;
  35848. private _pointB;
  35849. private _pointC;
  35850. private _lineA;
  35851. private _lineB;
  35852. private _localAxis;
  35853. private _lookAt;
  35854. private _updateDragPlanePosition;
  35855. /**
  35856. * Detaches the behavior from the mesh
  35857. */
  35858. detach(): void;
  35859. }
  35860. }
  35861. declare module BABYLON {
  35862. /**
  35863. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35864. */
  35865. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35866. private _dragBehaviorA;
  35867. private _dragBehaviorB;
  35868. private _startDistance;
  35869. private _initialScale;
  35870. private _targetScale;
  35871. private _ownerNode;
  35872. private _sceneRenderObserver;
  35873. /**
  35874. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35875. */
  35876. constructor();
  35877. /**
  35878. * The name of the behavior
  35879. */
  35880. readonly name: string;
  35881. /**
  35882. * Initializes the behavior
  35883. */
  35884. init(): void;
  35885. private _getCurrentDistance;
  35886. /**
  35887. * Attaches the scale behavior the passed in mesh
  35888. * @param ownerNode The mesh that will be scaled around once attached
  35889. */
  35890. attach(ownerNode: Mesh): void;
  35891. /**
  35892. * Detaches the behavior from the mesh
  35893. */
  35894. detach(): void;
  35895. }
  35896. }
  35897. declare module BABYLON {
  35898. /**
  35899. * 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
  35900. */
  35901. export class SixDofDragBehavior implements Behavior<Mesh> {
  35902. private static _virtualScene;
  35903. private _ownerNode;
  35904. private _sceneRenderObserver;
  35905. private _scene;
  35906. private _targetPosition;
  35907. private _virtualOriginMesh;
  35908. private _virtualDragMesh;
  35909. private _pointerObserver;
  35910. private _moving;
  35911. private _startingOrientation;
  35912. /**
  35913. * 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)
  35914. */
  35915. private zDragFactor;
  35916. /**
  35917. * If the object should rotate to face the drag origin
  35918. */
  35919. rotateDraggedObject: boolean;
  35920. /**
  35921. * If the behavior is currently in a dragging state
  35922. */
  35923. dragging: boolean;
  35924. /**
  35925. * 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)
  35926. */
  35927. dragDeltaRatio: number;
  35928. /**
  35929. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35930. */
  35931. currentDraggingPointerID: number;
  35932. /**
  35933. * If camera controls should be detached during the drag
  35934. */
  35935. detachCameraControls: boolean;
  35936. /**
  35937. * Fires each time a drag starts
  35938. */
  35939. onDragStartObservable: Observable<{}>;
  35940. /**
  35941. * Fires each time a drag ends (eg. mouse release after drag)
  35942. */
  35943. onDragEndObservable: Observable<{}>;
  35944. /**
  35945. * 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
  35946. */
  35947. constructor();
  35948. /**
  35949. * The name of the behavior
  35950. */
  35951. readonly name: string;
  35952. /**
  35953. * Initializes the behavior
  35954. */
  35955. init(): void;
  35956. /**
  35957. * Attaches the scale behavior the passed in mesh
  35958. * @param ownerNode The mesh that will be scaled around once attached
  35959. */
  35960. attach(ownerNode: Mesh): void;
  35961. /**
  35962. * Detaches the behavior from the mesh
  35963. */
  35964. detach(): void;
  35965. }
  35966. }
  35967. declare module BABYLON {
  35968. /**
  35969. * Class used to apply inverse kinematics to bones
  35970. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35971. */
  35972. export class BoneIKController {
  35973. private static _tmpVecs;
  35974. private static _tmpQuat;
  35975. private static _tmpMats;
  35976. /**
  35977. * Gets or sets the target mesh
  35978. */
  35979. targetMesh: AbstractMesh;
  35980. /** Gets or sets the mesh used as pole */
  35981. poleTargetMesh: AbstractMesh;
  35982. /**
  35983. * Gets or sets the bone used as pole
  35984. */
  35985. poleTargetBone: Nullable<Bone>;
  35986. /**
  35987. * Gets or sets the target position
  35988. */
  35989. targetPosition: Vector3;
  35990. /**
  35991. * Gets or sets the pole target position
  35992. */
  35993. poleTargetPosition: Vector3;
  35994. /**
  35995. * Gets or sets the pole target local offset
  35996. */
  35997. poleTargetLocalOffset: Vector3;
  35998. /**
  35999. * Gets or sets the pole angle
  36000. */
  36001. poleAngle: number;
  36002. /**
  36003. * Gets or sets the mesh associated with the controller
  36004. */
  36005. mesh: AbstractMesh;
  36006. /**
  36007. * 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)
  36008. */
  36009. slerpAmount: number;
  36010. private _bone1Quat;
  36011. private _bone1Mat;
  36012. private _bone2Ang;
  36013. private _bone1;
  36014. private _bone2;
  36015. private _bone1Length;
  36016. private _bone2Length;
  36017. private _maxAngle;
  36018. private _maxReach;
  36019. private _rightHandedSystem;
  36020. private _bendAxis;
  36021. private _slerping;
  36022. private _adjustRoll;
  36023. /**
  36024. * Gets or sets maximum allowed angle
  36025. */
  36026. maxAngle: number;
  36027. /**
  36028. * Creates a new BoneIKController
  36029. * @param mesh defines the mesh to control
  36030. * @param bone defines the bone to control
  36031. * @param options defines options to set up the controller
  36032. */
  36033. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36034. targetMesh?: AbstractMesh;
  36035. poleTargetMesh?: AbstractMesh;
  36036. poleTargetBone?: Bone;
  36037. poleTargetLocalOffset?: Vector3;
  36038. poleAngle?: number;
  36039. bendAxis?: Vector3;
  36040. maxAngle?: number;
  36041. slerpAmount?: number;
  36042. });
  36043. private _setMaxAngle;
  36044. /**
  36045. * Force the controller to update the bones
  36046. */
  36047. update(): void;
  36048. }
  36049. }
  36050. declare module BABYLON {
  36051. /**
  36052. * Class used to make a bone look toward a point in space
  36053. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36054. */
  36055. export class BoneLookController {
  36056. private static _tmpVecs;
  36057. private static _tmpQuat;
  36058. private static _tmpMats;
  36059. /**
  36060. * The target Vector3 that the bone will look at
  36061. */
  36062. target: Vector3;
  36063. /**
  36064. * The mesh that the bone is attached to
  36065. */
  36066. mesh: AbstractMesh;
  36067. /**
  36068. * The bone that will be looking to the target
  36069. */
  36070. bone: Bone;
  36071. /**
  36072. * The up axis of the coordinate system that is used when the bone is rotated
  36073. */
  36074. upAxis: Vector3;
  36075. /**
  36076. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36077. */
  36078. upAxisSpace: Space;
  36079. /**
  36080. * Used to make an adjustment to the yaw of the bone
  36081. */
  36082. adjustYaw: number;
  36083. /**
  36084. * Used to make an adjustment to the pitch of the bone
  36085. */
  36086. adjustPitch: number;
  36087. /**
  36088. * Used to make an adjustment to the roll of the bone
  36089. */
  36090. adjustRoll: number;
  36091. /**
  36092. * 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)
  36093. */
  36094. slerpAmount: number;
  36095. private _minYaw;
  36096. private _maxYaw;
  36097. private _minPitch;
  36098. private _maxPitch;
  36099. private _minYawSin;
  36100. private _minYawCos;
  36101. private _maxYawSin;
  36102. private _maxYawCos;
  36103. private _midYawConstraint;
  36104. private _minPitchTan;
  36105. private _maxPitchTan;
  36106. private _boneQuat;
  36107. private _slerping;
  36108. private _transformYawPitch;
  36109. private _transformYawPitchInv;
  36110. private _firstFrameSkipped;
  36111. private _yawRange;
  36112. private _fowardAxis;
  36113. /**
  36114. * Gets or sets the minimum yaw angle that the bone can look to
  36115. */
  36116. minYaw: number;
  36117. /**
  36118. * Gets or sets the maximum yaw angle that the bone can look to
  36119. */
  36120. maxYaw: number;
  36121. /**
  36122. * Gets or sets the minimum pitch angle that the bone can look to
  36123. */
  36124. minPitch: number;
  36125. /**
  36126. * Gets or sets the maximum pitch angle that the bone can look to
  36127. */
  36128. maxPitch: number;
  36129. /**
  36130. * Create a BoneLookController
  36131. * @param mesh the mesh that the bone belongs to
  36132. * @param bone the bone that will be looking to the target
  36133. * @param target the target Vector3 to look at
  36134. * @param options optional settings:
  36135. * * maxYaw: the maximum angle the bone will yaw to
  36136. * * minYaw: the minimum angle the bone will yaw to
  36137. * * maxPitch: the maximum angle the bone will pitch to
  36138. * * minPitch: the minimum angle the bone will yaw to
  36139. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36140. * * upAxis: the up axis of the coordinate system
  36141. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36142. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36143. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36144. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36145. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36146. * * adjustRoll: used to make an adjustment to the roll of the bone
  36147. **/
  36148. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36149. maxYaw?: number;
  36150. minYaw?: number;
  36151. maxPitch?: number;
  36152. minPitch?: number;
  36153. slerpAmount?: number;
  36154. upAxis?: Vector3;
  36155. upAxisSpace?: Space;
  36156. yawAxis?: Vector3;
  36157. pitchAxis?: Vector3;
  36158. adjustYaw?: number;
  36159. adjustPitch?: number;
  36160. adjustRoll?: number;
  36161. });
  36162. /**
  36163. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36164. */
  36165. update(): void;
  36166. private _getAngleDiff;
  36167. private _getAngleBetween;
  36168. private _isAngleBetween;
  36169. }
  36170. }
  36171. declare module BABYLON {
  36172. /**
  36173. * Manage the gamepad inputs to control an arc rotate camera.
  36174. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36175. */
  36176. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36177. /**
  36178. * Defines the camera the input is attached to.
  36179. */
  36180. camera: ArcRotateCamera;
  36181. /**
  36182. * Defines the gamepad the input is gathering event from.
  36183. */
  36184. gamepad: Nullable<Gamepad>;
  36185. /**
  36186. * Defines the gamepad rotation sensiblity.
  36187. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36188. */
  36189. gamepadRotationSensibility: number;
  36190. /**
  36191. * Defines the gamepad move sensiblity.
  36192. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36193. */
  36194. gamepadMoveSensibility: number;
  36195. private _onGamepadConnectedObserver;
  36196. private _onGamepadDisconnectedObserver;
  36197. /**
  36198. * Attach the input controls to a specific dom element to get the input from.
  36199. * @param element Defines the element the controls should be listened from
  36200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36201. */
  36202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36203. /**
  36204. * Detach the current controls from the specified dom element.
  36205. * @param element Defines the element to stop listening the inputs from
  36206. */
  36207. detachControl(element: Nullable<HTMLElement>): void;
  36208. /**
  36209. * Update the current camera state depending on the inputs that have been used this frame.
  36210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36211. */
  36212. checkInputs(): void;
  36213. /**
  36214. * Gets the class name of the current intput.
  36215. * @returns the class name
  36216. */
  36217. getClassName(): string;
  36218. /**
  36219. * Get the friendly name associated with the input class.
  36220. * @returns the input friendly name
  36221. */
  36222. getSimpleName(): string;
  36223. }
  36224. }
  36225. declare module BABYLON {
  36226. interface ArcRotateCameraInputsManager {
  36227. /**
  36228. * Add orientation input support to the input manager.
  36229. * @returns the current input manager
  36230. */
  36231. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36232. }
  36233. /**
  36234. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36236. */
  36237. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36238. /**
  36239. * Defines the camera the input is attached to.
  36240. */
  36241. camera: ArcRotateCamera;
  36242. /**
  36243. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36244. */
  36245. alphaCorrection: number;
  36246. /**
  36247. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36248. */
  36249. gammaCorrection: number;
  36250. private _alpha;
  36251. private _gamma;
  36252. private _dirty;
  36253. private _deviceOrientationHandler;
  36254. /**
  36255. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36256. */
  36257. constructor();
  36258. /**
  36259. * Attach the input controls to a specific dom element to get the input from.
  36260. * @param element Defines the element the controls should be listened from
  36261. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36262. */
  36263. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36264. /** @hidden */
  36265. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36266. /**
  36267. * Update the current camera state depending on the inputs that have been used this frame.
  36268. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36269. */
  36270. checkInputs(): void;
  36271. /**
  36272. * Detach the current controls from the specified dom element.
  36273. * @param element Defines the element to stop listening the inputs from
  36274. */
  36275. detachControl(element: Nullable<HTMLElement>): void;
  36276. /**
  36277. * Gets the class name of the current intput.
  36278. * @returns the class name
  36279. */
  36280. getClassName(): string;
  36281. /**
  36282. * Get the friendly name associated with the input class.
  36283. * @returns the input friendly name
  36284. */
  36285. getSimpleName(): string;
  36286. }
  36287. }
  36288. declare module BABYLON {
  36289. /**
  36290. * Listen to mouse events to control the camera.
  36291. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36292. */
  36293. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36294. /**
  36295. * Defines the camera the input is attached to.
  36296. */
  36297. camera: FlyCamera;
  36298. /**
  36299. * Defines if touch is enabled. (Default is true.)
  36300. */
  36301. touchEnabled: boolean;
  36302. /**
  36303. * Defines the buttons associated with the input to handle camera rotation.
  36304. */
  36305. buttons: number[];
  36306. /**
  36307. * Assign buttons for Yaw control.
  36308. */
  36309. buttonsYaw: number[];
  36310. /**
  36311. * Assign buttons for Pitch control.
  36312. */
  36313. buttonsPitch: number[];
  36314. /**
  36315. * Assign buttons for Roll control.
  36316. */
  36317. buttonsRoll: number[];
  36318. /**
  36319. * Detect if any button is being pressed while mouse is moved.
  36320. * -1 = Mouse locked.
  36321. * 0 = Left button.
  36322. * 1 = Middle Button.
  36323. * 2 = Right Button.
  36324. */
  36325. activeButton: number;
  36326. /**
  36327. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36328. * Higher values reduce its sensitivity.
  36329. */
  36330. angularSensibility: number;
  36331. private _mousemoveCallback;
  36332. private _observer;
  36333. private _rollObserver;
  36334. private previousPosition;
  36335. private noPreventDefault;
  36336. private element;
  36337. /**
  36338. * Listen to mouse events to control the camera.
  36339. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36341. */
  36342. constructor(touchEnabled?: boolean);
  36343. /**
  36344. * Attach the mouse control to the HTML DOM element.
  36345. * @param element Defines the element that listens to the input events.
  36346. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36347. */
  36348. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36349. /**
  36350. * Detach the current controls from the specified dom element.
  36351. * @param element Defines the element to stop listening the inputs from
  36352. */
  36353. detachControl(element: Nullable<HTMLElement>): void;
  36354. /**
  36355. * Gets the class name of the current input.
  36356. * @returns the class name.
  36357. */
  36358. getClassName(): string;
  36359. /**
  36360. * Get the friendly name associated with the input class.
  36361. * @returns the input's friendly name.
  36362. */
  36363. getSimpleName(): string;
  36364. private _pointerInput;
  36365. private _onMouseMove;
  36366. /**
  36367. * Rotate camera by mouse offset.
  36368. */
  36369. private rotateCamera;
  36370. }
  36371. }
  36372. declare module BABYLON {
  36373. /**
  36374. * Default Inputs manager for the FlyCamera.
  36375. * It groups all the default supported inputs for ease of use.
  36376. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36377. */
  36378. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36379. /**
  36380. * Instantiates a new FlyCameraInputsManager.
  36381. * @param camera Defines the camera the inputs belong to.
  36382. */
  36383. constructor(camera: FlyCamera);
  36384. /**
  36385. * Add keyboard input support to the input manager.
  36386. * @returns the new FlyCameraKeyboardMoveInput().
  36387. */
  36388. addKeyboard(): FlyCameraInputsManager;
  36389. /**
  36390. * Add mouse input support to the input manager.
  36391. * @param touchEnabled Enable touch screen support.
  36392. * @returns the new FlyCameraMouseInput().
  36393. */
  36394. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36395. }
  36396. }
  36397. declare module BABYLON {
  36398. /**
  36399. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36400. * such as in a 3D Space Shooter or a Flight Simulator.
  36401. */
  36402. export class FlyCamera extends TargetCamera {
  36403. /**
  36404. * Define the collision ellipsoid of the camera.
  36405. * This is helpful for simulating a camera body, like a player's body.
  36406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36407. */
  36408. ellipsoid: Vector3;
  36409. /**
  36410. * Define an offset for the position of the ellipsoid around the camera.
  36411. * This can be helpful if the camera is attached away from the player's body center,
  36412. * such as at its head.
  36413. */
  36414. ellipsoidOffset: Vector3;
  36415. /**
  36416. * Enable or disable collisions of the camera with the rest of the scene objects.
  36417. */
  36418. checkCollisions: boolean;
  36419. /**
  36420. * Enable or disable gravity on the camera.
  36421. */
  36422. applyGravity: boolean;
  36423. /**
  36424. * Define the current direction the camera is moving to.
  36425. */
  36426. cameraDirection: Vector3;
  36427. /**
  36428. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36429. * This overrides and empties cameraRotation.
  36430. */
  36431. rotationQuaternion: Quaternion;
  36432. /**
  36433. * Track Roll to maintain the wanted Rolling when looking around.
  36434. */
  36435. _trackRoll: number;
  36436. /**
  36437. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36438. */
  36439. rollCorrect: number;
  36440. /**
  36441. * Mimic a banked turn, Rolling the camera when Yawing.
  36442. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36443. */
  36444. bankedTurn: boolean;
  36445. /**
  36446. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36447. */
  36448. bankedTurnLimit: number;
  36449. /**
  36450. * Value of 0 disables the banked Roll.
  36451. * Value of 1 is equal to the Yaw angle in radians.
  36452. */
  36453. bankedTurnMultiplier: number;
  36454. /**
  36455. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36456. */
  36457. inputs: FlyCameraInputsManager;
  36458. /**
  36459. * Gets the input sensibility for mouse input.
  36460. * Higher values reduce sensitivity.
  36461. */
  36462. /**
  36463. * Sets the input sensibility for a mouse input.
  36464. * Higher values reduce sensitivity.
  36465. */
  36466. angularSensibility: number;
  36467. /**
  36468. * Get the keys for camera movement forward.
  36469. */
  36470. /**
  36471. * Set the keys for camera movement forward.
  36472. */
  36473. keysForward: number[];
  36474. /**
  36475. * Get the keys for camera movement backward.
  36476. */
  36477. keysBackward: number[];
  36478. /**
  36479. * Get the keys for camera movement up.
  36480. */
  36481. /**
  36482. * Set the keys for camera movement up.
  36483. */
  36484. keysUp: number[];
  36485. /**
  36486. * Get the keys for camera movement down.
  36487. */
  36488. /**
  36489. * Set the keys for camera movement down.
  36490. */
  36491. keysDown: number[];
  36492. /**
  36493. * Get the keys for camera movement left.
  36494. */
  36495. /**
  36496. * Set the keys for camera movement left.
  36497. */
  36498. keysLeft: number[];
  36499. /**
  36500. * Set the keys for camera movement right.
  36501. */
  36502. /**
  36503. * Set the keys for camera movement right.
  36504. */
  36505. keysRight: number[];
  36506. /**
  36507. * Event raised when the camera collides with a mesh in the scene.
  36508. */
  36509. onCollide: (collidedMesh: AbstractMesh) => void;
  36510. private _collider;
  36511. private _needMoveForGravity;
  36512. private _oldPosition;
  36513. private _diffPosition;
  36514. private _newPosition;
  36515. /** @hidden */
  36516. _localDirection: Vector3;
  36517. /** @hidden */
  36518. _transformedDirection: Vector3;
  36519. /**
  36520. * Instantiates a FlyCamera.
  36521. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36522. * such as in a 3D Space Shooter or a Flight Simulator.
  36523. * @param name Define the name of the camera in the scene.
  36524. * @param position Define the starting position of the camera in the scene.
  36525. * @param scene Define the scene the camera belongs to.
  36526. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36527. */
  36528. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36529. /**
  36530. * Attach a control to the HTML DOM element.
  36531. * @param element Defines the element that listens to the input events.
  36532. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36533. */
  36534. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36535. /**
  36536. * Detach a control from the HTML DOM element.
  36537. * The camera will stop reacting to that input.
  36538. * @param element Defines the element that listens to the input events.
  36539. */
  36540. detachControl(element: HTMLElement): void;
  36541. private _collisionMask;
  36542. /**
  36543. * Get the mask that the camera ignores in collision events.
  36544. */
  36545. /**
  36546. * Set the mask that the camera ignores in collision events.
  36547. */
  36548. collisionMask: number;
  36549. /** @hidden */
  36550. _collideWithWorld(displacement: Vector3): void;
  36551. /** @hidden */
  36552. private _onCollisionPositionChange;
  36553. /** @hidden */
  36554. _checkInputs(): void;
  36555. /** @hidden */
  36556. _decideIfNeedsToMove(): boolean;
  36557. /** @hidden */
  36558. _updatePosition(): void;
  36559. /**
  36560. * Restore the Roll to its target value at the rate specified.
  36561. * @param rate - Higher means slower restoring.
  36562. * @hidden
  36563. */
  36564. restoreRoll(rate: number): void;
  36565. /**
  36566. * Destroy the camera and release the current resources held by it.
  36567. */
  36568. dispose(): void;
  36569. /**
  36570. * Get the current object class name.
  36571. * @returns the class name.
  36572. */
  36573. getClassName(): string;
  36574. }
  36575. }
  36576. declare module BABYLON {
  36577. /**
  36578. * Listen to keyboard events to control the camera.
  36579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36580. */
  36581. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36582. /**
  36583. * Defines the camera the input is attached to.
  36584. */
  36585. camera: FlyCamera;
  36586. /**
  36587. * The list of keyboard keys used to control the forward move of the camera.
  36588. */
  36589. keysForward: number[];
  36590. /**
  36591. * The list of keyboard keys used to control the backward move of the camera.
  36592. */
  36593. keysBackward: number[];
  36594. /**
  36595. * The list of keyboard keys used to control the forward move of the camera.
  36596. */
  36597. keysUp: number[];
  36598. /**
  36599. * The list of keyboard keys used to control the backward move of the camera.
  36600. */
  36601. keysDown: number[];
  36602. /**
  36603. * The list of keyboard keys used to control the right strafe move of the camera.
  36604. */
  36605. keysRight: number[];
  36606. /**
  36607. * The list of keyboard keys used to control the left strafe move of the camera.
  36608. */
  36609. keysLeft: number[];
  36610. private _keys;
  36611. private _onCanvasBlurObserver;
  36612. private _onKeyboardObserver;
  36613. private _engine;
  36614. private _scene;
  36615. /**
  36616. * Attach the input controls to a specific dom element to get the input from.
  36617. * @param element Defines the element the controls should be listened from
  36618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36619. */
  36620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36621. /**
  36622. * Detach the current controls from the specified dom element.
  36623. * @param element Defines the element to stop listening the inputs from
  36624. */
  36625. detachControl(element: Nullable<HTMLElement>): void;
  36626. /**
  36627. * Gets the class name of the current intput.
  36628. * @returns the class name
  36629. */
  36630. getClassName(): string;
  36631. /** @hidden */
  36632. _onLostFocus(e: FocusEvent): void;
  36633. /**
  36634. * Get the friendly name associated with the input class.
  36635. * @returns the input friendly name
  36636. */
  36637. getSimpleName(): string;
  36638. /**
  36639. * Update the current camera state depending on the inputs that have been used this frame.
  36640. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36641. */
  36642. checkInputs(): void;
  36643. }
  36644. }
  36645. declare module BABYLON {
  36646. /**
  36647. * Manage the mouse wheel inputs to control a follow camera.
  36648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36649. */
  36650. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36651. /**
  36652. * Defines the camera the input is attached to.
  36653. */
  36654. camera: FollowCamera;
  36655. /**
  36656. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36657. */
  36658. axisControlRadius: boolean;
  36659. /**
  36660. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36661. */
  36662. axisControlHeight: boolean;
  36663. /**
  36664. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36665. */
  36666. axisControlRotation: boolean;
  36667. /**
  36668. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36669. * relation to mouseWheel events.
  36670. */
  36671. wheelPrecision: number;
  36672. /**
  36673. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36674. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36675. */
  36676. wheelDeltaPercentage: number;
  36677. private _wheel;
  36678. private _observer;
  36679. /**
  36680. * Attach the input controls to a specific dom element to get the input from.
  36681. * @param element Defines the element the controls should be listened from
  36682. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36683. */
  36684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36685. /**
  36686. * Detach the current controls from the specified dom element.
  36687. * @param element Defines the element to stop listening the inputs from
  36688. */
  36689. detachControl(element: Nullable<HTMLElement>): void;
  36690. /**
  36691. * Gets the class name of the current intput.
  36692. * @returns the class name
  36693. */
  36694. getClassName(): string;
  36695. /**
  36696. * Get the friendly name associated with the input class.
  36697. * @returns the input friendly name
  36698. */
  36699. getSimpleName(): string;
  36700. }
  36701. }
  36702. declare module BABYLON {
  36703. /**
  36704. * Manage the pointers inputs to control an follow camera.
  36705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36706. */
  36707. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36708. /**
  36709. * Defines the camera the input is attached to.
  36710. */
  36711. camera: FollowCamera;
  36712. /**
  36713. * Gets the class name of the current input.
  36714. * @returns the class name
  36715. */
  36716. getClassName(): string;
  36717. /**
  36718. * Defines the pointer angular sensibility along the X axis or how fast is
  36719. * the camera rotating.
  36720. * A negative number will reverse the axis direction.
  36721. */
  36722. angularSensibilityX: number;
  36723. /**
  36724. * Defines the pointer angular sensibility along the Y axis or how fast is
  36725. * the camera rotating.
  36726. * A negative number will reverse the axis direction.
  36727. */
  36728. angularSensibilityY: number;
  36729. /**
  36730. * Defines the pointer pinch precision or how fast is the camera zooming.
  36731. * A negative number will reverse the axis direction.
  36732. */
  36733. pinchPrecision: number;
  36734. /**
  36735. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36736. * from 0.
  36737. * It defines the percentage of current camera.radius to use as delta when
  36738. * pinch zoom is used.
  36739. */
  36740. pinchDeltaPercentage: number;
  36741. /**
  36742. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36743. */
  36744. axisXControlRadius: boolean;
  36745. /**
  36746. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36747. */
  36748. axisXControlHeight: boolean;
  36749. /**
  36750. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36751. */
  36752. axisXControlRotation: boolean;
  36753. /**
  36754. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36755. */
  36756. axisYControlRadius: boolean;
  36757. /**
  36758. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36759. */
  36760. axisYControlHeight: boolean;
  36761. /**
  36762. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36763. */
  36764. axisYControlRotation: boolean;
  36765. /**
  36766. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36767. */
  36768. axisPinchControlRadius: boolean;
  36769. /**
  36770. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36771. */
  36772. axisPinchControlHeight: boolean;
  36773. /**
  36774. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36775. */
  36776. axisPinchControlRotation: boolean;
  36777. /**
  36778. * Log error messages if basic misconfiguration has occurred.
  36779. */
  36780. warningEnable: boolean;
  36781. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36782. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36783. private _warningCounter;
  36784. private _warning;
  36785. }
  36786. }
  36787. declare module BABYLON {
  36788. /**
  36789. * Default Inputs manager for the FollowCamera.
  36790. * It groups all the default supported inputs for ease of use.
  36791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36792. */
  36793. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36794. /**
  36795. * Instantiates a new FollowCameraInputsManager.
  36796. * @param camera Defines the camera the inputs belong to
  36797. */
  36798. constructor(camera: FollowCamera);
  36799. /**
  36800. * Add keyboard input support to the input manager.
  36801. * @returns the current input manager
  36802. */
  36803. addKeyboard(): FollowCameraInputsManager;
  36804. /**
  36805. * Add mouse wheel input support to the input manager.
  36806. * @returns the current input manager
  36807. */
  36808. addMouseWheel(): FollowCameraInputsManager;
  36809. /**
  36810. * Add pointers input support to the input manager.
  36811. * @returns the current input manager
  36812. */
  36813. addPointers(): FollowCameraInputsManager;
  36814. /**
  36815. * Add orientation input support to the input manager.
  36816. * @returns the current input manager
  36817. */
  36818. addVRDeviceOrientation(): FollowCameraInputsManager;
  36819. }
  36820. }
  36821. declare module BABYLON {
  36822. /**
  36823. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36824. * an arc rotate version arcFollowCamera are available.
  36825. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36826. */
  36827. export class FollowCamera extends TargetCamera {
  36828. /**
  36829. * Distance the follow camera should follow an object at
  36830. */
  36831. radius: number;
  36832. /**
  36833. * Minimum allowed distance of the camera to the axis of rotation
  36834. * (The camera can not get closer).
  36835. * This can help limiting how the Camera is able to move in the scene.
  36836. */
  36837. lowerRadiusLimit: Nullable<number>;
  36838. /**
  36839. * Maximum allowed distance of the camera to the axis of rotation
  36840. * (The camera can not get further).
  36841. * This can help limiting how the Camera is able to move in the scene.
  36842. */
  36843. upperRadiusLimit: Nullable<number>;
  36844. /**
  36845. * Define a rotation offset between the camera and the object it follows
  36846. */
  36847. rotationOffset: number;
  36848. /**
  36849. * Minimum allowed angle to camera position relative to target object.
  36850. * This can help limiting how the Camera is able to move in the scene.
  36851. */
  36852. lowerRotationOffsetLimit: Nullable<number>;
  36853. /**
  36854. * Maximum allowed angle to camera position relative to target object.
  36855. * This can help limiting how the Camera is able to move in the scene.
  36856. */
  36857. upperRotationOffsetLimit: Nullable<number>;
  36858. /**
  36859. * Define a height offset between the camera and the object it follows.
  36860. * It can help following an object from the top (like a car chaing a plane)
  36861. */
  36862. heightOffset: number;
  36863. /**
  36864. * Minimum allowed height of camera position relative to target object.
  36865. * This can help limiting how the Camera is able to move in the scene.
  36866. */
  36867. lowerHeightOffsetLimit: Nullable<number>;
  36868. /**
  36869. * Maximum allowed height of camera position relative to target object.
  36870. * This can help limiting how the Camera is able to move in the scene.
  36871. */
  36872. upperHeightOffsetLimit: Nullable<number>;
  36873. /**
  36874. * Define how fast the camera can accelerate to follow it s target.
  36875. */
  36876. cameraAcceleration: number;
  36877. /**
  36878. * Define the speed limit of the camera following an object.
  36879. */
  36880. maxCameraSpeed: number;
  36881. /**
  36882. * Define the target of the camera.
  36883. */
  36884. lockedTarget: Nullable<AbstractMesh>;
  36885. /**
  36886. * Defines the input associated with the camera.
  36887. */
  36888. inputs: FollowCameraInputsManager;
  36889. /**
  36890. * Instantiates the follow camera.
  36891. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36892. * @param name Define the name of the camera in the scene
  36893. * @param position Define the position of the camera
  36894. * @param scene Define the scene the camera belong to
  36895. * @param lockedTarget Define the target of the camera
  36896. */
  36897. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36898. private _follow;
  36899. /**
  36900. * Attached controls to the current camera.
  36901. * @param element Defines the element the controls should be listened from
  36902. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36903. */
  36904. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36905. /**
  36906. * Detach the current controls from the camera.
  36907. * The camera will stop reacting to inputs.
  36908. * @param element Defines the element to stop listening the inputs from
  36909. */
  36910. detachControl(element: HTMLElement): void;
  36911. /** @hidden */
  36912. _checkInputs(): void;
  36913. private _checkLimits;
  36914. /**
  36915. * Gets the camera class name.
  36916. * @returns the class name
  36917. */
  36918. getClassName(): string;
  36919. }
  36920. /**
  36921. * Arc Rotate version of the follow camera.
  36922. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36923. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36924. */
  36925. export class ArcFollowCamera extends TargetCamera {
  36926. /** The longitudinal angle of the camera */
  36927. alpha: number;
  36928. /** The latitudinal angle of the camera */
  36929. beta: number;
  36930. /** The radius of the camera from its target */
  36931. radius: number;
  36932. /** Define the camera target (the messh it should follow) */
  36933. target: Nullable<AbstractMesh>;
  36934. private _cartesianCoordinates;
  36935. /**
  36936. * Instantiates a new ArcFollowCamera
  36937. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36938. * @param name Define the name of the camera
  36939. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36940. * @param beta Define the rotation angle of the camera around the elevation axis
  36941. * @param radius Define the radius of the camera from its target point
  36942. * @param target Define the target of the camera
  36943. * @param scene Define the scene the camera belongs to
  36944. */
  36945. constructor(name: string,
  36946. /** The longitudinal angle of the camera */
  36947. alpha: number,
  36948. /** The latitudinal angle of the camera */
  36949. beta: number,
  36950. /** The radius of the camera from its target */
  36951. radius: number,
  36952. /** Define the camera target (the messh it should follow) */
  36953. target: Nullable<AbstractMesh>, scene: Scene);
  36954. private _follow;
  36955. /** @hidden */
  36956. _checkInputs(): void;
  36957. /**
  36958. * Returns the class name of the object.
  36959. * It is mostly used internally for serialization purposes.
  36960. */
  36961. getClassName(): string;
  36962. }
  36963. }
  36964. declare module BABYLON {
  36965. /**
  36966. * Manage the keyboard inputs to control the movement of a follow camera.
  36967. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36968. */
  36969. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36970. /**
  36971. * Defines the camera the input is attached to.
  36972. */
  36973. camera: FollowCamera;
  36974. /**
  36975. * Defines the list of key codes associated with the up action (increase heightOffset)
  36976. */
  36977. keysHeightOffsetIncr: number[];
  36978. /**
  36979. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36980. */
  36981. keysHeightOffsetDecr: number[];
  36982. /**
  36983. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36984. */
  36985. keysHeightOffsetModifierAlt: boolean;
  36986. /**
  36987. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36988. */
  36989. keysHeightOffsetModifierCtrl: boolean;
  36990. /**
  36991. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36992. */
  36993. keysHeightOffsetModifierShift: boolean;
  36994. /**
  36995. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36996. */
  36997. keysRotationOffsetIncr: number[];
  36998. /**
  36999. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37000. */
  37001. keysRotationOffsetDecr: number[];
  37002. /**
  37003. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37004. */
  37005. keysRotationOffsetModifierAlt: boolean;
  37006. /**
  37007. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37008. */
  37009. keysRotationOffsetModifierCtrl: boolean;
  37010. /**
  37011. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37012. */
  37013. keysRotationOffsetModifierShift: boolean;
  37014. /**
  37015. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37016. */
  37017. keysRadiusIncr: number[];
  37018. /**
  37019. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37020. */
  37021. keysRadiusDecr: number[];
  37022. /**
  37023. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37024. */
  37025. keysRadiusModifierAlt: boolean;
  37026. /**
  37027. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37028. */
  37029. keysRadiusModifierCtrl: boolean;
  37030. /**
  37031. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37032. */
  37033. keysRadiusModifierShift: boolean;
  37034. /**
  37035. * Defines the rate of change of heightOffset.
  37036. */
  37037. heightSensibility: number;
  37038. /**
  37039. * Defines the rate of change of rotationOffset.
  37040. */
  37041. rotationSensibility: number;
  37042. /**
  37043. * Defines the rate of change of radius.
  37044. */
  37045. radiusSensibility: number;
  37046. private _keys;
  37047. private _ctrlPressed;
  37048. private _altPressed;
  37049. private _shiftPressed;
  37050. private _onCanvasBlurObserver;
  37051. private _onKeyboardObserver;
  37052. private _engine;
  37053. private _scene;
  37054. /**
  37055. * Attach the input controls to a specific dom element to get the input from.
  37056. * @param element Defines the element the controls should be listened from
  37057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37058. */
  37059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37060. /**
  37061. * Detach the current controls from the specified dom element.
  37062. * @param element Defines the element to stop listening the inputs from
  37063. */
  37064. detachControl(element: Nullable<HTMLElement>): void;
  37065. /**
  37066. * Update the current camera state depending on the inputs that have been used this frame.
  37067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37068. */
  37069. checkInputs(): void;
  37070. /**
  37071. * Gets the class name of the current input.
  37072. * @returns the class name
  37073. */
  37074. getClassName(): string;
  37075. /**
  37076. * Get the friendly name associated with the input class.
  37077. * @returns the input friendly name
  37078. */
  37079. getSimpleName(): string;
  37080. /**
  37081. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37082. * allow modification of the heightOffset value.
  37083. */
  37084. private _modifierHeightOffset;
  37085. /**
  37086. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37087. * allow modification of the rotationOffset value.
  37088. */
  37089. private _modifierRotationOffset;
  37090. /**
  37091. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37092. * allow modification of the radius value.
  37093. */
  37094. private _modifierRadius;
  37095. }
  37096. }
  37097. declare module BABYLON {
  37098. interface FreeCameraInputsManager {
  37099. /**
  37100. * @hidden
  37101. */
  37102. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37103. /**
  37104. * Add orientation input support to the input manager.
  37105. * @returns the current input manager
  37106. */
  37107. addDeviceOrientation(): FreeCameraInputsManager;
  37108. }
  37109. /**
  37110. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37111. * Screen rotation is taken into account.
  37112. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37113. */
  37114. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37115. private _camera;
  37116. private _screenOrientationAngle;
  37117. private _constantTranform;
  37118. private _screenQuaternion;
  37119. private _alpha;
  37120. private _beta;
  37121. private _gamma;
  37122. /**
  37123. * @hidden
  37124. */
  37125. _onDeviceOrientationChangedObservable: Observable<void>;
  37126. /**
  37127. * Instantiates a new input
  37128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37129. */
  37130. constructor();
  37131. /**
  37132. * Define the camera controlled by the input.
  37133. */
  37134. camera: FreeCamera;
  37135. /**
  37136. * Attach the input controls to a specific dom element to get the input from.
  37137. * @param element Defines the element the controls should be listened from
  37138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37139. */
  37140. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37141. private _orientationChanged;
  37142. private _deviceOrientation;
  37143. /**
  37144. * Detach the current controls from the specified dom element.
  37145. * @param element Defines the element to stop listening the inputs from
  37146. */
  37147. detachControl(element: Nullable<HTMLElement>): void;
  37148. /**
  37149. * Update the current camera state depending on the inputs that have been used this frame.
  37150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37151. */
  37152. checkInputs(): void;
  37153. /**
  37154. * Gets the class name of the current intput.
  37155. * @returns the class name
  37156. */
  37157. getClassName(): string;
  37158. /**
  37159. * Get the friendly name associated with the input class.
  37160. * @returns the input friendly name
  37161. */
  37162. getSimpleName(): string;
  37163. }
  37164. }
  37165. declare module BABYLON {
  37166. /**
  37167. * Manage the gamepad inputs to control a free camera.
  37168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37169. */
  37170. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37171. /**
  37172. * Define the camera the input is attached to.
  37173. */
  37174. camera: FreeCamera;
  37175. /**
  37176. * Define the Gamepad controlling the input
  37177. */
  37178. gamepad: Nullable<Gamepad>;
  37179. /**
  37180. * Defines the gamepad rotation sensiblity.
  37181. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37182. */
  37183. gamepadAngularSensibility: number;
  37184. /**
  37185. * Defines the gamepad move sensiblity.
  37186. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37187. */
  37188. gamepadMoveSensibility: number;
  37189. private _onGamepadConnectedObserver;
  37190. private _onGamepadDisconnectedObserver;
  37191. private _cameraTransform;
  37192. private _deltaTransform;
  37193. private _vector3;
  37194. private _vector2;
  37195. /**
  37196. * Attach the input controls to a specific dom element to get the input from.
  37197. * @param element Defines the element the controls should be listened from
  37198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37199. */
  37200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37201. /**
  37202. * Detach the current controls from the specified dom element.
  37203. * @param element Defines the element to stop listening the inputs from
  37204. */
  37205. detachControl(element: Nullable<HTMLElement>): void;
  37206. /**
  37207. * Update the current camera state depending on the inputs that have been used this frame.
  37208. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37209. */
  37210. checkInputs(): void;
  37211. /**
  37212. * Gets the class name of the current intput.
  37213. * @returns the class name
  37214. */
  37215. getClassName(): string;
  37216. /**
  37217. * Get the friendly name associated with the input class.
  37218. * @returns the input friendly name
  37219. */
  37220. getSimpleName(): string;
  37221. }
  37222. }
  37223. declare module BABYLON {
  37224. /**
  37225. * Defines the potential axis of a Joystick
  37226. */
  37227. export enum JoystickAxis {
  37228. /** X axis */
  37229. X = 0,
  37230. /** Y axis */
  37231. Y = 1,
  37232. /** Z axis */
  37233. Z = 2
  37234. }
  37235. /**
  37236. * Class used to define virtual joystick (used in touch mode)
  37237. */
  37238. export class VirtualJoystick {
  37239. /**
  37240. * Gets or sets a boolean indicating that left and right values must be inverted
  37241. */
  37242. reverseLeftRight: boolean;
  37243. /**
  37244. * Gets or sets a boolean indicating that up and down values must be inverted
  37245. */
  37246. reverseUpDown: boolean;
  37247. /**
  37248. * Gets the offset value for the position (ie. the change of the position value)
  37249. */
  37250. deltaPosition: Vector3;
  37251. /**
  37252. * Gets a boolean indicating if the virtual joystick was pressed
  37253. */
  37254. pressed: boolean;
  37255. /**
  37256. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37257. */
  37258. static Canvas: Nullable<HTMLCanvasElement>;
  37259. private static _globalJoystickIndex;
  37260. private static vjCanvasContext;
  37261. private static vjCanvasWidth;
  37262. private static vjCanvasHeight;
  37263. private static halfWidth;
  37264. private _action;
  37265. private _axisTargetedByLeftAndRight;
  37266. private _axisTargetedByUpAndDown;
  37267. private _joystickSensibility;
  37268. private _inversedSensibility;
  37269. private _joystickPointerID;
  37270. private _joystickColor;
  37271. private _joystickPointerPos;
  37272. private _joystickPreviousPointerPos;
  37273. private _joystickPointerStartPos;
  37274. private _deltaJoystickVector;
  37275. private _leftJoystick;
  37276. private _touches;
  37277. private _onPointerDownHandlerRef;
  37278. private _onPointerMoveHandlerRef;
  37279. private _onPointerUpHandlerRef;
  37280. private _onResize;
  37281. /**
  37282. * Creates a new virtual joystick
  37283. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37284. */
  37285. constructor(leftJoystick?: boolean);
  37286. /**
  37287. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37288. * @param newJoystickSensibility defines the new sensibility
  37289. */
  37290. setJoystickSensibility(newJoystickSensibility: number): void;
  37291. private _onPointerDown;
  37292. private _onPointerMove;
  37293. private _onPointerUp;
  37294. /**
  37295. * Change the color of the virtual joystick
  37296. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37297. */
  37298. setJoystickColor(newColor: string): void;
  37299. /**
  37300. * Defines a callback to call when the joystick is touched
  37301. * @param action defines the callback
  37302. */
  37303. setActionOnTouch(action: () => any): void;
  37304. /**
  37305. * Defines which axis you'd like to control for left & right
  37306. * @param axis defines the axis to use
  37307. */
  37308. setAxisForLeftRight(axis: JoystickAxis): void;
  37309. /**
  37310. * Defines which axis you'd like to control for up & down
  37311. * @param axis defines the axis to use
  37312. */
  37313. setAxisForUpDown(axis: JoystickAxis): void;
  37314. private _drawVirtualJoystick;
  37315. /**
  37316. * Release internal HTML canvas
  37317. */
  37318. releaseCanvas(): void;
  37319. }
  37320. }
  37321. declare module BABYLON {
  37322. interface FreeCameraInputsManager {
  37323. /**
  37324. * Add virtual joystick input support to the input manager.
  37325. * @returns the current input manager
  37326. */
  37327. addVirtualJoystick(): FreeCameraInputsManager;
  37328. }
  37329. /**
  37330. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37331. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37332. */
  37333. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37334. /**
  37335. * Defines the camera the input is attached to.
  37336. */
  37337. camera: FreeCamera;
  37338. private _leftjoystick;
  37339. private _rightjoystick;
  37340. /**
  37341. * Gets the left stick of the virtual joystick.
  37342. * @returns The virtual Joystick
  37343. */
  37344. getLeftJoystick(): VirtualJoystick;
  37345. /**
  37346. * Gets the right stick of the virtual joystick.
  37347. * @returns The virtual Joystick
  37348. */
  37349. getRightJoystick(): VirtualJoystick;
  37350. /**
  37351. * Update the current camera state depending on the inputs that have been used this frame.
  37352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37353. */
  37354. checkInputs(): void;
  37355. /**
  37356. * Attach the input controls to a specific dom element to get the input from.
  37357. * @param element Defines the element the controls should be listened from
  37358. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37359. */
  37360. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37361. /**
  37362. * Detach the current controls from the specified dom element.
  37363. * @param element Defines the element to stop listening the inputs from
  37364. */
  37365. detachControl(element: Nullable<HTMLElement>): void;
  37366. /**
  37367. * Gets the class name of the current intput.
  37368. * @returns the class name
  37369. */
  37370. getClassName(): string;
  37371. /**
  37372. * Get the friendly name associated with the input class.
  37373. * @returns the input friendly name
  37374. */
  37375. getSimpleName(): string;
  37376. }
  37377. }
  37378. declare module BABYLON {
  37379. /**
  37380. * This represents a FPS type of camera controlled by touch.
  37381. * This is like a universal camera minus the Gamepad controls.
  37382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37383. */
  37384. export class TouchCamera extends FreeCamera {
  37385. /**
  37386. * Defines the touch sensibility for rotation.
  37387. * The higher the faster.
  37388. */
  37389. touchAngularSensibility: number;
  37390. /**
  37391. * Defines the touch sensibility for move.
  37392. * The higher the faster.
  37393. */
  37394. touchMoveSensibility: number;
  37395. /**
  37396. * Instantiates a new touch camera.
  37397. * This represents a FPS type of camera controlled by touch.
  37398. * This is like a universal camera minus the Gamepad controls.
  37399. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37400. * @param name Define the name of the camera in the scene
  37401. * @param position Define the start position of the camera in the scene
  37402. * @param scene Define the scene the camera belongs to
  37403. */
  37404. constructor(name: string, position: Vector3, scene: Scene);
  37405. /**
  37406. * Gets the current object class name.
  37407. * @return the class name
  37408. */
  37409. getClassName(): string;
  37410. /** @hidden */
  37411. _setupInputs(): void;
  37412. }
  37413. }
  37414. declare module BABYLON {
  37415. /**
  37416. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37417. * being tilted forward or back and left or right.
  37418. */
  37419. export class DeviceOrientationCamera extends FreeCamera {
  37420. private _initialQuaternion;
  37421. private _quaternionCache;
  37422. private _tmpDragQuaternion;
  37423. /**
  37424. * Creates a new device orientation camera
  37425. * @param name The name of the camera
  37426. * @param position The start position camera
  37427. * @param scene The scene the camera belongs to
  37428. */
  37429. constructor(name: string, position: Vector3, scene: Scene);
  37430. /**
  37431. * @hidden
  37432. * Disabled pointer input on first orientation sensor update (Default: true)
  37433. */
  37434. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  37435. private _dragFactor;
  37436. /**
  37437. * Enabled turning on the y axis when the orientation sensor is active
  37438. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37439. */
  37440. enableHorizontalDragging(dragFactor?: number): void;
  37441. /**
  37442. * Gets the current instance class name ("DeviceOrientationCamera").
  37443. * This helps avoiding instanceof at run time.
  37444. * @returns the class name
  37445. */
  37446. getClassName(): string;
  37447. /**
  37448. * @hidden
  37449. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37450. */
  37451. _checkInputs(): void;
  37452. /**
  37453. * Reset the camera to its default orientation on the specified axis only.
  37454. * @param axis The axis to reset
  37455. */
  37456. resetToCurrentRotation(axis?: Axis): void;
  37457. }
  37458. }
  37459. declare module BABYLON {
  37460. /**
  37461. * Defines supported buttons for XBox360 compatible gamepads
  37462. */
  37463. export enum Xbox360Button {
  37464. /** A */
  37465. A = 0,
  37466. /** B */
  37467. B = 1,
  37468. /** X */
  37469. X = 2,
  37470. /** Y */
  37471. Y = 3,
  37472. /** Start */
  37473. Start = 4,
  37474. /** Back */
  37475. Back = 5,
  37476. /** Left button */
  37477. LB = 6,
  37478. /** Right button */
  37479. RB = 7,
  37480. /** Left stick */
  37481. LeftStick = 8,
  37482. /** Right stick */
  37483. RightStick = 9
  37484. }
  37485. /** Defines values for XBox360 DPad */
  37486. export enum Xbox360Dpad {
  37487. /** Up */
  37488. Up = 0,
  37489. /** Down */
  37490. Down = 1,
  37491. /** Left */
  37492. Left = 2,
  37493. /** Right */
  37494. Right = 3
  37495. }
  37496. /**
  37497. * Defines a XBox360 gamepad
  37498. */
  37499. export class Xbox360Pad extends Gamepad {
  37500. private _leftTrigger;
  37501. private _rightTrigger;
  37502. private _onlefttriggerchanged;
  37503. private _onrighttriggerchanged;
  37504. private _onbuttondown;
  37505. private _onbuttonup;
  37506. private _ondpaddown;
  37507. private _ondpadup;
  37508. /** Observable raised when a button is pressed */
  37509. onButtonDownObservable: Observable<Xbox360Button>;
  37510. /** Observable raised when a button is released */
  37511. onButtonUpObservable: Observable<Xbox360Button>;
  37512. /** Observable raised when a pad is pressed */
  37513. onPadDownObservable: Observable<Xbox360Dpad>;
  37514. /** Observable raised when a pad is released */
  37515. onPadUpObservable: Observable<Xbox360Dpad>;
  37516. private _buttonA;
  37517. private _buttonB;
  37518. private _buttonX;
  37519. private _buttonY;
  37520. private _buttonBack;
  37521. private _buttonStart;
  37522. private _buttonLB;
  37523. private _buttonRB;
  37524. private _buttonLeftStick;
  37525. private _buttonRightStick;
  37526. private _dPadUp;
  37527. private _dPadDown;
  37528. private _dPadLeft;
  37529. private _dPadRight;
  37530. private _isXboxOnePad;
  37531. /**
  37532. * Creates a new XBox360 gamepad object
  37533. * @param id defines the id of this gamepad
  37534. * @param index defines its index
  37535. * @param gamepad defines the internal HTML gamepad object
  37536. * @param xboxOne defines if it is a XBox One gamepad
  37537. */
  37538. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37539. /**
  37540. * Defines the callback to call when left trigger is pressed
  37541. * @param callback defines the callback to use
  37542. */
  37543. onlefttriggerchanged(callback: (value: number) => void): void;
  37544. /**
  37545. * Defines the callback to call when right trigger is pressed
  37546. * @param callback defines the callback to use
  37547. */
  37548. onrighttriggerchanged(callback: (value: number) => void): void;
  37549. /**
  37550. * Gets the left trigger value
  37551. */
  37552. /**
  37553. * Sets the left trigger value
  37554. */
  37555. leftTrigger: number;
  37556. /**
  37557. * Gets the right trigger value
  37558. */
  37559. /**
  37560. * Sets the right trigger value
  37561. */
  37562. rightTrigger: number;
  37563. /**
  37564. * Defines the callback to call when a button is pressed
  37565. * @param callback defines the callback to use
  37566. */
  37567. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37568. /**
  37569. * Defines the callback to call when a button is released
  37570. * @param callback defines the callback to use
  37571. */
  37572. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37573. /**
  37574. * Defines the callback to call when a pad is pressed
  37575. * @param callback defines the callback to use
  37576. */
  37577. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37578. /**
  37579. * Defines the callback to call when a pad is released
  37580. * @param callback defines the callback to use
  37581. */
  37582. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37583. private _setButtonValue;
  37584. private _setDPadValue;
  37585. /**
  37586. * Gets the value of the `A` button
  37587. */
  37588. /**
  37589. * Sets the value of the `A` button
  37590. */
  37591. buttonA: number;
  37592. /**
  37593. * Gets the value of the `B` button
  37594. */
  37595. /**
  37596. * Sets the value of the `B` button
  37597. */
  37598. buttonB: number;
  37599. /**
  37600. * Gets the value of the `X` button
  37601. */
  37602. /**
  37603. * Sets the value of the `X` button
  37604. */
  37605. buttonX: number;
  37606. /**
  37607. * Gets the value of the `Y` button
  37608. */
  37609. /**
  37610. * Sets the value of the `Y` button
  37611. */
  37612. buttonY: number;
  37613. /**
  37614. * Gets the value of the `Start` button
  37615. */
  37616. /**
  37617. * Sets the value of the `Start` button
  37618. */
  37619. buttonStart: number;
  37620. /**
  37621. * Gets the value of the `Back` button
  37622. */
  37623. /**
  37624. * Sets the value of the `Back` button
  37625. */
  37626. buttonBack: number;
  37627. /**
  37628. * Gets the value of the `Left` button
  37629. */
  37630. /**
  37631. * Sets the value of the `Left` button
  37632. */
  37633. buttonLB: number;
  37634. /**
  37635. * Gets the value of the `Right` button
  37636. */
  37637. /**
  37638. * Sets the value of the `Right` button
  37639. */
  37640. buttonRB: number;
  37641. /**
  37642. * Gets the value of the Left joystick
  37643. */
  37644. /**
  37645. * Sets the value of the Left joystick
  37646. */
  37647. buttonLeftStick: number;
  37648. /**
  37649. * Gets the value of the Right joystick
  37650. */
  37651. /**
  37652. * Sets the value of the Right joystick
  37653. */
  37654. buttonRightStick: number;
  37655. /**
  37656. * Gets the value of D-pad up
  37657. */
  37658. /**
  37659. * Sets the value of D-pad up
  37660. */
  37661. dPadUp: number;
  37662. /**
  37663. * Gets the value of D-pad down
  37664. */
  37665. /**
  37666. * Sets the value of D-pad down
  37667. */
  37668. dPadDown: number;
  37669. /**
  37670. * Gets the value of D-pad left
  37671. */
  37672. /**
  37673. * Sets the value of D-pad left
  37674. */
  37675. dPadLeft: number;
  37676. /**
  37677. * Gets the value of D-pad right
  37678. */
  37679. /**
  37680. * Sets the value of D-pad right
  37681. */
  37682. dPadRight: number;
  37683. /**
  37684. * Force the gamepad to synchronize with device values
  37685. */
  37686. update(): void;
  37687. /**
  37688. * Disposes the gamepad
  37689. */
  37690. dispose(): void;
  37691. }
  37692. }
  37693. declare module BABYLON {
  37694. /**
  37695. * Manager for handling gamepads
  37696. */
  37697. export class GamepadManager {
  37698. private _scene?;
  37699. private _babylonGamepads;
  37700. private _oneGamepadConnected;
  37701. /** @hidden */
  37702. _isMonitoring: boolean;
  37703. private _gamepadEventSupported;
  37704. private _gamepadSupport;
  37705. /**
  37706. * observable to be triggered when the gamepad controller has been connected
  37707. */
  37708. onGamepadConnectedObservable: Observable<Gamepad>;
  37709. /**
  37710. * observable to be triggered when the gamepad controller has been disconnected
  37711. */
  37712. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37713. private _onGamepadConnectedEvent;
  37714. private _onGamepadDisconnectedEvent;
  37715. /**
  37716. * Initializes the gamepad manager
  37717. * @param _scene BabylonJS scene
  37718. */
  37719. constructor(_scene?: Scene | undefined);
  37720. /**
  37721. * The gamepads in the game pad manager
  37722. */
  37723. readonly gamepads: Gamepad[];
  37724. /**
  37725. * Get the gamepad controllers based on type
  37726. * @param type The type of gamepad controller
  37727. * @returns Nullable gamepad
  37728. */
  37729. getGamepadByType(type?: number): Nullable<Gamepad>;
  37730. /**
  37731. * Disposes the gamepad manager
  37732. */
  37733. dispose(): void;
  37734. private _addNewGamepad;
  37735. private _startMonitoringGamepads;
  37736. private _stopMonitoringGamepads;
  37737. /** @hidden */
  37738. _checkGamepadsStatus(): void;
  37739. private _updateGamepadObjects;
  37740. }
  37741. }
  37742. declare module BABYLON {
  37743. interface Scene {
  37744. /** @hidden */
  37745. _gamepadManager: Nullable<GamepadManager>;
  37746. /**
  37747. * Gets the gamepad manager associated with the scene
  37748. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37749. */
  37750. gamepadManager: GamepadManager;
  37751. }
  37752. /**
  37753. * Interface representing a free camera inputs manager
  37754. */
  37755. interface FreeCameraInputsManager {
  37756. /**
  37757. * Adds gamepad input support to the FreeCameraInputsManager.
  37758. * @returns the FreeCameraInputsManager
  37759. */
  37760. addGamepad(): FreeCameraInputsManager;
  37761. }
  37762. /**
  37763. * Interface representing an arc rotate camera inputs manager
  37764. */
  37765. interface ArcRotateCameraInputsManager {
  37766. /**
  37767. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37768. * @returns the camera inputs manager
  37769. */
  37770. addGamepad(): ArcRotateCameraInputsManager;
  37771. }
  37772. /**
  37773. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37774. */
  37775. export class GamepadSystemSceneComponent implements ISceneComponent {
  37776. /**
  37777. * The component name helpfull to identify the component in the list of scene components.
  37778. */
  37779. readonly name: string;
  37780. /**
  37781. * The scene the component belongs to.
  37782. */
  37783. scene: Scene;
  37784. /**
  37785. * Creates a new instance of the component for the given scene
  37786. * @param scene Defines the scene to register the component in
  37787. */
  37788. constructor(scene: Scene);
  37789. /**
  37790. * Registers the component in a given scene
  37791. */
  37792. register(): void;
  37793. /**
  37794. * Rebuilds the elements related to this component in case of
  37795. * context lost for instance.
  37796. */
  37797. rebuild(): void;
  37798. /**
  37799. * Disposes the component and the associated ressources
  37800. */
  37801. dispose(): void;
  37802. private _beforeCameraUpdate;
  37803. }
  37804. }
  37805. declare module BABYLON {
  37806. /**
  37807. * 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,
  37808. * which still works and will still be found in many Playgrounds.
  37809. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37810. */
  37811. export class UniversalCamera extends TouchCamera {
  37812. /**
  37813. * Defines the gamepad rotation sensiblity.
  37814. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37815. */
  37816. gamepadAngularSensibility: number;
  37817. /**
  37818. * Defines the gamepad move sensiblity.
  37819. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37820. */
  37821. gamepadMoveSensibility: number;
  37822. /**
  37823. * 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,
  37824. * which still works and will still be found in many Playgrounds.
  37825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37826. * @param name Define the name of the camera in the scene
  37827. * @param position Define the start position of the camera in the scene
  37828. * @param scene Define the scene the camera belongs to
  37829. */
  37830. constructor(name: string, position: Vector3, scene: Scene);
  37831. /**
  37832. * Gets the current object class name.
  37833. * @return the class name
  37834. */
  37835. getClassName(): string;
  37836. }
  37837. }
  37838. declare module BABYLON {
  37839. /**
  37840. * This represents a FPS type of camera. This is only here for back compat purpose.
  37841. * Please use the UniversalCamera instead as both are identical.
  37842. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37843. */
  37844. export class GamepadCamera extends UniversalCamera {
  37845. /**
  37846. * Instantiates a new Gamepad Camera
  37847. * This represents a FPS type of camera. This is only here for back compat purpose.
  37848. * Please use the UniversalCamera instead as both are identical.
  37849. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37850. * @param name Define the name of the camera in the scene
  37851. * @param position Define the start position of the camera in the scene
  37852. * @param scene Define the scene the camera belongs to
  37853. */
  37854. constructor(name: string, position: Vector3, scene: Scene);
  37855. /**
  37856. * Gets the current object class name.
  37857. * @return the class name
  37858. */
  37859. getClassName(): string;
  37860. }
  37861. }
  37862. declare module BABYLON {
  37863. /** @hidden */
  37864. export var passPixelShader: {
  37865. name: string;
  37866. shader: string;
  37867. };
  37868. }
  37869. declare module BABYLON {
  37870. /** @hidden */
  37871. export var passCubePixelShader: {
  37872. name: string;
  37873. shader: string;
  37874. };
  37875. }
  37876. declare module BABYLON {
  37877. /**
  37878. * PassPostProcess which produces an output the same as it's input
  37879. */
  37880. export class PassPostProcess extends PostProcess {
  37881. /**
  37882. * Creates the PassPostProcess
  37883. * @param name The name of the effect.
  37884. * @param options The required width/height ratio to downsize to before computing the render pass.
  37885. * @param camera The camera to apply the render pass to.
  37886. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37887. * @param engine The engine which the post process will be applied. (default: current engine)
  37888. * @param reusable If the post process can be reused on the same frame. (default: false)
  37889. * @param textureType The type of texture to be used when performing the post processing.
  37890. * @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)
  37891. */
  37892. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37893. }
  37894. /**
  37895. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37896. */
  37897. export class PassCubePostProcess extends PostProcess {
  37898. private _face;
  37899. /**
  37900. * Gets or sets the cube face to display.
  37901. * * 0 is +X
  37902. * * 1 is -X
  37903. * * 2 is +Y
  37904. * * 3 is -Y
  37905. * * 4 is +Z
  37906. * * 5 is -Z
  37907. */
  37908. face: number;
  37909. /**
  37910. * Creates the PassCubePostProcess
  37911. * @param name The name of the effect.
  37912. * @param options The required width/height ratio to downsize to before computing the render pass.
  37913. * @param camera The camera to apply the render pass to.
  37914. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37915. * @param engine The engine which the post process will be applied. (default: current engine)
  37916. * @param reusable If the post process can be reused on the same frame. (default: false)
  37917. * @param textureType The type of texture to be used when performing the post processing.
  37918. * @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)
  37919. */
  37920. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37921. }
  37922. }
  37923. declare module BABYLON {
  37924. /** @hidden */
  37925. export var anaglyphPixelShader: {
  37926. name: string;
  37927. shader: string;
  37928. };
  37929. }
  37930. declare module BABYLON {
  37931. /**
  37932. * Postprocess used to generate anaglyphic rendering
  37933. */
  37934. export class AnaglyphPostProcess extends PostProcess {
  37935. private _passedProcess;
  37936. /**
  37937. * Creates a new AnaglyphPostProcess
  37938. * @param name defines postprocess name
  37939. * @param options defines creation options or target ratio scale
  37940. * @param rigCameras defines cameras using this postprocess
  37941. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37942. * @param engine defines hosting engine
  37943. * @param reusable defines if the postprocess will be reused multiple times per frame
  37944. */
  37945. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37946. }
  37947. }
  37948. declare module BABYLON {
  37949. /**
  37950. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37951. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37952. */
  37953. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37954. /**
  37955. * Creates a new AnaglyphArcRotateCamera
  37956. * @param name defines camera name
  37957. * @param alpha defines alpha angle (in radians)
  37958. * @param beta defines beta angle (in radians)
  37959. * @param radius defines radius
  37960. * @param target defines camera target
  37961. * @param interaxialDistance defines distance between each color axis
  37962. * @param scene defines the hosting scene
  37963. */
  37964. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37965. /**
  37966. * Gets camera class name
  37967. * @returns AnaglyphArcRotateCamera
  37968. */
  37969. getClassName(): string;
  37970. }
  37971. }
  37972. declare module BABYLON {
  37973. /**
  37974. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37975. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37976. */
  37977. export class AnaglyphFreeCamera extends FreeCamera {
  37978. /**
  37979. * Creates a new AnaglyphFreeCamera
  37980. * @param name defines camera name
  37981. * @param position defines initial position
  37982. * @param interaxialDistance defines distance between each color axis
  37983. * @param scene defines the hosting scene
  37984. */
  37985. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37986. /**
  37987. * Gets camera class name
  37988. * @returns AnaglyphFreeCamera
  37989. */
  37990. getClassName(): string;
  37991. }
  37992. }
  37993. declare module BABYLON {
  37994. /**
  37995. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37996. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37997. */
  37998. export class AnaglyphGamepadCamera extends GamepadCamera {
  37999. /**
  38000. * Creates a new AnaglyphGamepadCamera
  38001. * @param name defines camera name
  38002. * @param position defines initial position
  38003. * @param interaxialDistance defines distance between each color axis
  38004. * @param scene defines the hosting scene
  38005. */
  38006. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38007. /**
  38008. * Gets camera class name
  38009. * @returns AnaglyphGamepadCamera
  38010. */
  38011. getClassName(): string;
  38012. }
  38013. }
  38014. declare module BABYLON {
  38015. /**
  38016. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38017. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38018. */
  38019. export class AnaglyphUniversalCamera extends UniversalCamera {
  38020. /**
  38021. * Creates a new AnaglyphUniversalCamera
  38022. * @param name defines camera name
  38023. * @param position defines initial position
  38024. * @param interaxialDistance defines distance between each color axis
  38025. * @param scene defines the hosting scene
  38026. */
  38027. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38028. /**
  38029. * Gets camera class name
  38030. * @returns AnaglyphUniversalCamera
  38031. */
  38032. getClassName(): string;
  38033. }
  38034. }
  38035. declare module BABYLON {
  38036. /** @hidden */
  38037. export var stereoscopicInterlacePixelShader: {
  38038. name: string;
  38039. shader: string;
  38040. };
  38041. }
  38042. declare module BABYLON {
  38043. /**
  38044. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38045. */
  38046. export class StereoscopicInterlacePostProcess extends PostProcess {
  38047. private _stepSize;
  38048. private _passedProcess;
  38049. /**
  38050. * Initializes a StereoscopicInterlacePostProcess
  38051. * @param name The name of the effect.
  38052. * @param rigCameras The rig cameras to be appled to the post process
  38053. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38055. * @param engine The engine which the post process will be applied. (default: current engine)
  38056. * @param reusable If the post process can be reused on the same frame. (default: false)
  38057. */
  38058. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38059. }
  38060. }
  38061. declare module BABYLON {
  38062. /**
  38063. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38064. * @see http://doc.babylonjs.com/features/cameras
  38065. */
  38066. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38067. /**
  38068. * Creates a new StereoscopicArcRotateCamera
  38069. * @param name defines camera name
  38070. * @param alpha defines alpha angle (in radians)
  38071. * @param beta defines beta angle (in radians)
  38072. * @param radius defines radius
  38073. * @param target defines camera target
  38074. * @param interaxialDistance defines distance between each color axis
  38075. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38076. * @param scene defines the hosting scene
  38077. */
  38078. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38079. /**
  38080. * Gets camera class name
  38081. * @returns StereoscopicArcRotateCamera
  38082. */
  38083. getClassName(): string;
  38084. }
  38085. }
  38086. declare module BABYLON {
  38087. /**
  38088. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38089. * @see http://doc.babylonjs.com/features/cameras
  38090. */
  38091. export class StereoscopicFreeCamera extends FreeCamera {
  38092. /**
  38093. * Creates a new StereoscopicFreeCamera
  38094. * @param name defines camera name
  38095. * @param position defines initial position
  38096. * @param interaxialDistance defines distance between each color axis
  38097. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38098. * @param scene defines the hosting scene
  38099. */
  38100. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38101. /**
  38102. * Gets camera class name
  38103. * @returns StereoscopicFreeCamera
  38104. */
  38105. getClassName(): string;
  38106. }
  38107. }
  38108. declare module BABYLON {
  38109. /**
  38110. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38111. * @see http://doc.babylonjs.com/features/cameras
  38112. */
  38113. export class StereoscopicGamepadCamera extends GamepadCamera {
  38114. /**
  38115. * Creates a new StereoscopicGamepadCamera
  38116. * @param name defines camera name
  38117. * @param position defines initial position
  38118. * @param interaxialDistance defines distance between each color axis
  38119. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38120. * @param scene defines the hosting scene
  38121. */
  38122. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38123. /**
  38124. * Gets camera class name
  38125. * @returns StereoscopicGamepadCamera
  38126. */
  38127. getClassName(): string;
  38128. }
  38129. }
  38130. declare module BABYLON {
  38131. /**
  38132. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38133. * @see http://doc.babylonjs.com/features/cameras
  38134. */
  38135. export class StereoscopicUniversalCamera extends UniversalCamera {
  38136. /**
  38137. * Creates a new StereoscopicUniversalCamera
  38138. * @param name defines camera name
  38139. * @param position defines initial position
  38140. * @param interaxialDistance defines distance between each color axis
  38141. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38142. * @param scene defines the hosting scene
  38143. */
  38144. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38145. /**
  38146. * Gets camera class name
  38147. * @returns StereoscopicUniversalCamera
  38148. */
  38149. getClassName(): string;
  38150. }
  38151. }
  38152. declare module BABYLON {
  38153. /**
  38154. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38155. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38156. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38157. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38158. */
  38159. export class VirtualJoysticksCamera extends FreeCamera {
  38160. /**
  38161. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38162. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38163. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38164. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38165. * @param name Define the name of the camera in the scene
  38166. * @param position Define the start position of the camera in the scene
  38167. * @param scene Define the scene the camera belongs to
  38168. */
  38169. constructor(name: string, position: Vector3, scene: Scene);
  38170. /**
  38171. * Gets the current object class name.
  38172. * @return the class name
  38173. */
  38174. getClassName(): string;
  38175. }
  38176. }
  38177. declare module BABYLON {
  38178. /**
  38179. * This represents all the required metrics to create a VR camera.
  38180. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38181. */
  38182. export class VRCameraMetrics {
  38183. /**
  38184. * Define the horizontal resolution off the screen.
  38185. */
  38186. hResolution: number;
  38187. /**
  38188. * Define the vertical resolution off the screen.
  38189. */
  38190. vResolution: number;
  38191. /**
  38192. * Define the horizontal screen size.
  38193. */
  38194. hScreenSize: number;
  38195. /**
  38196. * Define the vertical screen size.
  38197. */
  38198. vScreenSize: number;
  38199. /**
  38200. * Define the vertical screen center position.
  38201. */
  38202. vScreenCenter: number;
  38203. /**
  38204. * Define the distance of the eyes to the screen.
  38205. */
  38206. eyeToScreenDistance: number;
  38207. /**
  38208. * Define the distance between both lenses
  38209. */
  38210. lensSeparationDistance: number;
  38211. /**
  38212. * Define the distance between both viewer's eyes.
  38213. */
  38214. interpupillaryDistance: number;
  38215. /**
  38216. * Define the distortion factor of the VR postprocess.
  38217. * Please, touch with care.
  38218. */
  38219. distortionK: number[];
  38220. /**
  38221. * Define the chromatic aberration correction factors for the VR post process.
  38222. */
  38223. chromaAbCorrection: number[];
  38224. /**
  38225. * Define the scale factor of the post process.
  38226. * The smaller the better but the slower.
  38227. */
  38228. postProcessScaleFactor: number;
  38229. /**
  38230. * Define an offset for the lens center.
  38231. */
  38232. lensCenterOffset: number;
  38233. /**
  38234. * Define if the current vr camera should compensate the distortion of the lense or not.
  38235. */
  38236. compensateDistortion: boolean;
  38237. /**
  38238. * Defines if multiview should be enabled when rendering (Default: false)
  38239. */
  38240. multiviewEnabled: boolean;
  38241. /**
  38242. * Gets the rendering aspect ratio based on the provided resolutions.
  38243. */
  38244. readonly aspectRatio: number;
  38245. /**
  38246. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38247. */
  38248. readonly aspectRatioFov: number;
  38249. /**
  38250. * @hidden
  38251. */
  38252. readonly leftHMatrix: Matrix;
  38253. /**
  38254. * @hidden
  38255. */
  38256. readonly rightHMatrix: Matrix;
  38257. /**
  38258. * @hidden
  38259. */
  38260. readonly leftPreViewMatrix: Matrix;
  38261. /**
  38262. * @hidden
  38263. */
  38264. readonly rightPreViewMatrix: Matrix;
  38265. /**
  38266. * Get the default VRMetrics based on the most generic setup.
  38267. * @returns the default vr metrics
  38268. */
  38269. static GetDefault(): VRCameraMetrics;
  38270. }
  38271. }
  38272. declare module BABYLON {
  38273. /** @hidden */
  38274. export var vrDistortionCorrectionPixelShader: {
  38275. name: string;
  38276. shader: string;
  38277. };
  38278. }
  38279. declare module BABYLON {
  38280. /**
  38281. * VRDistortionCorrectionPostProcess used for mobile VR
  38282. */
  38283. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38284. private _isRightEye;
  38285. private _distortionFactors;
  38286. private _postProcessScaleFactor;
  38287. private _lensCenterOffset;
  38288. private _scaleIn;
  38289. private _scaleFactor;
  38290. private _lensCenter;
  38291. /**
  38292. * Initializes the VRDistortionCorrectionPostProcess
  38293. * @param name The name of the effect.
  38294. * @param camera The camera to apply the render pass to.
  38295. * @param isRightEye If this is for the right eye distortion
  38296. * @param vrMetrics All the required metrics for the VR camera
  38297. */
  38298. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38299. }
  38300. }
  38301. declare module BABYLON {
  38302. /**
  38303. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38304. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38305. */
  38306. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38307. /**
  38308. * Creates a new VRDeviceOrientationArcRotateCamera
  38309. * @param name defines camera name
  38310. * @param alpha defines the camera rotation along the logitudinal axis
  38311. * @param beta defines the camera rotation along the latitudinal axis
  38312. * @param radius defines the camera distance from its target
  38313. * @param target defines the camera target
  38314. * @param scene defines the scene the camera belongs to
  38315. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38316. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38317. */
  38318. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38319. /**
  38320. * Gets camera class name
  38321. * @returns VRDeviceOrientationArcRotateCamera
  38322. */
  38323. getClassName(): string;
  38324. }
  38325. }
  38326. declare module BABYLON {
  38327. /**
  38328. * Camera used to simulate VR rendering (based on FreeCamera)
  38329. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38330. */
  38331. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38332. /**
  38333. * Creates a new VRDeviceOrientationFreeCamera
  38334. * @param name defines camera name
  38335. * @param position defines the start position of the camera
  38336. * @param scene defines the scene the camera belongs to
  38337. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38338. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38339. */
  38340. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38341. /**
  38342. * Gets camera class name
  38343. * @returns VRDeviceOrientationFreeCamera
  38344. */
  38345. getClassName(): string;
  38346. }
  38347. }
  38348. declare module BABYLON {
  38349. /**
  38350. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38351. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38352. */
  38353. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38354. /**
  38355. * Creates a new VRDeviceOrientationGamepadCamera
  38356. * @param name defines camera name
  38357. * @param position defines the start position of the camera
  38358. * @param scene defines the scene the camera belongs to
  38359. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38360. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38361. */
  38362. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38363. /**
  38364. * Gets camera class name
  38365. * @returns VRDeviceOrientationGamepadCamera
  38366. */
  38367. getClassName(): string;
  38368. }
  38369. }
  38370. declare module BABYLON {
  38371. /**
  38372. * Base class of materials working in push mode in babylon JS
  38373. * @hidden
  38374. */
  38375. export class PushMaterial extends Material {
  38376. protected _activeEffect: Effect;
  38377. protected _normalMatrix: Matrix;
  38378. /**
  38379. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38380. * This means that the material can keep using a previous shader while a new one is being compiled.
  38381. * This is mostly used when shader parallel compilation is supported (true by default)
  38382. */
  38383. allowShaderHotSwapping: boolean;
  38384. constructor(name: string, scene: Scene);
  38385. getEffect(): Effect;
  38386. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38387. /**
  38388. * Binds the given world matrix to the active effect
  38389. *
  38390. * @param world the matrix to bind
  38391. */
  38392. bindOnlyWorldMatrix(world: Matrix): void;
  38393. /**
  38394. * Binds the given normal matrix to the active effect
  38395. *
  38396. * @param normalMatrix the matrix to bind
  38397. */
  38398. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38399. bind(world: Matrix, mesh?: Mesh): void;
  38400. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38401. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38402. }
  38403. }
  38404. declare module BABYLON {
  38405. /**
  38406. * This groups all the flags used to control the materials channel.
  38407. */
  38408. export class MaterialFlags {
  38409. private static _DiffuseTextureEnabled;
  38410. /**
  38411. * Are diffuse textures enabled in the application.
  38412. */
  38413. static DiffuseTextureEnabled: boolean;
  38414. private static _AmbientTextureEnabled;
  38415. /**
  38416. * Are ambient textures enabled in the application.
  38417. */
  38418. static AmbientTextureEnabled: boolean;
  38419. private static _OpacityTextureEnabled;
  38420. /**
  38421. * Are opacity textures enabled in the application.
  38422. */
  38423. static OpacityTextureEnabled: boolean;
  38424. private static _ReflectionTextureEnabled;
  38425. /**
  38426. * Are reflection textures enabled in the application.
  38427. */
  38428. static ReflectionTextureEnabled: boolean;
  38429. private static _EmissiveTextureEnabled;
  38430. /**
  38431. * Are emissive textures enabled in the application.
  38432. */
  38433. static EmissiveTextureEnabled: boolean;
  38434. private static _SpecularTextureEnabled;
  38435. /**
  38436. * Are specular textures enabled in the application.
  38437. */
  38438. static SpecularTextureEnabled: boolean;
  38439. private static _BumpTextureEnabled;
  38440. /**
  38441. * Are bump textures enabled in the application.
  38442. */
  38443. static BumpTextureEnabled: boolean;
  38444. private static _LightmapTextureEnabled;
  38445. /**
  38446. * Are lightmap textures enabled in the application.
  38447. */
  38448. static LightmapTextureEnabled: boolean;
  38449. private static _RefractionTextureEnabled;
  38450. /**
  38451. * Are refraction textures enabled in the application.
  38452. */
  38453. static RefractionTextureEnabled: boolean;
  38454. private static _ColorGradingTextureEnabled;
  38455. /**
  38456. * Are color grading textures enabled in the application.
  38457. */
  38458. static ColorGradingTextureEnabled: boolean;
  38459. private static _FresnelEnabled;
  38460. /**
  38461. * Are fresnels enabled in the application.
  38462. */
  38463. static FresnelEnabled: boolean;
  38464. private static _ClearCoatTextureEnabled;
  38465. /**
  38466. * Are clear coat textures enabled in the application.
  38467. */
  38468. static ClearCoatTextureEnabled: boolean;
  38469. private static _ClearCoatBumpTextureEnabled;
  38470. /**
  38471. * Are clear coat bump textures enabled in the application.
  38472. */
  38473. static ClearCoatBumpTextureEnabled: boolean;
  38474. private static _ClearCoatTintTextureEnabled;
  38475. /**
  38476. * Are clear coat tint textures enabled in the application.
  38477. */
  38478. static ClearCoatTintTextureEnabled: boolean;
  38479. private static _SheenTextureEnabled;
  38480. /**
  38481. * Are sheen textures enabled in the application.
  38482. */
  38483. static SheenTextureEnabled: boolean;
  38484. private static _AnisotropicTextureEnabled;
  38485. /**
  38486. * Are anisotropic textures enabled in the application.
  38487. */
  38488. static AnisotropicTextureEnabled: boolean;
  38489. private static _ThicknessTextureEnabled;
  38490. /**
  38491. * Are thickness textures enabled in the application.
  38492. */
  38493. static ThicknessTextureEnabled: boolean;
  38494. }
  38495. }
  38496. declare module BABYLON {
  38497. /** @hidden */
  38498. export var defaultFragmentDeclaration: {
  38499. name: string;
  38500. shader: string;
  38501. };
  38502. }
  38503. declare module BABYLON {
  38504. /** @hidden */
  38505. export var defaultUboDeclaration: {
  38506. name: string;
  38507. shader: string;
  38508. };
  38509. }
  38510. declare module BABYLON {
  38511. /** @hidden */
  38512. export var lightFragmentDeclaration: {
  38513. name: string;
  38514. shader: string;
  38515. };
  38516. }
  38517. declare module BABYLON {
  38518. /** @hidden */
  38519. export var lightUboDeclaration: {
  38520. name: string;
  38521. shader: string;
  38522. };
  38523. }
  38524. declare module BABYLON {
  38525. /** @hidden */
  38526. export var lightsFragmentFunctions: {
  38527. name: string;
  38528. shader: string;
  38529. };
  38530. }
  38531. declare module BABYLON {
  38532. /** @hidden */
  38533. export var shadowsFragmentFunctions: {
  38534. name: string;
  38535. shader: string;
  38536. };
  38537. }
  38538. declare module BABYLON {
  38539. /** @hidden */
  38540. export var fresnelFunction: {
  38541. name: string;
  38542. shader: string;
  38543. };
  38544. }
  38545. declare module BABYLON {
  38546. /** @hidden */
  38547. export var reflectionFunction: {
  38548. name: string;
  38549. shader: string;
  38550. };
  38551. }
  38552. declare module BABYLON {
  38553. /** @hidden */
  38554. export var bumpFragmentFunctions: {
  38555. name: string;
  38556. shader: string;
  38557. };
  38558. }
  38559. declare module BABYLON {
  38560. /** @hidden */
  38561. export var logDepthDeclaration: {
  38562. name: string;
  38563. shader: string;
  38564. };
  38565. }
  38566. declare module BABYLON {
  38567. /** @hidden */
  38568. export var bumpFragment: {
  38569. name: string;
  38570. shader: string;
  38571. };
  38572. }
  38573. declare module BABYLON {
  38574. /** @hidden */
  38575. export var depthPrePass: {
  38576. name: string;
  38577. shader: string;
  38578. };
  38579. }
  38580. declare module BABYLON {
  38581. /** @hidden */
  38582. export var lightFragment: {
  38583. name: string;
  38584. shader: string;
  38585. };
  38586. }
  38587. declare module BABYLON {
  38588. /** @hidden */
  38589. export var logDepthFragment: {
  38590. name: string;
  38591. shader: string;
  38592. };
  38593. }
  38594. declare module BABYLON {
  38595. /** @hidden */
  38596. export var defaultPixelShader: {
  38597. name: string;
  38598. shader: string;
  38599. };
  38600. }
  38601. declare module BABYLON {
  38602. /** @hidden */
  38603. export var defaultVertexDeclaration: {
  38604. name: string;
  38605. shader: string;
  38606. };
  38607. }
  38608. declare module BABYLON {
  38609. /** @hidden */
  38610. export var bumpVertexDeclaration: {
  38611. name: string;
  38612. shader: string;
  38613. };
  38614. }
  38615. declare module BABYLON {
  38616. /** @hidden */
  38617. export var bumpVertex: {
  38618. name: string;
  38619. shader: string;
  38620. };
  38621. }
  38622. declare module BABYLON {
  38623. /** @hidden */
  38624. export var fogVertex: {
  38625. name: string;
  38626. shader: string;
  38627. };
  38628. }
  38629. declare module BABYLON {
  38630. /** @hidden */
  38631. export var shadowsVertex: {
  38632. name: string;
  38633. shader: string;
  38634. };
  38635. }
  38636. declare module BABYLON {
  38637. /** @hidden */
  38638. export var pointCloudVertex: {
  38639. name: string;
  38640. shader: string;
  38641. };
  38642. }
  38643. declare module BABYLON {
  38644. /** @hidden */
  38645. export var logDepthVertex: {
  38646. name: string;
  38647. shader: string;
  38648. };
  38649. }
  38650. declare module BABYLON {
  38651. /** @hidden */
  38652. export var defaultVertexShader: {
  38653. name: string;
  38654. shader: string;
  38655. };
  38656. }
  38657. declare module BABYLON {
  38658. /** @hidden */
  38659. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38660. MAINUV1: boolean;
  38661. MAINUV2: boolean;
  38662. DIFFUSE: boolean;
  38663. DIFFUSEDIRECTUV: number;
  38664. AMBIENT: boolean;
  38665. AMBIENTDIRECTUV: number;
  38666. OPACITY: boolean;
  38667. OPACITYDIRECTUV: number;
  38668. OPACITYRGB: boolean;
  38669. REFLECTION: boolean;
  38670. EMISSIVE: boolean;
  38671. EMISSIVEDIRECTUV: number;
  38672. SPECULAR: boolean;
  38673. SPECULARDIRECTUV: number;
  38674. BUMP: boolean;
  38675. BUMPDIRECTUV: number;
  38676. PARALLAX: boolean;
  38677. PARALLAXOCCLUSION: boolean;
  38678. SPECULAROVERALPHA: boolean;
  38679. CLIPPLANE: boolean;
  38680. CLIPPLANE2: boolean;
  38681. CLIPPLANE3: boolean;
  38682. CLIPPLANE4: boolean;
  38683. ALPHATEST: boolean;
  38684. DEPTHPREPASS: boolean;
  38685. ALPHAFROMDIFFUSE: boolean;
  38686. POINTSIZE: boolean;
  38687. FOG: boolean;
  38688. SPECULARTERM: boolean;
  38689. DIFFUSEFRESNEL: boolean;
  38690. OPACITYFRESNEL: boolean;
  38691. REFLECTIONFRESNEL: boolean;
  38692. REFRACTIONFRESNEL: boolean;
  38693. EMISSIVEFRESNEL: boolean;
  38694. FRESNEL: boolean;
  38695. NORMAL: boolean;
  38696. UV1: boolean;
  38697. UV2: boolean;
  38698. VERTEXCOLOR: boolean;
  38699. VERTEXALPHA: boolean;
  38700. NUM_BONE_INFLUENCERS: number;
  38701. BonesPerMesh: number;
  38702. BONETEXTURE: boolean;
  38703. INSTANCES: boolean;
  38704. GLOSSINESS: boolean;
  38705. ROUGHNESS: boolean;
  38706. EMISSIVEASILLUMINATION: boolean;
  38707. LINKEMISSIVEWITHDIFFUSE: boolean;
  38708. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38709. LIGHTMAP: boolean;
  38710. LIGHTMAPDIRECTUV: number;
  38711. OBJECTSPACE_NORMALMAP: boolean;
  38712. USELIGHTMAPASSHADOWMAP: boolean;
  38713. REFLECTIONMAP_3D: boolean;
  38714. REFLECTIONMAP_SPHERICAL: boolean;
  38715. REFLECTIONMAP_PLANAR: boolean;
  38716. REFLECTIONMAP_CUBIC: boolean;
  38717. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38718. REFLECTIONMAP_PROJECTION: boolean;
  38719. REFLECTIONMAP_SKYBOX: boolean;
  38720. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38721. REFLECTIONMAP_EXPLICIT: boolean;
  38722. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38723. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38724. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38725. INVERTCUBICMAP: boolean;
  38726. LOGARITHMICDEPTH: boolean;
  38727. REFRACTION: boolean;
  38728. REFRACTIONMAP_3D: boolean;
  38729. REFLECTIONOVERALPHA: boolean;
  38730. TWOSIDEDLIGHTING: boolean;
  38731. SHADOWFLOAT: boolean;
  38732. MORPHTARGETS: boolean;
  38733. MORPHTARGETS_NORMAL: boolean;
  38734. MORPHTARGETS_TANGENT: boolean;
  38735. NUM_MORPH_INFLUENCERS: number;
  38736. NONUNIFORMSCALING: boolean;
  38737. PREMULTIPLYALPHA: boolean;
  38738. IMAGEPROCESSING: boolean;
  38739. VIGNETTE: boolean;
  38740. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38741. VIGNETTEBLENDMODEOPAQUE: boolean;
  38742. TONEMAPPING: boolean;
  38743. TONEMAPPING_ACES: boolean;
  38744. CONTRAST: boolean;
  38745. COLORCURVES: boolean;
  38746. COLORGRADING: boolean;
  38747. COLORGRADING3D: boolean;
  38748. SAMPLER3DGREENDEPTH: boolean;
  38749. SAMPLER3DBGRMAP: boolean;
  38750. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38751. MULTIVIEW: boolean;
  38752. /**
  38753. * If the reflection texture on this material is in linear color space
  38754. * @hidden
  38755. */
  38756. IS_REFLECTION_LINEAR: boolean;
  38757. /**
  38758. * If the refraction texture on this material is in linear color space
  38759. * @hidden
  38760. */
  38761. IS_REFRACTION_LINEAR: boolean;
  38762. EXPOSURE: boolean;
  38763. constructor();
  38764. setReflectionMode(modeToEnable: string): void;
  38765. }
  38766. /**
  38767. * This is the default material used in Babylon. It is the best trade off between quality
  38768. * and performances.
  38769. * @see http://doc.babylonjs.com/babylon101/materials
  38770. */
  38771. export class StandardMaterial extends PushMaterial {
  38772. private _diffuseTexture;
  38773. /**
  38774. * The basic texture of the material as viewed under a light.
  38775. */
  38776. diffuseTexture: Nullable<BaseTexture>;
  38777. private _ambientTexture;
  38778. /**
  38779. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38780. */
  38781. ambientTexture: Nullable<BaseTexture>;
  38782. private _opacityTexture;
  38783. /**
  38784. * Define the transparency of the material from a texture.
  38785. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38786. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38787. */
  38788. opacityTexture: Nullable<BaseTexture>;
  38789. private _reflectionTexture;
  38790. /**
  38791. * Define the texture used to display the reflection.
  38792. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38793. */
  38794. reflectionTexture: Nullable<BaseTexture>;
  38795. private _emissiveTexture;
  38796. /**
  38797. * Define texture of the material as if self lit.
  38798. * This will be mixed in the final result even in the absence of light.
  38799. */
  38800. emissiveTexture: Nullable<BaseTexture>;
  38801. private _specularTexture;
  38802. /**
  38803. * Define how the color and intensity of the highlight given by the light in the material.
  38804. */
  38805. specularTexture: Nullable<BaseTexture>;
  38806. private _bumpTexture;
  38807. /**
  38808. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38809. * 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.
  38810. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38811. */
  38812. bumpTexture: Nullable<BaseTexture>;
  38813. private _lightmapTexture;
  38814. /**
  38815. * Complex lighting can be computationally expensive to compute at runtime.
  38816. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38817. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38818. */
  38819. lightmapTexture: Nullable<BaseTexture>;
  38820. private _refractionTexture;
  38821. /**
  38822. * Define the texture used to display the refraction.
  38823. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38824. */
  38825. refractionTexture: Nullable<BaseTexture>;
  38826. /**
  38827. * The color of the material lit by the environmental background lighting.
  38828. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38829. */
  38830. ambientColor: Color3;
  38831. /**
  38832. * The basic color of the material as viewed under a light.
  38833. */
  38834. diffuseColor: Color3;
  38835. /**
  38836. * Define how the color and intensity of the highlight given by the light in the material.
  38837. */
  38838. specularColor: Color3;
  38839. /**
  38840. * Define the color of the material as if self lit.
  38841. * This will be mixed in the final result even in the absence of light.
  38842. */
  38843. emissiveColor: Color3;
  38844. /**
  38845. * Defines how sharp are the highlights in the material.
  38846. * The bigger the value the sharper giving a more glossy feeling to the result.
  38847. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38848. */
  38849. specularPower: number;
  38850. private _useAlphaFromDiffuseTexture;
  38851. /**
  38852. * Does the transparency come from the diffuse texture alpha channel.
  38853. */
  38854. useAlphaFromDiffuseTexture: boolean;
  38855. private _useEmissiveAsIllumination;
  38856. /**
  38857. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38858. */
  38859. useEmissiveAsIllumination: boolean;
  38860. private _linkEmissiveWithDiffuse;
  38861. /**
  38862. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38863. * the emissive level when the final color is close to one.
  38864. */
  38865. linkEmissiveWithDiffuse: boolean;
  38866. private _useSpecularOverAlpha;
  38867. /**
  38868. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38869. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38870. */
  38871. useSpecularOverAlpha: boolean;
  38872. private _useReflectionOverAlpha;
  38873. /**
  38874. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38875. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38876. */
  38877. useReflectionOverAlpha: boolean;
  38878. private _disableLighting;
  38879. /**
  38880. * Does lights from the scene impacts this material.
  38881. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38882. */
  38883. disableLighting: boolean;
  38884. private _useObjectSpaceNormalMap;
  38885. /**
  38886. * Allows using an object space normal map (instead of tangent space).
  38887. */
  38888. useObjectSpaceNormalMap: boolean;
  38889. private _useParallax;
  38890. /**
  38891. * Is parallax enabled or not.
  38892. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38893. */
  38894. useParallax: boolean;
  38895. private _useParallaxOcclusion;
  38896. /**
  38897. * Is parallax occlusion enabled or not.
  38898. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38899. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38900. */
  38901. useParallaxOcclusion: boolean;
  38902. /**
  38903. * 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.
  38904. */
  38905. parallaxScaleBias: number;
  38906. private _roughness;
  38907. /**
  38908. * Helps to define how blurry the reflections should appears in the material.
  38909. */
  38910. roughness: number;
  38911. /**
  38912. * In case of refraction, define the value of the indice of refraction.
  38913. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38914. */
  38915. indexOfRefraction: number;
  38916. /**
  38917. * Invert the refraction texture alongside the y axis.
  38918. * It can be useful with procedural textures or probe for instance.
  38919. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38920. */
  38921. invertRefractionY: boolean;
  38922. /**
  38923. * Defines the alpha limits in alpha test mode.
  38924. */
  38925. alphaCutOff: number;
  38926. private _useLightmapAsShadowmap;
  38927. /**
  38928. * In case of light mapping, define whether the map contains light or shadow informations.
  38929. */
  38930. useLightmapAsShadowmap: boolean;
  38931. private _diffuseFresnelParameters;
  38932. /**
  38933. * Define the diffuse fresnel parameters of the material.
  38934. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38935. */
  38936. diffuseFresnelParameters: FresnelParameters;
  38937. private _opacityFresnelParameters;
  38938. /**
  38939. * Define the opacity fresnel parameters of the material.
  38940. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38941. */
  38942. opacityFresnelParameters: FresnelParameters;
  38943. private _reflectionFresnelParameters;
  38944. /**
  38945. * Define the reflection fresnel parameters of the material.
  38946. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38947. */
  38948. reflectionFresnelParameters: FresnelParameters;
  38949. private _refractionFresnelParameters;
  38950. /**
  38951. * Define the refraction fresnel parameters of the material.
  38952. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38953. */
  38954. refractionFresnelParameters: FresnelParameters;
  38955. private _emissiveFresnelParameters;
  38956. /**
  38957. * Define the emissive fresnel parameters of the material.
  38958. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38959. */
  38960. emissiveFresnelParameters: FresnelParameters;
  38961. private _useReflectionFresnelFromSpecular;
  38962. /**
  38963. * If true automatically deducts the fresnels values from the material specularity.
  38964. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38965. */
  38966. useReflectionFresnelFromSpecular: boolean;
  38967. private _useGlossinessFromSpecularMapAlpha;
  38968. /**
  38969. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38970. */
  38971. useGlossinessFromSpecularMapAlpha: boolean;
  38972. private _maxSimultaneousLights;
  38973. /**
  38974. * Defines the maximum number of lights that can be used in the material
  38975. */
  38976. maxSimultaneousLights: number;
  38977. private _invertNormalMapX;
  38978. /**
  38979. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38980. */
  38981. invertNormalMapX: boolean;
  38982. private _invertNormalMapY;
  38983. /**
  38984. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38985. */
  38986. invertNormalMapY: boolean;
  38987. private _twoSidedLighting;
  38988. /**
  38989. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38990. */
  38991. twoSidedLighting: boolean;
  38992. /**
  38993. * Default configuration related to image processing available in the standard Material.
  38994. */
  38995. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38996. /**
  38997. * Gets the image processing configuration used either in this material.
  38998. */
  38999. /**
  39000. * Sets the Default image processing configuration used either in the this material.
  39001. *
  39002. * If sets to null, the scene one is in use.
  39003. */
  39004. imageProcessingConfiguration: ImageProcessingConfiguration;
  39005. /**
  39006. * Keep track of the image processing observer to allow dispose and replace.
  39007. */
  39008. private _imageProcessingObserver;
  39009. /**
  39010. * Attaches a new image processing configuration to the Standard Material.
  39011. * @param configuration
  39012. */
  39013. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39014. /**
  39015. * Gets wether the color curves effect is enabled.
  39016. */
  39017. /**
  39018. * Sets wether the color curves effect is enabled.
  39019. */
  39020. cameraColorCurvesEnabled: boolean;
  39021. /**
  39022. * Gets wether the color grading effect is enabled.
  39023. */
  39024. /**
  39025. * Gets wether the color grading effect is enabled.
  39026. */
  39027. cameraColorGradingEnabled: boolean;
  39028. /**
  39029. * Gets wether tonemapping is enabled or not.
  39030. */
  39031. /**
  39032. * Sets wether tonemapping is enabled or not
  39033. */
  39034. cameraToneMappingEnabled: boolean;
  39035. /**
  39036. * The camera exposure used on this material.
  39037. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39038. * This corresponds to a photographic exposure.
  39039. */
  39040. /**
  39041. * The camera exposure used on this material.
  39042. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39043. * This corresponds to a photographic exposure.
  39044. */
  39045. cameraExposure: number;
  39046. /**
  39047. * Gets The camera contrast used on this material.
  39048. */
  39049. /**
  39050. * Sets The camera contrast used on this material.
  39051. */
  39052. cameraContrast: number;
  39053. /**
  39054. * Gets the Color Grading 2D Lookup Texture.
  39055. */
  39056. /**
  39057. * Sets the Color Grading 2D Lookup Texture.
  39058. */
  39059. cameraColorGradingTexture: Nullable<BaseTexture>;
  39060. /**
  39061. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39062. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39063. * 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;
  39064. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39065. */
  39066. /**
  39067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39069. * 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;
  39070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39071. */
  39072. cameraColorCurves: Nullable<ColorCurves>;
  39073. /**
  39074. * Custom callback helping to override the default shader used in the material.
  39075. */
  39076. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39077. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39078. protected _worldViewProjectionMatrix: Matrix;
  39079. protected _globalAmbientColor: Color3;
  39080. protected _useLogarithmicDepth: boolean;
  39081. /**
  39082. * Instantiates a new standard material.
  39083. * This is the default material used in Babylon. It is the best trade off between quality
  39084. * and performances.
  39085. * @see http://doc.babylonjs.com/babylon101/materials
  39086. * @param name Define the name of the material in the scene
  39087. * @param scene Define the scene the material belong to
  39088. */
  39089. constructor(name: string, scene: Scene);
  39090. /**
  39091. * Gets a boolean indicating that current material needs to register RTT
  39092. */
  39093. readonly hasRenderTargetTextures: boolean;
  39094. /**
  39095. * Gets the current class name of the material e.g. "StandardMaterial"
  39096. * Mainly use in serialization.
  39097. * @returns the class name
  39098. */
  39099. getClassName(): string;
  39100. /**
  39101. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39102. * You can try switching to logarithmic depth.
  39103. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39104. */
  39105. useLogarithmicDepth: boolean;
  39106. /**
  39107. * Specifies if the material will require alpha blending
  39108. * @returns a boolean specifying if alpha blending is needed
  39109. */
  39110. needAlphaBlending(): boolean;
  39111. /**
  39112. * Specifies if this material should be rendered in alpha test mode
  39113. * @returns a boolean specifying if an alpha test is needed.
  39114. */
  39115. needAlphaTesting(): boolean;
  39116. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39117. /**
  39118. * Get the texture used for alpha test purpose.
  39119. * @returns the diffuse texture in case of the standard material.
  39120. */
  39121. getAlphaTestTexture(): Nullable<BaseTexture>;
  39122. /**
  39123. * Get if the submesh is ready to be used and all its information available.
  39124. * Child classes can use it to update shaders
  39125. * @param mesh defines the mesh to check
  39126. * @param subMesh defines which submesh to check
  39127. * @param useInstances specifies that instances should be used
  39128. * @returns a boolean indicating that the submesh is ready or not
  39129. */
  39130. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39131. /**
  39132. * Builds the material UBO layouts.
  39133. * Used internally during the effect preparation.
  39134. */
  39135. buildUniformLayout(): void;
  39136. /**
  39137. * Unbinds the material from the mesh
  39138. */
  39139. unbind(): void;
  39140. /**
  39141. * Binds the submesh to this material by preparing the effect and shader to draw
  39142. * @param world defines the world transformation matrix
  39143. * @param mesh defines the mesh containing the submesh
  39144. * @param subMesh defines the submesh to bind the material to
  39145. */
  39146. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39147. /**
  39148. * Get the list of animatables in the material.
  39149. * @returns the list of animatables object used in the material
  39150. */
  39151. getAnimatables(): IAnimatable[];
  39152. /**
  39153. * Gets the active textures from the material
  39154. * @returns an array of textures
  39155. */
  39156. getActiveTextures(): BaseTexture[];
  39157. /**
  39158. * Specifies if the material uses a texture
  39159. * @param texture defines the texture to check against the material
  39160. * @returns a boolean specifying if the material uses the texture
  39161. */
  39162. hasTexture(texture: BaseTexture): boolean;
  39163. /**
  39164. * Disposes the material
  39165. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39166. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39167. */
  39168. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39169. /**
  39170. * Makes a duplicate of the material, and gives it a new name
  39171. * @param name defines the new name for the duplicated material
  39172. * @returns the cloned material
  39173. */
  39174. clone(name: string): StandardMaterial;
  39175. /**
  39176. * Serializes this material in a JSON representation
  39177. * @returns the serialized material object
  39178. */
  39179. serialize(): any;
  39180. /**
  39181. * Creates a standard material from parsed material data
  39182. * @param source defines the JSON representation of the material
  39183. * @param scene defines the hosting scene
  39184. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39185. * @returns a new standard material
  39186. */
  39187. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39188. /**
  39189. * Are diffuse textures enabled in the application.
  39190. */
  39191. static DiffuseTextureEnabled: boolean;
  39192. /**
  39193. * Are ambient textures enabled in the application.
  39194. */
  39195. static AmbientTextureEnabled: boolean;
  39196. /**
  39197. * Are opacity textures enabled in the application.
  39198. */
  39199. static OpacityTextureEnabled: boolean;
  39200. /**
  39201. * Are reflection textures enabled in the application.
  39202. */
  39203. static ReflectionTextureEnabled: boolean;
  39204. /**
  39205. * Are emissive textures enabled in the application.
  39206. */
  39207. static EmissiveTextureEnabled: boolean;
  39208. /**
  39209. * Are specular textures enabled in the application.
  39210. */
  39211. static SpecularTextureEnabled: boolean;
  39212. /**
  39213. * Are bump textures enabled in the application.
  39214. */
  39215. static BumpTextureEnabled: boolean;
  39216. /**
  39217. * Are lightmap textures enabled in the application.
  39218. */
  39219. static LightmapTextureEnabled: boolean;
  39220. /**
  39221. * Are refraction textures enabled in the application.
  39222. */
  39223. static RefractionTextureEnabled: boolean;
  39224. /**
  39225. * Are color grading textures enabled in the application.
  39226. */
  39227. static ColorGradingTextureEnabled: boolean;
  39228. /**
  39229. * Are fresnels enabled in the application.
  39230. */
  39231. static FresnelEnabled: boolean;
  39232. }
  39233. }
  39234. declare module BABYLON {
  39235. /**
  39236. * A class extending Texture allowing drawing on a texture
  39237. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39238. */
  39239. export class DynamicTexture extends Texture {
  39240. private _generateMipMaps;
  39241. private _canvas;
  39242. private _context;
  39243. private _engine;
  39244. /**
  39245. * Creates a DynamicTexture
  39246. * @param name defines the name of the texture
  39247. * @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
  39248. * @param scene defines the scene where you want the texture
  39249. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39250. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39251. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39252. */
  39253. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39254. /**
  39255. * Get the current class name of the texture useful for serialization or dynamic coding.
  39256. * @returns "DynamicTexture"
  39257. */
  39258. getClassName(): string;
  39259. /**
  39260. * Gets the current state of canRescale
  39261. */
  39262. readonly canRescale: boolean;
  39263. private _recreate;
  39264. /**
  39265. * Scales the texture
  39266. * @param ratio the scale factor to apply to both width and height
  39267. */
  39268. scale(ratio: number): void;
  39269. /**
  39270. * Resizes the texture
  39271. * @param width the new width
  39272. * @param height the new height
  39273. */
  39274. scaleTo(width: number, height: number): void;
  39275. /**
  39276. * Gets the context of the canvas used by the texture
  39277. * @returns the canvas context of the dynamic texture
  39278. */
  39279. getContext(): CanvasRenderingContext2D;
  39280. /**
  39281. * Clears the texture
  39282. */
  39283. clear(): void;
  39284. /**
  39285. * Updates the texture
  39286. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39287. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39288. */
  39289. update(invertY?: boolean, premulAlpha?: boolean): void;
  39290. /**
  39291. * Draws text onto the texture
  39292. * @param text defines the text to be drawn
  39293. * @param x defines the placement of the text from the left
  39294. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39295. * @param font defines the font to be used with font-style, font-size, font-name
  39296. * @param color defines the color used for the text
  39297. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39298. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39299. * @param update defines whether texture is immediately update (default is true)
  39300. */
  39301. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39302. /**
  39303. * Clones the texture
  39304. * @returns the clone of the texture.
  39305. */
  39306. clone(): DynamicTexture;
  39307. /**
  39308. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39309. * @returns a serialized dynamic texture object
  39310. */
  39311. serialize(): any;
  39312. /** @hidden */
  39313. _rebuild(): void;
  39314. }
  39315. }
  39316. declare module BABYLON {
  39317. /** @hidden */
  39318. export var imageProcessingPixelShader: {
  39319. name: string;
  39320. shader: string;
  39321. };
  39322. }
  39323. declare module BABYLON {
  39324. /**
  39325. * ImageProcessingPostProcess
  39326. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39327. */
  39328. export class ImageProcessingPostProcess extends PostProcess {
  39329. /**
  39330. * Default configuration related to image processing available in the PBR Material.
  39331. */
  39332. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39333. /**
  39334. * Gets the image processing configuration used either in this material.
  39335. */
  39336. /**
  39337. * Sets the Default image processing configuration used either in the this material.
  39338. *
  39339. * If sets to null, the scene one is in use.
  39340. */
  39341. imageProcessingConfiguration: ImageProcessingConfiguration;
  39342. /**
  39343. * Keep track of the image processing observer to allow dispose and replace.
  39344. */
  39345. private _imageProcessingObserver;
  39346. /**
  39347. * Attaches a new image processing configuration to the PBR Material.
  39348. * @param configuration
  39349. */
  39350. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39351. /**
  39352. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39353. */
  39354. /**
  39355. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39356. */
  39357. colorCurves: Nullable<ColorCurves>;
  39358. /**
  39359. * Gets wether the color curves effect is enabled.
  39360. */
  39361. /**
  39362. * Sets wether the color curves effect is enabled.
  39363. */
  39364. colorCurvesEnabled: boolean;
  39365. /**
  39366. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39367. */
  39368. /**
  39369. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39370. */
  39371. colorGradingTexture: Nullable<BaseTexture>;
  39372. /**
  39373. * Gets wether the color grading effect is enabled.
  39374. */
  39375. /**
  39376. * Gets wether the color grading effect is enabled.
  39377. */
  39378. colorGradingEnabled: boolean;
  39379. /**
  39380. * Gets exposure used in the effect.
  39381. */
  39382. /**
  39383. * Sets exposure used in the effect.
  39384. */
  39385. exposure: number;
  39386. /**
  39387. * Gets wether tonemapping is enabled or not.
  39388. */
  39389. /**
  39390. * Sets wether tonemapping is enabled or not
  39391. */
  39392. toneMappingEnabled: boolean;
  39393. /**
  39394. * Gets the type of tone mapping effect.
  39395. */
  39396. /**
  39397. * Sets the type of tone mapping effect.
  39398. */
  39399. toneMappingType: number;
  39400. /**
  39401. * Gets contrast used in the effect.
  39402. */
  39403. /**
  39404. * Sets contrast used in the effect.
  39405. */
  39406. contrast: number;
  39407. /**
  39408. * Gets Vignette stretch size.
  39409. */
  39410. /**
  39411. * Sets Vignette stretch size.
  39412. */
  39413. vignetteStretch: number;
  39414. /**
  39415. * Gets Vignette centre X Offset.
  39416. */
  39417. /**
  39418. * Sets Vignette centre X Offset.
  39419. */
  39420. vignetteCentreX: number;
  39421. /**
  39422. * Gets Vignette centre Y Offset.
  39423. */
  39424. /**
  39425. * Sets Vignette centre Y Offset.
  39426. */
  39427. vignetteCentreY: number;
  39428. /**
  39429. * Gets Vignette weight or intensity of the vignette effect.
  39430. */
  39431. /**
  39432. * Sets Vignette weight or intensity of the vignette effect.
  39433. */
  39434. vignetteWeight: number;
  39435. /**
  39436. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39437. * if vignetteEnabled is set to true.
  39438. */
  39439. /**
  39440. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39441. * if vignetteEnabled is set to true.
  39442. */
  39443. vignetteColor: Color4;
  39444. /**
  39445. * Gets Camera field of view used by the Vignette effect.
  39446. */
  39447. /**
  39448. * Sets Camera field of view used by the Vignette effect.
  39449. */
  39450. vignetteCameraFov: number;
  39451. /**
  39452. * Gets the vignette blend mode allowing different kind of effect.
  39453. */
  39454. /**
  39455. * Sets the vignette blend mode allowing different kind of effect.
  39456. */
  39457. vignetteBlendMode: number;
  39458. /**
  39459. * Gets wether the vignette effect is enabled.
  39460. */
  39461. /**
  39462. * Sets wether the vignette effect is enabled.
  39463. */
  39464. vignetteEnabled: boolean;
  39465. private _fromLinearSpace;
  39466. /**
  39467. * Gets wether the input of the processing is in Gamma or Linear Space.
  39468. */
  39469. /**
  39470. * Sets wether the input of the processing is in Gamma or Linear Space.
  39471. */
  39472. fromLinearSpace: boolean;
  39473. /**
  39474. * Defines cache preventing GC.
  39475. */
  39476. private _defines;
  39477. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39478. /**
  39479. * "ImageProcessingPostProcess"
  39480. * @returns "ImageProcessingPostProcess"
  39481. */
  39482. getClassName(): string;
  39483. protected _updateParameters(): void;
  39484. dispose(camera?: Camera): void;
  39485. }
  39486. }
  39487. declare module BABYLON {
  39488. /**
  39489. * Class containing static functions to help procedurally build meshes
  39490. */
  39491. export class GroundBuilder {
  39492. /**
  39493. * Creates a ground mesh
  39494. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39495. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39497. * @param name defines the name of the mesh
  39498. * @param options defines the options used to create the mesh
  39499. * @param scene defines the hosting scene
  39500. * @returns the ground mesh
  39501. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39502. */
  39503. static CreateGround(name: string, options: {
  39504. width?: number;
  39505. height?: number;
  39506. subdivisions?: number;
  39507. subdivisionsX?: number;
  39508. subdivisionsY?: number;
  39509. updatable?: boolean;
  39510. }, scene: any): Mesh;
  39511. /**
  39512. * Creates a tiled ground mesh
  39513. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39514. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39515. * * 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
  39516. * * 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
  39517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39518. * @param name defines the name of the mesh
  39519. * @param options defines the options used to create the mesh
  39520. * @param scene defines the hosting scene
  39521. * @returns the tiled ground mesh
  39522. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39523. */
  39524. static CreateTiledGround(name: string, options: {
  39525. xmin: number;
  39526. zmin: number;
  39527. xmax: number;
  39528. zmax: number;
  39529. subdivisions?: {
  39530. w: number;
  39531. h: number;
  39532. };
  39533. precision?: {
  39534. w: number;
  39535. h: number;
  39536. };
  39537. updatable?: boolean;
  39538. }, scene?: Nullable<Scene>): Mesh;
  39539. /**
  39540. * Creates a ground mesh from a height map
  39541. * * The parameter `url` sets the URL of the height map image resource.
  39542. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39543. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39544. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39545. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39546. * * 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.
  39547. * * 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).
  39548. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39550. * @param name defines the name of the mesh
  39551. * @param url defines the url to the height map
  39552. * @param options defines the options used to create the mesh
  39553. * @param scene defines the hosting scene
  39554. * @returns the ground mesh
  39555. * @see https://doc.babylonjs.com/babylon101/height_map
  39556. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39557. */
  39558. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39559. width?: number;
  39560. height?: number;
  39561. subdivisions?: number;
  39562. minHeight?: number;
  39563. maxHeight?: number;
  39564. colorFilter?: Color3;
  39565. alphaFilter?: number;
  39566. updatable?: boolean;
  39567. onReady?: (mesh: GroundMesh) => void;
  39568. }, scene?: Nullable<Scene>): GroundMesh;
  39569. }
  39570. }
  39571. declare module BABYLON {
  39572. /**
  39573. * Class containing static functions to help procedurally build meshes
  39574. */
  39575. export class TorusBuilder {
  39576. /**
  39577. * Creates a torus mesh
  39578. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39579. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39580. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39582. * * 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
  39583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39584. * @param name defines the name of the mesh
  39585. * @param options defines the options used to create the mesh
  39586. * @param scene defines the hosting scene
  39587. * @returns the torus mesh
  39588. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39589. */
  39590. static CreateTorus(name: string, options: {
  39591. diameter?: number;
  39592. thickness?: number;
  39593. tessellation?: number;
  39594. updatable?: boolean;
  39595. sideOrientation?: number;
  39596. frontUVs?: Vector4;
  39597. backUVs?: Vector4;
  39598. }, scene: any): Mesh;
  39599. }
  39600. }
  39601. declare module BABYLON {
  39602. /**
  39603. * Class containing static functions to help procedurally build meshes
  39604. */
  39605. export class CylinderBuilder {
  39606. /**
  39607. * Creates a cylinder or a cone mesh
  39608. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39609. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39610. * * 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.
  39611. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39612. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39613. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39614. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39615. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39616. * * 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).
  39617. * * 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
  39618. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39619. * * 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
  39620. * * 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.
  39621. * * If `enclose` is false, a ring surface is one element.
  39622. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39623. * * 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
  39624. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39625. * * 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
  39626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39627. * @param name defines the name of the mesh
  39628. * @param options defines the options used to create the mesh
  39629. * @param scene defines the hosting scene
  39630. * @returns the cylinder mesh
  39631. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39632. */
  39633. static CreateCylinder(name: string, options: {
  39634. height?: number;
  39635. diameterTop?: number;
  39636. diameterBottom?: number;
  39637. diameter?: number;
  39638. tessellation?: number;
  39639. subdivisions?: number;
  39640. arc?: number;
  39641. faceColors?: Color4[];
  39642. faceUV?: Vector4[];
  39643. updatable?: boolean;
  39644. hasRings?: boolean;
  39645. enclose?: boolean;
  39646. sideOrientation?: number;
  39647. frontUVs?: Vector4;
  39648. backUVs?: Vector4;
  39649. }, scene: any): Mesh;
  39650. }
  39651. }
  39652. declare module BABYLON {
  39653. /**
  39654. * Options to modify the vr teleportation behavior.
  39655. */
  39656. export interface VRTeleportationOptions {
  39657. /**
  39658. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39659. */
  39660. floorMeshName?: string;
  39661. /**
  39662. * A list of meshes to be used as the teleportation floor. (default: empty)
  39663. */
  39664. floorMeshes?: Mesh[];
  39665. }
  39666. /**
  39667. * Options to modify the vr experience helper's behavior.
  39668. */
  39669. export interface VRExperienceHelperOptions extends WebVROptions {
  39670. /**
  39671. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39672. */
  39673. createDeviceOrientationCamera?: boolean;
  39674. /**
  39675. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39676. */
  39677. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39678. /**
  39679. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39680. */
  39681. laserToggle?: boolean;
  39682. /**
  39683. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39684. */
  39685. floorMeshes?: Mesh[];
  39686. /**
  39687. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39688. */
  39689. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39690. }
  39691. /**
  39692. * Event containing information after VR has been entered
  39693. */
  39694. export class OnAfterEnteringVRObservableEvent {
  39695. /**
  39696. * If entering vr was successful
  39697. */
  39698. success: boolean;
  39699. }
  39700. /**
  39701. * Helps to quickly add VR support to an existing scene.
  39702. * See http://doc.babylonjs.com/how_to/webvr_helper
  39703. */
  39704. export class VRExperienceHelper {
  39705. /** Options to modify the vr experience helper's behavior. */
  39706. webVROptions: VRExperienceHelperOptions;
  39707. private _scene;
  39708. private _position;
  39709. private _btnVR;
  39710. private _btnVRDisplayed;
  39711. private _webVRsupported;
  39712. private _webVRready;
  39713. private _webVRrequesting;
  39714. private _webVRpresenting;
  39715. private _hasEnteredVR;
  39716. private _fullscreenVRpresenting;
  39717. private _canvas;
  39718. private _webVRCamera;
  39719. private _vrDeviceOrientationCamera;
  39720. private _deviceOrientationCamera;
  39721. private _existingCamera;
  39722. private _onKeyDown;
  39723. private _onVrDisplayPresentChange;
  39724. private _onVRDisplayChanged;
  39725. private _onVRRequestPresentStart;
  39726. private _onVRRequestPresentComplete;
  39727. /**
  39728. * Observable raised right before entering VR.
  39729. */
  39730. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39731. /**
  39732. * Observable raised when entering VR has completed.
  39733. */
  39734. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39735. /**
  39736. * Observable raised when exiting VR.
  39737. */
  39738. onExitingVRObservable: Observable<VRExperienceHelper>;
  39739. /**
  39740. * Observable raised when controller mesh is loaded.
  39741. */
  39742. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39743. /** Return this.onEnteringVRObservable
  39744. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39745. */
  39746. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39747. /** Return this.onExitingVRObservable
  39748. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39749. */
  39750. readonly onExitingVR: Observable<VRExperienceHelper>;
  39751. /** Return this.onControllerMeshLoadedObservable
  39752. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39753. */
  39754. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39755. private _rayLength;
  39756. private _useCustomVRButton;
  39757. private _teleportationRequested;
  39758. private _teleportActive;
  39759. private _floorMeshName;
  39760. private _floorMeshesCollection;
  39761. private _rotationAllowed;
  39762. private _teleportBackwardsVector;
  39763. private _teleportationTarget;
  39764. private _isDefaultTeleportationTarget;
  39765. private _postProcessMove;
  39766. private _teleportationFillColor;
  39767. private _teleportationBorderColor;
  39768. private _rotationAngle;
  39769. private _haloCenter;
  39770. private _cameraGazer;
  39771. private _padSensibilityUp;
  39772. private _padSensibilityDown;
  39773. private _leftController;
  39774. private _rightController;
  39775. /**
  39776. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39777. */
  39778. onNewMeshSelected: Observable<AbstractMesh>;
  39779. /**
  39780. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39781. */
  39782. onNewMeshPicked: Observable<PickingInfo>;
  39783. private _circleEase;
  39784. /**
  39785. * Observable raised before camera teleportation
  39786. */
  39787. onBeforeCameraTeleport: Observable<Vector3>;
  39788. /**
  39789. * Observable raised after camera teleportation
  39790. */
  39791. onAfterCameraTeleport: Observable<Vector3>;
  39792. /**
  39793. * Observable raised when current selected mesh gets unselected
  39794. */
  39795. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39796. private _raySelectionPredicate;
  39797. /**
  39798. * To be optionaly changed by user to define custom ray selection
  39799. */
  39800. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39801. /**
  39802. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39803. */
  39804. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39805. /**
  39806. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39807. */
  39808. teleportationEnabled: boolean;
  39809. private _defaultHeight;
  39810. private _teleportationInitialized;
  39811. private _interactionsEnabled;
  39812. private _interactionsRequested;
  39813. private _displayGaze;
  39814. private _displayLaserPointer;
  39815. /**
  39816. * The mesh used to display where the user is going to teleport.
  39817. */
  39818. /**
  39819. * Sets the mesh to be used to display where the user is going to teleport.
  39820. */
  39821. teleportationTarget: Mesh;
  39822. /**
  39823. * 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
  39824. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39825. * See http://doc.babylonjs.com/resources/baking_transformations
  39826. */
  39827. gazeTrackerMesh: Mesh;
  39828. /**
  39829. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39830. */
  39831. updateGazeTrackerScale: boolean;
  39832. /**
  39833. * If the gaze trackers color should be updated when selecting meshes
  39834. */
  39835. updateGazeTrackerColor: boolean;
  39836. /**
  39837. * The gaze tracking mesh corresponding to the left controller
  39838. */
  39839. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39840. /**
  39841. * The gaze tracking mesh corresponding to the right controller
  39842. */
  39843. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39844. /**
  39845. * If the ray of the gaze should be displayed.
  39846. */
  39847. /**
  39848. * Sets if the ray of the gaze should be displayed.
  39849. */
  39850. displayGaze: boolean;
  39851. /**
  39852. * If the ray of the LaserPointer should be displayed.
  39853. */
  39854. /**
  39855. * Sets if the ray of the LaserPointer should be displayed.
  39856. */
  39857. displayLaserPointer: boolean;
  39858. /**
  39859. * The deviceOrientationCamera used as the camera when not in VR.
  39860. */
  39861. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39862. /**
  39863. * Based on the current WebVR support, returns the current VR camera used.
  39864. */
  39865. readonly currentVRCamera: Nullable<Camera>;
  39866. /**
  39867. * The webVRCamera which is used when in VR.
  39868. */
  39869. readonly webVRCamera: WebVRFreeCamera;
  39870. /**
  39871. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39872. */
  39873. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39874. private readonly _teleportationRequestInitiated;
  39875. /**
  39876. * Defines wether or not Pointer lock should be requested when switching to
  39877. * full screen.
  39878. */
  39879. requestPointerLockOnFullScreen: boolean;
  39880. /**
  39881. * Instantiates a VRExperienceHelper.
  39882. * Helps to quickly add VR support to an existing scene.
  39883. * @param scene The scene the VRExperienceHelper belongs to.
  39884. * @param webVROptions Options to modify the vr experience helper's behavior.
  39885. */
  39886. constructor(scene: Scene,
  39887. /** Options to modify the vr experience helper's behavior. */
  39888. webVROptions?: VRExperienceHelperOptions);
  39889. private _onDefaultMeshLoaded;
  39890. private _onResize;
  39891. private _onFullscreenChange;
  39892. /**
  39893. * Gets a value indicating if we are currently in VR mode.
  39894. */
  39895. readonly isInVRMode: boolean;
  39896. private onVrDisplayPresentChange;
  39897. private onVRDisplayChanged;
  39898. private moveButtonToBottomRight;
  39899. private displayVRButton;
  39900. private updateButtonVisibility;
  39901. private _cachedAngularSensibility;
  39902. /**
  39903. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39904. * Otherwise, will use the fullscreen API.
  39905. */
  39906. enterVR(): void;
  39907. /**
  39908. * Attempt to exit VR, or fullscreen.
  39909. */
  39910. exitVR(): void;
  39911. /**
  39912. * The position of the vr experience helper.
  39913. */
  39914. /**
  39915. * Sets the position of the vr experience helper.
  39916. */
  39917. position: Vector3;
  39918. /**
  39919. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39920. */
  39921. enableInteractions(): void;
  39922. private readonly _noControllerIsActive;
  39923. private beforeRender;
  39924. private _isTeleportationFloor;
  39925. /**
  39926. * Adds a floor mesh to be used for teleportation.
  39927. * @param floorMesh the mesh to be used for teleportation.
  39928. */
  39929. addFloorMesh(floorMesh: Mesh): void;
  39930. /**
  39931. * Removes a floor mesh from being used for teleportation.
  39932. * @param floorMesh the mesh to be removed.
  39933. */
  39934. removeFloorMesh(floorMesh: Mesh): void;
  39935. /**
  39936. * Enables interactions and teleportation using the VR controllers and gaze.
  39937. * @param vrTeleportationOptions options to modify teleportation behavior.
  39938. */
  39939. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39940. private _onNewGamepadConnected;
  39941. private _tryEnableInteractionOnController;
  39942. private _onNewGamepadDisconnected;
  39943. private _enableInteractionOnController;
  39944. private _checkTeleportWithRay;
  39945. private _checkRotate;
  39946. private _checkTeleportBackwards;
  39947. private _enableTeleportationOnController;
  39948. private _createTeleportationCircles;
  39949. private _displayTeleportationTarget;
  39950. private _hideTeleportationTarget;
  39951. private _rotateCamera;
  39952. private _moveTeleportationSelectorTo;
  39953. private _workingVector;
  39954. private _workingQuaternion;
  39955. private _workingMatrix;
  39956. /**
  39957. * Teleports the users feet to the desired location
  39958. * @param location The location where the user's feet should be placed
  39959. */
  39960. teleportCamera(location: Vector3): void;
  39961. private _convertNormalToDirectionOfRay;
  39962. private _castRayAndSelectObject;
  39963. private _notifySelectedMeshUnselected;
  39964. /**
  39965. * Sets the color of the laser ray from the vr controllers.
  39966. * @param color new color for the ray.
  39967. */
  39968. changeLaserColor(color: Color3): void;
  39969. /**
  39970. * Sets the color of the ray from the vr headsets gaze.
  39971. * @param color new color for the ray.
  39972. */
  39973. changeGazeColor(color: Color3): void;
  39974. /**
  39975. * Exits VR and disposes of the vr experience helper
  39976. */
  39977. dispose(): void;
  39978. /**
  39979. * Gets the name of the VRExperienceHelper class
  39980. * @returns "VRExperienceHelper"
  39981. */
  39982. getClassName(): string;
  39983. }
  39984. }
  39985. declare module BABYLON {
  39986. /**
  39987. * Manages an XRSession
  39988. * @see https://doc.babylonjs.com/how_to/webxr
  39989. */
  39990. export class WebXRSessionManager implements IDisposable {
  39991. private scene;
  39992. /**
  39993. * Fires every time a new xrFrame arrives which can be used to update the camera
  39994. */
  39995. onXRFrameObservable: Observable<any>;
  39996. /**
  39997. * Fires when the xr session is ended either by the device or manually done
  39998. */
  39999. onXRSessionEnded: Observable<any>;
  40000. /** @hidden */
  40001. _xrSession: XRSession;
  40002. /** @hidden */
  40003. _frameOfReference: XRFrameOfReference;
  40004. /** @hidden */
  40005. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40006. /** @hidden */
  40007. _currentXRFrame: Nullable<XRFrame>;
  40008. private _xrNavigator;
  40009. private _xrDevice;
  40010. private _tmpMatrix;
  40011. /**
  40012. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40013. * @param scene The scene which the session should be created for
  40014. */
  40015. constructor(scene: Scene);
  40016. /**
  40017. * Initializes the manager
  40018. * After initialization enterXR can be called to start an XR session
  40019. * @returns Promise which resolves after it is initialized
  40020. */
  40021. initializeAsync(): Promise<void>;
  40022. /**
  40023. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  40024. * @param sessionCreationOptions xr options to create the session with
  40025. * @param frameOfReferenceType option to configure how the xr pose is expressed
  40026. * @returns Promise which resolves after it enters XR
  40027. */
  40028. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  40029. /**
  40030. * Stops the xrSession and restores the renderloop
  40031. * @returns Promise which resolves after it exits XR
  40032. */
  40033. exitXRAsync(): Promise<void>;
  40034. /**
  40035. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40036. * @param ray ray to cast into the environment
  40037. * @returns Promise which resolves with a collision point in the environment if it exists
  40038. */
  40039. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40040. /**
  40041. * Checks if a session would be supported for the creation options specified
  40042. * @param options creation options to check if they are supported
  40043. * @returns true if supported
  40044. */
  40045. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40046. /**
  40047. * @hidden
  40048. * Converts the render layer of xrSession to a render target
  40049. * @param session session to create render target for
  40050. * @param scene scene the new render target should be created for
  40051. */
  40052. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  40053. /**
  40054. * Disposes of the session manager
  40055. */
  40056. dispose(): void;
  40057. }
  40058. }
  40059. declare module BABYLON {
  40060. /**
  40061. * WebXR Camera which holds the views for the xrSession
  40062. * @see https://doc.babylonjs.com/how_to/webxr
  40063. */
  40064. export class WebXRCamera extends FreeCamera {
  40065. private static _TmpMatrix;
  40066. /**
  40067. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40068. * @param name the name of the camera
  40069. * @param scene the scene to add the camera to
  40070. */
  40071. constructor(name: string, scene: Scene);
  40072. private _updateNumberOfRigCameras;
  40073. /** @hidden */
  40074. _updateForDualEyeDebugging(pupilDistance?: number): void;
  40075. /**
  40076. * Updates the cameras position from the current pose information of the XR session
  40077. * @param xrSessionManager the session containing pose information
  40078. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40079. */
  40080. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40081. }
  40082. }
  40083. declare module BABYLON {
  40084. /**
  40085. * States of the webXR experience
  40086. */
  40087. export enum WebXRState {
  40088. /**
  40089. * Transitioning to being in XR mode
  40090. */
  40091. ENTERING_XR = 0,
  40092. /**
  40093. * Transitioning to non XR mode
  40094. */
  40095. EXITING_XR = 1,
  40096. /**
  40097. * In XR mode and presenting
  40098. */
  40099. IN_XR = 2,
  40100. /**
  40101. * Not entered XR mode
  40102. */
  40103. NOT_IN_XR = 3
  40104. }
  40105. /**
  40106. * Helper class used to enable XR
  40107. * @see https://doc.babylonjs.com/how_to/webxr
  40108. */
  40109. export class WebXRExperienceHelper implements IDisposable {
  40110. private scene;
  40111. /**
  40112. * 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
  40113. */
  40114. container: AbstractMesh;
  40115. /**
  40116. * Camera used to render xr content
  40117. */
  40118. camera: WebXRCamera;
  40119. /**
  40120. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40121. */
  40122. state: WebXRState;
  40123. private _setState;
  40124. private static _TmpVector;
  40125. /**
  40126. * Fires when the state of the experience helper has changed
  40127. */
  40128. onStateChangedObservable: Observable<WebXRState>;
  40129. /** @hidden */
  40130. _sessionManager: WebXRSessionManager;
  40131. private _nonVRCamera;
  40132. private _originalSceneAutoClear;
  40133. private _supported;
  40134. /**
  40135. * Creates the experience helper
  40136. * @param scene the scene to attach the experience helper to
  40137. * @returns a promise for the experience helper
  40138. */
  40139. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40140. /**
  40141. * Creates a WebXRExperienceHelper
  40142. * @param scene The scene the helper should be created in
  40143. */
  40144. private constructor();
  40145. /**
  40146. * Exits XR mode and returns the scene to its original state
  40147. * @returns promise that resolves after xr mode has exited
  40148. */
  40149. exitXRAsync(): Promise<void>;
  40150. /**
  40151. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40152. * @param sessionCreationOptions options for the XR session
  40153. * @param frameOfReference frame of reference of the XR session
  40154. * @returns promise that resolves after xr mode has entered
  40155. */
  40156. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  40157. /**
  40158. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  40159. * @param ray ray to cast into the environment
  40160. * @returns Promise which resolves with a collision point in the environment if it exists
  40161. */
  40162. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  40163. /**
  40164. * Updates the global position of the camera by moving the camera's container
  40165. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40166. * @param position The desired global position of the camera
  40167. */
  40168. setPositionOfCameraUsingContainer(position: Vector3): void;
  40169. /**
  40170. * Rotates the xr camera by rotating the camera's container around the camera's position
  40171. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40172. * @param rotation the desired quaternion rotation to apply to the camera
  40173. */
  40174. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40175. /**
  40176. * Checks if the creation options are supported by the xr session
  40177. * @param options creation options
  40178. * @returns true if supported
  40179. */
  40180. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  40181. /**
  40182. * Disposes of the experience helper
  40183. */
  40184. dispose(): void;
  40185. }
  40186. }
  40187. declare module BABYLON {
  40188. /**
  40189. * Button which can be used to enter a different mode of XR
  40190. */
  40191. export class WebXREnterExitUIButton {
  40192. /** button element */
  40193. element: HTMLElement;
  40194. /** XR initialization options for the button */
  40195. initializationOptions: XRSessionCreationOptions;
  40196. /**
  40197. * Creates a WebXREnterExitUIButton
  40198. * @param element button element
  40199. * @param initializationOptions XR initialization options for the button
  40200. */
  40201. constructor(
  40202. /** button element */
  40203. element: HTMLElement,
  40204. /** XR initialization options for the button */
  40205. initializationOptions: XRSessionCreationOptions);
  40206. /**
  40207. * Overwritable function which can be used to update the button's visuals when the state changes
  40208. * @param activeButton the current active button in the UI
  40209. */
  40210. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40211. }
  40212. /**
  40213. * Options to create the webXR UI
  40214. */
  40215. export class WebXREnterExitUIOptions {
  40216. /**
  40217. * Context to enter xr with
  40218. */
  40219. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  40220. /**
  40221. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40222. */
  40223. customButtons?: Array<WebXREnterExitUIButton>;
  40224. }
  40225. /**
  40226. * UI to allow the user to enter/exit XR mode
  40227. */
  40228. export class WebXREnterExitUI implements IDisposable {
  40229. private scene;
  40230. private _overlay;
  40231. private _buttons;
  40232. private _activeButton;
  40233. /**
  40234. * Fired every time the active button is changed.
  40235. *
  40236. * When xr is entered via a button that launches xr that button will be the callback parameter
  40237. *
  40238. * When exiting xr the callback parameter will be null)
  40239. */
  40240. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40241. /**
  40242. * Creates UI to allow the user to enter/exit XR mode
  40243. * @param scene the scene to add the ui to
  40244. * @param helper the xr experience helper to enter/exit xr with
  40245. * @param options options to configure the UI
  40246. * @returns the created ui
  40247. */
  40248. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40249. private constructor();
  40250. private _updateButtons;
  40251. /**
  40252. * Disposes of the object
  40253. */
  40254. dispose(): void;
  40255. }
  40256. }
  40257. declare module BABYLON {
  40258. /**
  40259. * Represents an XR input
  40260. */
  40261. export class WebXRController {
  40262. /**
  40263. * 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
  40264. */
  40265. grip?: AbstractMesh;
  40266. /**
  40267. * Pointer which can be used to select objects or attach a visible laser to
  40268. */
  40269. pointer: AbstractMesh;
  40270. /**
  40271. * Creates the controller
  40272. * @see https://doc.babylonjs.com/how_to/webxr
  40273. * @param scene the scene which the controller should be associated to
  40274. */
  40275. constructor(scene: Scene);
  40276. /**
  40277. * Disposes of the object
  40278. */
  40279. dispose(): void;
  40280. }
  40281. /**
  40282. * XR input used to track XR inputs such as controllers/rays
  40283. */
  40284. export class WebXRInput implements IDisposable {
  40285. private helper;
  40286. /**
  40287. * XR controllers being tracked
  40288. */
  40289. controllers: Array<WebXRController>;
  40290. private _tmpMatrix;
  40291. private _frameObserver;
  40292. /**
  40293. * Initializes the WebXRInput
  40294. * @param helper experience helper which the input should be created for
  40295. */
  40296. constructor(helper: WebXRExperienceHelper);
  40297. /**
  40298. * Disposes of the object
  40299. */
  40300. dispose(): void;
  40301. }
  40302. }
  40303. declare module BABYLON {
  40304. /**
  40305. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40306. */
  40307. export class WebXRManagedOutputCanvas implements IDisposable {
  40308. private _canvas;
  40309. /**
  40310. * xrpresent context of the canvas which can be used to display/mirror xr content
  40311. */
  40312. canvasContext: Nullable<WebGLRenderingContext>;
  40313. /**
  40314. * Initializes the canvas to be added/removed upon entering/exiting xr
  40315. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40316. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40317. */
  40318. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40319. /**
  40320. * Disposes of the object
  40321. */
  40322. dispose(): void;
  40323. private _setManagedOutputCanvas;
  40324. private _addCanvas;
  40325. private _removeCanvas;
  40326. }
  40327. }
  40328. declare module BABYLON {
  40329. /**
  40330. * Contains an array of blocks representing the octree
  40331. */
  40332. export interface IOctreeContainer<T> {
  40333. /**
  40334. * Blocks within the octree
  40335. */
  40336. blocks: Array<OctreeBlock<T>>;
  40337. }
  40338. /**
  40339. * Class used to store a cell in an octree
  40340. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40341. */
  40342. export class OctreeBlock<T> {
  40343. /**
  40344. * Gets the content of the current block
  40345. */
  40346. entries: T[];
  40347. /**
  40348. * Gets the list of block children
  40349. */
  40350. blocks: Array<OctreeBlock<T>>;
  40351. private _depth;
  40352. private _maxDepth;
  40353. private _capacity;
  40354. private _minPoint;
  40355. private _maxPoint;
  40356. private _boundingVectors;
  40357. private _creationFunc;
  40358. /**
  40359. * Creates a new block
  40360. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40361. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40362. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40363. * @param depth defines the current depth of this block in the octree
  40364. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40365. * @param creationFunc defines a callback to call when an element is added to the block
  40366. */
  40367. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40368. /**
  40369. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40370. */
  40371. readonly capacity: number;
  40372. /**
  40373. * Gets the minimum vector (in world space) of the block's bounding box
  40374. */
  40375. readonly minPoint: Vector3;
  40376. /**
  40377. * Gets the maximum vector (in world space) of the block's bounding box
  40378. */
  40379. readonly maxPoint: Vector3;
  40380. /**
  40381. * Add a new element to this block
  40382. * @param entry defines the element to add
  40383. */
  40384. addEntry(entry: T): void;
  40385. /**
  40386. * Remove an element from this block
  40387. * @param entry defines the element to remove
  40388. */
  40389. removeEntry(entry: T): void;
  40390. /**
  40391. * Add an array of elements to this block
  40392. * @param entries defines the array of elements to add
  40393. */
  40394. addEntries(entries: T[]): void;
  40395. /**
  40396. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40397. * @param frustumPlanes defines the frustum planes to test
  40398. * @param selection defines the array to store current content if selection is positive
  40399. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40400. */
  40401. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40402. /**
  40403. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40404. * @param sphereCenter defines the bounding sphere center
  40405. * @param sphereRadius defines the bounding sphere radius
  40406. * @param selection defines the array to store current content if selection is positive
  40407. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40408. */
  40409. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40410. /**
  40411. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40412. * @param ray defines the ray to test with
  40413. * @param selection defines the array to store current content if selection is positive
  40414. */
  40415. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40416. /**
  40417. * Subdivide the content into child blocks (this block will then be empty)
  40418. */
  40419. createInnerBlocks(): void;
  40420. /**
  40421. * @hidden
  40422. */
  40423. 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;
  40424. }
  40425. }
  40426. declare module BABYLON {
  40427. /**
  40428. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40429. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40430. */
  40431. export class Octree<T> {
  40432. /** 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.) */
  40433. maxDepth: number;
  40434. /**
  40435. * Blocks within the octree containing objects
  40436. */
  40437. blocks: Array<OctreeBlock<T>>;
  40438. /**
  40439. * Content stored in the octree
  40440. */
  40441. dynamicContent: T[];
  40442. private _maxBlockCapacity;
  40443. private _selectionContent;
  40444. private _creationFunc;
  40445. /**
  40446. * Creates a octree
  40447. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40448. * @param creationFunc function to be used to instatiate the octree
  40449. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40450. * @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.)
  40451. */
  40452. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40453. /** 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.) */
  40454. maxDepth?: number);
  40455. /**
  40456. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40457. * @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);
  40458. * @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);
  40459. * @param entries meshes to be added to the octree blocks
  40460. */
  40461. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40462. /**
  40463. * Adds a mesh to the octree
  40464. * @param entry Mesh to add to the octree
  40465. */
  40466. addMesh(entry: T): void;
  40467. /**
  40468. * Remove an element from the octree
  40469. * @param entry defines the element to remove
  40470. */
  40471. removeMesh(entry: T): void;
  40472. /**
  40473. * Selects an array of meshes within the frustum
  40474. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40475. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40476. * @returns array of meshes within the frustum
  40477. */
  40478. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40479. /**
  40480. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40481. * @param sphereCenter defines the bounding sphere center
  40482. * @param sphereRadius defines the bounding sphere radius
  40483. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40484. * @returns an array of objects that intersect the sphere
  40485. */
  40486. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40487. /**
  40488. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40489. * @param ray defines the ray to test with
  40490. * @returns array of intersected objects
  40491. */
  40492. intersectsRay(ray: Ray): SmartArray<T>;
  40493. /**
  40494. * Adds a mesh into the octree block if it intersects the block
  40495. */
  40496. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40497. /**
  40498. * Adds a submesh into the octree block if it intersects the block
  40499. */
  40500. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40501. }
  40502. }
  40503. declare module BABYLON {
  40504. interface Scene {
  40505. /**
  40506. * @hidden
  40507. * Backing Filed
  40508. */
  40509. _selectionOctree: Octree<AbstractMesh>;
  40510. /**
  40511. * Gets the octree used to boost mesh selection (picking)
  40512. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40513. */
  40514. selectionOctree: Octree<AbstractMesh>;
  40515. /**
  40516. * Creates or updates the octree used to boost selection (picking)
  40517. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40518. * @param maxCapacity defines the maximum capacity per leaf
  40519. * @param maxDepth defines the maximum depth of the octree
  40520. * @returns an octree of AbstractMesh
  40521. */
  40522. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40523. }
  40524. interface AbstractMesh {
  40525. /**
  40526. * @hidden
  40527. * Backing Field
  40528. */
  40529. _submeshesOctree: Octree<SubMesh>;
  40530. /**
  40531. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40532. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40533. * @param maxCapacity defines the maximum size of each block (64 by default)
  40534. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40535. * @returns the new octree
  40536. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40537. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40538. */
  40539. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40540. }
  40541. /**
  40542. * Defines the octree scene component responsible to manage any octrees
  40543. * in a given scene.
  40544. */
  40545. export class OctreeSceneComponent {
  40546. /**
  40547. * The component name help to identify the component in the list of scene components.
  40548. */
  40549. readonly name: string;
  40550. /**
  40551. * The scene the component belongs to.
  40552. */
  40553. scene: Scene;
  40554. /**
  40555. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40556. */
  40557. readonly checksIsEnabled: boolean;
  40558. /**
  40559. * Creates a new instance of the component for the given scene
  40560. * @param scene Defines the scene to register the component in
  40561. */
  40562. constructor(scene: Scene);
  40563. /**
  40564. * Registers the component in a given scene
  40565. */
  40566. register(): void;
  40567. /**
  40568. * Return the list of active meshes
  40569. * @returns the list of active meshes
  40570. */
  40571. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40572. /**
  40573. * Return the list of active sub meshes
  40574. * @param mesh The mesh to get the candidates sub meshes from
  40575. * @returns the list of active sub meshes
  40576. */
  40577. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40578. private _tempRay;
  40579. /**
  40580. * Return the list of sub meshes intersecting with a given local ray
  40581. * @param mesh defines the mesh to find the submesh for
  40582. * @param localRay defines the ray in local space
  40583. * @returns the list of intersecting sub meshes
  40584. */
  40585. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40586. /**
  40587. * Return the list of sub meshes colliding with a collider
  40588. * @param mesh defines the mesh to find the submesh for
  40589. * @param collider defines the collider to evaluate the collision against
  40590. * @returns the list of colliding sub meshes
  40591. */
  40592. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40593. /**
  40594. * Rebuilds the elements related to this component in case of
  40595. * context lost for instance.
  40596. */
  40597. rebuild(): void;
  40598. /**
  40599. * Disposes the component and the associated ressources.
  40600. */
  40601. dispose(): void;
  40602. }
  40603. }
  40604. declare module BABYLON {
  40605. /**
  40606. * Renders a layer on top of an existing scene
  40607. */
  40608. export class UtilityLayerRenderer implements IDisposable {
  40609. /** the original scene that will be rendered on top of */
  40610. originalScene: Scene;
  40611. private _pointerCaptures;
  40612. private _lastPointerEvents;
  40613. private static _DefaultUtilityLayer;
  40614. private static _DefaultKeepDepthUtilityLayer;
  40615. private _sharedGizmoLight;
  40616. /**
  40617. * @hidden
  40618. * Light which used by gizmos to get light shading
  40619. */
  40620. _getSharedGizmoLight(): HemisphericLight;
  40621. /**
  40622. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40623. */
  40624. pickUtilitySceneFirst: boolean;
  40625. /**
  40626. * 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)
  40627. */
  40628. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40629. /**
  40630. * 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)
  40631. */
  40632. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40633. /**
  40634. * The scene that is rendered on top of the original scene
  40635. */
  40636. utilityLayerScene: Scene;
  40637. /**
  40638. * If the utility layer should automatically be rendered on top of existing scene
  40639. */
  40640. shouldRender: boolean;
  40641. /**
  40642. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40643. */
  40644. onlyCheckPointerDownEvents: boolean;
  40645. /**
  40646. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40647. */
  40648. processAllEvents: boolean;
  40649. /**
  40650. * Observable raised when the pointer move from the utility layer scene to the main scene
  40651. */
  40652. onPointerOutObservable: Observable<number>;
  40653. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40654. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40655. private _afterRenderObserver;
  40656. private _sceneDisposeObserver;
  40657. private _originalPointerObserver;
  40658. /**
  40659. * Instantiates a UtilityLayerRenderer
  40660. * @param originalScene the original scene that will be rendered on top of
  40661. * @param handleEvents boolean indicating if the utility layer should handle events
  40662. */
  40663. constructor(
  40664. /** the original scene that will be rendered on top of */
  40665. originalScene: Scene, handleEvents?: boolean);
  40666. private _notifyObservers;
  40667. /**
  40668. * Renders the utility layers scene on top of the original scene
  40669. */
  40670. render(): void;
  40671. /**
  40672. * Disposes of the renderer
  40673. */
  40674. dispose(): void;
  40675. private _updateCamera;
  40676. }
  40677. }
  40678. declare module BABYLON {
  40679. /**
  40680. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40681. */
  40682. export class Gizmo implements IDisposable {
  40683. /** The utility layer the gizmo will be added to */
  40684. gizmoLayer: UtilityLayerRenderer;
  40685. /**
  40686. * The root mesh of the gizmo
  40687. */
  40688. _rootMesh: Mesh;
  40689. private _attachedMesh;
  40690. /**
  40691. * Ratio for the scale of the gizmo (Default: 1)
  40692. */
  40693. scaleRatio: number;
  40694. /**
  40695. * If a custom mesh has been set (Default: false)
  40696. */
  40697. protected _customMeshSet: boolean;
  40698. /**
  40699. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40700. * * When set, interactions will be enabled
  40701. */
  40702. attachedMesh: Nullable<AbstractMesh>;
  40703. /**
  40704. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40705. * @param mesh The mesh to replace the default mesh of the gizmo
  40706. */
  40707. setCustomMesh(mesh: Mesh): void;
  40708. /**
  40709. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40710. */
  40711. updateGizmoRotationToMatchAttachedMesh: boolean;
  40712. /**
  40713. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40714. */
  40715. updateGizmoPositionToMatchAttachedMesh: boolean;
  40716. /**
  40717. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40718. */
  40719. protected _updateScale: boolean;
  40720. protected _interactionsEnabled: boolean;
  40721. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40722. private _beforeRenderObserver;
  40723. private _tempVector;
  40724. /**
  40725. * Creates a gizmo
  40726. * @param gizmoLayer The utility layer the gizmo will be added to
  40727. */
  40728. constructor(
  40729. /** The utility layer the gizmo will be added to */
  40730. gizmoLayer?: UtilityLayerRenderer);
  40731. /**
  40732. * Updates the gizmo to match the attached mesh's position/rotation
  40733. */
  40734. protected _update(): void;
  40735. /**
  40736. * Disposes of the gizmo
  40737. */
  40738. dispose(): void;
  40739. }
  40740. }
  40741. declare module BABYLON {
  40742. /**
  40743. * Single axis drag gizmo
  40744. */
  40745. export class AxisDragGizmo extends Gizmo {
  40746. /**
  40747. * Drag behavior responsible for the gizmos dragging interactions
  40748. */
  40749. dragBehavior: PointerDragBehavior;
  40750. private _pointerObserver;
  40751. /**
  40752. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40753. */
  40754. snapDistance: number;
  40755. /**
  40756. * Event that fires each time the gizmo snaps to a new location.
  40757. * * snapDistance is the the change in distance
  40758. */
  40759. onSnapObservable: Observable<{
  40760. snapDistance: number;
  40761. }>;
  40762. /** @hidden */
  40763. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40764. /** @hidden */
  40765. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40766. /**
  40767. * Creates an AxisDragGizmo
  40768. * @param gizmoLayer The utility layer the gizmo will be added to
  40769. * @param dragAxis The axis which the gizmo will be able to drag on
  40770. * @param color The color of the gizmo
  40771. */
  40772. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40773. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40774. /**
  40775. * Disposes of the gizmo
  40776. */
  40777. dispose(): void;
  40778. }
  40779. }
  40780. declare module BABYLON.Debug {
  40781. /**
  40782. * The Axes viewer will show 3 axes in a specific point in space
  40783. */
  40784. export class AxesViewer {
  40785. private _xAxis;
  40786. private _yAxis;
  40787. private _zAxis;
  40788. private _scaleLinesFactor;
  40789. private _instanced;
  40790. /**
  40791. * Gets the hosting scene
  40792. */
  40793. scene: Scene;
  40794. /**
  40795. * Gets or sets a number used to scale line length
  40796. */
  40797. scaleLines: number;
  40798. /** Gets the node hierarchy used to render x-axis */
  40799. readonly xAxis: TransformNode;
  40800. /** Gets the node hierarchy used to render y-axis */
  40801. readonly yAxis: TransformNode;
  40802. /** Gets the node hierarchy used to render z-axis */
  40803. readonly zAxis: TransformNode;
  40804. /**
  40805. * Creates a new AxesViewer
  40806. * @param scene defines the hosting scene
  40807. * @param scaleLines defines a number used to scale line length (1 by default)
  40808. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40809. * @param xAxis defines the node hierarchy used to render the x-axis
  40810. * @param yAxis defines the node hierarchy used to render the y-axis
  40811. * @param zAxis defines the node hierarchy used to render the z-axis
  40812. */
  40813. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40814. /**
  40815. * Force the viewer to update
  40816. * @param position defines the position of the viewer
  40817. * @param xaxis defines the x axis of the viewer
  40818. * @param yaxis defines the y axis of the viewer
  40819. * @param zaxis defines the z axis of the viewer
  40820. */
  40821. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40822. /**
  40823. * Creates an instance of this axes viewer.
  40824. * @returns a new axes viewer with instanced meshes
  40825. */
  40826. createInstance(): AxesViewer;
  40827. /** Releases resources */
  40828. dispose(): void;
  40829. private static _SetRenderingGroupId;
  40830. }
  40831. }
  40832. declare module BABYLON.Debug {
  40833. /**
  40834. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40835. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40836. */
  40837. export class BoneAxesViewer extends AxesViewer {
  40838. /**
  40839. * Gets or sets the target mesh where to display the axes viewer
  40840. */
  40841. mesh: Nullable<Mesh>;
  40842. /**
  40843. * Gets or sets the target bone where to display the axes viewer
  40844. */
  40845. bone: Nullable<Bone>;
  40846. /** Gets current position */
  40847. pos: Vector3;
  40848. /** Gets direction of X axis */
  40849. xaxis: Vector3;
  40850. /** Gets direction of Y axis */
  40851. yaxis: Vector3;
  40852. /** Gets direction of Z axis */
  40853. zaxis: Vector3;
  40854. /**
  40855. * Creates a new BoneAxesViewer
  40856. * @param scene defines the hosting scene
  40857. * @param bone defines the target bone
  40858. * @param mesh defines the target mesh
  40859. * @param scaleLines defines a scaling factor for line length (1 by default)
  40860. */
  40861. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40862. /**
  40863. * Force the viewer to update
  40864. */
  40865. update(): void;
  40866. /** Releases resources */
  40867. dispose(): void;
  40868. }
  40869. }
  40870. declare module BABYLON {
  40871. /**
  40872. * Interface used to define scene explorer extensibility option
  40873. */
  40874. export interface IExplorerExtensibilityOption {
  40875. /**
  40876. * Define the option label
  40877. */
  40878. label: string;
  40879. /**
  40880. * Defines the action to execute on click
  40881. */
  40882. action: (entity: any) => void;
  40883. }
  40884. /**
  40885. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40886. */
  40887. export interface IExplorerExtensibilityGroup {
  40888. /**
  40889. * Defines a predicate to test if a given type mut be extended
  40890. */
  40891. predicate: (entity: any) => boolean;
  40892. /**
  40893. * Gets the list of options added to a type
  40894. */
  40895. entries: IExplorerExtensibilityOption[];
  40896. }
  40897. /**
  40898. * Interface used to define the options to use to create the Inspector
  40899. */
  40900. export interface IInspectorOptions {
  40901. /**
  40902. * Display in overlay mode (default: false)
  40903. */
  40904. overlay?: boolean;
  40905. /**
  40906. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40907. */
  40908. globalRoot?: HTMLElement;
  40909. /**
  40910. * Display the Scene explorer
  40911. */
  40912. showExplorer?: boolean;
  40913. /**
  40914. * Display the property inspector
  40915. */
  40916. showInspector?: boolean;
  40917. /**
  40918. * Display in embed mode (both panes on the right)
  40919. */
  40920. embedMode?: boolean;
  40921. /**
  40922. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40923. */
  40924. handleResize?: boolean;
  40925. /**
  40926. * Allow the panes to popup (default: true)
  40927. */
  40928. enablePopup?: boolean;
  40929. /**
  40930. * Allow the panes to be closed by users (default: true)
  40931. */
  40932. enableClose?: boolean;
  40933. /**
  40934. * Optional list of extensibility entries
  40935. */
  40936. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40937. /**
  40938. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40939. */
  40940. inspectorURL?: string;
  40941. }
  40942. interface Scene {
  40943. /**
  40944. * @hidden
  40945. * Backing field
  40946. */
  40947. _debugLayer: DebugLayer;
  40948. /**
  40949. * Gets the debug layer (aka Inspector) associated with the scene
  40950. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40951. */
  40952. debugLayer: DebugLayer;
  40953. }
  40954. /**
  40955. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40956. * what is happening in your scene
  40957. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40958. */
  40959. export class DebugLayer {
  40960. /**
  40961. * Define the url to get the inspector script from.
  40962. * By default it uses the babylonjs CDN.
  40963. * @ignoreNaming
  40964. */
  40965. static InspectorURL: string;
  40966. private _scene;
  40967. private BJSINSPECTOR;
  40968. /**
  40969. * Observable triggered when a property is changed through the inspector.
  40970. */
  40971. onPropertyChangedObservable: Observable<{
  40972. object: any;
  40973. property: string;
  40974. value: any;
  40975. initialValue: any;
  40976. }>;
  40977. /**
  40978. * Instantiates a new debug layer.
  40979. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40980. * what is happening in your scene
  40981. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40982. * @param scene Defines the scene to inspect
  40983. */
  40984. constructor(scene: Scene);
  40985. /** Creates the inspector window. */
  40986. private _createInspector;
  40987. /**
  40988. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40989. * @param entity defines the entity to select
  40990. * @param lineContainerTitle defines the specific block to highlight
  40991. */
  40992. select(entity: any, lineContainerTitle?: string): void;
  40993. /** Get the inspector from bundle or global */
  40994. private _getGlobalInspector;
  40995. /**
  40996. * Get if the inspector is visible or not.
  40997. * @returns true if visible otherwise, false
  40998. */
  40999. isVisible(): boolean;
  41000. /**
  41001. * Hide the inspector and close its window.
  41002. */
  41003. hide(): void;
  41004. /**
  41005. * Launch the debugLayer.
  41006. * @param config Define the configuration of the inspector
  41007. * @return a promise fulfilled when the debug layer is visible
  41008. */
  41009. show(config?: IInspectorOptions): Promise<DebugLayer>;
  41010. }
  41011. }
  41012. declare module BABYLON {
  41013. /**
  41014. * Class containing static functions to help procedurally build meshes
  41015. */
  41016. export class BoxBuilder {
  41017. /**
  41018. * Creates a box mesh
  41019. * * The parameter `size` sets the size (float) of each box side (default 1)
  41020. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  41021. * * 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)
  41022. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  41023. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41024. * * 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
  41025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41026. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  41027. * @param name defines the name of the mesh
  41028. * @param options defines the options used to create the mesh
  41029. * @param scene defines the hosting scene
  41030. * @returns the box mesh
  41031. */
  41032. static CreateBox(name: string, options: {
  41033. size?: number;
  41034. width?: number;
  41035. height?: number;
  41036. depth?: number;
  41037. faceUV?: Vector4[];
  41038. faceColors?: Color4[];
  41039. sideOrientation?: number;
  41040. frontUVs?: Vector4;
  41041. backUVs?: Vector4;
  41042. wrap?: boolean;
  41043. topBaseAt?: number;
  41044. bottomBaseAt?: number;
  41045. updatable?: boolean;
  41046. }, scene?: Nullable<Scene>): Mesh;
  41047. }
  41048. }
  41049. declare module BABYLON {
  41050. /**
  41051. * Class containing static functions to help procedurally build meshes
  41052. */
  41053. export class SphereBuilder {
  41054. /**
  41055. * Creates a sphere mesh
  41056. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  41057. * * 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`)
  41058. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  41059. * * 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
  41060. * * 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)
  41061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41062. * * 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
  41063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41064. * @param name defines the name of the mesh
  41065. * @param options defines the options used to create the mesh
  41066. * @param scene defines the hosting scene
  41067. * @returns the sphere mesh
  41068. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  41069. */
  41070. static CreateSphere(name: string, options: {
  41071. segments?: number;
  41072. diameter?: number;
  41073. diameterX?: number;
  41074. diameterY?: number;
  41075. diameterZ?: number;
  41076. arc?: number;
  41077. slice?: number;
  41078. sideOrientation?: number;
  41079. frontUVs?: Vector4;
  41080. backUVs?: Vector4;
  41081. updatable?: boolean;
  41082. }, scene: any): Mesh;
  41083. }
  41084. }
  41085. declare module BABYLON.Debug {
  41086. /**
  41087. * Used to show the physics impostor around the specific mesh
  41088. */
  41089. export class PhysicsViewer {
  41090. /** @hidden */
  41091. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41092. /** @hidden */
  41093. protected _meshes: Array<Nullable<AbstractMesh>>;
  41094. /** @hidden */
  41095. protected _scene: Nullable<Scene>;
  41096. /** @hidden */
  41097. protected _numMeshes: number;
  41098. /** @hidden */
  41099. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41100. private _renderFunction;
  41101. private _utilityLayer;
  41102. private _debugBoxMesh;
  41103. private _debugSphereMesh;
  41104. private _debugCylinderMesh;
  41105. private _debugMaterial;
  41106. private _debugMeshMeshes;
  41107. /**
  41108. * Creates a new PhysicsViewer
  41109. * @param scene defines the hosting scene
  41110. */
  41111. constructor(scene: Scene);
  41112. /** @hidden */
  41113. protected _updateDebugMeshes(): void;
  41114. /**
  41115. * Renders a specified physic impostor
  41116. * @param impostor defines the impostor to render
  41117. * @param targetMesh defines the mesh represented by the impostor
  41118. * @returns the new debug mesh used to render the impostor
  41119. */
  41120. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  41121. /**
  41122. * Hides a specified physic impostor
  41123. * @param impostor defines the impostor to hide
  41124. */
  41125. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41126. private _getDebugMaterial;
  41127. private _getDebugBoxMesh;
  41128. private _getDebugSphereMesh;
  41129. private _getDebugCylinderMesh;
  41130. private _getDebugMeshMesh;
  41131. private _getDebugMesh;
  41132. /** Releases all resources */
  41133. dispose(): void;
  41134. }
  41135. }
  41136. declare module BABYLON {
  41137. /**
  41138. * Class containing static functions to help procedurally build meshes
  41139. */
  41140. export class LinesBuilder {
  41141. /**
  41142. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  41143. * * 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
  41144. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  41145. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  41146. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  41147. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  41148. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  41149. * * 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
  41150. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  41151. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  41153. * @param name defines the name of the new line system
  41154. * @param options defines the options used to create the line system
  41155. * @param scene defines the hosting scene
  41156. * @returns a new line system mesh
  41157. */
  41158. static CreateLineSystem(name: string, options: {
  41159. lines: Vector3[][];
  41160. updatable?: boolean;
  41161. instance?: Nullable<LinesMesh>;
  41162. colors?: Nullable<Color4[][]>;
  41163. useVertexAlpha?: boolean;
  41164. }, scene: Nullable<Scene>): LinesMesh;
  41165. /**
  41166. * Creates a line mesh
  41167. * 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
  41168. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41169. * * The parameter `points` is an array successive Vector3
  41170. * * 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
  41171. * * The optional parameter `colors` is an array of successive Color4, one per line point
  41172. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  41173. * * When updating an instance, remember that only point positions can change, not the number of points
  41174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  41176. * @param name defines the name of the new line system
  41177. * @param options defines the options used to create the line system
  41178. * @param scene defines the hosting scene
  41179. * @returns a new line mesh
  41180. */
  41181. static CreateLines(name: string, options: {
  41182. points: Vector3[];
  41183. updatable?: boolean;
  41184. instance?: Nullable<LinesMesh>;
  41185. colors?: Color4[];
  41186. useVertexAlpha?: boolean;
  41187. }, scene?: Nullable<Scene>): LinesMesh;
  41188. /**
  41189. * Creates a dashed line mesh
  41190. * * 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
  41191. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  41192. * * The parameter `points` is an array successive Vector3
  41193. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  41194. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  41195. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  41196. * * 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
  41197. * * When updating an instance, remember that only point positions can change, not the number of points
  41198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41199. * @param name defines the name of the mesh
  41200. * @param options defines the options used to create the mesh
  41201. * @param scene defines the hosting scene
  41202. * @returns the dashed line mesh
  41203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  41204. */
  41205. static CreateDashedLines(name: string, options: {
  41206. points: Vector3[];
  41207. dashSize?: number;
  41208. gapSize?: number;
  41209. dashNb?: number;
  41210. updatable?: boolean;
  41211. instance?: LinesMesh;
  41212. }, scene?: Nullable<Scene>): LinesMesh;
  41213. }
  41214. }
  41215. declare module BABYLON {
  41216. /**
  41217. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41218. * in order to better appreciate the issue one might have.
  41219. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41220. */
  41221. export class RayHelper {
  41222. /**
  41223. * Defines the ray we are currently tryin to visualize.
  41224. */
  41225. ray: Nullable<Ray>;
  41226. private _renderPoints;
  41227. private _renderLine;
  41228. private _renderFunction;
  41229. private _scene;
  41230. private _updateToMeshFunction;
  41231. private _attachedToMesh;
  41232. private _meshSpaceDirection;
  41233. private _meshSpaceOrigin;
  41234. /**
  41235. * Helper function to create a colored helper in a scene in one line.
  41236. * @param ray Defines the ray we are currently tryin to visualize
  41237. * @param scene Defines the scene the ray is used in
  41238. * @param color Defines the color we want to see the ray in
  41239. * @returns The newly created ray helper.
  41240. */
  41241. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41242. /**
  41243. * Instantiate a new ray helper.
  41244. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41245. * in order to better appreciate the issue one might have.
  41246. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41247. * @param ray Defines the ray we are currently tryin to visualize
  41248. */
  41249. constructor(ray: Ray);
  41250. /**
  41251. * Shows the ray we are willing to debug.
  41252. * @param scene Defines the scene the ray needs to be rendered in
  41253. * @param color Defines the color the ray needs to be rendered in
  41254. */
  41255. show(scene: Scene, color?: Color3): void;
  41256. /**
  41257. * Hides the ray we are debugging.
  41258. */
  41259. hide(): void;
  41260. private _render;
  41261. /**
  41262. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41263. * @param mesh Defines the mesh we want the helper attached to
  41264. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41265. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41266. * @param length Defines the length of the ray
  41267. */
  41268. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41269. /**
  41270. * Detach the ray helper from the mesh it has previously been attached to.
  41271. */
  41272. detachFromMesh(): void;
  41273. private _updateToMesh;
  41274. /**
  41275. * Dispose the helper and release its associated resources.
  41276. */
  41277. dispose(): void;
  41278. }
  41279. }
  41280. declare module BABYLON.Debug {
  41281. /**
  41282. * Class used to render a debug view of a given skeleton
  41283. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41284. */
  41285. export class SkeletonViewer {
  41286. /** defines the skeleton to render */
  41287. skeleton: Skeleton;
  41288. /** defines the mesh attached to the skeleton */
  41289. mesh: AbstractMesh;
  41290. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41291. autoUpdateBonesMatrices: boolean;
  41292. /** defines the rendering group id to use with the viewer */
  41293. renderingGroupId: number;
  41294. /** Gets or sets the color used to render the skeleton */
  41295. color: Color3;
  41296. private _scene;
  41297. private _debugLines;
  41298. private _debugMesh;
  41299. private _isEnabled;
  41300. private _renderFunction;
  41301. private _utilityLayer;
  41302. /**
  41303. * Returns the mesh used to render the bones
  41304. */
  41305. readonly debugMesh: Nullable<LinesMesh>;
  41306. /**
  41307. * Creates a new SkeletonViewer
  41308. * @param skeleton defines the skeleton to render
  41309. * @param mesh defines the mesh attached to the skeleton
  41310. * @param scene defines the hosting scene
  41311. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41312. * @param renderingGroupId defines the rendering group id to use with the viewer
  41313. */
  41314. constructor(
  41315. /** defines the skeleton to render */
  41316. skeleton: Skeleton,
  41317. /** defines the mesh attached to the skeleton */
  41318. mesh: AbstractMesh, scene: Scene,
  41319. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41320. autoUpdateBonesMatrices?: boolean,
  41321. /** defines the rendering group id to use with the viewer */
  41322. renderingGroupId?: number);
  41323. /** Gets or sets a boolean indicating if the viewer is enabled */
  41324. isEnabled: boolean;
  41325. private _getBonePosition;
  41326. private _getLinesForBonesWithLength;
  41327. private _getLinesForBonesNoLength;
  41328. /** Update the viewer to sync with current skeleton state */
  41329. update(): void;
  41330. /** Release associated resources */
  41331. dispose(): void;
  41332. }
  41333. }
  41334. declare module BABYLON {
  41335. /**
  41336. * Options to create the null engine
  41337. */
  41338. export class NullEngineOptions {
  41339. /**
  41340. * Render width (Default: 512)
  41341. */
  41342. renderWidth: number;
  41343. /**
  41344. * Render height (Default: 256)
  41345. */
  41346. renderHeight: number;
  41347. /**
  41348. * Texture size (Default: 512)
  41349. */
  41350. textureSize: number;
  41351. /**
  41352. * If delta time between frames should be constant
  41353. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41354. */
  41355. deterministicLockstep: boolean;
  41356. /**
  41357. * Maximum about of steps between frames (Default: 4)
  41358. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41359. */
  41360. lockstepMaxSteps: number;
  41361. }
  41362. /**
  41363. * The null engine class provides support for headless version of babylon.js.
  41364. * This can be used in server side scenario or for testing purposes
  41365. */
  41366. export class NullEngine extends Engine {
  41367. private _options;
  41368. /**
  41369. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41370. */
  41371. isDeterministicLockStep(): boolean;
  41372. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41373. getLockstepMaxSteps(): number;
  41374. /**
  41375. * Sets hardware scaling, used to save performance if needed
  41376. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41377. */
  41378. getHardwareScalingLevel(): number;
  41379. constructor(options?: NullEngineOptions);
  41380. createVertexBuffer(vertices: FloatArray): DataBuffer;
  41381. createIndexBuffer(indices: IndicesArray): DataBuffer;
  41382. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41383. getRenderWidth(useScreen?: boolean): number;
  41384. getRenderHeight(useScreen?: boolean): number;
  41385. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41386. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41387. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  41388. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  41389. bindSamplers(effect: Effect): void;
  41390. enableEffect(effect: Effect): void;
  41391. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41392. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41393. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41394. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41395. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41396. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41397. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41398. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41399. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41400. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41401. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41402. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41403. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41404. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41405. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41406. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41407. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41408. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41409. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41410. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41411. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41412. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41413. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41414. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41415. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41416. bindBuffers(vertexBuffers: {
  41417. [key: string]: VertexBuffer;
  41418. }, indexBuffer: DataBuffer, effect: Effect): void;
  41419. wipeCaches(bruteForce?: boolean): void;
  41420. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41421. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41422. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41423. /** @hidden */
  41424. _createTexture(): WebGLTexture;
  41425. /** @hidden */
  41426. _releaseTexture(texture: InternalTexture): void;
  41427. 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;
  41428. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41429. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41430. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41431. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41432. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  41433. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41434. areAllEffectsReady(): boolean;
  41435. /**
  41436. * @hidden
  41437. * Get the current error code of the webGL context
  41438. * @returns the error code
  41439. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41440. */
  41441. getError(): number;
  41442. /** @hidden */
  41443. _getUnpackAlignement(): number;
  41444. /** @hidden */
  41445. _unpackFlipY(value: boolean): void;
  41446. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41447. /**
  41448. * Updates a dynamic vertex buffer.
  41449. * @param vertexBuffer the vertex buffer to update
  41450. * @param data the data used to update the vertex buffer
  41451. * @param byteOffset the byte offset of the data (optional)
  41452. * @param byteLength the byte length of the data (optional)
  41453. */
  41454. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41455. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41456. /** @hidden */
  41457. _bindTexture(channel: number, texture: InternalTexture): void;
  41458. /** @hidden */
  41459. _releaseBuffer(buffer: DataBuffer): boolean;
  41460. releaseEffects(): void;
  41461. displayLoadingUI(): void;
  41462. hideLoadingUI(): void;
  41463. /** @hidden */
  41464. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41465. /** @hidden */
  41466. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41467. /** @hidden */
  41468. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41469. /** @hidden */
  41470. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41471. }
  41472. }
  41473. declare module BABYLON {
  41474. /** @hidden */
  41475. export class _OcclusionDataStorage {
  41476. /** @hidden */
  41477. occlusionInternalRetryCounter: number;
  41478. /** @hidden */
  41479. isOcclusionQueryInProgress: boolean;
  41480. /** @hidden */
  41481. isOccluded: boolean;
  41482. /** @hidden */
  41483. occlusionRetryCount: number;
  41484. /** @hidden */
  41485. occlusionType: number;
  41486. /** @hidden */
  41487. occlusionQueryAlgorithmType: number;
  41488. }
  41489. interface Engine {
  41490. /**
  41491. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41492. * @return the new query
  41493. */
  41494. createQuery(): WebGLQuery;
  41495. /**
  41496. * Delete and release a webGL query
  41497. * @param query defines the query to delete
  41498. * @return the current engine
  41499. */
  41500. deleteQuery(query: WebGLQuery): Engine;
  41501. /**
  41502. * Check if a given query has resolved and got its value
  41503. * @param query defines the query to check
  41504. * @returns true if the query got its value
  41505. */
  41506. isQueryResultAvailable(query: WebGLQuery): boolean;
  41507. /**
  41508. * Gets the value of a given query
  41509. * @param query defines the query to check
  41510. * @returns the value of the query
  41511. */
  41512. getQueryResult(query: WebGLQuery): number;
  41513. /**
  41514. * Initiates an occlusion query
  41515. * @param algorithmType defines the algorithm to use
  41516. * @param query defines the query to use
  41517. * @returns the current engine
  41518. * @see http://doc.babylonjs.com/features/occlusionquery
  41519. */
  41520. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41521. /**
  41522. * Ends an occlusion query
  41523. * @see http://doc.babylonjs.com/features/occlusionquery
  41524. * @param algorithmType defines the algorithm to use
  41525. * @returns the current engine
  41526. */
  41527. endOcclusionQuery(algorithmType: number): Engine;
  41528. /**
  41529. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41530. * Please note that only one query can be issued at a time
  41531. * @returns a time token used to track the time span
  41532. */
  41533. startTimeQuery(): Nullable<_TimeToken>;
  41534. /**
  41535. * Ends a time query
  41536. * @param token defines the token used to measure the time span
  41537. * @returns the time spent (in ns)
  41538. */
  41539. endTimeQuery(token: _TimeToken): int;
  41540. /** @hidden */
  41541. _currentNonTimestampToken: Nullable<_TimeToken>;
  41542. /** @hidden */
  41543. _createTimeQuery(): WebGLQuery;
  41544. /** @hidden */
  41545. _deleteTimeQuery(query: WebGLQuery): void;
  41546. /** @hidden */
  41547. _getGlAlgorithmType(algorithmType: number): number;
  41548. /** @hidden */
  41549. _getTimeQueryResult(query: WebGLQuery): any;
  41550. /** @hidden */
  41551. _getTimeQueryAvailability(query: WebGLQuery): any;
  41552. }
  41553. interface AbstractMesh {
  41554. /**
  41555. * Backing filed
  41556. * @hidden
  41557. */
  41558. __occlusionDataStorage: _OcclusionDataStorage;
  41559. /**
  41560. * Access property
  41561. * @hidden
  41562. */
  41563. _occlusionDataStorage: _OcclusionDataStorage;
  41564. /**
  41565. * 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.
  41566. * The default value is -1 which means don't break the query and wait till the result
  41567. * @see http://doc.babylonjs.com/features/occlusionquery
  41568. */
  41569. occlusionRetryCount: number;
  41570. /**
  41571. * 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:
  41572. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41573. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41574. * * 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.
  41575. * @see http://doc.babylonjs.com/features/occlusionquery
  41576. */
  41577. occlusionType: number;
  41578. /**
  41579. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41580. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41581. * * 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.
  41582. * @see http://doc.babylonjs.com/features/occlusionquery
  41583. */
  41584. occlusionQueryAlgorithmType: number;
  41585. /**
  41586. * 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
  41587. * @see http://doc.babylonjs.com/features/occlusionquery
  41588. */
  41589. isOccluded: boolean;
  41590. /**
  41591. * Flag to check the progress status of the query
  41592. * @see http://doc.babylonjs.com/features/occlusionquery
  41593. */
  41594. isOcclusionQueryInProgress: boolean;
  41595. }
  41596. }
  41597. declare module BABYLON {
  41598. /** @hidden */
  41599. export var _forceTransformFeedbackToBundle: boolean;
  41600. interface Engine {
  41601. /**
  41602. * Creates a webGL transform feedback object
  41603. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41604. * @returns the webGL transform feedback object
  41605. */
  41606. createTransformFeedback(): WebGLTransformFeedback;
  41607. /**
  41608. * Delete a webGL transform feedback object
  41609. * @param value defines the webGL transform feedback object to delete
  41610. */
  41611. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41612. /**
  41613. * Bind a webGL transform feedback object to the webgl context
  41614. * @param value defines the webGL transform feedback object to bind
  41615. */
  41616. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41617. /**
  41618. * Begins a transform feedback operation
  41619. * @param usePoints defines if points or triangles must be used
  41620. */
  41621. beginTransformFeedback(usePoints: boolean): void;
  41622. /**
  41623. * Ends a transform feedback operation
  41624. */
  41625. endTransformFeedback(): void;
  41626. /**
  41627. * Specify the varyings to use with transform feedback
  41628. * @param program defines the associated webGL program
  41629. * @param value defines the list of strings representing the varying names
  41630. */
  41631. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41632. /**
  41633. * Bind a webGL buffer for a transform feedback operation
  41634. * @param value defines the webGL buffer to bind
  41635. */
  41636. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  41637. }
  41638. }
  41639. declare module BABYLON {
  41640. /**
  41641. * Creation options of the multi render target texture.
  41642. */
  41643. export interface IMultiRenderTargetOptions {
  41644. /**
  41645. * Define if the texture needs to create mip maps after render.
  41646. */
  41647. generateMipMaps?: boolean;
  41648. /**
  41649. * Define the types of all the draw buffers we want to create
  41650. */
  41651. types?: number[];
  41652. /**
  41653. * Define the sampling modes of all the draw buffers we want to create
  41654. */
  41655. samplingModes?: number[];
  41656. /**
  41657. * Define if a depth buffer is required
  41658. */
  41659. generateDepthBuffer?: boolean;
  41660. /**
  41661. * Define if a stencil buffer is required
  41662. */
  41663. generateStencilBuffer?: boolean;
  41664. /**
  41665. * Define if a depth texture is required instead of a depth buffer
  41666. */
  41667. generateDepthTexture?: boolean;
  41668. /**
  41669. * Define the number of desired draw buffers
  41670. */
  41671. textureCount?: number;
  41672. /**
  41673. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41674. */
  41675. doNotChangeAspectRatio?: boolean;
  41676. /**
  41677. * Define the default type of the buffers we are creating
  41678. */
  41679. defaultType?: number;
  41680. }
  41681. /**
  41682. * A multi render target, like a render target provides the ability to render to a texture.
  41683. * Unlike the render target, it can render to several draw buffers in one draw.
  41684. * This is specially interesting in deferred rendering or for any effects requiring more than
  41685. * just one color from a single pass.
  41686. */
  41687. export class MultiRenderTarget extends RenderTargetTexture {
  41688. private _internalTextures;
  41689. private _textures;
  41690. private _multiRenderTargetOptions;
  41691. /**
  41692. * Get if draw buffers are currently supported by the used hardware and browser.
  41693. */
  41694. readonly isSupported: boolean;
  41695. /**
  41696. * Get the list of textures generated by the multi render target.
  41697. */
  41698. readonly textures: Texture[];
  41699. /**
  41700. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41701. */
  41702. readonly depthTexture: Texture;
  41703. /**
  41704. * Set the wrapping mode on U of all the textures we are rendering to.
  41705. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41706. */
  41707. wrapU: number;
  41708. /**
  41709. * Set the wrapping mode on V of all the textures we are rendering to.
  41710. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41711. */
  41712. wrapV: number;
  41713. /**
  41714. * Instantiate a new multi render target texture.
  41715. * A multi render target, like a render target provides the ability to render to a texture.
  41716. * Unlike the render target, it can render to several draw buffers in one draw.
  41717. * This is specially interesting in deferred rendering or for any effects requiring more than
  41718. * just one color from a single pass.
  41719. * @param name Define the name of the texture
  41720. * @param size Define the size of the buffers to render to
  41721. * @param count Define the number of target we are rendering into
  41722. * @param scene Define the scene the texture belongs to
  41723. * @param options Define the options used to create the multi render target
  41724. */
  41725. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41726. /** @hidden */
  41727. _rebuild(): void;
  41728. private _createInternalTextures;
  41729. private _createTextures;
  41730. /**
  41731. * Define the number of samples used if MSAA is enabled.
  41732. */
  41733. samples: number;
  41734. /**
  41735. * Resize all the textures in the multi render target.
  41736. * Be carrefull as it will recreate all the data in the new texture.
  41737. * @param size Define the new size
  41738. */
  41739. resize(size: any): void;
  41740. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41741. /**
  41742. * Dispose the render targets and their associated resources
  41743. */
  41744. dispose(): void;
  41745. /**
  41746. * Release all the underlying texture used as draw buffers.
  41747. */
  41748. releaseInternalTextures(): void;
  41749. }
  41750. }
  41751. declare module BABYLON {
  41752. interface Engine {
  41753. /**
  41754. * Unbind a list of render target textures from the webGL context
  41755. * This is used only when drawBuffer extension or webGL2 are active
  41756. * @param textures defines the render target textures to unbind
  41757. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41758. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41759. */
  41760. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41761. /**
  41762. * Create a multi render target texture
  41763. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41764. * @param size defines the size of the texture
  41765. * @param options defines the creation options
  41766. * @returns the cube texture as an InternalTexture
  41767. */
  41768. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41769. /**
  41770. * Update the sample count for a given multiple render target texture
  41771. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41772. * @param textures defines the textures to update
  41773. * @param samples defines the sample count to set
  41774. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41775. */
  41776. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41777. }
  41778. }
  41779. declare module BABYLON {
  41780. /**
  41781. * Gather the list of clipboard event types as constants.
  41782. */
  41783. export class ClipboardEventTypes {
  41784. /**
  41785. * The clipboard event is fired when a copy command is active (pressed).
  41786. */
  41787. static readonly COPY: number;
  41788. /**
  41789. * The clipboard event is fired when a cut command is active (pressed).
  41790. */
  41791. static readonly CUT: number;
  41792. /**
  41793. * The clipboard event is fired when a paste command is active (pressed).
  41794. */
  41795. static readonly PASTE: number;
  41796. }
  41797. /**
  41798. * This class is used to store clipboard related info for the onClipboardObservable event.
  41799. */
  41800. export class ClipboardInfo {
  41801. /**
  41802. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41803. */
  41804. type: number;
  41805. /**
  41806. * Defines the related dom event
  41807. */
  41808. event: ClipboardEvent;
  41809. /**
  41810. *Creates an instance of ClipboardInfo.
  41811. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41812. * @param event Defines the related dom event
  41813. */
  41814. constructor(
  41815. /**
  41816. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41817. */
  41818. type: number,
  41819. /**
  41820. * Defines the related dom event
  41821. */
  41822. event: ClipboardEvent);
  41823. /**
  41824. * Get the clipboard event's type from the keycode.
  41825. * @param keyCode Defines the keyCode for the current keyboard event.
  41826. * @return {number}
  41827. */
  41828. static GetTypeFromCharacter(keyCode: number): number;
  41829. }
  41830. }
  41831. declare module BABYLON {
  41832. /**
  41833. * Class used to represent data loading progression
  41834. */
  41835. export class SceneLoaderProgressEvent {
  41836. /** defines if data length to load can be evaluated */
  41837. readonly lengthComputable: boolean;
  41838. /** defines the loaded data length */
  41839. readonly loaded: number;
  41840. /** defines the data length to load */
  41841. readonly total: number;
  41842. /**
  41843. * Create a new progress event
  41844. * @param lengthComputable defines if data length to load can be evaluated
  41845. * @param loaded defines the loaded data length
  41846. * @param total defines the data length to load
  41847. */
  41848. constructor(
  41849. /** defines if data length to load can be evaluated */
  41850. lengthComputable: boolean,
  41851. /** defines the loaded data length */
  41852. loaded: number,
  41853. /** defines the data length to load */
  41854. total: number);
  41855. /**
  41856. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41857. * @param event defines the source event
  41858. * @returns a new SceneLoaderProgressEvent
  41859. */
  41860. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41861. }
  41862. /**
  41863. * Interface used by SceneLoader plugins to define supported file extensions
  41864. */
  41865. export interface ISceneLoaderPluginExtensions {
  41866. /**
  41867. * Defines the list of supported extensions
  41868. */
  41869. [extension: string]: {
  41870. isBinary: boolean;
  41871. };
  41872. }
  41873. /**
  41874. * Interface used by SceneLoader plugin factory
  41875. */
  41876. export interface ISceneLoaderPluginFactory {
  41877. /**
  41878. * Defines the name of the factory
  41879. */
  41880. name: string;
  41881. /**
  41882. * Function called to create a new plugin
  41883. * @return the new plugin
  41884. */
  41885. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41886. /**
  41887. * Boolean indicating if the plugin can direct load specific data
  41888. */
  41889. canDirectLoad?: (data: string) => boolean;
  41890. }
  41891. /**
  41892. * Interface used to define a SceneLoader plugin
  41893. */
  41894. export interface ISceneLoaderPlugin {
  41895. /**
  41896. * The friendly name of this plugin.
  41897. */
  41898. name: string;
  41899. /**
  41900. * The file extensions supported by this plugin.
  41901. */
  41902. extensions: string | ISceneLoaderPluginExtensions;
  41903. /**
  41904. * Import meshes into a scene.
  41905. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41906. * @param scene The scene to import into
  41907. * @param data The data to import
  41908. * @param rootUrl The root url for scene and resources
  41909. * @param meshes The meshes array to import into
  41910. * @param particleSystems The particle systems array to import into
  41911. * @param skeletons The skeletons array to import into
  41912. * @param onError The callback when import fails
  41913. * @returns True if successful or false otherwise
  41914. */
  41915. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41916. /**
  41917. * Load into a scene.
  41918. * @param scene The scene to load into
  41919. * @param data The data to import
  41920. * @param rootUrl The root url for scene and resources
  41921. * @param onError The callback when import fails
  41922. * @returns true if successful or false otherwise
  41923. */
  41924. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41925. /**
  41926. * The callback that returns true if the data can be directly loaded.
  41927. */
  41928. canDirectLoad?: (data: string) => boolean;
  41929. /**
  41930. * The callback that allows custom handling of the root url based on the response url.
  41931. */
  41932. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41933. /**
  41934. * Load into an asset container.
  41935. * @param scene The scene to load into
  41936. * @param data The data to import
  41937. * @param rootUrl The root url for scene and resources
  41938. * @param onError The callback when import fails
  41939. * @returns The loaded asset container
  41940. */
  41941. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41942. }
  41943. /**
  41944. * Interface used to define an async SceneLoader plugin
  41945. */
  41946. export interface ISceneLoaderPluginAsync {
  41947. /**
  41948. * The friendly name of this plugin.
  41949. */
  41950. name: string;
  41951. /**
  41952. * The file extensions supported by this plugin.
  41953. */
  41954. extensions: string | ISceneLoaderPluginExtensions;
  41955. /**
  41956. * Import meshes into a scene.
  41957. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41958. * @param scene The scene to import into
  41959. * @param data The data to import
  41960. * @param rootUrl The root url for scene and resources
  41961. * @param onProgress The callback when the load progresses
  41962. * @param fileName Defines the name of the file to load
  41963. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41964. */
  41965. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41966. meshes: AbstractMesh[];
  41967. particleSystems: IParticleSystem[];
  41968. skeletons: Skeleton[];
  41969. animationGroups: AnimationGroup[];
  41970. }>;
  41971. /**
  41972. * Load into a scene.
  41973. * @param scene The scene to load into
  41974. * @param data The data to import
  41975. * @param rootUrl The root url for scene and resources
  41976. * @param onProgress The callback when the load progresses
  41977. * @param fileName Defines the name of the file to load
  41978. * @returns Nothing
  41979. */
  41980. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41981. /**
  41982. * The callback that returns true if the data can be directly loaded.
  41983. */
  41984. canDirectLoad?: (data: string) => boolean;
  41985. /**
  41986. * The callback that allows custom handling of the root url based on the response url.
  41987. */
  41988. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41989. /**
  41990. * Load into an asset container.
  41991. * @param scene The scene to load into
  41992. * @param data The data to import
  41993. * @param rootUrl The root url for scene and resources
  41994. * @param onProgress The callback when the load progresses
  41995. * @param fileName Defines the name of the file to load
  41996. * @returns The loaded asset container
  41997. */
  41998. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41999. }
  42000. /**
  42001. * Class used to load scene from various file formats using registered plugins
  42002. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42003. */
  42004. export class SceneLoader {
  42005. /**
  42006. * No logging while loading
  42007. */
  42008. static readonly NO_LOGGING: number;
  42009. /**
  42010. * Minimal logging while loading
  42011. */
  42012. static readonly MINIMAL_LOGGING: number;
  42013. /**
  42014. * Summary logging while loading
  42015. */
  42016. static readonly SUMMARY_LOGGING: number;
  42017. /**
  42018. * Detailled logging while loading
  42019. */
  42020. static readonly DETAILED_LOGGING: number;
  42021. /**
  42022. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42023. */
  42024. static ForceFullSceneLoadingForIncremental: boolean;
  42025. /**
  42026. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42027. */
  42028. static ShowLoadingScreen: boolean;
  42029. /**
  42030. * Defines the current logging level (while loading the scene)
  42031. * @ignorenaming
  42032. */
  42033. static loggingLevel: number;
  42034. /**
  42035. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42036. */
  42037. static CleanBoneMatrixWeights: boolean;
  42038. /**
  42039. * Event raised when a plugin is used to load a scene
  42040. */
  42041. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42042. private static _registeredPlugins;
  42043. private static _getDefaultPlugin;
  42044. private static _getPluginForExtension;
  42045. private static _getPluginForDirectLoad;
  42046. private static _getPluginForFilename;
  42047. private static _getDirectLoad;
  42048. private static _loadData;
  42049. private static _getFileInfo;
  42050. /**
  42051. * Gets a plugin that can load the given extension
  42052. * @param extension defines the extension to load
  42053. * @returns a plugin or null if none works
  42054. */
  42055. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42056. /**
  42057. * Gets a boolean indicating that the given extension can be loaded
  42058. * @param extension defines the extension to load
  42059. * @returns true if the extension is supported
  42060. */
  42061. static IsPluginForExtensionAvailable(extension: string): boolean;
  42062. /**
  42063. * Adds a new plugin to the list of registered plugins
  42064. * @param plugin defines the plugin to add
  42065. */
  42066. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42067. /**
  42068. * Import meshes into a scene
  42069. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42070. * @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)
  42071. * @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)
  42072. * @param scene the instance of BABYLON.Scene to append to
  42073. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42074. * @param onProgress a callback with a progress event for each file being loaded
  42075. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42076. * @param pluginExtension the extension used to determine the plugin
  42077. * @returns The loaded plugin
  42078. */
  42079. 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>;
  42080. /**
  42081. * Import meshes into a scene
  42082. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42083. * @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)
  42084. * @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)
  42085. * @param scene the instance of BABYLON.Scene to append to
  42086. * @param onProgress a callback with a progress event for each file being loaded
  42087. * @param pluginExtension the extension used to determine the plugin
  42088. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42089. */
  42090. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42091. meshes: AbstractMesh[];
  42092. particleSystems: IParticleSystem[];
  42093. skeletons: Skeleton[];
  42094. animationGroups: AnimationGroup[];
  42095. }>;
  42096. /**
  42097. * Load a scene
  42098. * @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)
  42099. * @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)
  42100. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42101. * @param onSuccess a callback with the scene when import succeeds
  42102. * @param onProgress a callback with a progress event for each file being loaded
  42103. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42104. * @param pluginExtension the extension used to determine the plugin
  42105. * @returns The loaded plugin
  42106. */
  42107. 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>;
  42108. /**
  42109. * Load a scene
  42110. * @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)
  42111. * @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)
  42112. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42113. * @param onProgress a callback with a progress event for each file being loaded
  42114. * @param pluginExtension the extension used to determine the plugin
  42115. * @returns The loaded scene
  42116. */
  42117. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42118. /**
  42119. * Append a scene
  42120. * @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)
  42121. * @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)
  42122. * @param scene is the instance of BABYLON.Scene to append to
  42123. * @param onSuccess a callback with the scene when import succeeds
  42124. * @param onProgress a callback with a progress event for each file being loaded
  42125. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42126. * @param pluginExtension the extension used to determine the plugin
  42127. * @returns The loaded plugin
  42128. */
  42129. 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>;
  42130. /**
  42131. * Append a scene
  42132. * @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)
  42133. * @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)
  42134. * @param scene is the instance of BABYLON.Scene to append to
  42135. * @param onProgress a callback with a progress event for each file being loaded
  42136. * @param pluginExtension the extension used to determine the plugin
  42137. * @returns The given scene
  42138. */
  42139. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42140. /**
  42141. * Load a scene into an asset container
  42142. * @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)
  42143. * @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)
  42144. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42145. * @param onSuccess a callback with the scene when import succeeds
  42146. * @param onProgress a callback with a progress event for each file being loaded
  42147. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42148. * @param pluginExtension the extension used to determine the plugin
  42149. * @returns The loaded plugin
  42150. */
  42151. 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>;
  42152. /**
  42153. * Load a scene into an asset container
  42154. * @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)
  42155. * @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)
  42156. * @param scene is the instance of Scene to append to
  42157. * @param onProgress a callback with a progress event for each file being loaded
  42158. * @param pluginExtension the extension used to determine the plugin
  42159. * @returns The loaded asset container
  42160. */
  42161. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42162. }
  42163. }
  42164. declare module BABYLON {
  42165. /**
  42166. * Google Daydream controller
  42167. */
  42168. export class DaydreamController extends WebVRController {
  42169. /**
  42170. * Base Url for the controller model.
  42171. */
  42172. static MODEL_BASE_URL: string;
  42173. /**
  42174. * File name for the controller model.
  42175. */
  42176. static MODEL_FILENAME: string;
  42177. /**
  42178. * Gamepad Id prefix used to identify Daydream Controller.
  42179. */
  42180. static readonly GAMEPAD_ID_PREFIX: string;
  42181. /**
  42182. * Creates a new DaydreamController from a gamepad
  42183. * @param vrGamepad the gamepad that the controller should be created from
  42184. */
  42185. constructor(vrGamepad: any);
  42186. /**
  42187. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42188. * @param scene scene in which to add meshes
  42189. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42190. */
  42191. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42192. /**
  42193. * Called once for each button that changed state since the last frame
  42194. * @param buttonIdx Which button index changed
  42195. * @param state New state of the button
  42196. * @param changes Which properties on the state changed since last frame
  42197. */
  42198. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42199. }
  42200. }
  42201. declare module BABYLON {
  42202. /**
  42203. * Gear VR Controller
  42204. */
  42205. export class GearVRController extends WebVRController {
  42206. /**
  42207. * Base Url for the controller model.
  42208. */
  42209. static MODEL_BASE_URL: string;
  42210. /**
  42211. * File name for the controller model.
  42212. */
  42213. static MODEL_FILENAME: string;
  42214. /**
  42215. * Gamepad Id prefix used to identify this controller.
  42216. */
  42217. static readonly GAMEPAD_ID_PREFIX: string;
  42218. private readonly _buttonIndexToObservableNameMap;
  42219. /**
  42220. * Creates a new GearVRController from a gamepad
  42221. * @param vrGamepad the gamepad that the controller should be created from
  42222. */
  42223. constructor(vrGamepad: any);
  42224. /**
  42225. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42226. * @param scene scene in which to add meshes
  42227. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42228. */
  42229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42230. /**
  42231. * Called once for each button that changed state since the last frame
  42232. * @param buttonIdx Which button index changed
  42233. * @param state New state of the button
  42234. * @param changes Which properties on the state changed since last frame
  42235. */
  42236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42237. }
  42238. }
  42239. declare module BABYLON {
  42240. /**
  42241. * Generic Controller
  42242. */
  42243. export class GenericController extends WebVRController {
  42244. /**
  42245. * Base Url for the controller model.
  42246. */
  42247. static readonly MODEL_BASE_URL: string;
  42248. /**
  42249. * File name for the controller model.
  42250. */
  42251. static readonly MODEL_FILENAME: string;
  42252. /**
  42253. * Creates a new GenericController from a gamepad
  42254. * @param vrGamepad the gamepad that the controller should be created from
  42255. */
  42256. constructor(vrGamepad: any);
  42257. /**
  42258. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42259. * @param scene scene in which to add meshes
  42260. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42261. */
  42262. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42263. /**
  42264. * Called once for each button that changed state since the last frame
  42265. * @param buttonIdx Which button index changed
  42266. * @param state New state of the button
  42267. * @param changes Which properties on the state changed since last frame
  42268. */
  42269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42270. }
  42271. }
  42272. declare module BABYLON {
  42273. /**
  42274. * Oculus Touch Controller
  42275. */
  42276. export class OculusTouchController extends WebVRController {
  42277. /**
  42278. * Base Url for the controller model.
  42279. */
  42280. static MODEL_BASE_URL: string;
  42281. /**
  42282. * File name for the left controller model.
  42283. */
  42284. static MODEL_LEFT_FILENAME: string;
  42285. /**
  42286. * File name for the right controller model.
  42287. */
  42288. static MODEL_RIGHT_FILENAME: string;
  42289. /**
  42290. * Fired when the secondary trigger on this controller is modified
  42291. */
  42292. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42293. /**
  42294. * Fired when the thumb rest on this controller is modified
  42295. */
  42296. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42297. /**
  42298. * Creates a new OculusTouchController from a gamepad
  42299. * @param vrGamepad the gamepad that the controller should be created from
  42300. */
  42301. constructor(vrGamepad: any);
  42302. /**
  42303. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42304. * @param scene scene in which to add meshes
  42305. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42306. */
  42307. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42308. /**
  42309. * Fired when the A button on this controller is modified
  42310. */
  42311. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42312. /**
  42313. * Fired when the B button on this controller is modified
  42314. */
  42315. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42316. /**
  42317. * Fired when the X button on this controller is modified
  42318. */
  42319. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42320. /**
  42321. * Fired when the Y button on this controller is modified
  42322. */
  42323. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42324. /**
  42325. * Called once for each button that changed state since the last frame
  42326. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42327. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42328. * 2) secondary trigger (same)
  42329. * 3) A (right) X (left), touch, pressed = value
  42330. * 4) B / Y
  42331. * 5) thumb rest
  42332. * @param buttonIdx Which button index changed
  42333. * @param state New state of the button
  42334. * @param changes Which properties on the state changed since last frame
  42335. */
  42336. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42337. }
  42338. }
  42339. declare module BABYLON {
  42340. /**
  42341. * Vive Controller
  42342. */
  42343. export class ViveController extends WebVRController {
  42344. /**
  42345. * Base Url for the controller model.
  42346. */
  42347. static MODEL_BASE_URL: string;
  42348. /**
  42349. * File name for the controller model.
  42350. */
  42351. static MODEL_FILENAME: string;
  42352. /**
  42353. * Creates a new ViveController from a gamepad
  42354. * @param vrGamepad the gamepad that the controller should be created from
  42355. */
  42356. constructor(vrGamepad: any);
  42357. /**
  42358. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42359. * @param scene scene in which to add meshes
  42360. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42361. */
  42362. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42363. /**
  42364. * Fired when the left button on this controller is modified
  42365. */
  42366. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42367. /**
  42368. * Fired when the right button on this controller is modified
  42369. */
  42370. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42371. /**
  42372. * Fired when the menu button on this controller is modified
  42373. */
  42374. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42375. /**
  42376. * Called once for each button that changed state since the last frame
  42377. * Vive mapping:
  42378. * 0: touchpad
  42379. * 1: trigger
  42380. * 2: left AND right buttons
  42381. * 3: menu button
  42382. * @param buttonIdx Which button index changed
  42383. * @param state New state of the button
  42384. * @param changes Which properties on the state changed since last frame
  42385. */
  42386. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42387. }
  42388. }
  42389. declare module BABYLON {
  42390. /**
  42391. * Defines the WindowsMotionController object that the state of the windows motion controller
  42392. */
  42393. export class WindowsMotionController extends WebVRController {
  42394. /**
  42395. * The base url used to load the left and right controller models
  42396. */
  42397. static MODEL_BASE_URL: string;
  42398. /**
  42399. * The name of the left controller model file
  42400. */
  42401. static MODEL_LEFT_FILENAME: string;
  42402. /**
  42403. * The name of the right controller model file
  42404. */
  42405. static MODEL_RIGHT_FILENAME: string;
  42406. /**
  42407. * The controller name prefix for this controller type
  42408. */
  42409. static readonly GAMEPAD_ID_PREFIX: string;
  42410. /**
  42411. * The controller id pattern for this controller type
  42412. */
  42413. private static readonly GAMEPAD_ID_PATTERN;
  42414. private _loadedMeshInfo;
  42415. private readonly _mapping;
  42416. /**
  42417. * Fired when the trackpad on this controller is clicked
  42418. */
  42419. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42420. /**
  42421. * Fired when the trackpad on this controller is modified
  42422. */
  42423. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42424. /**
  42425. * The current x and y values of this controller's trackpad
  42426. */
  42427. trackpad: StickValues;
  42428. /**
  42429. * Creates a new WindowsMotionController from a gamepad
  42430. * @param vrGamepad the gamepad that the controller should be created from
  42431. */
  42432. constructor(vrGamepad: any);
  42433. /**
  42434. * Fired when the trigger on this controller is modified
  42435. */
  42436. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42437. /**
  42438. * Fired when the menu button on this controller is modified
  42439. */
  42440. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42441. /**
  42442. * Fired when the grip button on this controller is modified
  42443. */
  42444. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42445. /**
  42446. * Fired when the thumbstick button on this controller is modified
  42447. */
  42448. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42449. /**
  42450. * Fired when the touchpad button on this controller is modified
  42451. */
  42452. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42453. /**
  42454. * Fired when the touchpad values on this controller are modified
  42455. */
  42456. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42457. private _updateTrackpad;
  42458. /**
  42459. * Called once per frame by the engine.
  42460. */
  42461. update(): void;
  42462. /**
  42463. * Called once for each button that changed state since the last frame
  42464. * @param buttonIdx Which button index changed
  42465. * @param state New state of the button
  42466. * @param changes Which properties on the state changed since last frame
  42467. */
  42468. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42469. /**
  42470. * Moves the buttons on the controller mesh based on their current state
  42471. * @param buttonName the name of the button to move
  42472. * @param buttonValue the value of the button which determines the buttons new position
  42473. */
  42474. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42475. /**
  42476. * Moves the axis on the controller mesh based on its current state
  42477. * @param axis the index of the axis
  42478. * @param axisValue the value of the axis which determines the meshes new position
  42479. * @hidden
  42480. */
  42481. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42482. /**
  42483. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42484. * @param scene scene in which to add meshes
  42485. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42486. */
  42487. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42488. /**
  42489. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42490. * can be transformed by button presses and axes values, based on this._mapping.
  42491. *
  42492. * @param scene scene in which the meshes exist
  42493. * @param meshes list of meshes that make up the controller model to process
  42494. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42495. */
  42496. private processModel;
  42497. private createMeshInfo;
  42498. /**
  42499. * Gets the ray of the controller in the direction the controller is pointing
  42500. * @param length the length the resulting ray should be
  42501. * @returns a ray in the direction the controller is pointing
  42502. */
  42503. getForwardRay(length?: number): Ray;
  42504. /**
  42505. * Disposes of the controller
  42506. */
  42507. dispose(): void;
  42508. }
  42509. }
  42510. declare module BABYLON {
  42511. /**
  42512. * Single axis scale gizmo
  42513. */
  42514. export class AxisScaleGizmo extends Gizmo {
  42515. private _coloredMaterial;
  42516. /**
  42517. * Drag behavior responsible for the gizmos dragging interactions
  42518. */
  42519. dragBehavior: PointerDragBehavior;
  42520. private _pointerObserver;
  42521. /**
  42522. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42523. */
  42524. snapDistance: number;
  42525. /**
  42526. * Event that fires each time the gizmo snaps to a new location.
  42527. * * snapDistance is the the change in distance
  42528. */
  42529. onSnapObservable: Observable<{
  42530. snapDistance: number;
  42531. }>;
  42532. /**
  42533. * If the scaling operation should be done on all axis (default: false)
  42534. */
  42535. uniformScaling: boolean;
  42536. /**
  42537. * Creates an AxisScaleGizmo
  42538. * @param gizmoLayer The utility layer the gizmo will be added to
  42539. * @param dragAxis The axis which the gizmo will be able to scale on
  42540. * @param color The color of the gizmo
  42541. */
  42542. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42543. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42544. /**
  42545. * Disposes of the gizmo
  42546. */
  42547. dispose(): void;
  42548. /**
  42549. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42550. * @param mesh The mesh to replace the default mesh of the gizmo
  42551. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42552. */
  42553. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42554. }
  42555. }
  42556. declare module BABYLON {
  42557. /**
  42558. * Bounding box gizmo
  42559. */
  42560. export class BoundingBoxGizmo extends Gizmo {
  42561. private _lineBoundingBox;
  42562. private _rotateSpheresParent;
  42563. private _scaleBoxesParent;
  42564. private _boundingDimensions;
  42565. private _renderObserver;
  42566. private _pointerObserver;
  42567. private _scaleDragSpeed;
  42568. private _tmpQuaternion;
  42569. private _tmpVector;
  42570. private _tmpRotationMatrix;
  42571. /**
  42572. * 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)
  42573. */
  42574. ignoreChildren: boolean;
  42575. /**
  42576. * 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)
  42577. */
  42578. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42579. /**
  42580. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42581. */
  42582. rotationSphereSize: number;
  42583. /**
  42584. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42585. */
  42586. scaleBoxSize: number;
  42587. /**
  42588. * 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)
  42589. */
  42590. fixedDragMeshScreenSize: boolean;
  42591. /**
  42592. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42593. */
  42594. fixedDragMeshScreenSizeDistanceFactor: number;
  42595. /**
  42596. * Fired when a rotation sphere or scale box is dragged
  42597. */
  42598. onDragStartObservable: Observable<{}>;
  42599. /**
  42600. * Fired when a scale box is dragged
  42601. */
  42602. onScaleBoxDragObservable: Observable<{}>;
  42603. /**
  42604. * Fired when a scale box drag is ended
  42605. */
  42606. onScaleBoxDragEndObservable: Observable<{}>;
  42607. /**
  42608. * Fired when a rotation sphere is dragged
  42609. */
  42610. onRotationSphereDragObservable: Observable<{}>;
  42611. /**
  42612. * Fired when a rotation sphere drag is ended
  42613. */
  42614. onRotationSphereDragEndObservable: Observable<{}>;
  42615. /**
  42616. * 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)
  42617. */
  42618. scalePivot: Nullable<Vector3>;
  42619. /**
  42620. * Mesh used as a pivot to rotate the attached mesh
  42621. */
  42622. private _anchorMesh;
  42623. private _existingMeshScale;
  42624. private _dragMesh;
  42625. private pointerDragBehavior;
  42626. private coloredMaterial;
  42627. private hoverColoredMaterial;
  42628. /**
  42629. * Sets the color of the bounding box gizmo
  42630. * @param color the color to set
  42631. */
  42632. setColor(color: Color3): void;
  42633. /**
  42634. * Creates an BoundingBoxGizmo
  42635. * @param gizmoLayer The utility layer the gizmo will be added to
  42636. * @param color The color of the gizmo
  42637. */
  42638. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42639. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42640. private _selectNode;
  42641. /**
  42642. * Updates the bounding box information for the Gizmo
  42643. */
  42644. updateBoundingBox(): void;
  42645. private _updateRotationSpheres;
  42646. private _updateScaleBoxes;
  42647. /**
  42648. * Enables rotation on the specified axis and disables rotation on the others
  42649. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42650. */
  42651. setEnabledRotationAxis(axis: string): void;
  42652. /**
  42653. * Enables/disables scaling
  42654. * @param enable if scaling should be enabled
  42655. */
  42656. setEnabledScaling(enable: boolean): void;
  42657. private _updateDummy;
  42658. /**
  42659. * Enables a pointer drag behavior on the bounding box of the gizmo
  42660. */
  42661. enableDragBehavior(): void;
  42662. /**
  42663. * Disposes of the gizmo
  42664. */
  42665. dispose(): void;
  42666. /**
  42667. * 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)
  42668. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42669. * @returns the bounding box mesh with the passed in mesh as a child
  42670. */
  42671. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42672. /**
  42673. * CustomMeshes are not supported by this gizmo
  42674. * @param mesh The mesh to replace the default mesh of the gizmo
  42675. */
  42676. setCustomMesh(mesh: Mesh): void;
  42677. }
  42678. }
  42679. declare module BABYLON {
  42680. /**
  42681. * Single plane rotation gizmo
  42682. */
  42683. export class PlaneRotationGizmo extends Gizmo {
  42684. /**
  42685. * Drag behavior responsible for the gizmos dragging interactions
  42686. */
  42687. dragBehavior: PointerDragBehavior;
  42688. private _pointerObserver;
  42689. /**
  42690. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42691. */
  42692. snapDistance: number;
  42693. /**
  42694. * Event that fires each time the gizmo snaps to a new location.
  42695. * * snapDistance is the the change in distance
  42696. */
  42697. onSnapObservable: Observable<{
  42698. snapDistance: number;
  42699. }>;
  42700. /**
  42701. * Creates a PlaneRotationGizmo
  42702. * @param gizmoLayer The utility layer the gizmo will be added to
  42703. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42704. * @param color The color of the gizmo
  42705. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42706. */
  42707. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42708. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42709. /**
  42710. * Disposes of the gizmo
  42711. */
  42712. dispose(): void;
  42713. }
  42714. }
  42715. declare module BABYLON {
  42716. /**
  42717. * Gizmo that enables rotating a mesh along 3 axis
  42718. */
  42719. export class RotationGizmo extends Gizmo {
  42720. /**
  42721. * Internal gizmo used for interactions on the x axis
  42722. */
  42723. xGizmo: PlaneRotationGizmo;
  42724. /**
  42725. * Internal gizmo used for interactions on the y axis
  42726. */
  42727. yGizmo: PlaneRotationGizmo;
  42728. /**
  42729. * Internal gizmo used for interactions on the z axis
  42730. */
  42731. zGizmo: PlaneRotationGizmo;
  42732. /** Fires an event when any of it's sub gizmos are dragged */
  42733. onDragStartObservable: Observable<{}>;
  42734. /** Fires an event when any of it's sub gizmos are released from dragging */
  42735. onDragEndObservable: Observable<{}>;
  42736. attachedMesh: Nullable<AbstractMesh>;
  42737. /**
  42738. * Creates a RotationGizmo
  42739. * @param gizmoLayer The utility layer the gizmo will be added to
  42740. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42741. */
  42742. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42743. updateGizmoRotationToMatchAttachedMesh: boolean;
  42744. /**
  42745. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42746. */
  42747. snapDistance: number;
  42748. /**
  42749. * Ratio for the scale of the gizmo (Default: 1)
  42750. */
  42751. scaleRatio: number;
  42752. /**
  42753. * Disposes of the gizmo
  42754. */
  42755. dispose(): void;
  42756. /**
  42757. * CustomMeshes are not supported by this gizmo
  42758. * @param mesh The mesh to replace the default mesh of the gizmo
  42759. */
  42760. setCustomMesh(mesh: Mesh): void;
  42761. }
  42762. }
  42763. declare module BABYLON {
  42764. /**
  42765. * Gizmo that enables dragging a mesh along 3 axis
  42766. */
  42767. export class PositionGizmo extends Gizmo {
  42768. /**
  42769. * Internal gizmo used for interactions on the x axis
  42770. */
  42771. xGizmo: AxisDragGizmo;
  42772. /**
  42773. * Internal gizmo used for interactions on the y axis
  42774. */
  42775. yGizmo: AxisDragGizmo;
  42776. /**
  42777. * Internal gizmo used for interactions on the z axis
  42778. */
  42779. zGizmo: AxisDragGizmo;
  42780. /** Fires an event when any of it's sub gizmos are dragged */
  42781. onDragStartObservable: Observable<{}>;
  42782. /** Fires an event when any of it's sub gizmos are released from dragging */
  42783. onDragEndObservable: Observable<{}>;
  42784. attachedMesh: Nullable<AbstractMesh>;
  42785. /**
  42786. * Creates a PositionGizmo
  42787. * @param gizmoLayer The utility layer the gizmo will be added to
  42788. */
  42789. constructor(gizmoLayer?: UtilityLayerRenderer);
  42790. updateGizmoRotationToMatchAttachedMesh: boolean;
  42791. /**
  42792. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42793. */
  42794. snapDistance: number;
  42795. /**
  42796. * Ratio for the scale of the gizmo (Default: 1)
  42797. */
  42798. scaleRatio: number;
  42799. /**
  42800. * Disposes of the gizmo
  42801. */
  42802. dispose(): void;
  42803. /**
  42804. * CustomMeshes are not supported by this gizmo
  42805. * @param mesh The mesh to replace the default mesh of the gizmo
  42806. */
  42807. setCustomMesh(mesh: Mesh): void;
  42808. }
  42809. }
  42810. declare module BABYLON {
  42811. /**
  42812. * Class containing static functions to help procedurally build meshes
  42813. */
  42814. export class PolyhedronBuilder {
  42815. /**
  42816. * Creates a polyhedron mesh
  42817. * * 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
  42818. * * The parameter `size` (positive float, default 1) sets the polygon size
  42819. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42820. * * 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`
  42821. * * 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
  42822. * * 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)`)
  42823. * * 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
  42824. * * 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
  42825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42826. * * 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
  42827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42828. * @param name defines the name of the mesh
  42829. * @param options defines the options used to create the mesh
  42830. * @param scene defines the hosting scene
  42831. * @returns the polyhedron mesh
  42832. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42833. */
  42834. static CreatePolyhedron(name: string, options: {
  42835. type?: number;
  42836. size?: number;
  42837. sizeX?: number;
  42838. sizeY?: number;
  42839. sizeZ?: number;
  42840. custom?: any;
  42841. faceUV?: Vector4[];
  42842. faceColors?: Color4[];
  42843. flat?: boolean;
  42844. updatable?: boolean;
  42845. sideOrientation?: number;
  42846. frontUVs?: Vector4;
  42847. backUVs?: Vector4;
  42848. }, scene?: Nullable<Scene>): Mesh;
  42849. }
  42850. }
  42851. declare module BABYLON {
  42852. /**
  42853. * Gizmo that enables scaling a mesh along 3 axis
  42854. */
  42855. export class ScaleGizmo extends Gizmo {
  42856. /**
  42857. * Internal gizmo used for interactions on the x axis
  42858. */
  42859. xGizmo: AxisScaleGizmo;
  42860. /**
  42861. * Internal gizmo used for interactions on the y axis
  42862. */
  42863. yGizmo: AxisScaleGizmo;
  42864. /**
  42865. * Internal gizmo used for interactions on the z axis
  42866. */
  42867. zGizmo: AxisScaleGizmo;
  42868. /**
  42869. * Internal gizmo used to scale all axis equally
  42870. */
  42871. uniformScaleGizmo: AxisScaleGizmo;
  42872. /** Fires an event when any of it's sub gizmos are dragged */
  42873. onDragStartObservable: Observable<{}>;
  42874. /** Fires an event when any of it's sub gizmos are released from dragging */
  42875. onDragEndObservable: Observable<{}>;
  42876. attachedMesh: Nullable<AbstractMesh>;
  42877. /**
  42878. * Creates a ScaleGizmo
  42879. * @param gizmoLayer The utility layer the gizmo will be added to
  42880. */
  42881. constructor(gizmoLayer?: UtilityLayerRenderer);
  42882. updateGizmoRotationToMatchAttachedMesh: boolean;
  42883. /**
  42884. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42885. */
  42886. snapDistance: number;
  42887. /**
  42888. * Ratio for the scale of the gizmo (Default: 1)
  42889. */
  42890. scaleRatio: number;
  42891. /**
  42892. * Disposes of the gizmo
  42893. */
  42894. dispose(): void;
  42895. }
  42896. }
  42897. declare module BABYLON {
  42898. /**
  42899. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42900. */
  42901. export class GizmoManager implements IDisposable {
  42902. private scene;
  42903. /**
  42904. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42905. */
  42906. gizmos: {
  42907. positionGizmo: Nullable<PositionGizmo>;
  42908. rotationGizmo: Nullable<RotationGizmo>;
  42909. scaleGizmo: Nullable<ScaleGizmo>;
  42910. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42911. };
  42912. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42913. clearGizmoOnEmptyPointerEvent: boolean;
  42914. /** Fires an event when the manager is attached to a mesh */
  42915. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42916. private _gizmosEnabled;
  42917. private _pointerObserver;
  42918. private _attachedMesh;
  42919. private _boundingBoxColor;
  42920. private _defaultUtilityLayer;
  42921. private _defaultKeepDepthUtilityLayer;
  42922. /**
  42923. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42924. */
  42925. boundingBoxDragBehavior: SixDofDragBehavior;
  42926. /**
  42927. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42928. */
  42929. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42930. /**
  42931. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42932. */
  42933. usePointerToAttachGizmos: boolean;
  42934. /**
  42935. * Instatiates a gizmo manager
  42936. * @param scene the scene to overlay the gizmos on top of
  42937. */
  42938. constructor(scene: Scene);
  42939. /**
  42940. * Attaches a set of gizmos to the specified mesh
  42941. * @param mesh The mesh the gizmo's should be attached to
  42942. */
  42943. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42944. /**
  42945. * If the position gizmo is enabled
  42946. */
  42947. positionGizmoEnabled: boolean;
  42948. /**
  42949. * If the rotation gizmo is enabled
  42950. */
  42951. rotationGizmoEnabled: boolean;
  42952. /**
  42953. * If the scale gizmo is enabled
  42954. */
  42955. scaleGizmoEnabled: boolean;
  42956. /**
  42957. * If the boundingBox gizmo is enabled
  42958. */
  42959. boundingBoxGizmoEnabled: boolean;
  42960. /**
  42961. * Disposes of the gizmo manager
  42962. */
  42963. dispose(): void;
  42964. }
  42965. }
  42966. declare module BABYLON {
  42967. /**
  42968. * A directional light is defined by a direction (what a surprise!).
  42969. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42970. * 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.
  42971. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42972. */
  42973. export class DirectionalLight extends ShadowLight {
  42974. private _shadowFrustumSize;
  42975. /**
  42976. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42977. */
  42978. /**
  42979. * Specifies a fix frustum size for the shadow generation.
  42980. */
  42981. shadowFrustumSize: number;
  42982. private _shadowOrthoScale;
  42983. /**
  42984. * Gets the shadow projection scale against the optimal computed one.
  42985. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42986. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42987. */
  42988. /**
  42989. * Sets the shadow projection scale against the optimal computed one.
  42990. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42991. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42992. */
  42993. shadowOrthoScale: number;
  42994. /**
  42995. * Automatically compute the projection matrix to best fit (including all the casters)
  42996. * on each frame.
  42997. */
  42998. autoUpdateExtends: boolean;
  42999. private _orthoLeft;
  43000. private _orthoRight;
  43001. private _orthoTop;
  43002. private _orthoBottom;
  43003. /**
  43004. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43005. * The directional light is emitted from everywhere in the given direction.
  43006. * It can cast shadows.
  43007. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43008. * @param name The friendly name of the light
  43009. * @param direction The direction of the light
  43010. * @param scene The scene the light belongs to
  43011. */
  43012. constructor(name: string, direction: Vector3, scene: Scene);
  43013. /**
  43014. * Returns the string "DirectionalLight".
  43015. * @return The class name
  43016. */
  43017. getClassName(): string;
  43018. /**
  43019. * Returns the integer 1.
  43020. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43021. */
  43022. getTypeID(): number;
  43023. /**
  43024. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43025. * Returns the DirectionalLight Shadow projection matrix.
  43026. */
  43027. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43028. /**
  43029. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43030. * Returns the DirectionalLight Shadow projection matrix.
  43031. */
  43032. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43033. /**
  43034. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43035. * Returns the DirectionalLight Shadow projection matrix.
  43036. */
  43037. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43038. protected _buildUniformLayout(): void;
  43039. /**
  43040. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43041. * @param effect The effect to update
  43042. * @param lightIndex The index of the light in the effect to update
  43043. * @returns The directional light
  43044. */
  43045. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43046. /**
  43047. * Gets the minZ used for shadow according to both the scene and the light.
  43048. *
  43049. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43050. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43051. * @param activeCamera The camera we are returning the min for
  43052. * @returns the depth min z
  43053. */
  43054. getDepthMinZ(activeCamera: Camera): number;
  43055. /**
  43056. * Gets the maxZ used for shadow according to both the scene and the light.
  43057. *
  43058. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43059. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43060. * @param activeCamera The camera we are returning the max for
  43061. * @returns the depth max z
  43062. */
  43063. getDepthMaxZ(activeCamera: Camera): number;
  43064. /**
  43065. * Prepares the list of defines specific to the light type.
  43066. * @param defines the list of defines
  43067. * @param lightIndex defines the index of the light for the effect
  43068. */
  43069. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43070. }
  43071. }
  43072. declare module BABYLON {
  43073. /**
  43074. * Class containing static functions to help procedurally build meshes
  43075. */
  43076. export class HemisphereBuilder {
  43077. /**
  43078. * Creates a hemisphere mesh
  43079. * @param name defines the name of the mesh
  43080. * @param options defines the options used to create the mesh
  43081. * @param scene defines the hosting scene
  43082. * @returns the hemisphere mesh
  43083. */
  43084. static CreateHemisphere(name: string, options: {
  43085. segments?: number;
  43086. diameter?: number;
  43087. sideOrientation?: number;
  43088. }, scene: any): Mesh;
  43089. }
  43090. }
  43091. declare module BABYLON {
  43092. /**
  43093. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43094. * These values define a cone of light starting from the position, emitting toward the direction.
  43095. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43096. * and the exponent defines the speed of the decay of the light with distance (reach).
  43097. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43098. */
  43099. export class SpotLight extends ShadowLight {
  43100. private _angle;
  43101. private _innerAngle;
  43102. private _cosHalfAngle;
  43103. private _lightAngleScale;
  43104. private _lightAngleOffset;
  43105. /**
  43106. * Gets the cone angle of the spot light in Radians.
  43107. */
  43108. /**
  43109. * Sets the cone angle of the spot light in Radians.
  43110. */
  43111. angle: number;
  43112. /**
  43113. * Only used in gltf falloff mode, this defines the angle where
  43114. * the directional falloff will start before cutting at angle which could be seen
  43115. * as outer angle.
  43116. */
  43117. /**
  43118. * Only used in gltf falloff mode, this defines the angle where
  43119. * the directional falloff will start before cutting at angle which could be seen
  43120. * as outer angle.
  43121. */
  43122. innerAngle: number;
  43123. private _shadowAngleScale;
  43124. /**
  43125. * Allows scaling the angle of the light for shadow generation only.
  43126. */
  43127. /**
  43128. * Allows scaling the angle of the light for shadow generation only.
  43129. */
  43130. shadowAngleScale: number;
  43131. /**
  43132. * The light decay speed with the distance from the emission spot.
  43133. */
  43134. exponent: number;
  43135. private _projectionTextureMatrix;
  43136. /**
  43137. * Allows reading the projecton texture
  43138. */
  43139. readonly projectionTextureMatrix: Matrix;
  43140. protected _projectionTextureLightNear: number;
  43141. /**
  43142. * Gets the near clip of the Spotlight for texture projection.
  43143. */
  43144. /**
  43145. * Sets the near clip of the Spotlight for texture projection.
  43146. */
  43147. projectionTextureLightNear: number;
  43148. protected _projectionTextureLightFar: number;
  43149. /**
  43150. * Gets the far clip of the Spotlight for texture projection.
  43151. */
  43152. /**
  43153. * Sets the far clip of the Spotlight for texture projection.
  43154. */
  43155. projectionTextureLightFar: number;
  43156. protected _projectionTextureUpDirection: Vector3;
  43157. /**
  43158. * Gets the Up vector of the Spotlight for texture projection.
  43159. */
  43160. /**
  43161. * Sets the Up vector of the Spotlight for texture projection.
  43162. */
  43163. projectionTextureUpDirection: Vector3;
  43164. private _projectionTexture;
  43165. /**
  43166. * Gets the projection texture of the light.
  43167. */
  43168. /**
  43169. * Sets the projection texture of the light.
  43170. */
  43171. projectionTexture: Nullable<BaseTexture>;
  43172. private _projectionTextureViewLightDirty;
  43173. private _projectionTextureProjectionLightDirty;
  43174. private _projectionTextureDirty;
  43175. private _projectionTextureViewTargetVector;
  43176. private _projectionTextureViewLightMatrix;
  43177. private _projectionTextureProjectionLightMatrix;
  43178. private _projectionTextureScalingMatrix;
  43179. /**
  43180. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43181. * It can cast shadows.
  43182. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43183. * @param name The light friendly name
  43184. * @param position The position of the spot light in the scene
  43185. * @param direction The direction of the light in the scene
  43186. * @param angle The cone angle of the light in Radians
  43187. * @param exponent The light decay speed with the distance from the emission spot
  43188. * @param scene The scene the lights belongs to
  43189. */
  43190. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43191. /**
  43192. * Returns the string "SpotLight".
  43193. * @returns the class name
  43194. */
  43195. getClassName(): string;
  43196. /**
  43197. * Returns the integer 2.
  43198. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43199. */
  43200. getTypeID(): number;
  43201. /**
  43202. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43203. */
  43204. protected _setDirection(value: Vector3): void;
  43205. /**
  43206. * Overrides the position setter to recompute the projection texture view light Matrix.
  43207. */
  43208. protected _setPosition(value: Vector3): void;
  43209. /**
  43210. * 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.
  43211. * Returns the SpotLight.
  43212. */
  43213. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43214. protected _computeProjectionTextureViewLightMatrix(): void;
  43215. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43216. /**
  43217. * Main function for light texture projection matrix computing.
  43218. */
  43219. protected _computeProjectionTextureMatrix(): void;
  43220. protected _buildUniformLayout(): void;
  43221. private _computeAngleValues;
  43222. /**
  43223. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43224. * @param effect The effect to update
  43225. * @param lightIndex The index of the light in the effect to update
  43226. * @returns The spot light
  43227. */
  43228. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43229. /**
  43230. * Disposes the light and the associated resources.
  43231. */
  43232. dispose(): void;
  43233. /**
  43234. * Prepares the list of defines specific to the light type.
  43235. * @param defines the list of defines
  43236. * @param lightIndex defines the index of the light for the effect
  43237. */
  43238. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43239. }
  43240. }
  43241. declare module BABYLON {
  43242. /**
  43243. * Gizmo that enables viewing a light
  43244. */
  43245. export class LightGizmo extends Gizmo {
  43246. private _lightMesh;
  43247. private _material;
  43248. private cachedPosition;
  43249. private cachedForward;
  43250. /**
  43251. * Creates a LightGizmo
  43252. * @param gizmoLayer The utility layer the gizmo will be added to
  43253. */
  43254. constructor(gizmoLayer?: UtilityLayerRenderer);
  43255. private _light;
  43256. /**
  43257. * The light that the gizmo is attached to
  43258. */
  43259. light: Nullable<Light>;
  43260. /**
  43261. * @hidden
  43262. * Updates the gizmo to match the attached mesh's position/rotation
  43263. */
  43264. protected _update(): void;
  43265. private static _Scale;
  43266. /**
  43267. * Creates the lines for a light mesh
  43268. */
  43269. private static _createLightLines;
  43270. /**
  43271. * Disposes of the light gizmo
  43272. */
  43273. dispose(): void;
  43274. private static _CreateHemisphericLightMesh;
  43275. private static _CreatePointLightMesh;
  43276. private static _CreateSpotLightMesh;
  43277. private static _CreateDirectionalLightMesh;
  43278. }
  43279. }
  43280. declare module BABYLON {
  43281. /** @hidden */
  43282. export var backgroundFragmentDeclaration: {
  43283. name: string;
  43284. shader: string;
  43285. };
  43286. }
  43287. declare module BABYLON {
  43288. /** @hidden */
  43289. export var backgroundUboDeclaration: {
  43290. name: string;
  43291. shader: string;
  43292. };
  43293. }
  43294. declare module BABYLON {
  43295. /** @hidden */
  43296. export var backgroundPixelShader: {
  43297. name: string;
  43298. shader: string;
  43299. };
  43300. }
  43301. declare module BABYLON {
  43302. /** @hidden */
  43303. export var backgroundVertexDeclaration: {
  43304. name: string;
  43305. shader: string;
  43306. };
  43307. }
  43308. declare module BABYLON {
  43309. /** @hidden */
  43310. export var backgroundVertexShader: {
  43311. name: string;
  43312. shader: string;
  43313. };
  43314. }
  43315. declare module BABYLON {
  43316. /**
  43317. * Background material used to create an efficient environement around your scene.
  43318. */
  43319. export class BackgroundMaterial extends PushMaterial {
  43320. /**
  43321. * Standard reflectance value at parallel view angle.
  43322. */
  43323. static StandardReflectance0: number;
  43324. /**
  43325. * Standard reflectance value at grazing angle.
  43326. */
  43327. static StandardReflectance90: number;
  43328. protected _primaryColor: Color3;
  43329. /**
  43330. * Key light Color (multiply against the environement texture)
  43331. */
  43332. primaryColor: Color3;
  43333. protected __perceptualColor: Nullable<Color3>;
  43334. /**
  43335. * Experimental Internal Use Only.
  43336. *
  43337. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43338. * This acts as a helper to set the primary color to a more "human friendly" value.
  43339. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43340. * output color as close as possible from the chosen value.
  43341. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43342. * part of lighting setup.)
  43343. */
  43344. _perceptualColor: Nullable<Color3>;
  43345. protected _primaryColorShadowLevel: float;
  43346. /**
  43347. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43348. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43349. */
  43350. primaryColorShadowLevel: float;
  43351. protected _primaryColorHighlightLevel: float;
  43352. /**
  43353. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43354. * The primary color is used at the level chosen to define what the white area would look.
  43355. */
  43356. primaryColorHighlightLevel: float;
  43357. protected _reflectionTexture: Nullable<BaseTexture>;
  43358. /**
  43359. * Reflection Texture used in the material.
  43360. * Should be author in a specific way for the best result (refer to the documentation).
  43361. */
  43362. reflectionTexture: Nullable<BaseTexture>;
  43363. protected _reflectionBlur: float;
  43364. /**
  43365. * Reflection Texture level of blur.
  43366. *
  43367. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43368. * texture twice.
  43369. */
  43370. reflectionBlur: float;
  43371. protected _diffuseTexture: Nullable<BaseTexture>;
  43372. /**
  43373. * Diffuse Texture used in the material.
  43374. * Should be author in a specific way for the best result (refer to the documentation).
  43375. */
  43376. diffuseTexture: Nullable<BaseTexture>;
  43377. protected _shadowLights: Nullable<IShadowLight[]>;
  43378. /**
  43379. * Specify the list of lights casting shadow on the material.
  43380. * All scene shadow lights will be included if null.
  43381. */
  43382. shadowLights: Nullable<IShadowLight[]>;
  43383. protected _shadowLevel: float;
  43384. /**
  43385. * Helps adjusting the shadow to a softer level if required.
  43386. * 0 means black shadows and 1 means no shadows.
  43387. */
  43388. shadowLevel: float;
  43389. protected _sceneCenter: Vector3;
  43390. /**
  43391. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43392. * It is usually zero but might be interesting to modify according to your setup.
  43393. */
  43394. sceneCenter: Vector3;
  43395. protected _opacityFresnel: boolean;
  43396. /**
  43397. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43398. * This helps ensuring a nice transition when the camera goes under the ground.
  43399. */
  43400. opacityFresnel: boolean;
  43401. protected _reflectionFresnel: boolean;
  43402. /**
  43403. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43404. * This helps adding a mirror texture on the ground.
  43405. */
  43406. reflectionFresnel: boolean;
  43407. protected _reflectionFalloffDistance: number;
  43408. /**
  43409. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43410. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43411. */
  43412. reflectionFalloffDistance: number;
  43413. protected _reflectionAmount: number;
  43414. /**
  43415. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43416. */
  43417. reflectionAmount: number;
  43418. protected _reflectionReflectance0: number;
  43419. /**
  43420. * This specifies the weight of the reflection at grazing angle.
  43421. */
  43422. reflectionReflectance0: number;
  43423. protected _reflectionReflectance90: number;
  43424. /**
  43425. * This specifies the weight of the reflection at a perpendicular point of view.
  43426. */
  43427. reflectionReflectance90: number;
  43428. /**
  43429. * Sets the reflection reflectance fresnel values according to the default standard
  43430. * empirically know to work well :-)
  43431. */
  43432. reflectionStandardFresnelWeight: number;
  43433. protected _useRGBColor: boolean;
  43434. /**
  43435. * Helps to directly use the maps channels instead of their level.
  43436. */
  43437. useRGBColor: boolean;
  43438. protected _enableNoise: boolean;
  43439. /**
  43440. * This helps reducing the banding effect that could occur on the background.
  43441. */
  43442. enableNoise: boolean;
  43443. /**
  43444. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43445. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43446. * Recommended to be keep at 1.0 except for special cases.
  43447. */
  43448. fovMultiplier: number;
  43449. private _fovMultiplier;
  43450. /**
  43451. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43452. */
  43453. useEquirectangularFOV: boolean;
  43454. private _maxSimultaneousLights;
  43455. /**
  43456. * Number of Simultaneous lights allowed on the material.
  43457. */
  43458. maxSimultaneousLights: int;
  43459. /**
  43460. * Default configuration related to image processing available in the Background Material.
  43461. */
  43462. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43463. /**
  43464. * Keep track of the image processing observer to allow dispose and replace.
  43465. */
  43466. private _imageProcessingObserver;
  43467. /**
  43468. * Attaches a new image processing configuration to the PBR Material.
  43469. * @param configuration (if null the scene configuration will be use)
  43470. */
  43471. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43472. /**
  43473. * Gets the image processing configuration used either in this material.
  43474. */
  43475. /**
  43476. * Sets the Default image processing configuration used either in the this material.
  43477. *
  43478. * If sets to null, the scene one is in use.
  43479. */
  43480. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43481. /**
  43482. * Gets wether the color curves effect is enabled.
  43483. */
  43484. /**
  43485. * Sets wether the color curves effect is enabled.
  43486. */
  43487. cameraColorCurvesEnabled: boolean;
  43488. /**
  43489. * Gets wether the color grading effect is enabled.
  43490. */
  43491. /**
  43492. * Gets wether the color grading effect is enabled.
  43493. */
  43494. cameraColorGradingEnabled: boolean;
  43495. /**
  43496. * Gets wether tonemapping is enabled or not.
  43497. */
  43498. /**
  43499. * Sets wether tonemapping is enabled or not
  43500. */
  43501. cameraToneMappingEnabled: boolean;
  43502. /**
  43503. * The camera exposure used on this material.
  43504. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43505. * This corresponds to a photographic exposure.
  43506. */
  43507. /**
  43508. * The camera exposure used on this material.
  43509. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43510. * This corresponds to a photographic exposure.
  43511. */
  43512. cameraExposure: float;
  43513. /**
  43514. * Gets The camera contrast used on this material.
  43515. */
  43516. /**
  43517. * Sets The camera contrast used on this material.
  43518. */
  43519. cameraContrast: float;
  43520. /**
  43521. * Gets the Color Grading 2D Lookup Texture.
  43522. */
  43523. /**
  43524. * Sets the Color Grading 2D Lookup Texture.
  43525. */
  43526. cameraColorGradingTexture: Nullable<BaseTexture>;
  43527. /**
  43528. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43529. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43530. * 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;
  43531. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43532. */
  43533. /**
  43534. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43535. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43536. * 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;
  43537. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43538. */
  43539. cameraColorCurves: Nullable<ColorCurves>;
  43540. /**
  43541. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43542. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43543. */
  43544. switchToBGR: boolean;
  43545. private _renderTargets;
  43546. private _reflectionControls;
  43547. private _white;
  43548. private _primaryShadowColor;
  43549. private _primaryHighlightColor;
  43550. /**
  43551. * Instantiates a Background Material in the given scene
  43552. * @param name The friendly name of the material
  43553. * @param scene The scene to add the material to
  43554. */
  43555. constructor(name: string, scene: Scene);
  43556. /**
  43557. * Gets a boolean indicating that current material needs to register RTT
  43558. */
  43559. readonly hasRenderTargetTextures: boolean;
  43560. /**
  43561. * The entire material has been created in order to prevent overdraw.
  43562. * @returns false
  43563. */
  43564. needAlphaTesting(): boolean;
  43565. /**
  43566. * The entire material has been created in order to prevent overdraw.
  43567. * @returns true if blending is enable
  43568. */
  43569. needAlphaBlending(): boolean;
  43570. /**
  43571. * Checks wether the material is ready to be rendered for a given mesh.
  43572. * @param mesh The mesh to render
  43573. * @param subMesh The submesh to check against
  43574. * @param useInstances Specify wether or not the material is used with instances
  43575. * @returns true if all the dependencies are ready (Textures, Effects...)
  43576. */
  43577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43578. /**
  43579. * Compute the primary color according to the chosen perceptual color.
  43580. */
  43581. private _computePrimaryColorFromPerceptualColor;
  43582. /**
  43583. * Compute the highlights and shadow colors according to their chosen levels.
  43584. */
  43585. private _computePrimaryColors;
  43586. /**
  43587. * Build the uniform buffer used in the material.
  43588. */
  43589. buildUniformLayout(): void;
  43590. /**
  43591. * Unbind the material.
  43592. */
  43593. unbind(): void;
  43594. /**
  43595. * Bind only the world matrix to the material.
  43596. * @param world The world matrix to bind.
  43597. */
  43598. bindOnlyWorldMatrix(world: Matrix): void;
  43599. /**
  43600. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43601. * @param world The world matrix to bind.
  43602. * @param subMesh The submesh to bind for.
  43603. */
  43604. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43605. /**
  43606. * Dispose the material.
  43607. * @param forceDisposeEffect Force disposal of the associated effect.
  43608. * @param forceDisposeTextures Force disposal of the associated textures.
  43609. */
  43610. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43611. /**
  43612. * Clones the material.
  43613. * @param name The cloned name.
  43614. * @returns The cloned material.
  43615. */
  43616. clone(name: string): BackgroundMaterial;
  43617. /**
  43618. * Serializes the current material to its JSON representation.
  43619. * @returns The JSON representation.
  43620. */
  43621. serialize(): any;
  43622. /**
  43623. * Gets the class name of the material
  43624. * @returns "BackgroundMaterial"
  43625. */
  43626. getClassName(): string;
  43627. /**
  43628. * Parse a JSON input to create back a background material.
  43629. * @param source The JSON data to parse
  43630. * @param scene The scene to create the parsed material in
  43631. * @param rootUrl The root url of the assets the material depends upon
  43632. * @returns the instantiated BackgroundMaterial.
  43633. */
  43634. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43635. }
  43636. }
  43637. declare module BABYLON {
  43638. /**
  43639. * Represents the different options available during the creation of
  43640. * a Environment helper.
  43641. *
  43642. * This can control the default ground, skybox and image processing setup of your scene.
  43643. */
  43644. export interface IEnvironmentHelperOptions {
  43645. /**
  43646. * Specifies wether or not to create a ground.
  43647. * True by default.
  43648. */
  43649. createGround: boolean;
  43650. /**
  43651. * Specifies the ground size.
  43652. * 15 by default.
  43653. */
  43654. groundSize: number;
  43655. /**
  43656. * The texture used on the ground for the main color.
  43657. * Comes from the BabylonJS CDN by default.
  43658. *
  43659. * Remarks: Can be either a texture or a url.
  43660. */
  43661. groundTexture: string | BaseTexture;
  43662. /**
  43663. * The color mixed in the ground texture by default.
  43664. * BabylonJS clearColor by default.
  43665. */
  43666. groundColor: Color3;
  43667. /**
  43668. * Specifies the ground opacity.
  43669. * 1 by default.
  43670. */
  43671. groundOpacity: number;
  43672. /**
  43673. * Enables the ground to receive shadows.
  43674. * True by default.
  43675. */
  43676. enableGroundShadow: boolean;
  43677. /**
  43678. * Helps preventing the shadow to be fully black on the ground.
  43679. * 0.5 by default.
  43680. */
  43681. groundShadowLevel: number;
  43682. /**
  43683. * Creates a mirror texture attach to the ground.
  43684. * false by default.
  43685. */
  43686. enableGroundMirror: boolean;
  43687. /**
  43688. * Specifies the ground mirror size ratio.
  43689. * 0.3 by default as the default kernel is 64.
  43690. */
  43691. groundMirrorSizeRatio: number;
  43692. /**
  43693. * Specifies the ground mirror blur kernel size.
  43694. * 64 by default.
  43695. */
  43696. groundMirrorBlurKernel: number;
  43697. /**
  43698. * Specifies the ground mirror visibility amount.
  43699. * 1 by default
  43700. */
  43701. groundMirrorAmount: number;
  43702. /**
  43703. * Specifies the ground mirror reflectance weight.
  43704. * This uses the standard weight of the background material to setup the fresnel effect
  43705. * of the mirror.
  43706. * 1 by default.
  43707. */
  43708. groundMirrorFresnelWeight: number;
  43709. /**
  43710. * Specifies the ground mirror Falloff distance.
  43711. * This can helps reducing the size of the reflection.
  43712. * 0 by Default.
  43713. */
  43714. groundMirrorFallOffDistance: number;
  43715. /**
  43716. * Specifies the ground mirror texture type.
  43717. * Unsigned Int by Default.
  43718. */
  43719. groundMirrorTextureType: number;
  43720. /**
  43721. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43722. * the shown objects.
  43723. */
  43724. groundYBias: number;
  43725. /**
  43726. * Specifies wether or not to create a skybox.
  43727. * True by default.
  43728. */
  43729. createSkybox: boolean;
  43730. /**
  43731. * Specifies the skybox size.
  43732. * 20 by default.
  43733. */
  43734. skyboxSize: number;
  43735. /**
  43736. * The texture used on the skybox for the main color.
  43737. * Comes from the BabylonJS CDN by default.
  43738. *
  43739. * Remarks: Can be either a texture or a url.
  43740. */
  43741. skyboxTexture: string | BaseTexture;
  43742. /**
  43743. * The color mixed in the skybox texture by default.
  43744. * BabylonJS clearColor by default.
  43745. */
  43746. skyboxColor: Color3;
  43747. /**
  43748. * The background rotation around the Y axis of the scene.
  43749. * This helps aligning the key lights of your scene with the background.
  43750. * 0 by default.
  43751. */
  43752. backgroundYRotation: number;
  43753. /**
  43754. * Compute automatically the size of the elements to best fit with the scene.
  43755. */
  43756. sizeAuto: boolean;
  43757. /**
  43758. * Default position of the rootMesh if autoSize is not true.
  43759. */
  43760. rootPosition: Vector3;
  43761. /**
  43762. * Sets up the image processing in the scene.
  43763. * true by default.
  43764. */
  43765. setupImageProcessing: boolean;
  43766. /**
  43767. * The texture used as your environment texture in the scene.
  43768. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43769. *
  43770. * Remarks: Can be either a texture or a url.
  43771. */
  43772. environmentTexture: string | BaseTexture;
  43773. /**
  43774. * The value of the exposure to apply to the scene.
  43775. * 0.6 by default if setupImageProcessing is true.
  43776. */
  43777. cameraExposure: number;
  43778. /**
  43779. * The value of the contrast to apply to the scene.
  43780. * 1.6 by default if setupImageProcessing is true.
  43781. */
  43782. cameraContrast: number;
  43783. /**
  43784. * Specifies wether or not tonemapping should be enabled in the scene.
  43785. * true by default if setupImageProcessing is true.
  43786. */
  43787. toneMappingEnabled: boolean;
  43788. }
  43789. /**
  43790. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43791. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43792. * It also helps with the default setup of your imageProcessing configuration.
  43793. */
  43794. export class EnvironmentHelper {
  43795. /**
  43796. * Default ground texture URL.
  43797. */
  43798. private static _groundTextureCDNUrl;
  43799. /**
  43800. * Default skybox texture URL.
  43801. */
  43802. private static _skyboxTextureCDNUrl;
  43803. /**
  43804. * Default environment texture URL.
  43805. */
  43806. private static _environmentTextureCDNUrl;
  43807. /**
  43808. * Creates the default options for the helper.
  43809. */
  43810. private static _getDefaultOptions;
  43811. private _rootMesh;
  43812. /**
  43813. * Gets the root mesh created by the helper.
  43814. */
  43815. readonly rootMesh: Mesh;
  43816. private _skybox;
  43817. /**
  43818. * Gets the skybox created by the helper.
  43819. */
  43820. readonly skybox: Nullable<Mesh>;
  43821. private _skyboxTexture;
  43822. /**
  43823. * Gets the skybox texture created by the helper.
  43824. */
  43825. readonly skyboxTexture: Nullable<BaseTexture>;
  43826. private _skyboxMaterial;
  43827. /**
  43828. * Gets the skybox material created by the helper.
  43829. */
  43830. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43831. private _ground;
  43832. /**
  43833. * Gets the ground mesh created by the helper.
  43834. */
  43835. readonly ground: Nullable<Mesh>;
  43836. private _groundTexture;
  43837. /**
  43838. * Gets the ground texture created by the helper.
  43839. */
  43840. readonly groundTexture: Nullable<BaseTexture>;
  43841. private _groundMirror;
  43842. /**
  43843. * Gets the ground mirror created by the helper.
  43844. */
  43845. readonly groundMirror: Nullable<MirrorTexture>;
  43846. /**
  43847. * Gets the ground mirror render list to helps pushing the meshes
  43848. * you wish in the ground reflection.
  43849. */
  43850. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43851. private _groundMaterial;
  43852. /**
  43853. * Gets the ground material created by the helper.
  43854. */
  43855. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43856. /**
  43857. * Stores the creation options.
  43858. */
  43859. private readonly _scene;
  43860. private _options;
  43861. /**
  43862. * This observable will be notified with any error during the creation of the environment,
  43863. * mainly texture creation errors.
  43864. */
  43865. onErrorObservable: Observable<{
  43866. message?: string;
  43867. exception?: any;
  43868. }>;
  43869. /**
  43870. * constructor
  43871. * @param options Defines the options we want to customize the helper
  43872. * @param scene The scene to add the material to
  43873. */
  43874. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43875. /**
  43876. * Updates the background according to the new options
  43877. * @param options
  43878. */
  43879. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43880. /**
  43881. * Sets the primary color of all the available elements.
  43882. * @param color the main color to affect to the ground and the background
  43883. */
  43884. setMainColor(color: Color3): void;
  43885. /**
  43886. * Setup the image processing according to the specified options.
  43887. */
  43888. private _setupImageProcessing;
  43889. /**
  43890. * Setup the environment texture according to the specified options.
  43891. */
  43892. private _setupEnvironmentTexture;
  43893. /**
  43894. * Setup the background according to the specified options.
  43895. */
  43896. private _setupBackground;
  43897. /**
  43898. * Get the scene sizes according to the setup.
  43899. */
  43900. private _getSceneSize;
  43901. /**
  43902. * Setup the ground according to the specified options.
  43903. */
  43904. private _setupGround;
  43905. /**
  43906. * Setup the ground material according to the specified options.
  43907. */
  43908. private _setupGroundMaterial;
  43909. /**
  43910. * Setup the ground diffuse texture according to the specified options.
  43911. */
  43912. private _setupGroundDiffuseTexture;
  43913. /**
  43914. * Setup the ground mirror texture according to the specified options.
  43915. */
  43916. private _setupGroundMirrorTexture;
  43917. /**
  43918. * Setup the ground to receive the mirror texture.
  43919. */
  43920. private _setupMirrorInGroundMaterial;
  43921. /**
  43922. * Setup the skybox according to the specified options.
  43923. */
  43924. private _setupSkybox;
  43925. /**
  43926. * Setup the skybox material according to the specified options.
  43927. */
  43928. private _setupSkyboxMaterial;
  43929. /**
  43930. * Setup the skybox reflection texture according to the specified options.
  43931. */
  43932. private _setupSkyboxReflectionTexture;
  43933. private _errorHandler;
  43934. /**
  43935. * Dispose all the elements created by the Helper.
  43936. */
  43937. dispose(): void;
  43938. }
  43939. }
  43940. declare module BABYLON {
  43941. /**
  43942. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43943. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43944. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43945. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43946. */
  43947. export class PhotoDome extends TransformNode {
  43948. private _useDirectMapping;
  43949. /**
  43950. * The texture being displayed on the sphere
  43951. */
  43952. protected _photoTexture: Texture;
  43953. /**
  43954. * Gets or sets the texture being displayed on the sphere
  43955. */
  43956. photoTexture: Texture;
  43957. /**
  43958. * Observable raised when an error occured while loading the 360 image
  43959. */
  43960. onLoadErrorObservable: Observable<string>;
  43961. /**
  43962. * The skybox material
  43963. */
  43964. protected _material: BackgroundMaterial;
  43965. /**
  43966. * The surface used for the skybox
  43967. */
  43968. protected _mesh: Mesh;
  43969. /**
  43970. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43971. * Also see the options.resolution property.
  43972. */
  43973. fovMultiplier: number;
  43974. /**
  43975. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43976. * @param name Element's name, child elements will append suffixes for their own names.
  43977. * @param urlsOfPhoto defines the url of the photo to display
  43978. * @param options defines an object containing optional or exposed sub element properties
  43979. * @param onError defines a callback called when an error occured while loading the texture
  43980. */
  43981. constructor(name: string, urlOfPhoto: string, options: {
  43982. resolution?: number;
  43983. size?: number;
  43984. useDirectMapping?: boolean;
  43985. faceForward?: boolean;
  43986. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43987. /**
  43988. * Releases resources associated with this node.
  43989. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43990. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43991. */
  43992. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43993. }
  43994. }
  43995. declare module BABYLON {
  43996. /** @hidden */
  43997. export var rgbdDecodePixelShader: {
  43998. name: string;
  43999. shader: string;
  44000. };
  44001. }
  44002. declare module BABYLON {
  44003. /**
  44004. * Class used to host texture specific utilities
  44005. */
  44006. export class BRDFTextureTools {
  44007. /**
  44008. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44009. * @param texture the texture to expand.
  44010. */
  44011. private static _ExpandDefaultBRDFTexture;
  44012. /**
  44013. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44014. * @param scene defines the hosting scene
  44015. * @returns the environment BRDF texture
  44016. */
  44017. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44018. private static _environmentBRDFBase64Texture;
  44019. }
  44020. }
  44021. declare module BABYLON {
  44022. /**
  44023. * @hidden
  44024. */
  44025. export interface IMaterialClearCoatDefines {
  44026. CLEARCOAT: boolean;
  44027. CLEARCOAT_DEFAULTIOR: boolean;
  44028. CLEARCOAT_TEXTURE: boolean;
  44029. CLEARCOAT_TEXTUREDIRECTUV: number;
  44030. CLEARCOAT_BUMP: boolean;
  44031. CLEARCOAT_BUMPDIRECTUV: number;
  44032. CLEARCOAT_TINT: boolean;
  44033. CLEARCOAT_TINT_TEXTURE: boolean;
  44034. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44035. /** @hidden */
  44036. _areTexturesDirty: boolean;
  44037. }
  44038. /**
  44039. * Define the code related to the clear coat parameters of the pbr material.
  44040. */
  44041. export class PBRClearCoatConfiguration {
  44042. /**
  44043. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44044. * The default fits with a polyurethane material.
  44045. */
  44046. private static readonly _DefaultIndiceOfRefraction;
  44047. private _isEnabled;
  44048. /**
  44049. * Defines if the clear coat is enabled in the material.
  44050. */
  44051. isEnabled: boolean;
  44052. /**
  44053. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44054. */
  44055. intensity: number;
  44056. /**
  44057. * Defines the clear coat layer roughness.
  44058. */
  44059. roughness: number;
  44060. private _indiceOfRefraction;
  44061. /**
  44062. * Defines the indice of refraction of the clear coat.
  44063. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44064. * The default fits with a polyurethane material.
  44065. * Changing the default value is more performance intensive.
  44066. */
  44067. indiceOfRefraction: number;
  44068. private _texture;
  44069. /**
  44070. * Stores the clear coat values in a texture.
  44071. */
  44072. texture: Nullable<BaseTexture>;
  44073. private _bumpTexture;
  44074. /**
  44075. * Define the clear coat specific bump texture.
  44076. */
  44077. bumpTexture: Nullable<BaseTexture>;
  44078. private _isTintEnabled;
  44079. /**
  44080. * Defines if the clear coat tint is enabled in the material.
  44081. */
  44082. isTintEnabled: boolean;
  44083. /**
  44084. * Defines the clear coat tint of the material.
  44085. * This is only use if tint is enabled
  44086. */
  44087. tintColor: Color3;
  44088. /**
  44089. * Defines the distance at which the tint color should be found in the
  44090. * clear coat media.
  44091. * This is only use if tint is enabled
  44092. */
  44093. tintColorAtDistance: number;
  44094. /**
  44095. * Defines the clear coat layer thickness.
  44096. * This is only use if tint is enabled
  44097. */
  44098. tintThickness: number;
  44099. private _tintTexture;
  44100. /**
  44101. * Stores the clear tint values in a texture.
  44102. * rgb is tint
  44103. * a is a thickness factor
  44104. */
  44105. tintTexture: Nullable<BaseTexture>;
  44106. /** @hidden */
  44107. private _internalMarkAllSubMeshesAsTexturesDirty;
  44108. /** @hidden */
  44109. _markAllSubMeshesAsTexturesDirty(): void;
  44110. /**
  44111. * Instantiate a new istance of clear coat configuration.
  44112. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44113. */
  44114. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44115. /**
  44116. * Gets wehter the submesh is ready to be used or not.
  44117. * @param defines the list of "defines" to update.
  44118. * @param scene defines the scene the material belongs to.
  44119. * @param engine defines the engine the material belongs to.
  44120. * @param disableBumpMap defines wether the material disables bump or not.
  44121. * @returns - boolean indicating that the submesh is ready or not.
  44122. */
  44123. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44124. /**
  44125. * Checks to see if a texture is used in the material.
  44126. * @param defines the list of "defines" to update.
  44127. * @param scene defines the scene to the material belongs to.
  44128. */
  44129. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44130. /**
  44131. * Binds the material data.
  44132. * @param uniformBuffer defines the Uniform buffer to fill in.
  44133. * @param scene defines the scene the material belongs to.
  44134. * @param engine defines the engine the material belongs to.
  44135. * @param disableBumpMap defines wether the material disables bump or not.
  44136. * @param isFrozen defines wether the material is frozen or not.
  44137. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44138. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44139. */
  44140. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44141. /**
  44142. * Checks to see if a texture is used in the material.
  44143. * @param texture - Base texture to use.
  44144. * @returns - Boolean specifying if a texture is used in the material.
  44145. */
  44146. hasTexture(texture: BaseTexture): boolean;
  44147. /**
  44148. * Returns an array of the actively used textures.
  44149. * @param activeTextures Array of BaseTextures
  44150. */
  44151. getActiveTextures(activeTextures: BaseTexture[]): void;
  44152. /**
  44153. * Returns the animatable textures.
  44154. * @param animatables Array of animatable textures.
  44155. */
  44156. getAnimatables(animatables: IAnimatable[]): void;
  44157. /**
  44158. * Disposes the resources of the material.
  44159. * @param forceDisposeTextures - Forces the disposal of all textures.
  44160. */
  44161. dispose(forceDisposeTextures?: boolean): void;
  44162. /**
  44163. * Get the current class name of the texture useful for serialization or dynamic coding.
  44164. * @returns "PBRClearCoatConfiguration"
  44165. */
  44166. getClassName(): string;
  44167. /**
  44168. * Add fallbacks to the effect fallbacks list.
  44169. * @param defines defines the Base texture to use.
  44170. * @param fallbacks defines the current fallback list.
  44171. * @param currentRank defines the current fallback rank.
  44172. * @returns the new fallback rank.
  44173. */
  44174. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44175. /**
  44176. * Add the required uniforms to the current list.
  44177. * @param uniforms defines the current uniform list.
  44178. */
  44179. static AddUniforms(uniforms: string[]): void;
  44180. /**
  44181. * Add the required samplers to the current list.
  44182. * @param samplers defines the current sampler list.
  44183. */
  44184. static AddSamplers(samplers: string[]): void;
  44185. /**
  44186. * Add the required uniforms to the current buffer.
  44187. * @param uniformBuffer defines the current uniform buffer.
  44188. */
  44189. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44190. /**
  44191. * Makes a duplicate of the current configuration into another one.
  44192. * @param clearCoatConfiguration define the config where to copy the info
  44193. */
  44194. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44195. /**
  44196. * Serializes this clear coat configuration.
  44197. * @returns - An object with the serialized config.
  44198. */
  44199. serialize(): any;
  44200. /**
  44201. * Parses a Clear Coat Configuration from a serialized object.
  44202. * @param source - Serialized object.
  44203. */
  44204. parse(source: any): void;
  44205. }
  44206. }
  44207. declare module BABYLON {
  44208. /**
  44209. * @hidden
  44210. */
  44211. export interface IMaterialAnisotropicDefines {
  44212. ANISOTROPIC: boolean;
  44213. ANISOTROPIC_TEXTURE: boolean;
  44214. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44215. MAINUV1: boolean;
  44216. _areTexturesDirty: boolean;
  44217. _needUVs: boolean;
  44218. }
  44219. /**
  44220. * Define the code related to the anisotropic parameters of the pbr material.
  44221. */
  44222. export class PBRAnisotropicConfiguration {
  44223. private _isEnabled;
  44224. /**
  44225. * Defines if the anisotropy is enabled in the material.
  44226. */
  44227. isEnabled: boolean;
  44228. /**
  44229. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44230. */
  44231. intensity: number;
  44232. /**
  44233. * Defines if the effect is along the tangents, bitangents or in between.
  44234. * By default, the effect is "strectching" the highlights along the tangents.
  44235. */
  44236. direction: Vector2;
  44237. private _texture;
  44238. /**
  44239. * Stores the anisotropy values in a texture.
  44240. * rg is direction (like normal from -1 to 1)
  44241. * b is a intensity
  44242. */
  44243. texture: Nullable<BaseTexture>;
  44244. /** @hidden */
  44245. private _internalMarkAllSubMeshesAsTexturesDirty;
  44246. /** @hidden */
  44247. _markAllSubMeshesAsTexturesDirty(): void;
  44248. /**
  44249. * Instantiate a new istance of anisotropy configuration.
  44250. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44251. */
  44252. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44253. /**
  44254. * Specifies that the submesh is ready to be used.
  44255. * @param defines the list of "defines" to update.
  44256. * @param scene defines the scene the material belongs to.
  44257. * @returns - boolean indicating that the submesh is ready or not.
  44258. */
  44259. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44260. /**
  44261. * Checks to see if a texture is used in the material.
  44262. * @param defines the list of "defines" to update.
  44263. * @param mesh the mesh we are preparing the defines for.
  44264. * @param scene defines the scene the material belongs to.
  44265. */
  44266. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44267. /**
  44268. * Binds the material data.
  44269. * @param uniformBuffer defines the Uniform buffer to fill in.
  44270. * @param scene defines the scene the material belongs to.
  44271. * @param isFrozen defines wether the material is frozen or not.
  44272. */
  44273. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44274. /**
  44275. * Checks to see if a texture is used in the material.
  44276. * @param texture - Base texture to use.
  44277. * @returns - Boolean specifying if a texture is used in the material.
  44278. */
  44279. hasTexture(texture: BaseTexture): boolean;
  44280. /**
  44281. * Returns an array of the actively used textures.
  44282. * @param activeTextures Array of BaseTextures
  44283. */
  44284. getActiveTextures(activeTextures: BaseTexture[]): void;
  44285. /**
  44286. * Returns the animatable textures.
  44287. * @param animatables Array of animatable textures.
  44288. */
  44289. getAnimatables(animatables: IAnimatable[]): void;
  44290. /**
  44291. * Disposes the resources of the material.
  44292. * @param forceDisposeTextures - Forces the disposal of all textures.
  44293. */
  44294. dispose(forceDisposeTextures?: boolean): void;
  44295. /**
  44296. * Get the current class name of the texture useful for serialization or dynamic coding.
  44297. * @returns "PBRAnisotropicConfiguration"
  44298. */
  44299. getClassName(): string;
  44300. /**
  44301. * Add fallbacks to the effect fallbacks list.
  44302. * @param defines defines the Base texture to use.
  44303. * @param fallbacks defines the current fallback list.
  44304. * @param currentRank defines the current fallback rank.
  44305. * @returns the new fallback rank.
  44306. */
  44307. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44308. /**
  44309. * Add the required uniforms to the current list.
  44310. * @param uniforms defines the current uniform list.
  44311. */
  44312. static AddUniforms(uniforms: string[]): void;
  44313. /**
  44314. * Add the required uniforms to the current buffer.
  44315. * @param uniformBuffer defines the current uniform buffer.
  44316. */
  44317. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44318. /**
  44319. * Add the required samplers to the current list.
  44320. * @param samplers defines the current sampler list.
  44321. */
  44322. static AddSamplers(samplers: string[]): void;
  44323. /**
  44324. * Makes a duplicate of the current configuration into another one.
  44325. * @param anisotropicConfiguration define the config where to copy the info
  44326. */
  44327. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44328. /**
  44329. * Serializes this anisotropy configuration.
  44330. * @returns - An object with the serialized config.
  44331. */
  44332. serialize(): any;
  44333. /**
  44334. * Parses a anisotropy Configuration from a serialized object.
  44335. * @param source - Serialized object.
  44336. */
  44337. parse(source: any): void;
  44338. }
  44339. }
  44340. declare module BABYLON {
  44341. /**
  44342. * @hidden
  44343. */
  44344. export interface IMaterialBRDFDefines {
  44345. BRDF_V_HEIGHT_CORRELATED: boolean;
  44346. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44347. SPHERICAL_HARMONICS: boolean;
  44348. /** @hidden */
  44349. _areMiscDirty: boolean;
  44350. }
  44351. /**
  44352. * Define the code related to the BRDF parameters of the pbr material.
  44353. */
  44354. export class PBRBRDFConfiguration {
  44355. /**
  44356. * Default value used for the energy conservation.
  44357. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44358. */
  44359. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44360. /**
  44361. * Default value used for the Smith Visibility Height Correlated mode.
  44362. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44363. */
  44364. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44365. /**
  44366. * Default value used for the IBL diffuse part.
  44367. * This can help switching back to the polynomials mode globally which is a tiny bit
  44368. * less GPU intensive at the drawback of a lower quality.
  44369. */
  44370. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44371. private _useEnergyConservation;
  44372. /**
  44373. * Defines if the material uses energy conservation.
  44374. */
  44375. useEnergyConservation: boolean;
  44376. private _useSmithVisibilityHeightCorrelated;
  44377. /**
  44378. * LEGACY Mode set to false
  44379. * Defines if the material uses height smith correlated visibility term.
  44380. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  44381. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44382. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  44383. * Not relying on height correlated will also disable energy conservation.
  44384. */
  44385. useSmithVisibilityHeightCorrelated: boolean;
  44386. private _useSphericalHarmonics;
  44387. /**
  44388. * LEGACY Mode set to false
  44389. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  44390. * diffuse part of the IBL.
  44391. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  44392. * to the ground truth.
  44393. */
  44394. useSphericalHarmonics: boolean;
  44395. /** @hidden */
  44396. private _internalMarkAllSubMeshesAsMiscDirty;
  44397. /** @hidden */
  44398. _markAllSubMeshesAsMiscDirty(): void;
  44399. /**
  44400. * Instantiate a new istance of clear coat configuration.
  44401. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  44402. */
  44403. constructor(markAllSubMeshesAsMiscDirty: () => void);
  44404. /**
  44405. * Checks to see if a texture is used in the material.
  44406. * @param defines the list of "defines" to update.
  44407. */
  44408. prepareDefines(defines: IMaterialBRDFDefines): void;
  44409. /**
  44410. * Get the current class name of the texture useful for serialization or dynamic coding.
  44411. * @returns "PBRClearCoatConfiguration"
  44412. */
  44413. getClassName(): string;
  44414. /**
  44415. * Makes a duplicate of the current configuration into another one.
  44416. * @param brdfConfiguration define the config where to copy the info
  44417. */
  44418. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  44419. /**
  44420. * Serializes this BRDF configuration.
  44421. * @returns - An object with the serialized config.
  44422. */
  44423. serialize(): any;
  44424. /**
  44425. * Parses a BRDF Configuration from a serialized object.
  44426. * @param source - Serialized object.
  44427. */
  44428. parse(source: any): void;
  44429. }
  44430. }
  44431. declare module BABYLON {
  44432. /**
  44433. * @hidden
  44434. */
  44435. export interface IMaterialSheenDefines {
  44436. SHEEN: boolean;
  44437. SHEEN_TEXTURE: boolean;
  44438. SHEEN_TEXTUREDIRECTUV: number;
  44439. SHEEN_LINKWITHALBEDO: boolean;
  44440. /** @hidden */
  44441. _areTexturesDirty: boolean;
  44442. }
  44443. /**
  44444. * Define the code related to the Sheen parameters of the pbr material.
  44445. */
  44446. export class PBRSheenConfiguration {
  44447. private _isEnabled;
  44448. /**
  44449. * Defines if the material uses sheen.
  44450. */
  44451. isEnabled: boolean;
  44452. private _linkSheenWithAlbedo;
  44453. /**
  44454. * Defines if the sheen is linked to the sheen color.
  44455. */
  44456. linkSheenWithAlbedo: boolean;
  44457. /**
  44458. * Defines the sheen intensity.
  44459. */
  44460. intensity: number;
  44461. /**
  44462. * Defines the sheen color.
  44463. */
  44464. color: Color3;
  44465. private _texture;
  44466. /**
  44467. * Stores the sheen tint values in a texture.
  44468. * rgb is tint
  44469. * a is a intensity
  44470. */
  44471. texture: Nullable<BaseTexture>;
  44472. /** @hidden */
  44473. private _internalMarkAllSubMeshesAsTexturesDirty;
  44474. /** @hidden */
  44475. _markAllSubMeshesAsTexturesDirty(): void;
  44476. /**
  44477. * Instantiate a new istance of clear coat configuration.
  44478. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44479. */
  44480. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44481. /**
  44482. * Specifies that the submesh is ready to be used.
  44483. * @param defines the list of "defines" to update.
  44484. * @param scene defines the scene the material belongs to.
  44485. * @returns - boolean indicating that the submesh is ready or not.
  44486. */
  44487. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  44488. /**
  44489. * Checks to see if a texture is used in the material.
  44490. * @param defines the list of "defines" to update.
  44491. * @param scene defines the scene the material belongs to.
  44492. */
  44493. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  44494. /**
  44495. * Binds the material data.
  44496. * @param uniformBuffer defines the Uniform buffer to fill in.
  44497. * @param scene defines the scene the material belongs to.
  44498. * @param isFrozen defines wether the material is frozen or not.
  44499. */
  44500. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44501. /**
  44502. * Checks to see if a texture is used in the material.
  44503. * @param texture - Base texture to use.
  44504. * @returns - Boolean specifying if a texture is used in the material.
  44505. */
  44506. hasTexture(texture: BaseTexture): boolean;
  44507. /**
  44508. * Returns an array of the actively used textures.
  44509. * @param activeTextures Array of BaseTextures
  44510. */
  44511. getActiveTextures(activeTextures: BaseTexture[]): void;
  44512. /**
  44513. * Returns the animatable textures.
  44514. * @param animatables Array of animatable textures.
  44515. */
  44516. getAnimatables(animatables: IAnimatable[]): void;
  44517. /**
  44518. * Disposes the resources of the material.
  44519. * @param forceDisposeTextures - Forces the disposal of all textures.
  44520. */
  44521. dispose(forceDisposeTextures?: boolean): void;
  44522. /**
  44523. * Get the current class name of the texture useful for serialization or dynamic coding.
  44524. * @returns "PBRSheenConfiguration"
  44525. */
  44526. getClassName(): string;
  44527. /**
  44528. * Add fallbacks to the effect fallbacks list.
  44529. * @param defines defines the Base texture to use.
  44530. * @param fallbacks defines the current fallback list.
  44531. * @param currentRank defines the current fallback rank.
  44532. * @returns the new fallback rank.
  44533. */
  44534. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44535. /**
  44536. * Add the required uniforms to the current list.
  44537. * @param uniforms defines the current uniform list.
  44538. */
  44539. static AddUniforms(uniforms: string[]): void;
  44540. /**
  44541. * Add the required uniforms to the current buffer.
  44542. * @param uniformBuffer defines the current uniform buffer.
  44543. */
  44544. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44545. /**
  44546. * Add the required samplers to the current list.
  44547. * @param samplers defines the current sampler list.
  44548. */
  44549. static AddSamplers(samplers: string[]): void;
  44550. /**
  44551. * Makes a duplicate of the current configuration into another one.
  44552. * @param sheenConfiguration define the config where to copy the info
  44553. */
  44554. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  44555. /**
  44556. * Serializes this BRDF configuration.
  44557. * @returns - An object with the serialized config.
  44558. */
  44559. serialize(): any;
  44560. /**
  44561. * Parses a Sheen Configuration from a serialized object.
  44562. * @param source - Serialized object.
  44563. */
  44564. parse(source: any): void;
  44565. }
  44566. }
  44567. declare module BABYLON {
  44568. /**
  44569. * @hidden
  44570. */
  44571. export interface IMaterialSubSurfaceDefines {
  44572. SUBSURFACE: boolean;
  44573. SS_REFRACTION: boolean;
  44574. SS_TRANSLUCENCY: boolean;
  44575. SS_SCATERRING: boolean;
  44576. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44577. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44578. SS_REFRACTIONMAP_3D: boolean;
  44579. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44580. SS_LODINREFRACTIONALPHA: boolean;
  44581. SS_GAMMAREFRACTION: boolean;
  44582. SS_RGBDREFRACTION: boolean;
  44583. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44584. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44585. /** @hidden */
  44586. _areTexturesDirty: boolean;
  44587. }
  44588. /**
  44589. * Define the code related to the sub surface parameters of the pbr material.
  44590. */
  44591. export class PBRSubSurfaceConfiguration {
  44592. private _isRefractionEnabled;
  44593. /**
  44594. * Defines if the refraction is enabled in the material.
  44595. */
  44596. isRefractionEnabled: boolean;
  44597. private _isTranslucencyEnabled;
  44598. /**
  44599. * Defines if the translucency is enabled in the material.
  44600. */
  44601. isTranslucencyEnabled: boolean;
  44602. private _isScatteringEnabled;
  44603. /**
  44604. * Defines the refraction intensity of the material.
  44605. * The refraction when enabled replaces the Diffuse part of the material.
  44606. * The intensity helps transitionning between diffuse and refraction.
  44607. */
  44608. refractionIntensity: number;
  44609. /**
  44610. * Defines the translucency intensity of the material.
  44611. * When translucency has been enabled, this defines how much of the "translucency"
  44612. * is addded to the diffuse part of the material.
  44613. */
  44614. translucencyIntensity: number;
  44615. /**
  44616. * Defines the scattering intensity of the material.
  44617. * When scattering has been enabled, this defines how much of the "scattered light"
  44618. * is addded to the diffuse part of the material.
  44619. */
  44620. scatteringIntensity: number;
  44621. private _thicknessTexture;
  44622. /**
  44623. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  44624. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  44625. * 0 would mean minimumThickness
  44626. * 1 would mean maximumThickness
  44627. * The other channels might be use as a mask to vary the different effects intensity.
  44628. */
  44629. thicknessTexture: Nullable<BaseTexture>;
  44630. private _refractionTexture;
  44631. /**
  44632. * Defines the texture to use for refraction.
  44633. */
  44634. refractionTexture: Nullable<BaseTexture>;
  44635. private _indexOfRefraction;
  44636. /**
  44637. * Defines the indice of refraction used in the material.
  44638. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  44639. */
  44640. indexOfRefraction: number;
  44641. private _invertRefractionY;
  44642. /**
  44643. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44644. */
  44645. invertRefractionY: boolean;
  44646. private _linkRefractionWithTransparency;
  44647. /**
  44648. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44649. * Materials half opaque for instance using refraction could benefit from this control.
  44650. */
  44651. linkRefractionWithTransparency: boolean;
  44652. /**
  44653. * Defines the minimum thickness stored in the thickness map.
  44654. * If no thickness map is defined, this value will be used to simulate thickness.
  44655. */
  44656. minimumThickness: number;
  44657. /**
  44658. * Defines the maximum thickness stored in the thickness map.
  44659. */
  44660. maximumThickness: number;
  44661. /**
  44662. * Defines the volume tint of the material.
  44663. * This is used for both translucency and scattering.
  44664. */
  44665. tintColor: Color3;
  44666. /**
  44667. * Defines the distance at which the tint color should be found in the media.
  44668. * This is used for refraction only.
  44669. */
  44670. tintColorAtDistance: number;
  44671. /**
  44672. * Defines how far each channel transmit through the media.
  44673. * It is defined as a color to simplify it selection.
  44674. */
  44675. diffusionDistance: Color3;
  44676. private _useMaskFromThicknessTexture;
  44677. /**
  44678. * Stores the intensity of the different subsurface effects in the thickness texture.
  44679. * * the green channel is the translucency intensity.
  44680. * * the blue channel is the scattering intensity.
  44681. * * the alpha channel is the refraction intensity.
  44682. */
  44683. useMaskFromThicknessTexture: boolean;
  44684. /** @hidden */
  44685. private _internalMarkAllSubMeshesAsTexturesDirty;
  44686. /** @hidden */
  44687. _markAllSubMeshesAsTexturesDirty(): void;
  44688. /**
  44689. * Instantiate a new istance of sub surface configuration.
  44690. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44691. */
  44692. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44693. /**
  44694. * Gets wehter the submesh is ready to be used or not.
  44695. * @param defines the list of "defines" to update.
  44696. * @param scene defines the scene the material belongs to.
  44697. * @returns - boolean indicating that the submesh is ready or not.
  44698. */
  44699. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44700. /**
  44701. * Checks to see if a texture is used in the material.
  44702. * @param defines the list of "defines" to update.
  44703. * @param scene defines the scene to the material belongs to.
  44704. */
  44705. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44706. /**
  44707. * Binds the material data.
  44708. * @param uniformBuffer defines the Uniform buffer to fill in.
  44709. * @param scene defines the scene the material belongs to.
  44710. * @param engine defines the engine the material belongs to.
  44711. * @param isFrozen defines wether the material is frozen or not.
  44712. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44713. */
  44714. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44715. /**
  44716. * Unbinds the material from the mesh.
  44717. * @param activeEffect defines the effect that should be unbound from.
  44718. * @returns true if unbound, otherwise false
  44719. */
  44720. unbind(activeEffect: Effect): boolean;
  44721. /**
  44722. * Returns the texture used for refraction or null if none is used.
  44723. * @param scene defines the scene the material belongs to.
  44724. * @returns - Refraction texture if present. If no refraction texture and refraction
  44725. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44726. */
  44727. private _getRefractionTexture;
  44728. /**
  44729. * Returns true if alpha blending should be disabled.
  44730. */
  44731. readonly disableAlphaBlending: boolean;
  44732. /**
  44733. * Fills the list of render target textures.
  44734. * @param renderTargets the list of render targets to update
  44735. */
  44736. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44737. /**
  44738. * Checks to see if a texture is used in the material.
  44739. * @param texture - Base texture to use.
  44740. * @returns - Boolean specifying if a texture is used in the material.
  44741. */
  44742. hasTexture(texture: BaseTexture): boolean;
  44743. /**
  44744. * Gets a boolean indicating that current material needs to register RTT
  44745. * @returns true if this uses a render target otherwise false.
  44746. */
  44747. hasRenderTargetTextures(): boolean;
  44748. /**
  44749. * Returns an array of the actively used textures.
  44750. * @param activeTextures Array of BaseTextures
  44751. */
  44752. getActiveTextures(activeTextures: BaseTexture[]): void;
  44753. /**
  44754. * Returns the animatable textures.
  44755. * @param animatables Array of animatable textures.
  44756. */
  44757. getAnimatables(animatables: IAnimatable[]): void;
  44758. /**
  44759. * Disposes the resources of the material.
  44760. * @param forceDisposeTextures - Forces the disposal of all textures.
  44761. */
  44762. dispose(forceDisposeTextures?: boolean): void;
  44763. /**
  44764. * Get the current class name of the texture useful for serialization or dynamic coding.
  44765. * @returns "PBRSubSurfaceConfiguration"
  44766. */
  44767. getClassName(): string;
  44768. /**
  44769. * Add fallbacks to the effect fallbacks list.
  44770. * @param defines defines the Base texture to use.
  44771. * @param fallbacks defines the current fallback list.
  44772. * @param currentRank defines the current fallback rank.
  44773. * @returns the new fallback rank.
  44774. */
  44775. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44776. /**
  44777. * Add the required uniforms to the current list.
  44778. * @param uniforms defines the current uniform list.
  44779. */
  44780. static AddUniforms(uniforms: string[]): void;
  44781. /**
  44782. * Add the required samplers to the current list.
  44783. * @param samplers defines the current sampler list.
  44784. */
  44785. static AddSamplers(samplers: string[]): void;
  44786. /**
  44787. * Add the required uniforms to the current buffer.
  44788. * @param uniformBuffer defines the current uniform buffer.
  44789. */
  44790. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44791. /**
  44792. * Makes a duplicate of the current configuration into another one.
  44793. * @param configuration define the config where to copy the info
  44794. */
  44795. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44796. /**
  44797. * Serializes this Sub Surface configuration.
  44798. * @returns - An object with the serialized config.
  44799. */
  44800. serialize(): any;
  44801. /**
  44802. * Parses a Sub Surface Configuration from a serialized object.
  44803. * @param source - Serialized object.
  44804. */
  44805. parse(source: any): void;
  44806. }
  44807. }
  44808. declare module BABYLON {
  44809. /** @hidden */
  44810. export var pbrFragmentDeclaration: {
  44811. name: string;
  44812. shader: string;
  44813. };
  44814. }
  44815. declare module BABYLON {
  44816. /** @hidden */
  44817. export var pbrUboDeclaration: {
  44818. name: string;
  44819. shader: string;
  44820. };
  44821. }
  44822. declare module BABYLON {
  44823. /** @hidden */
  44824. export var pbrFragmentExtraDeclaration: {
  44825. name: string;
  44826. shader: string;
  44827. };
  44828. }
  44829. declare module BABYLON {
  44830. /** @hidden */
  44831. export var pbrFragmentSamplersDeclaration: {
  44832. name: string;
  44833. shader: string;
  44834. };
  44835. }
  44836. declare module BABYLON {
  44837. /** @hidden */
  44838. export var pbrHelperFunctions: {
  44839. name: string;
  44840. shader: string;
  44841. };
  44842. }
  44843. declare module BABYLON {
  44844. /** @hidden */
  44845. export var harmonicsFunctions: {
  44846. name: string;
  44847. shader: string;
  44848. };
  44849. }
  44850. declare module BABYLON {
  44851. /** @hidden */
  44852. export var pbrDirectLightingSetupFunctions: {
  44853. name: string;
  44854. shader: string;
  44855. };
  44856. }
  44857. declare module BABYLON {
  44858. /** @hidden */
  44859. export var pbrDirectLightingFalloffFunctions: {
  44860. name: string;
  44861. shader: string;
  44862. };
  44863. }
  44864. declare module BABYLON {
  44865. /** @hidden */
  44866. export var pbrBRDFFunctions: {
  44867. name: string;
  44868. shader: string;
  44869. };
  44870. }
  44871. declare module BABYLON {
  44872. /** @hidden */
  44873. export var pbrDirectLightingFunctions: {
  44874. name: string;
  44875. shader: string;
  44876. };
  44877. }
  44878. declare module BABYLON {
  44879. /** @hidden */
  44880. export var pbrIBLFunctions: {
  44881. name: string;
  44882. shader: string;
  44883. };
  44884. }
  44885. declare module BABYLON {
  44886. /** @hidden */
  44887. export var pbrDebug: {
  44888. name: string;
  44889. shader: string;
  44890. };
  44891. }
  44892. declare module BABYLON {
  44893. /** @hidden */
  44894. export var pbrPixelShader: {
  44895. name: string;
  44896. shader: string;
  44897. };
  44898. }
  44899. declare module BABYLON {
  44900. /** @hidden */
  44901. export var pbrVertexDeclaration: {
  44902. name: string;
  44903. shader: string;
  44904. };
  44905. }
  44906. declare module BABYLON {
  44907. /** @hidden */
  44908. export var pbrVertexShader: {
  44909. name: string;
  44910. shader: string;
  44911. };
  44912. }
  44913. declare module BABYLON {
  44914. /**
  44915. * Manages the defines for the PBR Material.
  44916. * @hidden
  44917. */
  44918. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44919. PBR: boolean;
  44920. MAINUV1: boolean;
  44921. MAINUV2: boolean;
  44922. UV1: boolean;
  44923. UV2: boolean;
  44924. ALBEDO: boolean;
  44925. ALBEDODIRECTUV: number;
  44926. VERTEXCOLOR: boolean;
  44927. AMBIENT: boolean;
  44928. AMBIENTDIRECTUV: number;
  44929. AMBIENTINGRAYSCALE: boolean;
  44930. OPACITY: boolean;
  44931. VERTEXALPHA: boolean;
  44932. OPACITYDIRECTUV: number;
  44933. OPACITYRGB: boolean;
  44934. ALPHATEST: boolean;
  44935. DEPTHPREPASS: boolean;
  44936. ALPHABLEND: boolean;
  44937. ALPHAFROMALBEDO: boolean;
  44938. ALPHATESTVALUE: string;
  44939. SPECULAROVERALPHA: boolean;
  44940. RADIANCEOVERALPHA: boolean;
  44941. ALPHAFRESNEL: boolean;
  44942. LINEARALPHAFRESNEL: boolean;
  44943. PREMULTIPLYALPHA: boolean;
  44944. EMISSIVE: boolean;
  44945. EMISSIVEDIRECTUV: number;
  44946. REFLECTIVITY: boolean;
  44947. REFLECTIVITYDIRECTUV: number;
  44948. SPECULARTERM: boolean;
  44949. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44950. MICROSURFACEAUTOMATIC: boolean;
  44951. LODBASEDMICROSFURACE: boolean;
  44952. MICROSURFACEMAP: boolean;
  44953. MICROSURFACEMAPDIRECTUV: number;
  44954. METALLICWORKFLOW: boolean;
  44955. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44956. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44957. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44958. AOSTOREINMETALMAPRED: boolean;
  44959. ENVIRONMENTBRDF: boolean;
  44960. ENVIRONMENTBRDF_RGBD: boolean;
  44961. NORMAL: boolean;
  44962. TANGENT: boolean;
  44963. BUMP: boolean;
  44964. BUMPDIRECTUV: number;
  44965. OBJECTSPACE_NORMALMAP: boolean;
  44966. PARALLAX: boolean;
  44967. PARALLAXOCCLUSION: boolean;
  44968. NORMALXYSCALE: boolean;
  44969. LIGHTMAP: boolean;
  44970. LIGHTMAPDIRECTUV: number;
  44971. USELIGHTMAPASSHADOWMAP: boolean;
  44972. GAMMALIGHTMAP: boolean;
  44973. REFLECTION: boolean;
  44974. REFLECTIONMAP_3D: boolean;
  44975. REFLECTIONMAP_SPHERICAL: boolean;
  44976. REFLECTIONMAP_PLANAR: boolean;
  44977. REFLECTIONMAP_CUBIC: boolean;
  44978. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44979. REFLECTIONMAP_PROJECTION: boolean;
  44980. REFLECTIONMAP_SKYBOX: boolean;
  44981. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44982. REFLECTIONMAP_EXPLICIT: boolean;
  44983. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44984. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44985. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44986. INVERTCUBICMAP: boolean;
  44987. USESPHERICALFROMREFLECTIONMAP: boolean;
  44988. SPHERICAL_HARMONICS: boolean;
  44989. USESPHERICALINVERTEX: boolean;
  44990. REFLECTIONMAP_OPPOSITEZ: boolean;
  44991. LODINREFLECTIONALPHA: boolean;
  44992. GAMMAREFLECTION: boolean;
  44993. RGBDREFLECTION: boolean;
  44994. RADIANCEOCCLUSION: boolean;
  44995. HORIZONOCCLUSION: boolean;
  44996. INSTANCES: boolean;
  44997. NUM_BONE_INFLUENCERS: number;
  44998. BonesPerMesh: number;
  44999. BONETEXTURE: boolean;
  45000. NONUNIFORMSCALING: boolean;
  45001. MORPHTARGETS: boolean;
  45002. MORPHTARGETS_NORMAL: boolean;
  45003. MORPHTARGETS_TANGENT: boolean;
  45004. NUM_MORPH_INFLUENCERS: number;
  45005. IMAGEPROCESSING: boolean;
  45006. VIGNETTE: boolean;
  45007. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45008. VIGNETTEBLENDMODEOPAQUE: boolean;
  45009. TONEMAPPING: boolean;
  45010. TONEMAPPING_ACES: boolean;
  45011. CONTRAST: boolean;
  45012. COLORCURVES: boolean;
  45013. COLORGRADING: boolean;
  45014. COLORGRADING3D: boolean;
  45015. SAMPLER3DGREENDEPTH: boolean;
  45016. SAMPLER3DBGRMAP: boolean;
  45017. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45018. EXPOSURE: boolean;
  45019. MULTIVIEW: boolean;
  45020. USEPHYSICALLIGHTFALLOFF: boolean;
  45021. USEGLTFLIGHTFALLOFF: boolean;
  45022. TWOSIDEDLIGHTING: boolean;
  45023. SHADOWFLOAT: boolean;
  45024. CLIPPLANE: boolean;
  45025. CLIPPLANE2: boolean;
  45026. CLIPPLANE3: boolean;
  45027. CLIPPLANE4: boolean;
  45028. POINTSIZE: boolean;
  45029. FOG: boolean;
  45030. LOGARITHMICDEPTH: boolean;
  45031. FORCENORMALFORWARD: boolean;
  45032. SPECULARAA: boolean;
  45033. CLEARCOAT: boolean;
  45034. CLEARCOAT_DEFAULTIOR: boolean;
  45035. CLEARCOAT_TEXTURE: boolean;
  45036. CLEARCOAT_TEXTUREDIRECTUV: number;
  45037. CLEARCOAT_BUMP: boolean;
  45038. CLEARCOAT_BUMPDIRECTUV: number;
  45039. CLEARCOAT_TINT: boolean;
  45040. CLEARCOAT_TINT_TEXTURE: boolean;
  45041. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45042. ANISOTROPIC: boolean;
  45043. ANISOTROPIC_TEXTURE: boolean;
  45044. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45045. BRDF_V_HEIGHT_CORRELATED: boolean;
  45046. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45047. SHEEN: boolean;
  45048. SHEEN_TEXTURE: boolean;
  45049. SHEEN_TEXTUREDIRECTUV: number;
  45050. SHEEN_LINKWITHALBEDO: boolean;
  45051. SUBSURFACE: boolean;
  45052. SS_REFRACTION: boolean;
  45053. SS_TRANSLUCENCY: boolean;
  45054. SS_SCATERRING: boolean;
  45055. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45056. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45057. SS_REFRACTIONMAP_3D: boolean;
  45058. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45059. SS_LODINREFRACTIONALPHA: boolean;
  45060. SS_GAMMAREFRACTION: boolean;
  45061. SS_RGBDREFRACTION: boolean;
  45062. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45063. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45064. UNLIT: boolean;
  45065. DEBUGMODE: number;
  45066. /**
  45067. * Initializes the PBR Material defines.
  45068. */
  45069. constructor();
  45070. /**
  45071. * Resets the PBR Material defines.
  45072. */
  45073. reset(): void;
  45074. }
  45075. /**
  45076. * The Physically based material base class of BJS.
  45077. *
  45078. * This offers the main features of a standard PBR material.
  45079. * For more information, please refer to the documentation :
  45080. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45081. */
  45082. export abstract class PBRBaseMaterial extends PushMaterial {
  45083. /**
  45084. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45085. */
  45086. static readonly PBRMATERIAL_OPAQUE: number;
  45087. /**
  45088. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45089. */
  45090. static readonly PBRMATERIAL_ALPHATEST: number;
  45091. /**
  45092. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45093. */
  45094. static readonly PBRMATERIAL_ALPHABLEND: number;
  45095. /**
  45096. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45097. * They are also discarded below the alpha cutoff threshold to improve performances.
  45098. */
  45099. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45100. /**
  45101. * Defines the default value of how much AO map is occluding the analytical lights
  45102. * (point spot...).
  45103. */
  45104. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45105. /**
  45106. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45107. */
  45108. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45109. /**
  45110. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45111. * to enhance interoperability with other engines.
  45112. */
  45113. static readonly LIGHTFALLOFF_GLTF: number;
  45114. /**
  45115. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45116. * to enhance interoperability with other materials.
  45117. */
  45118. static readonly LIGHTFALLOFF_STANDARD: number;
  45119. /**
  45120. * Intensity of the direct lights e.g. the four lights available in your scene.
  45121. * This impacts both the direct diffuse and specular highlights.
  45122. */
  45123. protected _directIntensity: number;
  45124. /**
  45125. * Intensity of the emissive part of the material.
  45126. * This helps controlling the emissive effect without modifying the emissive color.
  45127. */
  45128. protected _emissiveIntensity: number;
  45129. /**
  45130. * Intensity of the environment e.g. how much the environment will light the object
  45131. * either through harmonics for rough material or through the refelction for shiny ones.
  45132. */
  45133. protected _environmentIntensity: number;
  45134. /**
  45135. * This is a special control allowing the reduction of the specular highlights coming from the
  45136. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45137. */
  45138. protected _specularIntensity: number;
  45139. /**
  45140. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45141. */
  45142. private _lightingInfos;
  45143. /**
  45144. * Debug Control allowing disabling the bump map on this material.
  45145. */
  45146. protected _disableBumpMap: boolean;
  45147. /**
  45148. * AKA Diffuse Texture in standard nomenclature.
  45149. */
  45150. protected _albedoTexture: Nullable<BaseTexture>;
  45151. /**
  45152. * AKA Occlusion Texture in other nomenclature.
  45153. */
  45154. protected _ambientTexture: Nullable<BaseTexture>;
  45155. /**
  45156. * AKA Occlusion Texture Intensity in other nomenclature.
  45157. */
  45158. protected _ambientTextureStrength: number;
  45159. /**
  45160. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45161. * 1 means it completely occludes it
  45162. * 0 mean it has no impact
  45163. */
  45164. protected _ambientTextureImpactOnAnalyticalLights: number;
  45165. /**
  45166. * Stores the alpha values in a texture.
  45167. */
  45168. protected _opacityTexture: Nullable<BaseTexture>;
  45169. /**
  45170. * Stores the reflection values in a texture.
  45171. */
  45172. protected _reflectionTexture: Nullable<BaseTexture>;
  45173. /**
  45174. * Stores the emissive values in a texture.
  45175. */
  45176. protected _emissiveTexture: Nullable<BaseTexture>;
  45177. /**
  45178. * AKA Specular texture in other nomenclature.
  45179. */
  45180. protected _reflectivityTexture: Nullable<BaseTexture>;
  45181. /**
  45182. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45183. */
  45184. protected _metallicTexture: Nullable<BaseTexture>;
  45185. /**
  45186. * Specifies the metallic scalar of the metallic/roughness workflow.
  45187. * Can also be used to scale the metalness values of the metallic texture.
  45188. */
  45189. protected _metallic: Nullable<number>;
  45190. /**
  45191. * Specifies the roughness scalar of the metallic/roughness workflow.
  45192. * Can also be used to scale the roughness values of the metallic texture.
  45193. */
  45194. protected _roughness: Nullable<number>;
  45195. /**
  45196. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45197. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45198. */
  45199. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45200. /**
  45201. * Stores surface normal data used to displace a mesh in a texture.
  45202. */
  45203. protected _bumpTexture: Nullable<BaseTexture>;
  45204. /**
  45205. * Stores the pre-calculated light information of a mesh in a texture.
  45206. */
  45207. protected _lightmapTexture: Nullable<BaseTexture>;
  45208. /**
  45209. * The color of a material in ambient lighting.
  45210. */
  45211. protected _ambientColor: Color3;
  45212. /**
  45213. * AKA Diffuse Color in other nomenclature.
  45214. */
  45215. protected _albedoColor: Color3;
  45216. /**
  45217. * AKA Specular Color in other nomenclature.
  45218. */
  45219. protected _reflectivityColor: Color3;
  45220. /**
  45221. * The color applied when light is reflected from a material.
  45222. */
  45223. protected _reflectionColor: Color3;
  45224. /**
  45225. * The color applied when light is emitted from a material.
  45226. */
  45227. protected _emissiveColor: Color3;
  45228. /**
  45229. * AKA Glossiness in other nomenclature.
  45230. */
  45231. protected _microSurface: number;
  45232. /**
  45233. * Specifies that the material will use the light map as a show map.
  45234. */
  45235. protected _useLightmapAsShadowmap: boolean;
  45236. /**
  45237. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45238. * makes the reflect vector face the model (under horizon).
  45239. */
  45240. protected _useHorizonOcclusion: boolean;
  45241. /**
  45242. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45243. * too much the area relying on ambient texture to define their ambient occlusion.
  45244. */
  45245. protected _useRadianceOcclusion: boolean;
  45246. /**
  45247. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45248. */
  45249. protected _useAlphaFromAlbedoTexture: boolean;
  45250. /**
  45251. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45252. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45253. */
  45254. protected _useSpecularOverAlpha: boolean;
  45255. /**
  45256. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45257. */
  45258. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45259. /**
  45260. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45261. */
  45262. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45263. /**
  45264. * Specifies if the metallic texture contains the roughness information in its green channel.
  45265. */
  45266. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45267. /**
  45268. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45269. */
  45270. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45271. /**
  45272. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45273. */
  45274. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45275. /**
  45276. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45277. */
  45278. protected _useAmbientInGrayScale: boolean;
  45279. /**
  45280. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45281. * The material will try to infer what glossiness each pixel should be.
  45282. */
  45283. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45284. /**
  45285. * Defines the falloff type used in this material.
  45286. * It by default is Physical.
  45287. */
  45288. protected _lightFalloff: number;
  45289. /**
  45290. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45291. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45292. */
  45293. protected _useRadianceOverAlpha: boolean;
  45294. /**
  45295. * Allows using an object space normal map (instead of tangent space).
  45296. */
  45297. protected _useObjectSpaceNormalMap: boolean;
  45298. /**
  45299. * Allows using the bump map in parallax mode.
  45300. */
  45301. protected _useParallax: boolean;
  45302. /**
  45303. * Allows using the bump map in parallax occlusion mode.
  45304. */
  45305. protected _useParallaxOcclusion: boolean;
  45306. /**
  45307. * Controls the scale bias of the parallax mode.
  45308. */
  45309. protected _parallaxScaleBias: number;
  45310. /**
  45311. * If sets to true, disables all the lights affecting the material.
  45312. */
  45313. protected _disableLighting: boolean;
  45314. /**
  45315. * Number of Simultaneous lights allowed on the material.
  45316. */
  45317. protected _maxSimultaneousLights: number;
  45318. /**
  45319. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45320. */
  45321. protected _invertNormalMapX: boolean;
  45322. /**
  45323. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45324. */
  45325. protected _invertNormalMapY: boolean;
  45326. /**
  45327. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45328. */
  45329. protected _twoSidedLighting: boolean;
  45330. /**
  45331. * Defines the alpha limits in alpha test mode.
  45332. */
  45333. protected _alphaCutOff: number;
  45334. /**
  45335. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45336. */
  45337. protected _forceAlphaTest: boolean;
  45338. /**
  45339. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45340. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45341. */
  45342. protected _useAlphaFresnel: boolean;
  45343. /**
  45344. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45345. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45346. */
  45347. protected _useLinearAlphaFresnel: boolean;
  45348. /**
  45349. * The transparency mode of the material.
  45350. */
  45351. protected _transparencyMode: Nullable<number>;
  45352. /**
  45353. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45354. * from cos thetav and roughness:
  45355. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45356. */
  45357. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45358. /**
  45359. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45360. */
  45361. protected _forceIrradianceInFragment: boolean;
  45362. /**
  45363. * Force normal to face away from face.
  45364. */
  45365. protected _forceNormalForward: boolean;
  45366. /**
  45367. * Enables specular anti aliasing in the PBR shader.
  45368. * It will both interacts on the Geometry for analytical and IBL lighting.
  45369. * It also prefilter the roughness map based on the bump values.
  45370. */
  45371. protected _enableSpecularAntiAliasing: boolean;
  45372. /**
  45373. * Default configuration related to image processing available in the PBR Material.
  45374. */
  45375. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45376. /**
  45377. * Keep track of the image processing observer to allow dispose and replace.
  45378. */
  45379. private _imageProcessingObserver;
  45380. /**
  45381. * Attaches a new image processing configuration to the PBR Material.
  45382. * @param configuration
  45383. */
  45384. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45385. /**
  45386. * Stores the available render targets.
  45387. */
  45388. private _renderTargets;
  45389. /**
  45390. * Sets the global ambient color for the material used in lighting calculations.
  45391. */
  45392. private _globalAmbientColor;
  45393. /**
  45394. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45395. */
  45396. private _useLogarithmicDepth;
  45397. /**
  45398. * If set to true, no lighting calculations will be applied.
  45399. */
  45400. private _unlit;
  45401. private _debugMode;
  45402. /**
  45403. * @hidden
  45404. * This is reserved for the inspector.
  45405. * Defines the material debug mode.
  45406. * It helps seeing only some components of the material while troubleshooting.
  45407. */
  45408. debugMode: number;
  45409. /**
  45410. * @hidden
  45411. * This is reserved for the inspector.
  45412. * Specify from where on screen the debug mode should start.
  45413. * The value goes from -1 (full screen) to 1 (not visible)
  45414. * It helps with side by side comparison against the final render
  45415. * This defaults to -1
  45416. */
  45417. private debugLimit;
  45418. /**
  45419. * @hidden
  45420. * This is reserved for the inspector.
  45421. * As the default viewing range might not be enough (if the ambient is really small for instance)
  45422. * You can use the factor to better multiply the final value.
  45423. */
  45424. private debugFactor;
  45425. /**
  45426. * Defines the clear coat layer parameters for the material.
  45427. */
  45428. readonly clearCoat: PBRClearCoatConfiguration;
  45429. /**
  45430. * Defines the anisotropic parameters for the material.
  45431. */
  45432. readonly anisotropy: PBRAnisotropicConfiguration;
  45433. /**
  45434. * Defines the BRDF parameters for the material.
  45435. */
  45436. readonly brdf: PBRBRDFConfiguration;
  45437. /**
  45438. * Defines the Sheen parameters for the material.
  45439. */
  45440. readonly sheen: PBRSheenConfiguration;
  45441. /**
  45442. * Defines the SubSurface parameters for the material.
  45443. */
  45444. readonly subSurface: PBRSubSurfaceConfiguration;
  45445. /**
  45446. * Custom callback helping to override the default shader used in the material.
  45447. */
  45448. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  45449. /**
  45450. * Instantiates a new PBRMaterial instance.
  45451. *
  45452. * @param name The material name
  45453. * @param scene The scene the material will be use in.
  45454. */
  45455. constructor(name: string, scene: Scene);
  45456. /**
  45457. * Gets a boolean indicating that current material needs to register RTT
  45458. */
  45459. readonly hasRenderTargetTextures: boolean;
  45460. /**
  45461. * Gets the name of the material class.
  45462. */
  45463. getClassName(): string;
  45464. /**
  45465. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45466. */
  45467. /**
  45468. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45469. */
  45470. useLogarithmicDepth: boolean;
  45471. /**
  45472. * Gets the current transparency mode.
  45473. */
  45474. /**
  45475. * Sets the transparency mode of the material.
  45476. *
  45477. * | Value | Type | Description |
  45478. * | ----- | ----------------------------------- | ----------- |
  45479. * | 0 | OPAQUE | |
  45480. * | 1 | ALPHATEST | |
  45481. * | 2 | ALPHABLEND | |
  45482. * | 3 | ALPHATESTANDBLEND | |
  45483. *
  45484. */
  45485. transparencyMode: Nullable<number>;
  45486. /**
  45487. * Returns true if alpha blending should be disabled.
  45488. */
  45489. private readonly _disableAlphaBlending;
  45490. /**
  45491. * Specifies whether or not this material should be rendered in alpha blend mode.
  45492. */
  45493. needAlphaBlending(): boolean;
  45494. /**
  45495. * Specifies if the mesh will require alpha blending.
  45496. * @param mesh - BJS mesh.
  45497. */
  45498. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45499. /**
  45500. * Specifies whether or not this material should be rendered in alpha test mode.
  45501. */
  45502. needAlphaTesting(): boolean;
  45503. /**
  45504. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45505. */
  45506. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45507. /**
  45508. * Gets the texture used for the alpha test.
  45509. */
  45510. getAlphaTestTexture(): Nullable<BaseTexture>;
  45511. /**
  45512. * Specifies that the submesh is ready to be used.
  45513. * @param mesh - BJS mesh.
  45514. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45515. * @param useInstances - Specifies that instances should be used.
  45516. * @returns - boolean indicating that the submesh is ready or not.
  45517. */
  45518. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45519. /**
  45520. * Specifies if the material uses metallic roughness workflow.
  45521. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45522. */
  45523. isMetallicWorkflow(): boolean;
  45524. private _prepareEffect;
  45525. private _prepareDefines;
  45526. /**
  45527. * Force shader compilation
  45528. */
  45529. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45530. clipPlane: boolean;
  45531. }>): void;
  45532. /**
  45533. * Initializes the uniform buffer layout for the shader.
  45534. */
  45535. buildUniformLayout(): void;
  45536. /**
  45537. * Unbinds the material from the mesh
  45538. */
  45539. unbind(): void;
  45540. /**
  45541. * Binds the submesh data.
  45542. * @param world - The world matrix.
  45543. * @param mesh - The BJS mesh.
  45544. * @param subMesh - A submesh of the BJS mesh.
  45545. */
  45546. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45547. /**
  45548. * Returns the animatable textures.
  45549. * @returns - Array of animatable textures.
  45550. */
  45551. getAnimatables(): IAnimatable[];
  45552. /**
  45553. * Returns the texture used for reflections.
  45554. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45555. */
  45556. private _getReflectionTexture;
  45557. /**
  45558. * Returns an array of the actively used textures.
  45559. * @returns - Array of BaseTextures
  45560. */
  45561. getActiveTextures(): BaseTexture[];
  45562. /**
  45563. * Checks to see if a texture is used in the material.
  45564. * @param texture - Base texture to use.
  45565. * @returns - Boolean specifying if a texture is used in the material.
  45566. */
  45567. hasTexture(texture: BaseTexture): boolean;
  45568. /**
  45569. * Disposes the resources of the material.
  45570. * @param forceDisposeEffect - Forces the disposal of effects.
  45571. * @param forceDisposeTextures - Forces the disposal of all textures.
  45572. */
  45573. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45574. }
  45575. }
  45576. declare module BABYLON {
  45577. /**
  45578. * The Physically based material of BJS.
  45579. *
  45580. * This offers the main features of a standard PBR material.
  45581. * For more information, please refer to the documentation :
  45582. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45583. */
  45584. export class PBRMaterial extends PBRBaseMaterial {
  45585. /**
  45586. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45587. */
  45588. static readonly PBRMATERIAL_OPAQUE: number;
  45589. /**
  45590. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45591. */
  45592. static readonly PBRMATERIAL_ALPHATEST: number;
  45593. /**
  45594. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45595. */
  45596. static readonly PBRMATERIAL_ALPHABLEND: number;
  45597. /**
  45598. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45599. * They are also discarded below the alpha cutoff threshold to improve performances.
  45600. */
  45601. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45602. /**
  45603. * Defines the default value of how much AO map is occluding the analytical lights
  45604. * (point spot...).
  45605. */
  45606. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45607. /**
  45608. * Intensity of the direct lights e.g. the four lights available in your scene.
  45609. * This impacts both the direct diffuse and specular highlights.
  45610. */
  45611. directIntensity: number;
  45612. /**
  45613. * Intensity of the emissive part of the material.
  45614. * This helps controlling the emissive effect without modifying the emissive color.
  45615. */
  45616. emissiveIntensity: number;
  45617. /**
  45618. * Intensity of the environment e.g. how much the environment will light the object
  45619. * either through harmonics for rough material or through the refelction for shiny ones.
  45620. */
  45621. environmentIntensity: number;
  45622. /**
  45623. * This is a special control allowing the reduction of the specular highlights coming from the
  45624. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45625. */
  45626. specularIntensity: number;
  45627. /**
  45628. * Debug Control allowing disabling the bump map on this material.
  45629. */
  45630. disableBumpMap: boolean;
  45631. /**
  45632. * AKA Diffuse Texture in standard nomenclature.
  45633. */
  45634. albedoTexture: BaseTexture;
  45635. /**
  45636. * AKA Occlusion Texture in other nomenclature.
  45637. */
  45638. ambientTexture: BaseTexture;
  45639. /**
  45640. * AKA Occlusion Texture Intensity in other nomenclature.
  45641. */
  45642. ambientTextureStrength: number;
  45643. /**
  45644. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45645. * 1 means it completely occludes it
  45646. * 0 mean it has no impact
  45647. */
  45648. ambientTextureImpactOnAnalyticalLights: number;
  45649. /**
  45650. * Stores the alpha values in a texture.
  45651. */
  45652. opacityTexture: BaseTexture;
  45653. /**
  45654. * Stores the reflection values in a texture.
  45655. */
  45656. reflectionTexture: Nullable<BaseTexture>;
  45657. /**
  45658. * Stores the emissive values in a texture.
  45659. */
  45660. emissiveTexture: BaseTexture;
  45661. /**
  45662. * AKA Specular texture in other nomenclature.
  45663. */
  45664. reflectivityTexture: BaseTexture;
  45665. /**
  45666. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45667. */
  45668. metallicTexture: BaseTexture;
  45669. /**
  45670. * Specifies the metallic scalar of the metallic/roughness workflow.
  45671. * Can also be used to scale the metalness values of the metallic texture.
  45672. */
  45673. metallic: Nullable<number>;
  45674. /**
  45675. * Specifies the roughness scalar of the metallic/roughness workflow.
  45676. * Can also be used to scale the roughness values of the metallic texture.
  45677. */
  45678. roughness: Nullable<number>;
  45679. /**
  45680. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45681. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45682. */
  45683. microSurfaceTexture: BaseTexture;
  45684. /**
  45685. * Stores surface normal data used to displace a mesh in a texture.
  45686. */
  45687. bumpTexture: BaseTexture;
  45688. /**
  45689. * Stores the pre-calculated light information of a mesh in a texture.
  45690. */
  45691. lightmapTexture: BaseTexture;
  45692. /**
  45693. * Stores the refracted light information in a texture.
  45694. */
  45695. refractionTexture: Nullable<BaseTexture>;
  45696. /**
  45697. * The color of a material in ambient lighting.
  45698. */
  45699. ambientColor: Color3;
  45700. /**
  45701. * AKA Diffuse Color in other nomenclature.
  45702. */
  45703. albedoColor: Color3;
  45704. /**
  45705. * AKA Specular Color in other nomenclature.
  45706. */
  45707. reflectivityColor: Color3;
  45708. /**
  45709. * The color reflected from the material.
  45710. */
  45711. reflectionColor: Color3;
  45712. /**
  45713. * The color emitted from the material.
  45714. */
  45715. emissiveColor: Color3;
  45716. /**
  45717. * AKA Glossiness in other nomenclature.
  45718. */
  45719. microSurface: number;
  45720. /**
  45721. * source material index of refraction (IOR)' / 'destination material IOR.
  45722. */
  45723. indexOfRefraction: number;
  45724. /**
  45725. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45726. */
  45727. invertRefractionY: boolean;
  45728. /**
  45729. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45730. * Materials half opaque for instance using refraction could benefit from this control.
  45731. */
  45732. linkRefractionWithTransparency: boolean;
  45733. /**
  45734. * If true, the light map contains occlusion information instead of lighting info.
  45735. */
  45736. useLightmapAsShadowmap: boolean;
  45737. /**
  45738. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45739. */
  45740. useAlphaFromAlbedoTexture: boolean;
  45741. /**
  45742. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45743. */
  45744. forceAlphaTest: boolean;
  45745. /**
  45746. * Defines the alpha limits in alpha test mode.
  45747. */
  45748. alphaCutOff: number;
  45749. /**
  45750. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45751. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45752. */
  45753. useSpecularOverAlpha: boolean;
  45754. /**
  45755. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45756. */
  45757. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45758. /**
  45759. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45760. */
  45761. useRoughnessFromMetallicTextureAlpha: boolean;
  45762. /**
  45763. * Specifies if the metallic texture contains the roughness information in its green channel.
  45764. */
  45765. useRoughnessFromMetallicTextureGreen: boolean;
  45766. /**
  45767. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45768. */
  45769. useMetallnessFromMetallicTextureBlue: boolean;
  45770. /**
  45771. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45772. */
  45773. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45774. /**
  45775. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45776. */
  45777. useAmbientInGrayScale: boolean;
  45778. /**
  45779. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45780. * The material will try to infer what glossiness each pixel should be.
  45781. */
  45782. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45783. /**
  45784. * BJS is using an harcoded light falloff based on a manually sets up range.
  45785. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45786. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45787. */
  45788. /**
  45789. * BJS is using an harcoded light falloff based on a manually sets up range.
  45790. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45791. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45792. */
  45793. usePhysicalLightFalloff: boolean;
  45794. /**
  45795. * In order to support the falloff compatibility with gltf, a special mode has been added
  45796. * to reproduce the gltf light falloff.
  45797. */
  45798. /**
  45799. * In order to support the falloff compatibility with gltf, a special mode has been added
  45800. * to reproduce the gltf light falloff.
  45801. */
  45802. useGLTFLightFalloff: boolean;
  45803. /**
  45804. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45805. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45806. */
  45807. useRadianceOverAlpha: boolean;
  45808. /**
  45809. * Allows using an object space normal map (instead of tangent space).
  45810. */
  45811. useObjectSpaceNormalMap: boolean;
  45812. /**
  45813. * Allows using the bump map in parallax mode.
  45814. */
  45815. useParallax: boolean;
  45816. /**
  45817. * Allows using the bump map in parallax occlusion mode.
  45818. */
  45819. useParallaxOcclusion: boolean;
  45820. /**
  45821. * Controls the scale bias of the parallax mode.
  45822. */
  45823. parallaxScaleBias: number;
  45824. /**
  45825. * If sets to true, disables all the lights affecting the material.
  45826. */
  45827. disableLighting: boolean;
  45828. /**
  45829. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45830. */
  45831. forceIrradianceInFragment: boolean;
  45832. /**
  45833. * Number of Simultaneous lights allowed on the material.
  45834. */
  45835. maxSimultaneousLights: number;
  45836. /**
  45837. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45838. */
  45839. invertNormalMapX: boolean;
  45840. /**
  45841. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45842. */
  45843. invertNormalMapY: boolean;
  45844. /**
  45845. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45846. */
  45847. twoSidedLighting: boolean;
  45848. /**
  45849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45850. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45851. */
  45852. useAlphaFresnel: boolean;
  45853. /**
  45854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45855. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45856. */
  45857. useLinearAlphaFresnel: boolean;
  45858. /**
  45859. * Let user defines the brdf lookup texture used for IBL.
  45860. * A default 8bit version is embedded but you could point at :
  45861. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45862. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45863. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45864. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45865. */
  45866. environmentBRDFTexture: Nullable<BaseTexture>;
  45867. /**
  45868. * Force normal to face away from face.
  45869. */
  45870. forceNormalForward: boolean;
  45871. /**
  45872. * Enables specular anti aliasing in the PBR shader.
  45873. * It will both interacts on the Geometry for analytical and IBL lighting.
  45874. * It also prefilter the roughness map based on the bump values.
  45875. */
  45876. enableSpecularAntiAliasing: boolean;
  45877. /**
  45878. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45879. * makes the reflect vector face the model (under horizon).
  45880. */
  45881. useHorizonOcclusion: boolean;
  45882. /**
  45883. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45884. * too much the area relying on ambient texture to define their ambient occlusion.
  45885. */
  45886. useRadianceOcclusion: boolean;
  45887. /**
  45888. * If set to true, no lighting calculations will be applied.
  45889. */
  45890. unlit: boolean;
  45891. /**
  45892. * Gets the image processing configuration used either in this material.
  45893. */
  45894. /**
  45895. * Sets the Default image processing configuration used either in the this material.
  45896. *
  45897. * If sets to null, the scene one is in use.
  45898. */
  45899. imageProcessingConfiguration: ImageProcessingConfiguration;
  45900. /**
  45901. * Gets wether the color curves effect is enabled.
  45902. */
  45903. /**
  45904. * Sets wether the color curves effect is enabled.
  45905. */
  45906. cameraColorCurvesEnabled: boolean;
  45907. /**
  45908. * Gets wether the color grading effect is enabled.
  45909. */
  45910. /**
  45911. * Gets wether the color grading effect is enabled.
  45912. */
  45913. cameraColorGradingEnabled: boolean;
  45914. /**
  45915. * Gets wether tonemapping is enabled or not.
  45916. */
  45917. /**
  45918. * Sets wether tonemapping is enabled or not
  45919. */
  45920. cameraToneMappingEnabled: boolean;
  45921. /**
  45922. * The camera exposure used on this material.
  45923. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45924. * This corresponds to a photographic exposure.
  45925. */
  45926. /**
  45927. * The camera exposure used on this material.
  45928. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45929. * This corresponds to a photographic exposure.
  45930. */
  45931. cameraExposure: number;
  45932. /**
  45933. * Gets The camera contrast used on this material.
  45934. */
  45935. /**
  45936. * Sets The camera contrast used on this material.
  45937. */
  45938. cameraContrast: number;
  45939. /**
  45940. * Gets the Color Grading 2D Lookup Texture.
  45941. */
  45942. /**
  45943. * Sets the Color Grading 2D Lookup Texture.
  45944. */
  45945. cameraColorGradingTexture: Nullable<BaseTexture>;
  45946. /**
  45947. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45948. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45949. * 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;
  45950. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45951. */
  45952. /**
  45953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45955. * 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;
  45956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45957. */
  45958. cameraColorCurves: Nullable<ColorCurves>;
  45959. /**
  45960. * Instantiates a new PBRMaterial instance.
  45961. *
  45962. * @param name The material name
  45963. * @param scene The scene the material will be use in.
  45964. */
  45965. constructor(name: string, scene: Scene);
  45966. /**
  45967. * Returns the name of this material class.
  45968. */
  45969. getClassName(): string;
  45970. /**
  45971. * Makes a duplicate of the current material.
  45972. * @param name - name to use for the new material.
  45973. */
  45974. clone(name: string): PBRMaterial;
  45975. /**
  45976. * Serializes this PBR Material.
  45977. * @returns - An object with the serialized material.
  45978. */
  45979. serialize(): any;
  45980. /**
  45981. * Parses a PBR Material from a serialized object.
  45982. * @param source - Serialized object.
  45983. * @param scene - BJS scene instance.
  45984. * @param rootUrl - url for the scene object
  45985. * @returns - PBRMaterial
  45986. */
  45987. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45988. }
  45989. }
  45990. declare module BABYLON {
  45991. /**
  45992. * Direct draw surface info
  45993. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45994. */
  45995. export interface DDSInfo {
  45996. /**
  45997. * Width of the texture
  45998. */
  45999. width: number;
  46000. /**
  46001. * Width of the texture
  46002. */
  46003. height: number;
  46004. /**
  46005. * Number of Mipmaps for the texture
  46006. * @see https://en.wikipedia.org/wiki/Mipmap
  46007. */
  46008. mipmapCount: number;
  46009. /**
  46010. * If the textures format is a known fourCC format
  46011. * @see https://www.fourcc.org/
  46012. */
  46013. isFourCC: boolean;
  46014. /**
  46015. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46016. */
  46017. isRGB: boolean;
  46018. /**
  46019. * If the texture is a lumincance format
  46020. */
  46021. isLuminance: boolean;
  46022. /**
  46023. * If this is a cube texture
  46024. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46025. */
  46026. isCube: boolean;
  46027. /**
  46028. * If the texture is a compressed format eg. FOURCC_DXT1
  46029. */
  46030. isCompressed: boolean;
  46031. /**
  46032. * The dxgiFormat of the texture
  46033. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46034. */
  46035. dxgiFormat: number;
  46036. /**
  46037. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46038. */
  46039. textureType: number;
  46040. /**
  46041. * Sphericle polynomial created for the dds texture
  46042. */
  46043. sphericalPolynomial?: SphericalPolynomial;
  46044. }
  46045. /**
  46046. * Class used to provide DDS decompression tools
  46047. */
  46048. export class DDSTools {
  46049. /**
  46050. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46051. */
  46052. static StoreLODInAlphaChannel: boolean;
  46053. /**
  46054. * Gets DDS information from an array buffer
  46055. * @param arrayBuffer defines the array buffer to read data from
  46056. * @returns the DDS information
  46057. */
  46058. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46059. private static _FloatView;
  46060. private static _Int32View;
  46061. private static _ToHalfFloat;
  46062. private static _FromHalfFloat;
  46063. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46064. private static _GetHalfFloatRGBAArrayBuffer;
  46065. private static _GetFloatRGBAArrayBuffer;
  46066. private static _GetFloatAsUIntRGBAArrayBuffer;
  46067. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46068. private static _GetRGBAArrayBuffer;
  46069. private static _ExtractLongWordOrder;
  46070. private static _GetRGBArrayBuffer;
  46071. private static _GetLuminanceArrayBuffer;
  46072. /**
  46073. * Uploads DDS Levels to a Babylon Texture
  46074. * @hidden
  46075. */
  46076. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46077. }
  46078. interface Engine {
  46079. /**
  46080. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46081. * @param rootUrl defines the url where the file to load is located
  46082. * @param scene defines the current scene
  46083. * @param lodScale defines scale to apply to the mip map selection
  46084. * @param lodOffset defines offset to apply to the mip map selection
  46085. * @param onLoad defines an optional callback raised when the texture is loaded
  46086. * @param onError defines an optional callback raised if there is an issue to load the texture
  46087. * @param format defines the format of the data
  46088. * @param forcedExtension defines the extension to use to pick the right loader
  46089. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46090. * @returns the cube texture as an InternalTexture
  46091. */
  46092. 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;
  46093. }
  46094. }
  46095. declare module BABYLON {
  46096. /**
  46097. * Implementation of the DDS Texture Loader.
  46098. * @hidden
  46099. */
  46100. export class _DDSTextureLoader implements IInternalTextureLoader {
  46101. /**
  46102. * Defines wether the loader supports cascade loading the different faces.
  46103. */
  46104. readonly supportCascades: boolean;
  46105. /**
  46106. * This returns if the loader support the current file information.
  46107. * @param extension defines the file extension of the file being loaded
  46108. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46109. * @param fallback defines the fallback internal texture if any
  46110. * @param isBase64 defines whether the texture is encoded as a base64
  46111. * @param isBuffer defines whether the texture data are stored as a buffer
  46112. * @returns true if the loader can load the specified file
  46113. */
  46114. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46115. /**
  46116. * Transform the url before loading if required.
  46117. * @param rootUrl the url of the texture
  46118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46119. * @returns the transformed texture
  46120. */
  46121. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46122. /**
  46123. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46124. * @param rootUrl the url of the texture
  46125. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46126. * @returns the fallback texture
  46127. */
  46128. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46129. /**
  46130. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46131. * @param data contains the texture data
  46132. * @param texture defines the BabylonJS internal texture
  46133. * @param createPolynomials will be true if polynomials have been requested
  46134. * @param onLoad defines the callback to trigger once the texture is ready
  46135. * @param onError defines the callback to trigger in case of error
  46136. */
  46137. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46138. /**
  46139. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46140. * @param data contains the texture data
  46141. * @param texture defines the BabylonJS internal texture
  46142. * @param callback defines the method to call once ready to upload
  46143. */
  46144. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46145. }
  46146. }
  46147. declare module BABYLON {
  46148. /** @hidden */
  46149. export var rgbdEncodePixelShader: {
  46150. name: string;
  46151. shader: string;
  46152. };
  46153. }
  46154. declare module BABYLON {
  46155. /**
  46156. * Raw texture data and descriptor sufficient for WebGL texture upload
  46157. */
  46158. export interface EnvironmentTextureInfo {
  46159. /**
  46160. * Version of the environment map
  46161. */
  46162. version: number;
  46163. /**
  46164. * Width of image
  46165. */
  46166. width: number;
  46167. /**
  46168. * Irradiance information stored in the file.
  46169. */
  46170. irradiance: any;
  46171. /**
  46172. * Specular information stored in the file.
  46173. */
  46174. specular: any;
  46175. }
  46176. /**
  46177. * Sets of helpers addressing the serialization and deserialization of environment texture
  46178. * stored in a BabylonJS env file.
  46179. * Those files are usually stored as .env files.
  46180. */
  46181. export class EnvironmentTextureTools {
  46182. /**
  46183. * Magic number identifying the env file.
  46184. */
  46185. private static _MagicBytes;
  46186. /**
  46187. * Gets the environment info from an env file.
  46188. * @param data The array buffer containing the .env bytes.
  46189. * @returns the environment file info (the json header) if successfully parsed.
  46190. */
  46191. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46192. /**
  46193. * Creates an environment texture from a loaded cube texture.
  46194. * @param texture defines the cube texture to convert in env file
  46195. * @return a promise containing the environment data if succesfull.
  46196. */
  46197. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46198. /**
  46199. * Creates a JSON representation of the spherical data.
  46200. * @param texture defines the texture containing the polynomials
  46201. * @return the JSON representation of the spherical info
  46202. */
  46203. private static _CreateEnvTextureIrradiance;
  46204. /**
  46205. * Uploads the texture info contained in the env file to the GPU.
  46206. * @param texture defines the internal texture to upload to
  46207. * @param arrayBuffer defines the buffer cotaining the data to load
  46208. * @param info defines the texture info retrieved through the GetEnvInfo method
  46209. * @returns a promise
  46210. */
  46211. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46212. /**
  46213. * Uploads the levels of image data to the GPU.
  46214. * @param texture defines the internal texture to upload to
  46215. * @param imageData defines the array buffer views of image data [mipmap][face]
  46216. * @returns a promise
  46217. */
  46218. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46219. /**
  46220. * Uploads spherical polynomials information to the texture.
  46221. * @param texture defines the texture we are trying to upload the information to
  46222. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46223. */
  46224. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46225. /** @hidden */
  46226. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46227. }
  46228. }
  46229. declare module BABYLON {
  46230. /**
  46231. * Implementation of the ENV Texture Loader.
  46232. * @hidden
  46233. */
  46234. export class _ENVTextureLoader implements IInternalTextureLoader {
  46235. /**
  46236. * Defines wether the loader supports cascade loading the different faces.
  46237. */
  46238. readonly supportCascades: boolean;
  46239. /**
  46240. * This returns if the loader support the current file information.
  46241. * @param extension defines the file extension of the file being loaded
  46242. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46243. * @param fallback defines the fallback internal texture if any
  46244. * @param isBase64 defines whether the texture is encoded as a base64
  46245. * @param isBuffer defines whether the texture data are stored as a buffer
  46246. * @returns true if the loader can load the specified file
  46247. */
  46248. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46249. /**
  46250. * Transform the url before loading if required.
  46251. * @param rootUrl the url of the texture
  46252. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46253. * @returns the transformed texture
  46254. */
  46255. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46256. /**
  46257. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46258. * @param rootUrl the url of the texture
  46259. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46260. * @returns the fallback texture
  46261. */
  46262. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46263. /**
  46264. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46265. * @param data contains the texture data
  46266. * @param texture defines the BabylonJS internal texture
  46267. * @param createPolynomials will be true if polynomials have been requested
  46268. * @param onLoad defines the callback to trigger once the texture is ready
  46269. * @param onError defines the callback to trigger in case of error
  46270. */
  46271. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46272. /**
  46273. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46274. * @param data contains the texture data
  46275. * @param texture defines the BabylonJS internal texture
  46276. * @param callback defines the method to call once ready to upload
  46277. */
  46278. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46279. }
  46280. }
  46281. declare module BABYLON {
  46282. /**
  46283. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46284. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46285. */
  46286. export class KhronosTextureContainer {
  46287. /** contents of the KTX container file */
  46288. arrayBuffer: any;
  46289. private static HEADER_LEN;
  46290. private static COMPRESSED_2D;
  46291. private static COMPRESSED_3D;
  46292. private static TEX_2D;
  46293. private static TEX_3D;
  46294. /**
  46295. * Gets the openGL type
  46296. */
  46297. glType: number;
  46298. /**
  46299. * Gets the openGL type size
  46300. */
  46301. glTypeSize: number;
  46302. /**
  46303. * Gets the openGL format
  46304. */
  46305. glFormat: number;
  46306. /**
  46307. * Gets the openGL internal format
  46308. */
  46309. glInternalFormat: number;
  46310. /**
  46311. * Gets the base internal format
  46312. */
  46313. glBaseInternalFormat: number;
  46314. /**
  46315. * Gets image width in pixel
  46316. */
  46317. pixelWidth: number;
  46318. /**
  46319. * Gets image height in pixel
  46320. */
  46321. pixelHeight: number;
  46322. /**
  46323. * Gets image depth in pixels
  46324. */
  46325. pixelDepth: number;
  46326. /**
  46327. * Gets the number of array elements
  46328. */
  46329. numberOfArrayElements: number;
  46330. /**
  46331. * Gets the number of faces
  46332. */
  46333. numberOfFaces: number;
  46334. /**
  46335. * Gets the number of mipmap levels
  46336. */
  46337. numberOfMipmapLevels: number;
  46338. /**
  46339. * Gets the bytes of key value data
  46340. */
  46341. bytesOfKeyValueData: number;
  46342. /**
  46343. * Gets the load type
  46344. */
  46345. loadType: number;
  46346. /**
  46347. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46348. */
  46349. isInvalid: boolean;
  46350. /**
  46351. * Creates a new KhronosTextureContainer
  46352. * @param arrayBuffer contents of the KTX container file
  46353. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46354. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46355. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46356. */
  46357. constructor(
  46358. /** contents of the KTX container file */
  46359. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46360. /**
  46361. * Uploads KTX content to a Babylon Texture.
  46362. * It is assumed that the texture has already been created & is currently bound
  46363. * @hidden
  46364. */
  46365. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46366. private _upload2DCompressedLevels;
  46367. }
  46368. }
  46369. declare module BABYLON {
  46370. /**
  46371. * Implementation of the KTX Texture Loader.
  46372. * @hidden
  46373. */
  46374. export class _KTXTextureLoader implements IInternalTextureLoader {
  46375. /**
  46376. * Defines wether the loader supports cascade loading the different faces.
  46377. */
  46378. readonly supportCascades: boolean;
  46379. /**
  46380. * This returns if the loader support the current file information.
  46381. * @param extension defines the file extension of the file being loaded
  46382. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46383. * @param fallback defines the fallback internal texture if any
  46384. * @param isBase64 defines whether the texture is encoded as a base64
  46385. * @param isBuffer defines whether the texture data are stored as a buffer
  46386. * @returns true if the loader can load the specified file
  46387. */
  46388. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46389. /**
  46390. * Transform the url before loading if required.
  46391. * @param rootUrl the url of the texture
  46392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46393. * @returns the transformed texture
  46394. */
  46395. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46396. /**
  46397. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46398. * @param rootUrl the url of the texture
  46399. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46400. * @returns the fallback texture
  46401. */
  46402. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46403. /**
  46404. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46405. * @param data contains the texture data
  46406. * @param texture defines the BabylonJS internal texture
  46407. * @param createPolynomials will be true if polynomials have been requested
  46408. * @param onLoad defines the callback to trigger once the texture is ready
  46409. * @param onError defines the callback to trigger in case of error
  46410. */
  46411. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46412. /**
  46413. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46414. * @param data contains the texture data
  46415. * @param texture defines the BabylonJS internal texture
  46416. * @param callback defines the method to call once ready to upload
  46417. */
  46418. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46419. }
  46420. }
  46421. declare module BABYLON {
  46422. /** @hidden */
  46423. export var _forceSceneHelpersToBundle: boolean;
  46424. interface Scene {
  46425. /**
  46426. * Creates a default light for the scene.
  46427. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  46428. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  46429. */
  46430. createDefaultLight(replace?: boolean): void;
  46431. /**
  46432. * Creates a default camera for the scene.
  46433. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  46434. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46435. * @param replace has default false, when true replaces the active camera in the scene
  46436. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  46437. */
  46438. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46439. /**
  46440. * Creates a default camera and a default light.
  46441. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  46442. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  46443. * @param replace has the default false, when true replaces the active camera/light in the scene
  46444. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  46445. */
  46446. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  46447. /**
  46448. * Creates a new sky box
  46449. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  46450. * @param environmentTexture defines the texture to use as environment texture
  46451. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  46452. * @param scale defines the overall scale of the skybox
  46453. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  46454. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  46455. * @returns a new mesh holding the sky box
  46456. */
  46457. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  46458. /**
  46459. * Creates a new environment
  46460. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  46461. * @param options defines the options you can use to configure the environment
  46462. * @returns the new EnvironmentHelper
  46463. */
  46464. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  46465. /**
  46466. * Creates a new VREXperienceHelper
  46467. * @see http://doc.babylonjs.com/how_to/webvr_helper
  46468. * @param webVROptions defines the options used to create the new VREXperienceHelper
  46469. * @returns a new VREXperienceHelper
  46470. */
  46471. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  46472. /**
  46473. * Creates a new XREXperienceHelper
  46474. * @see http://doc.babylonjs.com/how_to/webxr
  46475. * @returns a promise for a new XREXperienceHelper
  46476. */
  46477. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  46478. }
  46479. }
  46480. declare module BABYLON {
  46481. /**
  46482. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  46483. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  46484. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  46485. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46486. */
  46487. export class VideoDome extends TransformNode {
  46488. /**
  46489. * Define the video source as a Monoscopic panoramic 360 video.
  46490. */
  46491. static readonly MODE_MONOSCOPIC: number;
  46492. /**
  46493. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46494. */
  46495. static readonly MODE_TOPBOTTOM: number;
  46496. /**
  46497. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46498. */
  46499. static readonly MODE_SIDEBYSIDE: number;
  46500. private _useDirectMapping;
  46501. /**
  46502. * The video texture being displayed on the sphere
  46503. */
  46504. protected _videoTexture: VideoTexture;
  46505. /**
  46506. * Gets the video texture being displayed on the sphere
  46507. */
  46508. readonly videoTexture: VideoTexture;
  46509. /**
  46510. * The skybox material
  46511. */
  46512. protected _material: BackgroundMaterial;
  46513. /**
  46514. * The surface used for the skybox
  46515. */
  46516. protected _mesh: Mesh;
  46517. /**
  46518. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46519. * Also see the options.resolution property.
  46520. */
  46521. fovMultiplier: number;
  46522. private _videoMode;
  46523. /**
  46524. * Gets or set the current video mode for the video. It can be:
  46525. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  46526. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  46527. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  46528. */
  46529. videoMode: number;
  46530. /**
  46531. * Oberserver used in Stereoscopic VR Mode.
  46532. */
  46533. private _onBeforeCameraRenderObserver;
  46534. /**
  46535. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  46536. * @param name Element's name, child elements will append suffixes for their own names.
  46537. * @param urlsOrVideo defines the url(s) or the video element to use
  46538. * @param options An object containing optional or exposed sub element properties
  46539. */
  46540. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  46541. resolution?: number;
  46542. clickToPlay?: boolean;
  46543. autoPlay?: boolean;
  46544. loop?: boolean;
  46545. size?: number;
  46546. poster?: string;
  46547. faceForward?: boolean;
  46548. useDirectMapping?: boolean;
  46549. }, scene: Scene);
  46550. private _changeVideoMode;
  46551. /**
  46552. * Releases resources associated with this node.
  46553. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46554. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46555. */
  46556. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46557. }
  46558. }
  46559. declare module BABYLON {
  46560. /**
  46561. * This class can be used to get instrumentation data from a Babylon engine
  46562. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46563. */
  46564. export class EngineInstrumentation implements IDisposable {
  46565. /**
  46566. * Define the instrumented engine.
  46567. */
  46568. engine: Engine;
  46569. private _captureGPUFrameTime;
  46570. private _gpuFrameTimeToken;
  46571. private _gpuFrameTime;
  46572. private _captureShaderCompilationTime;
  46573. private _shaderCompilationTime;
  46574. private _onBeginFrameObserver;
  46575. private _onEndFrameObserver;
  46576. private _onBeforeShaderCompilationObserver;
  46577. private _onAfterShaderCompilationObserver;
  46578. /**
  46579. * Gets the perf counter used for GPU frame time
  46580. */
  46581. readonly gpuFrameTimeCounter: PerfCounter;
  46582. /**
  46583. * Gets the GPU frame time capture status
  46584. */
  46585. /**
  46586. * Enable or disable the GPU frame time capture
  46587. */
  46588. captureGPUFrameTime: boolean;
  46589. /**
  46590. * Gets the perf counter used for shader compilation time
  46591. */
  46592. readonly shaderCompilationTimeCounter: PerfCounter;
  46593. /**
  46594. * Gets the shader compilation time capture status
  46595. */
  46596. /**
  46597. * Enable or disable the shader compilation time capture
  46598. */
  46599. captureShaderCompilationTime: boolean;
  46600. /**
  46601. * Instantiates a new engine instrumentation.
  46602. * This class can be used to get instrumentation data from a Babylon engine
  46603. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  46604. * @param engine Defines the engine to instrument
  46605. */
  46606. constructor(
  46607. /**
  46608. * Define the instrumented engine.
  46609. */
  46610. engine: Engine);
  46611. /**
  46612. * Dispose and release associated resources.
  46613. */
  46614. dispose(): void;
  46615. }
  46616. }
  46617. declare module BABYLON {
  46618. /**
  46619. * This class can be used to get instrumentation data from a Babylon engine
  46620. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46621. */
  46622. export class SceneInstrumentation implements IDisposable {
  46623. /**
  46624. * Defines the scene to instrument
  46625. */
  46626. scene: Scene;
  46627. private _captureActiveMeshesEvaluationTime;
  46628. private _activeMeshesEvaluationTime;
  46629. private _captureRenderTargetsRenderTime;
  46630. private _renderTargetsRenderTime;
  46631. private _captureFrameTime;
  46632. private _frameTime;
  46633. private _captureRenderTime;
  46634. private _renderTime;
  46635. private _captureInterFrameTime;
  46636. private _interFrameTime;
  46637. private _captureParticlesRenderTime;
  46638. private _particlesRenderTime;
  46639. private _captureSpritesRenderTime;
  46640. private _spritesRenderTime;
  46641. private _capturePhysicsTime;
  46642. private _physicsTime;
  46643. private _captureAnimationsTime;
  46644. private _animationsTime;
  46645. private _captureCameraRenderTime;
  46646. private _cameraRenderTime;
  46647. private _onBeforeActiveMeshesEvaluationObserver;
  46648. private _onAfterActiveMeshesEvaluationObserver;
  46649. private _onBeforeRenderTargetsRenderObserver;
  46650. private _onAfterRenderTargetsRenderObserver;
  46651. private _onAfterRenderObserver;
  46652. private _onBeforeDrawPhaseObserver;
  46653. private _onAfterDrawPhaseObserver;
  46654. private _onBeforeAnimationsObserver;
  46655. private _onBeforeParticlesRenderingObserver;
  46656. private _onAfterParticlesRenderingObserver;
  46657. private _onBeforeSpritesRenderingObserver;
  46658. private _onAfterSpritesRenderingObserver;
  46659. private _onBeforePhysicsObserver;
  46660. private _onAfterPhysicsObserver;
  46661. private _onAfterAnimationsObserver;
  46662. private _onBeforeCameraRenderObserver;
  46663. private _onAfterCameraRenderObserver;
  46664. /**
  46665. * Gets the perf counter used for active meshes evaluation time
  46666. */
  46667. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  46668. /**
  46669. * Gets the active meshes evaluation time capture status
  46670. */
  46671. /**
  46672. * Enable or disable the active meshes evaluation time capture
  46673. */
  46674. captureActiveMeshesEvaluationTime: boolean;
  46675. /**
  46676. * Gets the perf counter used for render targets render time
  46677. */
  46678. readonly renderTargetsRenderTimeCounter: PerfCounter;
  46679. /**
  46680. * Gets the render targets render time capture status
  46681. */
  46682. /**
  46683. * Enable or disable the render targets render time capture
  46684. */
  46685. captureRenderTargetsRenderTime: boolean;
  46686. /**
  46687. * Gets the perf counter used for particles render time
  46688. */
  46689. readonly particlesRenderTimeCounter: PerfCounter;
  46690. /**
  46691. * Gets the particles render time capture status
  46692. */
  46693. /**
  46694. * Enable or disable the particles render time capture
  46695. */
  46696. captureParticlesRenderTime: boolean;
  46697. /**
  46698. * Gets the perf counter used for sprites render time
  46699. */
  46700. readonly spritesRenderTimeCounter: PerfCounter;
  46701. /**
  46702. * Gets the sprites render time capture status
  46703. */
  46704. /**
  46705. * Enable or disable the sprites render time capture
  46706. */
  46707. captureSpritesRenderTime: boolean;
  46708. /**
  46709. * Gets the perf counter used for physics time
  46710. */
  46711. readonly physicsTimeCounter: PerfCounter;
  46712. /**
  46713. * Gets the physics time capture status
  46714. */
  46715. /**
  46716. * Enable or disable the physics time capture
  46717. */
  46718. capturePhysicsTime: boolean;
  46719. /**
  46720. * Gets the perf counter used for animations time
  46721. */
  46722. readonly animationsTimeCounter: PerfCounter;
  46723. /**
  46724. * Gets the animations time capture status
  46725. */
  46726. /**
  46727. * Enable or disable the animations time capture
  46728. */
  46729. captureAnimationsTime: boolean;
  46730. /**
  46731. * Gets the perf counter used for frame time capture
  46732. */
  46733. readonly frameTimeCounter: PerfCounter;
  46734. /**
  46735. * Gets the frame time capture status
  46736. */
  46737. /**
  46738. * Enable or disable the frame time capture
  46739. */
  46740. captureFrameTime: boolean;
  46741. /**
  46742. * Gets the perf counter used for inter-frames time capture
  46743. */
  46744. readonly interFrameTimeCounter: PerfCounter;
  46745. /**
  46746. * Gets the inter-frames time capture status
  46747. */
  46748. /**
  46749. * Enable or disable the inter-frames time capture
  46750. */
  46751. captureInterFrameTime: boolean;
  46752. /**
  46753. * Gets the perf counter used for render time capture
  46754. */
  46755. readonly renderTimeCounter: PerfCounter;
  46756. /**
  46757. * Gets the render time capture status
  46758. */
  46759. /**
  46760. * Enable or disable the render time capture
  46761. */
  46762. captureRenderTime: boolean;
  46763. /**
  46764. * Gets the perf counter used for camera render time capture
  46765. */
  46766. readonly cameraRenderTimeCounter: PerfCounter;
  46767. /**
  46768. * Gets the camera render time capture status
  46769. */
  46770. /**
  46771. * Enable or disable the camera render time capture
  46772. */
  46773. captureCameraRenderTime: boolean;
  46774. /**
  46775. * Gets the perf counter used for draw calls
  46776. */
  46777. readonly drawCallsCounter: PerfCounter;
  46778. /**
  46779. * Instantiates a new scene instrumentation.
  46780. * This class can be used to get instrumentation data from a Babylon engine
  46781. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46782. * @param scene Defines the scene to instrument
  46783. */
  46784. constructor(
  46785. /**
  46786. * Defines the scene to instrument
  46787. */
  46788. scene: Scene);
  46789. /**
  46790. * Dispose and release associated resources.
  46791. */
  46792. dispose(): void;
  46793. }
  46794. }
  46795. declare module BABYLON {
  46796. /** @hidden */
  46797. export var glowMapGenerationPixelShader: {
  46798. name: string;
  46799. shader: string;
  46800. };
  46801. }
  46802. declare module BABYLON {
  46803. /** @hidden */
  46804. export var glowMapGenerationVertexShader: {
  46805. name: string;
  46806. shader: string;
  46807. };
  46808. }
  46809. declare module BABYLON {
  46810. /**
  46811. * Effect layer options. This helps customizing the behaviour
  46812. * of the effect layer.
  46813. */
  46814. export interface IEffectLayerOptions {
  46815. /**
  46816. * Multiplication factor apply to the canvas size to compute the render target size
  46817. * used to generated the objects (the smaller the faster).
  46818. */
  46819. mainTextureRatio: number;
  46820. /**
  46821. * Enforces a fixed size texture to ensure effect stability across devices.
  46822. */
  46823. mainTextureFixedSize?: number;
  46824. /**
  46825. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46826. */
  46827. alphaBlendingMode: number;
  46828. /**
  46829. * The camera attached to the layer.
  46830. */
  46831. camera: Nullable<Camera>;
  46832. /**
  46833. * The rendering group to draw the layer in.
  46834. */
  46835. renderingGroupId: number;
  46836. }
  46837. /**
  46838. * The effect layer Helps adding post process effect blended with the main pass.
  46839. *
  46840. * This can be for instance use to generate glow or higlight effects on the scene.
  46841. *
  46842. * The effect layer class can not be used directly and is intented to inherited from to be
  46843. * customized per effects.
  46844. */
  46845. export abstract class EffectLayer {
  46846. private _vertexBuffers;
  46847. private _indexBuffer;
  46848. private _cachedDefines;
  46849. private _effectLayerMapGenerationEffect;
  46850. private _effectLayerOptions;
  46851. private _mergeEffect;
  46852. protected _scene: Scene;
  46853. protected _engine: Engine;
  46854. protected _maxSize: number;
  46855. protected _mainTextureDesiredSize: ISize;
  46856. protected _mainTexture: RenderTargetTexture;
  46857. protected _shouldRender: boolean;
  46858. protected _postProcesses: PostProcess[];
  46859. protected _textures: BaseTexture[];
  46860. protected _emissiveTextureAndColor: {
  46861. texture: Nullable<BaseTexture>;
  46862. color: Color4;
  46863. };
  46864. /**
  46865. * The name of the layer
  46866. */
  46867. name: string;
  46868. /**
  46869. * The clear color of the texture used to generate the glow map.
  46870. */
  46871. neutralColor: Color4;
  46872. /**
  46873. * Specifies wether the highlight layer is enabled or not.
  46874. */
  46875. isEnabled: boolean;
  46876. /**
  46877. * Gets the camera attached to the layer.
  46878. */
  46879. readonly camera: Nullable<Camera>;
  46880. /**
  46881. * Gets the rendering group id the layer should render in.
  46882. */
  46883. readonly renderingGroupId: number;
  46884. /**
  46885. * An event triggered when the effect layer has been disposed.
  46886. */
  46887. onDisposeObservable: Observable<EffectLayer>;
  46888. /**
  46889. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46890. */
  46891. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46892. /**
  46893. * An event triggered when the generated texture is being merged in the scene.
  46894. */
  46895. onBeforeComposeObservable: Observable<EffectLayer>;
  46896. /**
  46897. * An event triggered when the generated texture has been merged in the scene.
  46898. */
  46899. onAfterComposeObservable: Observable<EffectLayer>;
  46900. /**
  46901. * An event triggered when the efffect layer changes its size.
  46902. */
  46903. onSizeChangedObservable: Observable<EffectLayer>;
  46904. /** @hidden */
  46905. static _SceneComponentInitialization: (scene: Scene) => void;
  46906. /**
  46907. * Instantiates a new effect Layer and references it in the scene.
  46908. * @param name The name of the layer
  46909. * @param scene The scene to use the layer in
  46910. */
  46911. constructor(
  46912. /** The Friendly of the effect in the scene */
  46913. name: string, scene: Scene);
  46914. /**
  46915. * Get the effect name of the layer.
  46916. * @return The effect name
  46917. */
  46918. abstract getEffectName(): string;
  46919. /**
  46920. * Checks for the readiness of the element composing the layer.
  46921. * @param subMesh the mesh to check for
  46922. * @param useInstances specify wether or not to use instances to render the mesh
  46923. * @return true if ready otherwise, false
  46924. */
  46925. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46926. /**
  46927. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46928. * @returns true if the effect requires stencil during the main canvas render pass.
  46929. */
  46930. abstract needStencil(): boolean;
  46931. /**
  46932. * Create the merge effect. This is the shader use to blit the information back
  46933. * to the main canvas at the end of the scene rendering.
  46934. * @returns The effect containing the shader used to merge the effect on the main canvas
  46935. */
  46936. protected abstract _createMergeEffect(): Effect;
  46937. /**
  46938. * Creates the render target textures and post processes used in the effect layer.
  46939. */
  46940. protected abstract _createTextureAndPostProcesses(): void;
  46941. /**
  46942. * Implementation specific of rendering the generating effect on the main canvas.
  46943. * @param effect The effect used to render through
  46944. */
  46945. protected abstract _internalRender(effect: Effect): void;
  46946. /**
  46947. * Sets the required values for both the emissive texture and and the main color.
  46948. */
  46949. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46950. /**
  46951. * Free any resources and references associated to a mesh.
  46952. * Internal use
  46953. * @param mesh The mesh to free.
  46954. */
  46955. abstract _disposeMesh(mesh: Mesh): void;
  46956. /**
  46957. * Serializes this layer (Glow or Highlight for example)
  46958. * @returns a serialized layer object
  46959. */
  46960. abstract serialize?(): any;
  46961. /**
  46962. * Initializes the effect layer with the required options.
  46963. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46964. */
  46965. protected _init(options: Partial<IEffectLayerOptions>): void;
  46966. /**
  46967. * Generates the index buffer of the full screen quad blending to the main canvas.
  46968. */
  46969. private _generateIndexBuffer;
  46970. /**
  46971. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46972. */
  46973. private _generateVertexBuffer;
  46974. /**
  46975. * Sets the main texture desired size which is the closest power of two
  46976. * of the engine canvas size.
  46977. */
  46978. private _setMainTextureSize;
  46979. /**
  46980. * Creates the main texture for the effect layer.
  46981. */
  46982. protected _createMainTexture(): void;
  46983. /**
  46984. * Adds specific effects defines.
  46985. * @param defines The defines to add specifics to.
  46986. */
  46987. protected _addCustomEffectDefines(defines: string[]): void;
  46988. /**
  46989. * Checks for the readiness of the element composing the layer.
  46990. * @param subMesh the mesh to check for
  46991. * @param useInstances specify wether or not to use instances to render the mesh
  46992. * @param emissiveTexture the associated emissive texture used to generate the glow
  46993. * @return true if ready otherwise, false
  46994. */
  46995. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46996. /**
  46997. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46998. */
  46999. render(): void;
  47000. /**
  47001. * Determine if a given mesh will be used in the current effect.
  47002. * @param mesh mesh to test
  47003. * @returns true if the mesh will be used
  47004. */
  47005. hasMesh(mesh: AbstractMesh): boolean;
  47006. /**
  47007. * Returns true if the layer contains information to display, otherwise false.
  47008. * @returns true if the glow layer should be rendered
  47009. */
  47010. shouldRender(): boolean;
  47011. /**
  47012. * Returns true if the mesh should render, otherwise false.
  47013. * @param mesh The mesh to render
  47014. * @returns true if it should render otherwise false
  47015. */
  47016. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47017. /**
  47018. * Returns true if the mesh can be rendered, otherwise false.
  47019. * @param mesh The mesh to render
  47020. * @param material The material used on the mesh
  47021. * @returns true if it can be rendered otherwise false
  47022. */
  47023. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47024. /**
  47025. * Returns true if the mesh should render, otherwise false.
  47026. * @param mesh The mesh to render
  47027. * @returns true if it should render otherwise false
  47028. */
  47029. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47030. /**
  47031. * Renders the submesh passed in parameter to the generation map.
  47032. */
  47033. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47034. /**
  47035. * Rebuild the required buffers.
  47036. * @hidden Internal use only.
  47037. */
  47038. _rebuild(): void;
  47039. /**
  47040. * Dispose only the render target textures and post process.
  47041. */
  47042. private _disposeTextureAndPostProcesses;
  47043. /**
  47044. * Dispose the highlight layer and free resources.
  47045. */
  47046. dispose(): void;
  47047. /**
  47048. * Gets the class name of the effect layer
  47049. * @returns the string with the class name of the effect layer
  47050. */
  47051. getClassName(): string;
  47052. /**
  47053. * Creates an effect layer from parsed effect layer data
  47054. * @param parsedEffectLayer defines effect layer data
  47055. * @param scene defines the current scene
  47056. * @param rootUrl defines the root URL containing the effect layer information
  47057. * @returns a parsed effect Layer
  47058. */
  47059. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47060. }
  47061. }
  47062. declare module BABYLON {
  47063. interface AbstractScene {
  47064. /**
  47065. * The list of effect layers (highlights/glow) added to the scene
  47066. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47067. * @see http://doc.babylonjs.com/how_to/glow_layer
  47068. */
  47069. effectLayers: Array<EffectLayer>;
  47070. /**
  47071. * Removes the given effect layer from this scene.
  47072. * @param toRemove defines the effect layer to remove
  47073. * @returns the index of the removed effect layer
  47074. */
  47075. removeEffectLayer(toRemove: EffectLayer): number;
  47076. /**
  47077. * Adds the given effect layer to this scene
  47078. * @param newEffectLayer defines the effect layer to add
  47079. */
  47080. addEffectLayer(newEffectLayer: EffectLayer): void;
  47081. }
  47082. /**
  47083. * Defines the layer scene component responsible to manage any effect layers
  47084. * in a given scene.
  47085. */
  47086. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47087. /**
  47088. * The component name helpfull to identify the component in the list of scene components.
  47089. */
  47090. readonly name: string;
  47091. /**
  47092. * The scene the component belongs to.
  47093. */
  47094. scene: Scene;
  47095. private _engine;
  47096. private _renderEffects;
  47097. private _needStencil;
  47098. private _previousStencilState;
  47099. /**
  47100. * Creates a new instance of the component for the given scene
  47101. * @param scene Defines the scene to register the component in
  47102. */
  47103. constructor(scene: Scene);
  47104. /**
  47105. * Registers the component in a given scene
  47106. */
  47107. register(): void;
  47108. /**
  47109. * Rebuilds the elements related to this component in case of
  47110. * context lost for instance.
  47111. */
  47112. rebuild(): void;
  47113. /**
  47114. * Serializes the component data to the specified json object
  47115. * @param serializationObject The object to serialize to
  47116. */
  47117. serialize(serializationObject: any): void;
  47118. /**
  47119. * Adds all the element from the container to the scene
  47120. * @param container the container holding the elements
  47121. */
  47122. addFromContainer(container: AbstractScene): void;
  47123. /**
  47124. * Removes all the elements in the container from the scene
  47125. * @param container contains the elements to remove
  47126. * @param dispose if the removed element should be disposed (default: false)
  47127. */
  47128. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47129. /**
  47130. * Disposes the component and the associated ressources.
  47131. */
  47132. dispose(): void;
  47133. private _isReadyForMesh;
  47134. private _renderMainTexture;
  47135. private _setStencil;
  47136. private _setStencilBack;
  47137. private _draw;
  47138. private _drawCamera;
  47139. private _drawRenderingGroup;
  47140. }
  47141. }
  47142. declare module BABYLON {
  47143. /** @hidden */
  47144. export var glowMapMergePixelShader: {
  47145. name: string;
  47146. shader: string;
  47147. };
  47148. }
  47149. declare module BABYLON {
  47150. /** @hidden */
  47151. export var glowMapMergeVertexShader: {
  47152. name: string;
  47153. shader: string;
  47154. };
  47155. }
  47156. declare module BABYLON {
  47157. interface AbstractScene {
  47158. /**
  47159. * Return a the first highlight layer of the scene with a given name.
  47160. * @param name The name of the highlight layer to look for.
  47161. * @return The highlight layer if found otherwise null.
  47162. */
  47163. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47164. }
  47165. /**
  47166. * Glow layer options. This helps customizing the behaviour
  47167. * of the glow layer.
  47168. */
  47169. export interface IGlowLayerOptions {
  47170. /**
  47171. * Multiplication factor apply to the canvas size to compute the render target size
  47172. * used to generated the glowing objects (the smaller the faster).
  47173. */
  47174. mainTextureRatio: number;
  47175. /**
  47176. * Enforces a fixed size texture to ensure resize independant blur.
  47177. */
  47178. mainTextureFixedSize?: number;
  47179. /**
  47180. * How big is the kernel of the blur texture.
  47181. */
  47182. blurKernelSize: number;
  47183. /**
  47184. * The camera attached to the layer.
  47185. */
  47186. camera: Nullable<Camera>;
  47187. /**
  47188. * Enable MSAA by chosing the number of samples.
  47189. */
  47190. mainTextureSamples?: number;
  47191. /**
  47192. * The rendering group to draw the layer in.
  47193. */
  47194. renderingGroupId: number;
  47195. }
  47196. /**
  47197. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47198. *
  47199. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47200. * glowy meshes to your scene.
  47201. *
  47202. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47203. */
  47204. export class GlowLayer extends EffectLayer {
  47205. /**
  47206. * Effect Name of the layer.
  47207. */
  47208. static readonly EffectName: string;
  47209. /**
  47210. * The default blur kernel size used for the glow.
  47211. */
  47212. static DefaultBlurKernelSize: number;
  47213. /**
  47214. * The default texture size ratio used for the glow.
  47215. */
  47216. static DefaultTextureRatio: number;
  47217. /**
  47218. * Sets the kernel size of the blur.
  47219. */
  47220. /**
  47221. * Gets the kernel size of the blur.
  47222. */
  47223. blurKernelSize: number;
  47224. /**
  47225. * Sets the glow intensity.
  47226. */
  47227. /**
  47228. * Gets the glow intensity.
  47229. */
  47230. intensity: number;
  47231. private _options;
  47232. private _intensity;
  47233. private _horizontalBlurPostprocess1;
  47234. private _verticalBlurPostprocess1;
  47235. private _horizontalBlurPostprocess2;
  47236. private _verticalBlurPostprocess2;
  47237. private _blurTexture1;
  47238. private _blurTexture2;
  47239. private _postProcesses1;
  47240. private _postProcesses2;
  47241. private _includedOnlyMeshes;
  47242. private _excludedMeshes;
  47243. /**
  47244. * Callback used to let the user override the color selection on a per mesh basis
  47245. */
  47246. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47247. /**
  47248. * Callback used to let the user override the texture selection on a per mesh basis
  47249. */
  47250. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  47251. /**
  47252. * Instantiates a new glow Layer and references it to the scene.
  47253. * @param name The name of the layer
  47254. * @param scene The scene to use the layer in
  47255. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  47256. */
  47257. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  47258. /**
  47259. * Get the effect name of the layer.
  47260. * @return The effect name
  47261. */
  47262. getEffectName(): string;
  47263. /**
  47264. * Create the merge effect. This is the shader use to blit the information back
  47265. * to the main canvas at the end of the scene rendering.
  47266. */
  47267. protected _createMergeEffect(): Effect;
  47268. /**
  47269. * Creates the render target textures and post processes used in the glow layer.
  47270. */
  47271. protected _createTextureAndPostProcesses(): void;
  47272. /**
  47273. * Checks for the readiness of the element composing the layer.
  47274. * @param subMesh the mesh to check for
  47275. * @param useInstances specify wether or not to use instances to render the mesh
  47276. * @param emissiveTexture the associated emissive texture used to generate the glow
  47277. * @return true if ready otherwise, false
  47278. */
  47279. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47280. /**
  47281. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47282. */
  47283. needStencil(): boolean;
  47284. /**
  47285. * Returns true if the mesh can be rendered, otherwise false.
  47286. * @param mesh The mesh to render
  47287. * @param material The material used on the mesh
  47288. * @returns true if it can be rendered otherwise false
  47289. */
  47290. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47291. /**
  47292. * Implementation specific of rendering the generating effect on the main canvas.
  47293. * @param effect The effect used to render through
  47294. */
  47295. protected _internalRender(effect: Effect): void;
  47296. /**
  47297. * Sets the required values for both the emissive texture and and the main color.
  47298. */
  47299. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47300. /**
  47301. * Returns true if the mesh should render, otherwise false.
  47302. * @param mesh The mesh to render
  47303. * @returns true if it should render otherwise false
  47304. */
  47305. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47306. /**
  47307. * Adds specific effects defines.
  47308. * @param defines The defines to add specifics to.
  47309. */
  47310. protected _addCustomEffectDefines(defines: string[]): void;
  47311. /**
  47312. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  47313. * @param mesh The mesh to exclude from the glow layer
  47314. */
  47315. addExcludedMesh(mesh: Mesh): void;
  47316. /**
  47317. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  47318. * @param mesh The mesh to remove
  47319. */
  47320. removeExcludedMesh(mesh: Mesh): void;
  47321. /**
  47322. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  47323. * @param mesh The mesh to include in the glow layer
  47324. */
  47325. addIncludedOnlyMesh(mesh: Mesh): void;
  47326. /**
  47327. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  47328. * @param mesh The mesh to remove
  47329. */
  47330. removeIncludedOnlyMesh(mesh: Mesh): void;
  47331. /**
  47332. * Determine if a given mesh will be used in the glow layer
  47333. * @param mesh The mesh to test
  47334. * @returns true if the mesh will be highlighted by the current glow layer
  47335. */
  47336. hasMesh(mesh: AbstractMesh): boolean;
  47337. /**
  47338. * Free any resources and references associated to a mesh.
  47339. * Internal use
  47340. * @param mesh The mesh to free.
  47341. * @hidden
  47342. */
  47343. _disposeMesh(mesh: Mesh): void;
  47344. /**
  47345. * Gets the class name of the effect layer
  47346. * @returns the string with the class name of the effect layer
  47347. */
  47348. getClassName(): string;
  47349. /**
  47350. * Serializes this glow layer
  47351. * @returns a serialized glow layer object
  47352. */
  47353. serialize(): any;
  47354. /**
  47355. * Creates a Glow Layer from parsed glow layer data
  47356. * @param parsedGlowLayer defines glow layer data
  47357. * @param scene defines the current scene
  47358. * @param rootUrl defines the root URL containing the glow layer information
  47359. * @returns a parsed Glow Layer
  47360. */
  47361. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  47362. }
  47363. }
  47364. declare module BABYLON {
  47365. /** @hidden */
  47366. export var glowBlurPostProcessPixelShader: {
  47367. name: string;
  47368. shader: string;
  47369. };
  47370. }
  47371. declare module BABYLON {
  47372. interface AbstractScene {
  47373. /**
  47374. * Return a the first highlight layer of the scene with a given name.
  47375. * @param name The name of the highlight layer to look for.
  47376. * @return The highlight layer if found otherwise null.
  47377. */
  47378. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  47379. }
  47380. /**
  47381. * Highlight layer options. This helps customizing the behaviour
  47382. * of the highlight layer.
  47383. */
  47384. export interface IHighlightLayerOptions {
  47385. /**
  47386. * Multiplication factor apply to the canvas size to compute the render target size
  47387. * used to generated the glowing objects (the smaller the faster).
  47388. */
  47389. mainTextureRatio: number;
  47390. /**
  47391. * Enforces a fixed size texture to ensure resize independant blur.
  47392. */
  47393. mainTextureFixedSize?: number;
  47394. /**
  47395. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  47396. * of the picture to blur (the smaller the faster).
  47397. */
  47398. blurTextureSizeRatio: number;
  47399. /**
  47400. * How big in texel of the blur texture is the vertical blur.
  47401. */
  47402. blurVerticalSize: number;
  47403. /**
  47404. * How big in texel of the blur texture is the horizontal blur.
  47405. */
  47406. blurHorizontalSize: number;
  47407. /**
  47408. * Alpha blending mode used to apply the blur. Default is combine.
  47409. */
  47410. alphaBlendingMode: number;
  47411. /**
  47412. * The camera attached to the layer.
  47413. */
  47414. camera: Nullable<Camera>;
  47415. /**
  47416. * Should we display highlight as a solid stroke?
  47417. */
  47418. isStroke?: boolean;
  47419. /**
  47420. * The rendering group to draw the layer in.
  47421. */
  47422. renderingGroupId: number;
  47423. }
  47424. /**
  47425. * The highlight layer Helps adding a glow effect around a mesh.
  47426. *
  47427. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47428. * glowy meshes to your scene.
  47429. *
  47430. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  47431. */
  47432. export class HighlightLayer extends EffectLayer {
  47433. name: string;
  47434. /**
  47435. * Effect Name of the highlight layer.
  47436. */
  47437. static readonly EffectName: string;
  47438. /**
  47439. * The neutral color used during the preparation of the glow effect.
  47440. * This is black by default as the blend operation is a blend operation.
  47441. */
  47442. static NeutralColor: Color4;
  47443. /**
  47444. * Stencil value used for glowing meshes.
  47445. */
  47446. static GlowingMeshStencilReference: number;
  47447. /**
  47448. * Stencil value used for the other meshes in the scene.
  47449. */
  47450. static NormalMeshStencilReference: number;
  47451. /**
  47452. * Specifies whether or not the inner glow is ACTIVE in the layer.
  47453. */
  47454. innerGlow: boolean;
  47455. /**
  47456. * Specifies whether or not the outer glow is ACTIVE in the layer.
  47457. */
  47458. outerGlow: boolean;
  47459. /**
  47460. * Specifies the horizontal size of the blur.
  47461. */
  47462. /**
  47463. * Gets the horizontal size of the blur.
  47464. */
  47465. blurHorizontalSize: number;
  47466. /**
  47467. * Specifies the vertical size of the blur.
  47468. */
  47469. /**
  47470. * Gets the vertical size of the blur.
  47471. */
  47472. blurVerticalSize: number;
  47473. /**
  47474. * An event triggered when the highlight layer is being blurred.
  47475. */
  47476. onBeforeBlurObservable: Observable<HighlightLayer>;
  47477. /**
  47478. * An event triggered when the highlight layer has been blurred.
  47479. */
  47480. onAfterBlurObservable: Observable<HighlightLayer>;
  47481. private _instanceGlowingMeshStencilReference;
  47482. private _options;
  47483. private _downSamplePostprocess;
  47484. private _horizontalBlurPostprocess;
  47485. private _verticalBlurPostprocess;
  47486. private _blurTexture;
  47487. private _meshes;
  47488. private _excludedMeshes;
  47489. /**
  47490. * Instantiates a new highlight Layer and references it to the scene..
  47491. * @param name The name of the layer
  47492. * @param scene The scene to use the layer in
  47493. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  47494. */
  47495. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  47496. /**
  47497. * Get the effect name of the layer.
  47498. * @return The effect name
  47499. */
  47500. getEffectName(): string;
  47501. /**
  47502. * Create the merge effect. This is the shader use to blit the information back
  47503. * to the main canvas at the end of the scene rendering.
  47504. */
  47505. protected _createMergeEffect(): Effect;
  47506. /**
  47507. * Creates the render target textures and post processes used in the highlight layer.
  47508. */
  47509. protected _createTextureAndPostProcesses(): void;
  47510. /**
  47511. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47512. */
  47513. needStencil(): boolean;
  47514. /**
  47515. * Checks for the readiness of the element composing the layer.
  47516. * @param subMesh the mesh to check for
  47517. * @param useInstances specify wether or not to use instances to render the mesh
  47518. * @param emissiveTexture the associated emissive texture used to generate the glow
  47519. * @return true if ready otherwise, false
  47520. */
  47521. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47522. /**
  47523. * Implementation specific of rendering the generating effect on the main canvas.
  47524. * @param effect The effect used to render through
  47525. */
  47526. protected _internalRender(effect: Effect): void;
  47527. /**
  47528. * Returns true if the layer contains information to display, otherwise false.
  47529. */
  47530. shouldRender(): boolean;
  47531. /**
  47532. * Returns true if the mesh should render, otherwise false.
  47533. * @param mesh The mesh to render
  47534. * @returns true if it should render otherwise false
  47535. */
  47536. protected _shouldRenderMesh(mesh: Mesh): boolean;
  47537. /**
  47538. * Sets the required values for both the emissive texture and and the main color.
  47539. */
  47540. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47541. /**
  47542. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  47543. * @param mesh The mesh to exclude from the highlight layer
  47544. */
  47545. addExcludedMesh(mesh: Mesh): void;
  47546. /**
  47547. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  47548. * @param mesh The mesh to highlight
  47549. */
  47550. removeExcludedMesh(mesh: Mesh): void;
  47551. /**
  47552. * Determine if a given mesh will be highlighted by the current HighlightLayer
  47553. * @param mesh mesh to test
  47554. * @returns true if the mesh will be highlighted by the current HighlightLayer
  47555. */
  47556. hasMesh(mesh: AbstractMesh): boolean;
  47557. /**
  47558. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  47559. * @param mesh The mesh to highlight
  47560. * @param color The color of the highlight
  47561. * @param glowEmissiveOnly Extract the glow from the emissive texture
  47562. */
  47563. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  47564. /**
  47565. * Remove a mesh from the highlight layer in order to make it stop glowing.
  47566. * @param mesh The mesh to highlight
  47567. */
  47568. removeMesh(mesh: Mesh): void;
  47569. /**
  47570. * Force the stencil to the normal expected value for none glowing parts
  47571. */
  47572. private _defaultStencilReference;
  47573. /**
  47574. * Free any resources and references associated to a mesh.
  47575. * Internal use
  47576. * @param mesh The mesh to free.
  47577. * @hidden
  47578. */
  47579. _disposeMesh(mesh: Mesh): void;
  47580. /**
  47581. * Dispose the highlight layer and free resources.
  47582. */
  47583. dispose(): void;
  47584. /**
  47585. * Gets the class name of the effect layer
  47586. * @returns the string with the class name of the effect layer
  47587. */
  47588. getClassName(): string;
  47589. /**
  47590. * Serializes this Highlight layer
  47591. * @returns a serialized Highlight layer object
  47592. */
  47593. serialize(): any;
  47594. /**
  47595. * Creates a Highlight layer from parsed Highlight layer data
  47596. * @param parsedHightlightLayer defines the Highlight layer data
  47597. * @param scene defines the current scene
  47598. * @param rootUrl defines the root URL containing the Highlight layer information
  47599. * @returns a parsed Highlight layer
  47600. */
  47601. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  47602. }
  47603. }
  47604. declare module BABYLON {
  47605. interface AbstractScene {
  47606. /**
  47607. * The list of layers (background and foreground) of the scene
  47608. */
  47609. layers: Array<Layer>;
  47610. }
  47611. /**
  47612. * Defines the layer scene component responsible to manage any layers
  47613. * in a given scene.
  47614. */
  47615. export class LayerSceneComponent implements ISceneComponent {
  47616. /**
  47617. * The component name helpfull to identify the component in the list of scene components.
  47618. */
  47619. readonly name: string;
  47620. /**
  47621. * The scene the component belongs to.
  47622. */
  47623. scene: Scene;
  47624. private _engine;
  47625. /**
  47626. * Creates a new instance of the component for the given scene
  47627. * @param scene Defines the scene to register the component in
  47628. */
  47629. constructor(scene: Scene);
  47630. /**
  47631. * Registers the component in a given scene
  47632. */
  47633. register(): void;
  47634. /**
  47635. * Rebuilds the elements related to this component in case of
  47636. * context lost for instance.
  47637. */
  47638. rebuild(): void;
  47639. /**
  47640. * Disposes the component and the associated ressources.
  47641. */
  47642. dispose(): void;
  47643. private _draw;
  47644. private _drawCameraPredicate;
  47645. private _drawCameraBackground;
  47646. private _drawCameraForeground;
  47647. private _drawRenderTargetPredicate;
  47648. private _drawRenderTargetBackground;
  47649. private _drawRenderTargetForeground;
  47650. }
  47651. }
  47652. declare module BABYLON {
  47653. /** @hidden */
  47654. export var layerPixelShader: {
  47655. name: string;
  47656. shader: string;
  47657. };
  47658. }
  47659. declare module BABYLON {
  47660. /** @hidden */
  47661. export var layerVertexShader: {
  47662. name: string;
  47663. shader: string;
  47664. };
  47665. }
  47666. declare module BABYLON {
  47667. /**
  47668. * This represents a full screen 2d layer.
  47669. * This can be useful to display a picture in the background of your scene for instance.
  47670. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47671. */
  47672. export class Layer {
  47673. /**
  47674. * Define the name of the layer.
  47675. */
  47676. name: string;
  47677. /**
  47678. * Define the texture the layer should display.
  47679. */
  47680. texture: Nullable<Texture>;
  47681. /**
  47682. * Is the layer in background or foreground.
  47683. */
  47684. isBackground: boolean;
  47685. /**
  47686. * Define the color of the layer (instead of texture).
  47687. */
  47688. color: Color4;
  47689. /**
  47690. * Define the scale of the layer in order to zoom in out of the texture.
  47691. */
  47692. scale: Vector2;
  47693. /**
  47694. * Define an offset for the layer in order to shift the texture.
  47695. */
  47696. offset: Vector2;
  47697. /**
  47698. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  47699. */
  47700. alphaBlendingMode: number;
  47701. /**
  47702. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  47703. * Alpha test will not mix with the background color in case of transparency.
  47704. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  47705. */
  47706. alphaTest: boolean;
  47707. /**
  47708. * Define a mask to restrict the layer to only some of the scene cameras.
  47709. */
  47710. layerMask: number;
  47711. /**
  47712. * Define the list of render target the layer is visible into.
  47713. */
  47714. renderTargetTextures: RenderTargetTexture[];
  47715. /**
  47716. * Define if the layer is only used in renderTarget or if it also
  47717. * renders in the main frame buffer of the canvas.
  47718. */
  47719. renderOnlyInRenderTargetTextures: boolean;
  47720. private _scene;
  47721. private _vertexBuffers;
  47722. private _indexBuffer;
  47723. private _effect;
  47724. private _alphaTestEffect;
  47725. /**
  47726. * An event triggered when the layer is disposed.
  47727. */
  47728. onDisposeObservable: Observable<Layer>;
  47729. private _onDisposeObserver;
  47730. /**
  47731. * Back compatibility with callback before the onDisposeObservable existed.
  47732. * The set callback will be triggered when the layer has been disposed.
  47733. */
  47734. onDispose: () => void;
  47735. /**
  47736. * An event triggered before rendering the scene
  47737. */
  47738. onBeforeRenderObservable: Observable<Layer>;
  47739. private _onBeforeRenderObserver;
  47740. /**
  47741. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47742. * The set callback will be triggered just before rendering the layer.
  47743. */
  47744. onBeforeRender: () => void;
  47745. /**
  47746. * An event triggered after rendering the scene
  47747. */
  47748. onAfterRenderObservable: Observable<Layer>;
  47749. private _onAfterRenderObserver;
  47750. /**
  47751. * Back compatibility with callback before the onAfterRenderObservable existed.
  47752. * The set callback will be triggered just after rendering the layer.
  47753. */
  47754. onAfterRender: () => void;
  47755. /**
  47756. * Instantiates a new layer.
  47757. * This represents a full screen 2d layer.
  47758. * This can be useful to display a picture in the background of your scene for instance.
  47759. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47760. * @param name Define the name of the layer in the scene
  47761. * @param imgUrl Define the url of the texture to display in the layer
  47762. * @param scene Define the scene the layer belongs to
  47763. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47764. * @param color Defines a color for the layer
  47765. */
  47766. constructor(
  47767. /**
  47768. * Define the name of the layer.
  47769. */
  47770. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  47771. private _createIndexBuffer;
  47772. /** @hidden */
  47773. _rebuild(): void;
  47774. /**
  47775. * Renders the layer in the scene.
  47776. */
  47777. render(): void;
  47778. /**
  47779. * Disposes and releases the associated ressources.
  47780. */
  47781. dispose(): void;
  47782. }
  47783. }
  47784. declare module BABYLON {
  47785. /** @hidden */
  47786. export var lensFlarePixelShader: {
  47787. name: string;
  47788. shader: string;
  47789. };
  47790. }
  47791. declare module BABYLON {
  47792. /** @hidden */
  47793. export var lensFlareVertexShader: {
  47794. name: string;
  47795. shader: string;
  47796. };
  47797. }
  47798. declare module BABYLON {
  47799. /**
  47800. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47801. * It is usually composed of several `lensFlare`.
  47802. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47803. */
  47804. export class LensFlareSystem {
  47805. /**
  47806. * Define the name of the lens flare system
  47807. */
  47808. name: string;
  47809. /**
  47810. * List of lens flares used in this system.
  47811. */
  47812. lensFlares: LensFlare[];
  47813. /**
  47814. * Define a limit from the border the lens flare can be visible.
  47815. */
  47816. borderLimit: number;
  47817. /**
  47818. * Define a viewport border we do not want to see the lens flare in.
  47819. */
  47820. viewportBorder: number;
  47821. /**
  47822. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47823. */
  47824. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47825. /**
  47826. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47827. */
  47828. layerMask: number;
  47829. /**
  47830. * Define the id of the lens flare system in the scene.
  47831. * (equal to name by default)
  47832. */
  47833. id: string;
  47834. private _scene;
  47835. private _emitter;
  47836. private _vertexBuffers;
  47837. private _indexBuffer;
  47838. private _effect;
  47839. private _positionX;
  47840. private _positionY;
  47841. private _isEnabled;
  47842. /** @hidden */
  47843. static _SceneComponentInitialization: (scene: Scene) => void;
  47844. /**
  47845. * Instantiates a lens flare system.
  47846. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47847. * It is usually composed of several `lensFlare`.
  47848. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47849. * @param name Define the name of the lens flare system in the scene
  47850. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47851. * @param scene Define the scene the lens flare system belongs to
  47852. */
  47853. constructor(
  47854. /**
  47855. * Define the name of the lens flare system
  47856. */
  47857. name: string, emitter: any, scene: Scene);
  47858. /**
  47859. * Define if the lens flare system is enabled.
  47860. */
  47861. isEnabled: boolean;
  47862. /**
  47863. * Get the scene the effects belongs to.
  47864. * @returns the scene holding the lens flare system
  47865. */
  47866. getScene(): Scene;
  47867. /**
  47868. * Get the emitter of the lens flare system.
  47869. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47870. * @returns the emitter of the lens flare system
  47871. */
  47872. getEmitter(): any;
  47873. /**
  47874. * Set the emitter of the lens flare system.
  47875. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47876. * @param newEmitter Define the new emitter of the system
  47877. */
  47878. setEmitter(newEmitter: any): void;
  47879. /**
  47880. * Get the lens flare system emitter position.
  47881. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47882. * @returns the position
  47883. */
  47884. getEmitterPosition(): Vector3;
  47885. /**
  47886. * @hidden
  47887. */
  47888. computeEffectivePosition(globalViewport: Viewport): boolean;
  47889. /** @hidden */
  47890. _isVisible(): boolean;
  47891. /**
  47892. * @hidden
  47893. */
  47894. render(): boolean;
  47895. /**
  47896. * Dispose and release the lens flare with its associated resources.
  47897. */
  47898. dispose(): void;
  47899. /**
  47900. * Parse a lens flare system from a JSON repressentation
  47901. * @param parsedLensFlareSystem Define the JSON to parse
  47902. * @param scene Define the scene the parsed system should be instantiated in
  47903. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47904. * @returns the parsed system
  47905. */
  47906. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47907. /**
  47908. * Serialize the current Lens Flare System into a JSON representation.
  47909. * @returns the serialized JSON
  47910. */
  47911. serialize(): any;
  47912. }
  47913. }
  47914. declare module BABYLON {
  47915. /**
  47916. * This represents one of the lens effect in a `lensFlareSystem`.
  47917. * It controls one of the indiviual texture used in the effect.
  47918. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47919. */
  47920. export class LensFlare {
  47921. /**
  47922. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47923. */
  47924. size: number;
  47925. /**
  47926. * 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.
  47927. */
  47928. position: number;
  47929. /**
  47930. * Define the lens color.
  47931. */
  47932. color: Color3;
  47933. /**
  47934. * Define the lens texture.
  47935. */
  47936. texture: Nullable<Texture>;
  47937. /**
  47938. * Define the alpha mode to render this particular lens.
  47939. */
  47940. alphaMode: number;
  47941. private _system;
  47942. /**
  47943. * Creates a new Lens Flare.
  47944. * This represents one of the lens effect in a `lensFlareSystem`.
  47945. * It controls one of the indiviual texture used in the effect.
  47946. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47947. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47948. * @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.
  47949. * @param color Define the lens color
  47950. * @param imgUrl Define the lens texture url
  47951. * @param system Define the `lensFlareSystem` this flare is part of
  47952. * @returns The newly created Lens Flare
  47953. */
  47954. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47955. /**
  47956. * Instantiates a new Lens Flare.
  47957. * This represents one of the lens effect in a `lensFlareSystem`.
  47958. * It controls one of the indiviual texture used in the effect.
  47959. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47960. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47961. * @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.
  47962. * @param color Define the lens color
  47963. * @param imgUrl Define the lens texture url
  47964. * @param system Define the `lensFlareSystem` this flare is part of
  47965. */
  47966. constructor(
  47967. /**
  47968. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47969. */
  47970. size: number,
  47971. /**
  47972. * 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.
  47973. */
  47974. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47975. /**
  47976. * Dispose and release the lens flare with its associated resources.
  47977. */
  47978. dispose(): void;
  47979. }
  47980. }
  47981. declare module BABYLON {
  47982. interface AbstractScene {
  47983. /**
  47984. * The list of lens flare system added to the scene
  47985. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47986. */
  47987. lensFlareSystems: Array<LensFlareSystem>;
  47988. /**
  47989. * Removes the given lens flare system from this scene.
  47990. * @param toRemove The lens flare system to remove
  47991. * @returns The index of the removed lens flare system
  47992. */
  47993. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47994. /**
  47995. * Adds the given lens flare system to this scene
  47996. * @param newLensFlareSystem The lens flare system to add
  47997. */
  47998. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47999. /**
  48000. * Gets a lens flare system using its name
  48001. * @param name defines the name to look for
  48002. * @returns the lens flare system or null if not found
  48003. */
  48004. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48005. /**
  48006. * Gets a lens flare system using its id
  48007. * @param id defines the id to look for
  48008. * @returns the lens flare system or null if not found
  48009. */
  48010. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48011. }
  48012. /**
  48013. * Defines the lens flare scene component responsible to manage any lens flares
  48014. * in a given scene.
  48015. */
  48016. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48017. /**
  48018. * The component name helpfull to identify the component in the list of scene components.
  48019. */
  48020. readonly name: string;
  48021. /**
  48022. * The scene the component belongs to.
  48023. */
  48024. scene: Scene;
  48025. /**
  48026. * Creates a new instance of the component for the given scene
  48027. * @param scene Defines the scene to register the component in
  48028. */
  48029. constructor(scene: Scene);
  48030. /**
  48031. * Registers the component in a given scene
  48032. */
  48033. register(): void;
  48034. /**
  48035. * Rebuilds the elements related to this component in case of
  48036. * context lost for instance.
  48037. */
  48038. rebuild(): void;
  48039. /**
  48040. * Adds all the element from the container to the scene
  48041. * @param container the container holding the elements
  48042. */
  48043. addFromContainer(container: AbstractScene): void;
  48044. /**
  48045. * Removes all the elements in the container from the scene
  48046. * @param container contains the elements to remove
  48047. * @param dispose if the removed element should be disposed (default: false)
  48048. */
  48049. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48050. /**
  48051. * Serializes the component data to the specified json object
  48052. * @param serializationObject The object to serialize to
  48053. */
  48054. serialize(serializationObject: any): void;
  48055. /**
  48056. * Disposes the component and the associated ressources.
  48057. */
  48058. dispose(): void;
  48059. private _draw;
  48060. }
  48061. }
  48062. declare module BABYLON {
  48063. /**
  48064. * Defines the shadow generator component responsible to manage any shadow generators
  48065. * in a given scene.
  48066. */
  48067. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48068. /**
  48069. * The component name helpfull to identify the component in the list of scene components.
  48070. */
  48071. readonly name: string;
  48072. /**
  48073. * The scene the component belongs to.
  48074. */
  48075. scene: Scene;
  48076. /**
  48077. * Creates a new instance of the component for the given scene
  48078. * @param scene Defines the scene to register the component in
  48079. */
  48080. constructor(scene: Scene);
  48081. /**
  48082. * Registers the component in a given scene
  48083. */
  48084. register(): void;
  48085. /**
  48086. * Rebuilds the elements related to this component in case of
  48087. * context lost for instance.
  48088. */
  48089. rebuild(): void;
  48090. /**
  48091. * Serializes the component data to the specified json object
  48092. * @param serializationObject The object to serialize to
  48093. */
  48094. serialize(serializationObject: any): void;
  48095. /**
  48096. * Adds all the element from the container to the scene
  48097. * @param container the container holding the elements
  48098. */
  48099. addFromContainer(container: AbstractScene): void;
  48100. /**
  48101. * Removes all the elements in the container from the scene
  48102. * @param container contains the elements to remove
  48103. * @param dispose if the removed element should be disposed (default: false)
  48104. */
  48105. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48106. /**
  48107. * Rebuilds the elements related to this component in case of
  48108. * context lost for instance.
  48109. */
  48110. dispose(): void;
  48111. private _gatherRenderTargets;
  48112. }
  48113. }
  48114. declare module BABYLON {
  48115. /**
  48116. * A point light is a light defined by an unique point in world space.
  48117. * The light is emitted in every direction from this point.
  48118. * A good example of a point light is a standard light bulb.
  48119. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48120. */
  48121. export class PointLight extends ShadowLight {
  48122. private _shadowAngle;
  48123. /**
  48124. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48125. * This specifies what angle the shadow will use to be created.
  48126. *
  48127. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48128. */
  48129. /**
  48130. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48131. * This specifies what angle the shadow will use to be created.
  48132. *
  48133. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48134. */
  48135. shadowAngle: number;
  48136. /**
  48137. * Gets the direction if it has been set.
  48138. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48139. */
  48140. /**
  48141. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48142. */
  48143. direction: Vector3;
  48144. /**
  48145. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48146. * A PointLight emits the light in every direction.
  48147. * It can cast shadows.
  48148. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48149. * ```javascript
  48150. * var pointLight = new PointLight("pl", camera.position, scene);
  48151. * ```
  48152. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48153. * @param name The light friendly name
  48154. * @param position The position of the point light in the scene
  48155. * @param scene The scene the lights belongs to
  48156. */
  48157. constructor(name: string, position: Vector3, scene: Scene);
  48158. /**
  48159. * Returns the string "PointLight"
  48160. * @returns the class name
  48161. */
  48162. getClassName(): string;
  48163. /**
  48164. * Returns the integer 0.
  48165. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48166. */
  48167. getTypeID(): number;
  48168. /**
  48169. * Specifies wether or not the shadowmap should be a cube texture.
  48170. * @returns true if the shadowmap needs to be a cube texture.
  48171. */
  48172. needCube(): boolean;
  48173. /**
  48174. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48175. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48176. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48177. */
  48178. getShadowDirection(faceIndex?: number): Vector3;
  48179. /**
  48180. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48181. * - fov = PI / 2
  48182. * - aspect ratio : 1.0
  48183. * - z-near and far equal to the active camera minZ and maxZ.
  48184. * Returns the PointLight.
  48185. */
  48186. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48187. protected _buildUniformLayout(): void;
  48188. /**
  48189. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48190. * @param effect The effect to update
  48191. * @param lightIndex The index of the light in the effect to update
  48192. * @returns The point light
  48193. */
  48194. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48195. /**
  48196. * Prepares the list of defines specific to the light type.
  48197. * @param defines the list of defines
  48198. * @param lightIndex defines the index of the light for the effect
  48199. */
  48200. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48201. }
  48202. }
  48203. declare module BABYLON {
  48204. /**
  48205. * Header information of HDR texture files.
  48206. */
  48207. export interface HDRInfo {
  48208. /**
  48209. * The height of the texture in pixels.
  48210. */
  48211. height: number;
  48212. /**
  48213. * The width of the texture in pixels.
  48214. */
  48215. width: number;
  48216. /**
  48217. * The index of the beginning of the data in the binary file.
  48218. */
  48219. dataPosition: number;
  48220. }
  48221. /**
  48222. * This groups tools to convert HDR texture to native colors array.
  48223. */
  48224. export class HDRTools {
  48225. private static Ldexp;
  48226. private static Rgbe2float;
  48227. private static readStringLine;
  48228. /**
  48229. * Reads header information from an RGBE texture stored in a native array.
  48230. * More information on this format are available here:
  48231. * https://en.wikipedia.org/wiki/RGBE_image_format
  48232. *
  48233. * @param uint8array The binary file stored in native array.
  48234. * @return The header information.
  48235. */
  48236. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48237. /**
  48238. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48239. * This RGBE texture needs to store the information as a panorama.
  48240. *
  48241. * More information on this format are available here:
  48242. * https://en.wikipedia.org/wiki/RGBE_image_format
  48243. *
  48244. * @param buffer The binary file stored in an array buffer.
  48245. * @param size The expected size of the extracted cubemap.
  48246. * @return The Cube Map information.
  48247. */
  48248. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  48249. /**
  48250. * Returns the pixels data extracted from an RGBE texture.
  48251. * This pixels will be stored left to right up to down in the R G B order in one array.
  48252. *
  48253. * More information on this format are available here:
  48254. * https://en.wikipedia.org/wiki/RGBE_image_format
  48255. *
  48256. * @param uint8array The binary file stored in an array buffer.
  48257. * @param hdrInfo The header information of the file.
  48258. * @return The pixels data in RGB right to left up to down order.
  48259. */
  48260. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  48261. private static RGBE_ReadPixels_RLE;
  48262. }
  48263. }
  48264. declare module BABYLON {
  48265. /**
  48266. * This represents a texture coming from an HDR input.
  48267. *
  48268. * The only supported format is currently panorama picture stored in RGBE format.
  48269. * Example of such files can be found on HDRLib: http://hdrlib.com/
  48270. */
  48271. export class HDRCubeTexture extends BaseTexture {
  48272. private static _facesMapping;
  48273. private _generateHarmonics;
  48274. private _noMipmap;
  48275. private _textureMatrix;
  48276. private _size;
  48277. private _onLoad;
  48278. private _onError;
  48279. /**
  48280. * The texture URL.
  48281. */
  48282. url: string;
  48283. /**
  48284. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  48285. */
  48286. coordinatesMode: number;
  48287. protected _isBlocking: boolean;
  48288. /**
  48289. * Sets wether or not the texture is blocking during loading.
  48290. */
  48291. /**
  48292. * Gets wether or not the texture is blocking during loading.
  48293. */
  48294. isBlocking: boolean;
  48295. protected _rotationY: number;
  48296. /**
  48297. * Sets texture matrix rotation angle around Y axis in radians.
  48298. */
  48299. /**
  48300. * Gets texture matrix rotation angle around Y axis radians.
  48301. */
  48302. rotationY: number;
  48303. /**
  48304. * Gets or sets the center of the bounding box associated with the cube texture
  48305. * It must define where the camera used to render the texture was set
  48306. */
  48307. boundingBoxPosition: Vector3;
  48308. private _boundingBoxSize;
  48309. /**
  48310. * Gets or sets the size of the bounding box associated with the cube texture
  48311. * When defined, the cubemap will switch to local mode
  48312. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  48313. * @example https://www.babylonjs-playground.com/#RNASML
  48314. */
  48315. boundingBoxSize: Vector3;
  48316. /**
  48317. * Instantiates an HDRTexture from the following parameters.
  48318. *
  48319. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  48320. * @param scene The scene the texture will be used in
  48321. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48322. * @param noMipmap Forces to not generate the mipmap if true
  48323. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  48324. * @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)
  48325. * @param reserved Reserved flag for internal use.
  48326. */
  48327. 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>);
  48328. /**
  48329. * Get the current class name of the texture useful for serialization or dynamic coding.
  48330. * @returns "HDRCubeTexture"
  48331. */
  48332. getClassName(): string;
  48333. /**
  48334. * Occurs when the file is raw .hdr file.
  48335. */
  48336. private loadTexture;
  48337. clone(): HDRCubeTexture;
  48338. delayLoad(): void;
  48339. /**
  48340. * Get the texture reflection matrix used to rotate/transform the reflection.
  48341. * @returns the reflection matrix
  48342. */
  48343. getReflectionTextureMatrix(): Matrix;
  48344. /**
  48345. * Set the texture reflection matrix used to rotate/transform the reflection.
  48346. * @param value Define the reflection matrix to set
  48347. */
  48348. setReflectionTextureMatrix(value: Matrix): void;
  48349. /**
  48350. * Parses a JSON representation of an HDR Texture in order to create the texture
  48351. * @param parsedTexture Define the JSON representation
  48352. * @param scene Define the scene the texture should be created in
  48353. * @param rootUrl Define the root url in case we need to load relative dependencies
  48354. * @returns the newly created texture after parsing
  48355. */
  48356. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  48357. serialize(): any;
  48358. }
  48359. }
  48360. declare module BABYLON {
  48361. /**
  48362. * Class used to control physics engine
  48363. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48364. */
  48365. export class PhysicsEngine implements IPhysicsEngine {
  48366. private _physicsPlugin;
  48367. /**
  48368. * Global value used to control the smallest number supported by the simulation
  48369. */
  48370. static Epsilon: number;
  48371. private _impostors;
  48372. private _joints;
  48373. /**
  48374. * Gets the gravity vector used by the simulation
  48375. */
  48376. gravity: Vector3;
  48377. /**
  48378. * Factory used to create the default physics plugin.
  48379. * @returns The default physics plugin
  48380. */
  48381. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  48382. /**
  48383. * Creates a new Physics Engine
  48384. * @param gravity defines the gravity vector used by the simulation
  48385. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  48386. */
  48387. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  48388. /**
  48389. * Sets the gravity vector used by the simulation
  48390. * @param gravity defines the gravity vector to use
  48391. */
  48392. setGravity(gravity: Vector3): void;
  48393. /**
  48394. * Set the time step of the physics engine.
  48395. * Default is 1/60.
  48396. * To slow it down, enter 1/600 for example.
  48397. * To speed it up, 1/30
  48398. * @param newTimeStep defines the new timestep to apply to this world.
  48399. */
  48400. setTimeStep(newTimeStep?: number): void;
  48401. /**
  48402. * Get the time step of the physics engine.
  48403. * @returns the current time step
  48404. */
  48405. getTimeStep(): number;
  48406. /**
  48407. * Release all resources
  48408. */
  48409. dispose(): void;
  48410. /**
  48411. * Gets the name of the current physics plugin
  48412. * @returns the name of the plugin
  48413. */
  48414. getPhysicsPluginName(): string;
  48415. /**
  48416. * Adding a new impostor for the impostor tracking.
  48417. * This will be done by the impostor itself.
  48418. * @param impostor the impostor to add
  48419. */
  48420. addImpostor(impostor: PhysicsImpostor): void;
  48421. /**
  48422. * Remove an impostor from the engine.
  48423. * This impostor and its mesh will not longer be updated by the physics engine.
  48424. * @param impostor the impostor to remove
  48425. */
  48426. removeImpostor(impostor: PhysicsImpostor): void;
  48427. /**
  48428. * Add a joint to the physics engine
  48429. * @param mainImpostor defines the main impostor to which the joint is added.
  48430. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  48431. * @param joint defines the joint that will connect both impostors.
  48432. */
  48433. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48434. /**
  48435. * Removes a joint from the simulation
  48436. * @param mainImpostor defines the impostor used with the joint
  48437. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  48438. * @param joint defines the joint to remove
  48439. */
  48440. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  48441. /**
  48442. * Called by the scene. No need to call it.
  48443. * @param delta defines the timespam between frames
  48444. */
  48445. _step(delta: number): void;
  48446. /**
  48447. * Gets the current plugin used to run the simulation
  48448. * @returns current plugin
  48449. */
  48450. getPhysicsPlugin(): IPhysicsEnginePlugin;
  48451. /**
  48452. * Gets the list of physic impostors
  48453. * @returns an array of PhysicsImpostor
  48454. */
  48455. getImpostors(): Array<PhysicsImpostor>;
  48456. /**
  48457. * Gets the impostor for a physics enabled object
  48458. * @param object defines the object impersonated by the impostor
  48459. * @returns the PhysicsImpostor or null if not found
  48460. */
  48461. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  48462. /**
  48463. * Gets the impostor for a physics body object
  48464. * @param body defines physics body used by the impostor
  48465. * @returns the PhysicsImpostor or null if not found
  48466. */
  48467. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  48468. /**
  48469. * Does a raycast in the physics world
  48470. * @param from when should the ray start?
  48471. * @param to when should the ray end?
  48472. * @returns PhysicsRaycastResult
  48473. */
  48474. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48475. }
  48476. }
  48477. declare module BABYLON {
  48478. /** @hidden */
  48479. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  48480. private _useDeltaForWorldStep;
  48481. world: any;
  48482. name: string;
  48483. private _physicsMaterials;
  48484. private _fixedTimeStep;
  48485. private _cannonRaycastResult;
  48486. private _raycastResult;
  48487. private _removeAfterStep;
  48488. BJSCANNON: any;
  48489. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  48490. setGravity(gravity: Vector3): void;
  48491. setTimeStep(timeStep: number): void;
  48492. getTimeStep(): number;
  48493. executeStep(delta: number): void;
  48494. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48495. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48496. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48497. private _processChildMeshes;
  48498. removePhysicsBody(impostor: PhysicsImpostor): void;
  48499. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48500. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48501. private _addMaterial;
  48502. private _checkWithEpsilon;
  48503. private _createShape;
  48504. private _createHeightmap;
  48505. private _minus90X;
  48506. private _plus90X;
  48507. private _tmpPosition;
  48508. private _tmpDeltaPosition;
  48509. private _tmpUnityRotation;
  48510. private _updatePhysicsBodyTransformation;
  48511. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48512. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48513. isSupported(): boolean;
  48514. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48515. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48516. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48519. getBodyMass(impostor: PhysicsImpostor): number;
  48520. getBodyFriction(impostor: PhysicsImpostor): number;
  48521. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48522. getBodyRestitution(impostor: PhysicsImpostor): number;
  48523. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48524. sleepBody(impostor: PhysicsImpostor): void;
  48525. wakeUpBody(impostor: PhysicsImpostor): void;
  48526. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  48527. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48528. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48529. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48530. getRadius(impostor: PhysicsImpostor): number;
  48531. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48532. dispose(): void;
  48533. private _extendNamespace;
  48534. /**
  48535. * Does a raycast in the physics world
  48536. * @param from when should the ray start?
  48537. * @param to when should the ray end?
  48538. * @returns PhysicsRaycastResult
  48539. */
  48540. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48541. }
  48542. }
  48543. declare module BABYLON {
  48544. /** @hidden */
  48545. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  48546. world: any;
  48547. name: string;
  48548. BJSOIMO: any;
  48549. private _raycastResult;
  48550. constructor(iterations?: number, oimoInjection?: any);
  48551. setGravity(gravity: Vector3): void;
  48552. setTimeStep(timeStep: number): void;
  48553. getTimeStep(): number;
  48554. private _tmpImpostorsArray;
  48555. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48556. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48557. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48558. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48559. private _tmpPositionVector;
  48560. removePhysicsBody(impostor: PhysicsImpostor): void;
  48561. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48562. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48563. isSupported(): boolean;
  48564. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48565. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48566. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48567. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48568. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48569. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48570. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48571. getBodyMass(impostor: PhysicsImpostor): number;
  48572. getBodyFriction(impostor: PhysicsImpostor): number;
  48573. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48574. getBodyRestitution(impostor: PhysicsImpostor): number;
  48575. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48576. sleepBody(impostor: PhysicsImpostor): void;
  48577. wakeUpBody(impostor: PhysicsImpostor): void;
  48578. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48579. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  48580. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  48581. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48582. getRadius(impostor: PhysicsImpostor): number;
  48583. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48584. dispose(): void;
  48585. /**
  48586. * Does a raycast in the physics world
  48587. * @param from when should the ray start?
  48588. * @param to when should the ray end?
  48589. * @returns PhysicsRaycastResult
  48590. */
  48591. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48592. }
  48593. }
  48594. declare module BABYLON {
  48595. /**
  48596. * Class containing static functions to help procedurally build meshes
  48597. */
  48598. export class RibbonBuilder {
  48599. /**
  48600. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48601. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48602. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48603. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48604. * * 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
  48605. * * 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
  48606. * * 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
  48607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48608. * * 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
  48609. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48610. * * 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
  48611. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48612. * * 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
  48613. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48615. * @param name defines the name of the mesh
  48616. * @param options defines the options used to create the mesh
  48617. * @param scene defines the hosting scene
  48618. * @returns the ribbon mesh
  48619. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48620. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48621. */
  48622. static CreateRibbon(name: string, options: {
  48623. pathArray: Vector3[][];
  48624. closeArray?: boolean;
  48625. closePath?: boolean;
  48626. offset?: number;
  48627. updatable?: boolean;
  48628. sideOrientation?: number;
  48629. frontUVs?: Vector4;
  48630. backUVs?: Vector4;
  48631. instance?: Mesh;
  48632. invertUV?: boolean;
  48633. uvs?: Vector2[];
  48634. colors?: Color4[];
  48635. }, scene?: Nullable<Scene>): Mesh;
  48636. }
  48637. }
  48638. declare module BABYLON {
  48639. /**
  48640. * Class containing static functions to help procedurally build meshes
  48641. */
  48642. export class ShapeBuilder {
  48643. /**
  48644. * 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.
  48645. * * 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.
  48646. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48647. * * 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.
  48648. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48649. * * 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
  48650. * * 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
  48651. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48653. * * 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
  48654. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48656. * @param name defines the name of the mesh
  48657. * @param options defines the options used to create the mesh
  48658. * @param scene defines the hosting scene
  48659. * @returns the extruded shape mesh
  48660. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48661. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48662. */
  48663. static ExtrudeShape(name: string, options: {
  48664. shape: Vector3[];
  48665. path: Vector3[];
  48666. scale?: number;
  48667. rotation?: number;
  48668. cap?: number;
  48669. updatable?: boolean;
  48670. sideOrientation?: number;
  48671. frontUVs?: Vector4;
  48672. backUVs?: Vector4;
  48673. instance?: Mesh;
  48674. invertUV?: boolean;
  48675. }, scene?: Nullable<Scene>): Mesh;
  48676. /**
  48677. * Creates an custom extruded shape mesh.
  48678. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48679. * * 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.
  48680. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48681. * * 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
  48682. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48683. * * 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
  48684. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48685. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48686. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48687. * * 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
  48688. * * 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
  48689. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48691. * * 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
  48692. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48694. * @param name defines the name of the mesh
  48695. * @param options defines the options used to create the mesh
  48696. * @param scene defines the hosting scene
  48697. * @returns the custom extruded shape mesh
  48698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48699. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48701. */
  48702. static ExtrudeShapeCustom(name: string, options: {
  48703. shape: Vector3[];
  48704. path: Vector3[];
  48705. scaleFunction?: any;
  48706. rotationFunction?: any;
  48707. ribbonCloseArray?: boolean;
  48708. ribbonClosePath?: boolean;
  48709. cap?: number;
  48710. updatable?: boolean;
  48711. sideOrientation?: number;
  48712. frontUVs?: Vector4;
  48713. backUVs?: Vector4;
  48714. instance?: Mesh;
  48715. invertUV?: boolean;
  48716. }, scene?: Nullable<Scene>): Mesh;
  48717. private static _ExtrudeShapeGeneric;
  48718. }
  48719. }
  48720. declare module BABYLON {
  48721. /**
  48722. * AmmoJS Physics plugin
  48723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48724. * @see https://github.com/kripken/ammo.js/
  48725. */
  48726. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48727. private _useDeltaForWorldStep;
  48728. /**
  48729. * Reference to the Ammo library
  48730. */
  48731. bjsAMMO: any;
  48732. /**
  48733. * Created ammoJS world which physics bodies are added to
  48734. */
  48735. world: any;
  48736. /**
  48737. * Name of the plugin
  48738. */
  48739. name: string;
  48740. private _timeStep;
  48741. private _fixedTimeStep;
  48742. private _maxSteps;
  48743. private _tmpQuaternion;
  48744. private _tmpAmmoTransform;
  48745. private _tmpAmmoQuaternion;
  48746. private _tmpAmmoConcreteContactResultCallback;
  48747. private _collisionConfiguration;
  48748. private _dispatcher;
  48749. private _overlappingPairCache;
  48750. private _solver;
  48751. private _softBodySolver;
  48752. private _tmpAmmoVectorA;
  48753. private _tmpAmmoVectorB;
  48754. private _tmpAmmoVectorC;
  48755. private _tmpAmmoVectorD;
  48756. private _tmpContactCallbackResult;
  48757. private _tmpAmmoVectorRCA;
  48758. private _tmpAmmoVectorRCB;
  48759. private _raycastResult;
  48760. private static readonly DISABLE_COLLISION_FLAG;
  48761. private static readonly KINEMATIC_FLAG;
  48762. private static readonly DISABLE_DEACTIVATION_FLAG;
  48763. /**
  48764. * Initializes the ammoJS plugin
  48765. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48766. * @param ammoInjection can be used to inject your own ammo reference
  48767. */
  48768. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48769. /**
  48770. * Sets the gravity of the physics world (m/(s^2))
  48771. * @param gravity Gravity to set
  48772. */
  48773. setGravity(gravity: Vector3): void;
  48774. /**
  48775. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48776. * @param timeStep timestep to use in seconds
  48777. */
  48778. setTimeStep(timeStep: number): void;
  48779. /**
  48780. * Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
  48781. * @param fixedTimeStep fixedTimeStep to use in seconds
  48782. */
  48783. setFixedTimeStep(fixedTimeStep: number): void;
  48784. /**
  48785. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48786. * @param maxSteps the maximum number of steps by the physics engine per frame
  48787. */
  48788. setMaxSteps(maxSteps: number): void;
  48789. /**
  48790. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48791. * @returns the current timestep in seconds
  48792. */
  48793. getTimeStep(): number;
  48794. private _isImpostorInContact;
  48795. private _isImpostorPairInContact;
  48796. private _stepSimulation;
  48797. /**
  48798. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48799. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48800. * After the step the babylon meshes are set to the position of the physics imposters
  48801. * @param delta amount of time to step forward
  48802. * @param impostors array of imposters to update before/after the step
  48803. */
  48804. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48805. /**
  48806. * Update babylon mesh to match physics world object
  48807. * @param impostor imposter to match
  48808. */
  48809. private _afterSoftStep;
  48810. /**
  48811. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48812. * @param impostor imposter to match
  48813. */
  48814. private _ropeStep;
  48815. /**
  48816. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48817. * @param impostor imposter to match
  48818. */
  48819. private _softbodyOrClothStep;
  48820. private _tmpVector;
  48821. private _tmpMatrix;
  48822. /**
  48823. * Applies an impulse on the imposter
  48824. * @param impostor imposter to apply impulse to
  48825. * @param force amount of force to be applied to the imposter
  48826. * @param contactPoint the location to apply the impulse on the imposter
  48827. */
  48828. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48829. /**
  48830. * Applies a force on the imposter
  48831. * @param impostor imposter to apply force
  48832. * @param force amount of force to be applied to the imposter
  48833. * @param contactPoint the location to apply the force on the imposter
  48834. */
  48835. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48836. /**
  48837. * Creates a physics body using the plugin
  48838. * @param impostor the imposter to create the physics body on
  48839. */
  48840. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48841. /**
  48842. * Removes the physics body from the imposter and disposes of the body's memory
  48843. * @param impostor imposter to remove the physics body from
  48844. */
  48845. removePhysicsBody(impostor: PhysicsImpostor): void;
  48846. /**
  48847. * Generates a joint
  48848. * @param impostorJoint the imposter joint to create the joint with
  48849. */
  48850. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48851. /**
  48852. * Removes a joint
  48853. * @param impostorJoint the imposter joint to remove the joint from
  48854. */
  48855. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48856. private _addMeshVerts;
  48857. /**
  48858. * Initialise the soft body vertices to match its object's (mesh) vertices
  48859. * Softbody vertices (nodes) are in world space and to match this
  48860. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48861. * @param impostor to create the softbody for
  48862. */
  48863. private _softVertexData;
  48864. /**
  48865. * Create an impostor's soft body
  48866. * @param impostor to create the softbody for
  48867. */
  48868. private _createSoftbody;
  48869. /**
  48870. * Create cloth for an impostor
  48871. * @param impostor to create the softbody for
  48872. */
  48873. private _createCloth;
  48874. /**
  48875. * Create rope for an impostor
  48876. * @param impostor to create the softbody for
  48877. */
  48878. private _createRope;
  48879. private _addHullVerts;
  48880. private _createShape;
  48881. /**
  48882. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48883. * @param impostor imposter containing the physics body and babylon object
  48884. */
  48885. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48886. /**
  48887. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48888. * @param impostor imposter containing the physics body and babylon object
  48889. * @param newPosition new position
  48890. * @param newRotation new rotation
  48891. */
  48892. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48893. /**
  48894. * If this plugin is supported
  48895. * @returns true if its supported
  48896. */
  48897. isSupported(): boolean;
  48898. /**
  48899. * Sets the linear velocity of the physics body
  48900. * @param impostor imposter to set the velocity on
  48901. * @param velocity velocity to set
  48902. */
  48903. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48904. /**
  48905. * Sets the angular velocity of the physics body
  48906. * @param impostor imposter to set the velocity on
  48907. * @param velocity velocity to set
  48908. */
  48909. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48910. /**
  48911. * gets the linear velocity
  48912. * @param impostor imposter to get linear velocity from
  48913. * @returns linear velocity
  48914. */
  48915. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48916. /**
  48917. * gets the angular velocity
  48918. * @param impostor imposter to get angular velocity from
  48919. * @returns angular velocity
  48920. */
  48921. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48922. /**
  48923. * Sets the mass of physics body
  48924. * @param impostor imposter to set the mass on
  48925. * @param mass mass to set
  48926. */
  48927. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48928. /**
  48929. * Gets the mass of the physics body
  48930. * @param impostor imposter to get the mass from
  48931. * @returns mass
  48932. */
  48933. getBodyMass(impostor: PhysicsImpostor): number;
  48934. /**
  48935. * Gets friction of the impostor
  48936. * @param impostor impostor to get friction from
  48937. * @returns friction value
  48938. */
  48939. getBodyFriction(impostor: PhysicsImpostor): number;
  48940. /**
  48941. * Sets friction of the impostor
  48942. * @param impostor impostor to set friction on
  48943. * @param friction friction value
  48944. */
  48945. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48946. /**
  48947. * Gets restitution of the impostor
  48948. * @param impostor impostor to get restitution from
  48949. * @returns restitution value
  48950. */
  48951. getBodyRestitution(impostor: PhysicsImpostor): number;
  48952. /**
  48953. * Sets resitution of the impostor
  48954. * @param impostor impostor to set resitution on
  48955. * @param restitution resitution value
  48956. */
  48957. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48958. /**
  48959. * Gets pressure inside the impostor
  48960. * @param impostor impostor to get pressure from
  48961. * @returns pressure value
  48962. */
  48963. getBodyPressure(impostor: PhysicsImpostor): number;
  48964. /**
  48965. * Sets pressure inside a soft body impostor
  48966. * Cloth and rope must remain 0 pressure
  48967. * @param impostor impostor to set pressure on
  48968. * @param pressure pressure value
  48969. */
  48970. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48971. /**
  48972. * Gets stiffness of the impostor
  48973. * @param impostor impostor to get stiffness from
  48974. * @returns pressure value
  48975. */
  48976. getBodyStiffness(impostor: PhysicsImpostor): number;
  48977. /**
  48978. * Sets stiffness of the impostor
  48979. * @param impostor impostor to set stiffness on
  48980. * @param stiffness stiffness value from 0 to 1
  48981. */
  48982. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48983. /**
  48984. * Gets velocityIterations of the impostor
  48985. * @param impostor impostor to get velocity iterations from
  48986. * @returns velocityIterations value
  48987. */
  48988. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48989. /**
  48990. * Sets velocityIterations of the impostor
  48991. * @param impostor impostor to set velocity iterations on
  48992. * @param velocityIterations velocityIterations value
  48993. */
  48994. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48995. /**
  48996. * Gets positionIterations of the impostor
  48997. * @param impostor impostor to get position iterations from
  48998. * @returns positionIterations value
  48999. */
  49000. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49001. /**
  49002. * Sets positionIterations of the impostor
  49003. * @param impostor impostor to set position on
  49004. * @param positionIterations positionIterations value
  49005. */
  49006. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49007. /**
  49008. * Append an anchor to a cloth object
  49009. * @param impostor is the cloth impostor to add anchor to
  49010. * @param otherImpostor is the rigid impostor to anchor to
  49011. * @param width ratio across width from 0 to 1
  49012. * @param height ratio up height from 0 to 1
  49013. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49014. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49015. */
  49016. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49017. /**
  49018. * Append an hook to a rope object
  49019. * @param impostor is the rope impostor to add hook to
  49020. * @param otherImpostor is the rigid impostor to hook to
  49021. * @param length ratio along the rope from 0 to 1
  49022. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49023. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49024. */
  49025. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49026. /**
  49027. * Sleeps the physics body and stops it from being active
  49028. * @param impostor impostor to sleep
  49029. */
  49030. sleepBody(impostor: PhysicsImpostor): void;
  49031. /**
  49032. * Activates the physics body
  49033. * @param impostor impostor to activate
  49034. */
  49035. wakeUpBody(impostor: PhysicsImpostor): void;
  49036. /**
  49037. * Updates the distance parameters of the joint
  49038. * @param joint joint to update
  49039. * @param maxDistance maximum distance of the joint
  49040. * @param minDistance minimum distance of the joint
  49041. */
  49042. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49043. /**
  49044. * Sets a motor on the joint
  49045. * @param joint joint to set motor on
  49046. * @param speed speed of the motor
  49047. * @param maxForce maximum force of the motor
  49048. * @param motorIndex index of the motor
  49049. */
  49050. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49051. /**
  49052. * Sets the motors limit
  49053. * @param joint joint to set limit on
  49054. * @param upperLimit upper limit
  49055. * @param lowerLimit lower limit
  49056. */
  49057. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49058. /**
  49059. * Syncs the position and rotation of a mesh with the impostor
  49060. * @param mesh mesh to sync
  49061. * @param impostor impostor to update the mesh with
  49062. */
  49063. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49064. /**
  49065. * Gets the radius of the impostor
  49066. * @param impostor impostor to get radius from
  49067. * @returns the radius
  49068. */
  49069. getRadius(impostor: PhysicsImpostor): number;
  49070. /**
  49071. * Gets the box size of the impostor
  49072. * @param impostor impostor to get box size from
  49073. * @param result the resulting box size
  49074. */
  49075. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49076. /**
  49077. * Disposes of the impostor
  49078. */
  49079. dispose(): void;
  49080. /**
  49081. * Does a raycast in the physics world
  49082. * @param from when should the ray start?
  49083. * @param to when should the ray end?
  49084. * @returns PhysicsRaycastResult
  49085. */
  49086. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49087. }
  49088. }
  49089. declare module BABYLON {
  49090. interface AbstractScene {
  49091. /**
  49092. * The list of reflection probes added to the scene
  49093. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49094. */
  49095. reflectionProbes: Array<ReflectionProbe>;
  49096. /**
  49097. * Removes the given reflection probe from this scene.
  49098. * @param toRemove The reflection probe to remove
  49099. * @returns The index of the removed reflection probe
  49100. */
  49101. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49102. /**
  49103. * Adds the given reflection probe to this scene.
  49104. * @param newReflectionProbe The reflection probe to add
  49105. */
  49106. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49107. }
  49108. /**
  49109. * Class used to generate realtime reflection / refraction cube textures
  49110. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49111. */
  49112. export class ReflectionProbe {
  49113. /** defines the name of the probe */
  49114. name: string;
  49115. private _scene;
  49116. private _renderTargetTexture;
  49117. private _projectionMatrix;
  49118. private _viewMatrix;
  49119. private _target;
  49120. private _add;
  49121. private _attachedMesh;
  49122. private _invertYAxis;
  49123. /** Gets or sets probe position (center of the cube map) */
  49124. position: Vector3;
  49125. /**
  49126. * Creates a new reflection probe
  49127. * @param name defines the name of the probe
  49128. * @param size defines the texture resolution (for each face)
  49129. * @param scene defines the hosting scene
  49130. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49131. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49132. */
  49133. constructor(
  49134. /** defines the name of the probe */
  49135. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49136. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49137. samples: number;
  49138. /** Gets or sets the refresh rate to use (on every frame by default) */
  49139. refreshRate: number;
  49140. /**
  49141. * Gets the hosting scene
  49142. * @returns a Scene
  49143. */
  49144. getScene(): Scene;
  49145. /** Gets the internal CubeTexture used to render to */
  49146. readonly cubeTexture: RenderTargetTexture;
  49147. /** Gets the list of meshes to render */
  49148. readonly renderList: Nullable<AbstractMesh[]>;
  49149. /**
  49150. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49151. * @param mesh defines the mesh to attach to
  49152. */
  49153. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49154. /**
  49155. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49156. * @param renderingGroupId The rendering group id corresponding to its index
  49157. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49158. */
  49159. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49160. /**
  49161. * Clean all associated resources
  49162. */
  49163. dispose(): void;
  49164. /**
  49165. * Converts the reflection probe information to a readable string for debug purpose.
  49166. * @param fullDetails Supports for multiple levels of logging within scene loading
  49167. * @returns the human readable reflection probe info
  49168. */
  49169. toString(fullDetails?: boolean): string;
  49170. /**
  49171. * Get the class name of the relfection probe.
  49172. * @returns "ReflectionProbe"
  49173. */
  49174. getClassName(): string;
  49175. /**
  49176. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49177. * @returns The JSON representation of the texture
  49178. */
  49179. serialize(): any;
  49180. /**
  49181. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49182. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49183. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49184. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49185. * @returns The parsed reflection probe if successful
  49186. */
  49187. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49188. }
  49189. }
  49190. declare module BABYLON {
  49191. /** @hidden */
  49192. export var _BabylonLoaderRegistered: boolean;
  49193. }
  49194. declare module BABYLON {
  49195. /**
  49196. * The Physically based simple base material of BJS.
  49197. *
  49198. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49199. * It is used as the base class for both the specGloss and metalRough conventions.
  49200. */
  49201. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49202. /**
  49203. * Number of Simultaneous lights allowed on the material.
  49204. */
  49205. maxSimultaneousLights: number;
  49206. /**
  49207. * If sets to true, disables all the lights affecting the material.
  49208. */
  49209. disableLighting: boolean;
  49210. /**
  49211. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49212. */
  49213. environmentTexture: BaseTexture;
  49214. /**
  49215. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49216. */
  49217. invertNormalMapX: boolean;
  49218. /**
  49219. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49220. */
  49221. invertNormalMapY: boolean;
  49222. /**
  49223. * Normal map used in the model.
  49224. */
  49225. normalTexture: BaseTexture;
  49226. /**
  49227. * Emissivie color used to self-illuminate the model.
  49228. */
  49229. emissiveColor: Color3;
  49230. /**
  49231. * Emissivie texture used to self-illuminate the model.
  49232. */
  49233. emissiveTexture: BaseTexture;
  49234. /**
  49235. * Occlusion Channel Strenght.
  49236. */
  49237. occlusionStrength: number;
  49238. /**
  49239. * Occlusion Texture of the material (adding extra occlusion effects).
  49240. */
  49241. occlusionTexture: BaseTexture;
  49242. /**
  49243. * Defines the alpha limits in alpha test mode.
  49244. */
  49245. alphaCutOff: number;
  49246. /**
  49247. * Gets the current double sided mode.
  49248. */
  49249. /**
  49250. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49251. */
  49252. doubleSided: boolean;
  49253. /**
  49254. * Stores the pre-calculated light information of a mesh in a texture.
  49255. */
  49256. lightmapTexture: BaseTexture;
  49257. /**
  49258. * If true, the light map contains occlusion information instead of lighting info.
  49259. */
  49260. useLightmapAsShadowmap: boolean;
  49261. /**
  49262. * Instantiates a new PBRMaterial instance.
  49263. *
  49264. * @param name The material name
  49265. * @param scene The scene the material will be use in.
  49266. */
  49267. constructor(name: string, scene: Scene);
  49268. getClassName(): string;
  49269. }
  49270. }
  49271. declare module BABYLON {
  49272. /**
  49273. * The PBR material of BJS following the metal roughness convention.
  49274. *
  49275. * This fits to the PBR convention in the GLTF definition:
  49276. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  49277. */
  49278. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  49279. /**
  49280. * The base color has two different interpretations depending on the value of metalness.
  49281. * When the material is a metal, the base color is the specific measured reflectance value
  49282. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  49283. * of the material.
  49284. */
  49285. baseColor: Color3;
  49286. /**
  49287. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  49288. * well as opacity information in the alpha channel.
  49289. */
  49290. baseTexture: BaseTexture;
  49291. /**
  49292. * Specifies the metallic scalar value of the material.
  49293. * Can also be used to scale the metalness values of the metallic texture.
  49294. */
  49295. metallic: number;
  49296. /**
  49297. * Specifies the roughness scalar value of the material.
  49298. * Can also be used to scale the roughness values of the metallic texture.
  49299. */
  49300. roughness: number;
  49301. /**
  49302. * Texture containing both the metallic value in the B channel and the
  49303. * roughness value in the G channel to keep better precision.
  49304. */
  49305. metallicRoughnessTexture: BaseTexture;
  49306. /**
  49307. * Instantiates a new PBRMetalRoughnessMaterial instance.
  49308. *
  49309. * @param name The material name
  49310. * @param scene The scene the material will be use in.
  49311. */
  49312. constructor(name: string, scene: Scene);
  49313. /**
  49314. * Return the currrent class name of the material.
  49315. */
  49316. getClassName(): string;
  49317. /**
  49318. * Makes a duplicate of the current material.
  49319. * @param name - name to use for the new material.
  49320. */
  49321. clone(name: string): PBRMetallicRoughnessMaterial;
  49322. /**
  49323. * Serialize the material to a parsable JSON object.
  49324. */
  49325. serialize(): any;
  49326. /**
  49327. * Parses a JSON object correponding to the serialize function.
  49328. */
  49329. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  49330. }
  49331. }
  49332. declare module BABYLON {
  49333. /**
  49334. * The PBR material of BJS following the specular glossiness convention.
  49335. *
  49336. * This fits to the PBR convention in the GLTF definition:
  49337. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  49338. */
  49339. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  49340. /**
  49341. * Specifies the diffuse color of the material.
  49342. */
  49343. diffuseColor: Color3;
  49344. /**
  49345. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  49346. * channel.
  49347. */
  49348. diffuseTexture: BaseTexture;
  49349. /**
  49350. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  49351. */
  49352. specularColor: Color3;
  49353. /**
  49354. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  49355. */
  49356. glossiness: number;
  49357. /**
  49358. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  49359. */
  49360. specularGlossinessTexture: BaseTexture;
  49361. /**
  49362. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  49363. *
  49364. * @param name The material name
  49365. * @param scene The scene the material will be use in.
  49366. */
  49367. constructor(name: string, scene: Scene);
  49368. /**
  49369. * Return the currrent class name of the material.
  49370. */
  49371. getClassName(): string;
  49372. /**
  49373. * Makes a duplicate of the current material.
  49374. * @param name - name to use for the new material.
  49375. */
  49376. clone(name: string): PBRSpecularGlossinessMaterial;
  49377. /**
  49378. * Serialize the material to a parsable JSON object.
  49379. */
  49380. serialize(): any;
  49381. /**
  49382. * Parses a JSON object correponding to the serialize function.
  49383. */
  49384. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  49385. }
  49386. }
  49387. declare module BABYLON {
  49388. /**
  49389. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  49390. * It can help converting any input color in a desired output one. This can then be used to create effects
  49391. * from sepia, black and white to sixties or futuristic rendering...
  49392. *
  49393. * The only supported format is currently 3dl.
  49394. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  49395. */
  49396. export class ColorGradingTexture extends BaseTexture {
  49397. /**
  49398. * The current texture matrix. (will always be identity in color grading texture)
  49399. */
  49400. private _textureMatrix;
  49401. /**
  49402. * The texture URL.
  49403. */
  49404. url: string;
  49405. /**
  49406. * Empty line regex stored for GC.
  49407. */
  49408. private static _noneEmptyLineRegex;
  49409. private _engine;
  49410. /**
  49411. * Instantiates a ColorGradingTexture from the following parameters.
  49412. *
  49413. * @param url The location of the color gradind data (currently only supporting 3dl)
  49414. * @param scene The scene the texture will be used in
  49415. */
  49416. constructor(url: string, scene: Scene);
  49417. /**
  49418. * Returns the texture matrix used in most of the material.
  49419. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  49420. */
  49421. getTextureMatrix(): Matrix;
  49422. /**
  49423. * Occurs when the file being loaded is a .3dl LUT file.
  49424. */
  49425. private load3dlTexture;
  49426. /**
  49427. * Starts the loading process of the texture.
  49428. */
  49429. private loadTexture;
  49430. /**
  49431. * Clones the color gradind texture.
  49432. */
  49433. clone(): ColorGradingTexture;
  49434. /**
  49435. * Called during delayed load for textures.
  49436. */
  49437. delayLoad(): void;
  49438. /**
  49439. * Parses a color grading texture serialized by Babylon.
  49440. * @param parsedTexture The texture information being parsedTexture
  49441. * @param scene The scene to load the texture in
  49442. * @param rootUrl The root url of the data assets to load
  49443. * @return A color gradind texture
  49444. */
  49445. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  49446. /**
  49447. * Serializes the LUT texture to json format.
  49448. */
  49449. serialize(): any;
  49450. }
  49451. }
  49452. declare module BABYLON {
  49453. /**
  49454. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  49455. */
  49456. export class EquiRectangularCubeTexture extends BaseTexture {
  49457. /** The six faces of the cube. */
  49458. private static _FacesMapping;
  49459. private _noMipmap;
  49460. private _onLoad;
  49461. private _onError;
  49462. /** The size of the cubemap. */
  49463. private _size;
  49464. /** The buffer of the image. */
  49465. private _buffer;
  49466. /** The width of the input image. */
  49467. private _width;
  49468. /** The height of the input image. */
  49469. private _height;
  49470. /** The URL to the image. */
  49471. url: string;
  49472. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  49473. coordinatesMode: number;
  49474. /**
  49475. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  49476. * @param url The location of the image
  49477. * @param scene The scene the texture will be used in
  49478. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49479. * @param noMipmap Forces to not generate the mipmap if true
  49480. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  49481. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  49482. * @param onLoad — defines a callback called when texture is loaded
  49483. * @param onError — defines a callback called if there is an error
  49484. */
  49485. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  49486. /**
  49487. * Load the image data, by putting the image on a canvas and extracting its buffer.
  49488. */
  49489. private loadImage;
  49490. /**
  49491. * Convert the image buffer into a cubemap and create a CubeTexture.
  49492. */
  49493. private loadTexture;
  49494. /**
  49495. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  49496. * @param buffer The ArrayBuffer that should be converted.
  49497. * @returns The buffer as Float32Array.
  49498. */
  49499. private getFloat32ArrayFromArrayBuffer;
  49500. /**
  49501. * Get the current class name of the texture useful for serialization or dynamic coding.
  49502. * @returns "EquiRectangularCubeTexture"
  49503. */
  49504. getClassName(): string;
  49505. /**
  49506. * Create a clone of the current EquiRectangularCubeTexture and return it.
  49507. * @returns A clone of the current EquiRectangularCubeTexture.
  49508. */
  49509. clone(): EquiRectangularCubeTexture;
  49510. }
  49511. }
  49512. declare module BABYLON {
  49513. /**
  49514. * Based on jsTGALoader - Javascript loader for TGA file
  49515. * By Vincent Thibault
  49516. * @see http://blog.robrowser.com/javascript-tga-loader.html
  49517. */
  49518. export class TGATools {
  49519. private static _TYPE_INDEXED;
  49520. private static _TYPE_RGB;
  49521. private static _TYPE_GREY;
  49522. private static _TYPE_RLE_INDEXED;
  49523. private static _TYPE_RLE_RGB;
  49524. private static _TYPE_RLE_GREY;
  49525. private static _ORIGIN_MASK;
  49526. private static _ORIGIN_SHIFT;
  49527. private static _ORIGIN_BL;
  49528. private static _ORIGIN_BR;
  49529. private static _ORIGIN_UL;
  49530. private static _ORIGIN_UR;
  49531. /**
  49532. * Gets the header of a TGA file
  49533. * @param data defines the TGA data
  49534. * @returns the header
  49535. */
  49536. static GetTGAHeader(data: Uint8Array): any;
  49537. /**
  49538. * Uploads TGA content to a Babylon Texture
  49539. * @hidden
  49540. */
  49541. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  49542. /** @hidden */
  49543. 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;
  49544. /** @hidden */
  49545. 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;
  49546. /** @hidden */
  49547. 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;
  49548. /** @hidden */
  49549. 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;
  49550. /** @hidden */
  49551. 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;
  49552. /** @hidden */
  49553. 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;
  49554. }
  49555. }
  49556. declare module BABYLON {
  49557. /**
  49558. * Implementation of the TGA Texture Loader.
  49559. * @hidden
  49560. */
  49561. export class _TGATextureLoader implements IInternalTextureLoader {
  49562. /**
  49563. * Defines wether the loader supports cascade loading the different faces.
  49564. */
  49565. readonly supportCascades: boolean;
  49566. /**
  49567. * This returns if the loader support the current file information.
  49568. * @param extension defines the file extension of the file being loaded
  49569. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49570. * @param fallback defines the fallback internal texture if any
  49571. * @param isBase64 defines whether the texture is encoded as a base64
  49572. * @param isBuffer defines whether the texture data are stored as a buffer
  49573. * @returns true if the loader can load the specified file
  49574. */
  49575. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49576. /**
  49577. * Transform the url before loading if required.
  49578. * @param rootUrl the url of the texture
  49579. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49580. * @returns the transformed texture
  49581. */
  49582. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49583. /**
  49584. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49585. * @param rootUrl the url of the texture
  49586. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49587. * @returns the fallback texture
  49588. */
  49589. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49590. /**
  49591. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49592. * @param data contains the texture data
  49593. * @param texture defines the BabylonJS internal texture
  49594. * @param createPolynomials will be true if polynomials have been requested
  49595. * @param onLoad defines the callback to trigger once the texture is ready
  49596. * @param onError defines the callback to trigger in case of error
  49597. */
  49598. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49599. /**
  49600. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49601. * @param data contains the texture data
  49602. * @param texture defines the BabylonJS internal texture
  49603. * @param callback defines the method to call once ready to upload
  49604. */
  49605. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49606. }
  49607. }
  49608. declare module BABYLON {
  49609. /**
  49610. * 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.
  49611. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49612. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49613. */
  49614. export class CustomProceduralTexture extends ProceduralTexture {
  49615. private _animate;
  49616. private _time;
  49617. private _config;
  49618. private _texturePath;
  49619. /**
  49620. * Instantiates a new Custom Procedural Texture.
  49621. * 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.
  49622. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49623. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49624. * @param name Define the name of the texture
  49625. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49626. * @param size Define the size of the texture to create
  49627. * @param scene Define the scene the texture belongs to
  49628. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49629. * @param generateMipMaps Define if the texture should creates mip maps or not
  49630. */
  49631. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49632. private _loadJson;
  49633. /**
  49634. * Is the texture ready to be used ? (rendered at least once)
  49635. * @returns true if ready, otherwise, false.
  49636. */
  49637. isReady(): boolean;
  49638. /**
  49639. * Render the texture to its associated render target.
  49640. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49641. */
  49642. render(useCameraPostProcess?: boolean): void;
  49643. /**
  49644. * Update the list of dependant textures samplers in the shader.
  49645. */
  49646. updateTextures(): void;
  49647. /**
  49648. * Update the uniform values of the procedural texture in the shader.
  49649. */
  49650. updateShaderUniforms(): void;
  49651. /**
  49652. * Define if the texture animates or not.
  49653. */
  49654. animate: boolean;
  49655. }
  49656. }
  49657. declare module BABYLON {
  49658. /** @hidden */
  49659. export var noisePixelShader: {
  49660. name: string;
  49661. shader: string;
  49662. };
  49663. }
  49664. declare module BABYLON {
  49665. /**
  49666. * Class used to generate noise procedural textures
  49667. */
  49668. export class NoiseProceduralTexture extends ProceduralTexture {
  49669. private _time;
  49670. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49671. brightness: number;
  49672. /** Defines the number of octaves to process */
  49673. octaves: number;
  49674. /** Defines the level of persistence (0.8 by default) */
  49675. persistence: number;
  49676. /** Gets or sets animation speed factor (default is 1) */
  49677. animationSpeedFactor: number;
  49678. /**
  49679. * Creates a new NoiseProceduralTexture
  49680. * @param name defines the name fo the texture
  49681. * @param size defines the size of the texture (default is 256)
  49682. * @param scene defines the hosting scene
  49683. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49684. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49685. */
  49686. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49687. private _updateShaderUniforms;
  49688. protected _getDefines(): string;
  49689. /** Generate the current state of the procedural texture */
  49690. render(useCameraPostProcess?: boolean): void;
  49691. /**
  49692. * Serializes this noise procedural texture
  49693. * @returns a serialized noise procedural texture object
  49694. */
  49695. serialize(): any;
  49696. /**
  49697. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49698. * @param parsedTexture defines parsed texture data
  49699. * @param scene defines the current scene
  49700. * @param rootUrl defines the root URL containing noise procedural texture information
  49701. * @returns a parsed NoiseProceduralTexture
  49702. */
  49703. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49704. }
  49705. }
  49706. declare module BABYLON {
  49707. /**
  49708. * Raw cube texture where the raw buffers are passed in
  49709. */
  49710. export class RawCubeTexture extends CubeTexture {
  49711. /**
  49712. * Creates a cube texture where the raw buffers are passed in.
  49713. * @param scene defines the scene the texture is attached to
  49714. * @param data defines the array of data to use to create each face
  49715. * @param size defines the size of the textures
  49716. * @param format defines the format of the data
  49717. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49718. * @param generateMipMaps defines if the engine should generate the mip levels
  49719. * @param invertY defines if data must be stored with Y axis inverted
  49720. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49721. * @param compression defines the compression used (null by default)
  49722. */
  49723. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49724. /**
  49725. * Updates the raw cube texture.
  49726. * @param data defines the data to store
  49727. * @param format defines the data format
  49728. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49729. * @param invertY defines if data must be stored with Y axis inverted
  49730. * @param compression defines the compression used (null by default)
  49731. * @param level defines which level of the texture to update
  49732. */
  49733. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49734. /**
  49735. * Updates a raw cube texture with RGBD encoded data.
  49736. * @param data defines the array of data [mipmap][face] to use to create each face
  49737. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49740. * @returns a promsie that resolves when the operation is complete
  49741. */
  49742. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49743. /**
  49744. * Clones the raw cube texture.
  49745. * @return a new cube texture
  49746. */
  49747. clone(): CubeTexture;
  49748. /** @hidden */
  49749. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49750. }
  49751. }
  49752. declare module BABYLON {
  49753. /**
  49754. * Class used to store 3D textures containing user data
  49755. */
  49756. export class RawTexture3D extends Texture {
  49757. /** Gets or sets the texture format to use */
  49758. format: number;
  49759. private _engine;
  49760. /**
  49761. * Create a new RawTexture3D
  49762. * @param data defines the data of the texture
  49763. * @param width defines the width of the texture
  49764. * @param height defines the height of the texture
  49765. * @param depth defines the depth of the texture
  49766. * @param format defines the texture format to use
  49767. * @param scene defines the hosting scene
  49768. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49769. * @param invertY defines if texture must be stored with Y axis inverted
  49770. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49771. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49772. */
  49773. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49774. /** Gets or sets the texture format to use */
  49775. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49776. /**
  49777. * Update the texture with new data
  49778. * @param data defines the data to store in the texture
  49779. */
  49780. update(data: ArrayBufferView): void;
  49781. }
  49782. }
  49783. declare module BABYLON {
  49784. /**
  49785. * Creates a refraction texture used by refraction channel of the standard material.
  49786. * It is like a mirror but to see through a material.
  49787. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49788. */
  49789. export class RefractionTexture extends RenderTargetTexture {
  49790. /**
  49791. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49792. * It is possible to directly set the refractionPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  49793. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49794. */
  49795. refractionPlane: Plane;
  49796. /**
  49797. * Define how deep under the surface we should see.
  49798. */
  49799. depth: number;
  49800. /**
  49801. * Creates a refraction texture used by refraction channel of the standard material.
  49802. * It is like a mirror but to see through a material.
  49803. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49804. * @param name Define the texture name
  49805. * @param size Define the size of the underlying texture
  49806. * @param scene Define the scene the refraction belongs to
  49807. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49808. */
  49809. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49810. /**
  49811. * Clone the refraction texture.
  49812. * @returns the cloned texture
  49813. */
  49814. clone(): RefractionTexture;
  49815. /**
  49816. * Serialize the texture to a JSON representation you could use in Parse later on
  49817. * @returns the serialized JSON representation
  49818. */
  49819. serialize(): any;
  49820. }
  49821. }
  49822. declare module BABYLON {
  49823. /**
  49824. * Defines the options related to the creation of an HtmlElementTexture
  49825. */
  49826. export interface IHtmlElementTextureOptions {
  49827. /**
  49828. * Defines wether mip maps should be created or not.
  49829. */
  49830. generateMipMaps?: boolean;
  49831. /**
  49832. * Defines the sampling mode of the texture.
  49833. */
  49834. samplingMode?: number;
  49835. /**
  49836. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49837. */
  49838. engine: Nullable<Engine>;
  49839. /**
  49840. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49841. */
  49842. scene: Nullable<Scene>;
  49843. }
  49844. /**
  49845. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49846. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49847. * is automatically managed.
  49848. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49849. * in your application.
  49850. *
  49851. * As the update is not automatic, you need to call them manually.
  49852. */
  49853. export class HtmlElementTexture extends BaseTexture {
  49854. /**
  49855. * The texture URL.
  49856. */
  49857. element: HTMLVideoElement | HTMLCanvasElement;
  49858. private static readonly DefaultOptions;
  49859. private _textureMatrix;
  49860. private _engine;
  49861. private _isVideo;
  49862. private _generateMipMaps;
  49863. private _samplingMode;
  49864. /**
  49865. * Instantiates a HtmlElementTexture from the following parameters.
  49866. *
  49867. * @param name Defines the name of the texture
  49868. * @param element Defines the video or canvas the texture is filled with
  49869. * @param options Defines the other none mandatory texture creation options
  49870. */
  49871. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49872. private _createInternalTexture;
  49873. /**
  49874. * Returns the texture matrix used in most of the material.
  49875. */
  49876. getTextureMatrix(): Matrix;
  49877. /**
  49878. * Updates the content of the texture.
  49879. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49880. */
  49881. update(invertY?: Nullable<boolean>): void;
  49882. }
  49883. }
  49884. declare module BABYLON {
  49885. /**
  49886. * Helper class to push actions to a pool of workers.
  49887. */
  49888. export class WorkerPool implements IDisposable {
  49889. private _workerInfos;
  49890. private _pendingActions;
  49891. /**
  49892. * Constructor
  49893. * @param workers Array of workers to use for actions
  49894. */
  49895. constructor(workers: Array<Worker>);
  49896. /**
  49897. * Terminates all workers and clears any pending actions.
  49898. */
  49899. dispose(): void;
  49900. /**
  49901. * Pushes an action to the worker pool. If all the workers are active, the action will be
  49902. * pended until a worker has completed its action.
  49903. * @param action The action to perform. Call onComplete when the action is complete.
  49904. */
  49905. push(action: (worker: Worker, onComplete: () => void) => void): void;
  49906. private _execute;
  49907. }
  49908. }
  49909. declare module BABYLON {
  49910. /**
  49911. * Configuration for Draco compression
  49912. */
  49913. export interface IDracoCompressionConfiguration {
  49914. /**
  49915. * Configuration for the decoder.
  49916. */
  49917. decoder: {
  49918. /**
  49919. * The url to the WebAssembly module.
  49920. */
  49921. wasmUrl?: string;
  49922. /**
  49923. * The url to the WebAssembly binary.
  49924. */
  49925. wasmBinaryUrl?: string;
  49926. /**
  49927. * The url to the fallback JavaScript module.
  49928. */
  49929. fallbackUrl?: string;
  49930. };
  49931. }
  49932. /**
  49933. * Draco compression (https://google.github.io/draco/)
  49934. *
  49935. * This class wraps the Draco module.
  49936. *
  49937. * **Encoder**
  49938. *
  49939. * The encoder is not currently implemented.
  49940. *
  49941. * **Decoder**
  49942. *
  49943. * 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.
  49944. *
  49945. * To update the configuration, use the following code:
  49946. * ```javascript
  49947. * DracoCompression.Configuration = {
  49948. * decoder: {
  49949. * wasmUrl: "<url to the WebAssembly library>",
  49950. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49951. * fallbackUrl: "<url to the fallback JavaScript library>",
  49952. * }
  49953. * };
  49954. * ```
  49955. *
  49956. * 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.
  49957. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49958. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49959. *
  49960. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49961. * ```javascript
  49962. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49963. * ```
  49964. *
  49965. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49966. */
  49967. export class DracoCompression implements IDisposable {
  49968. private _workerPoolPromise?;
  49969. private _decoderModulePromise?;
  49970. /**
  49971. * The configuration. Defaults to the following urls:
  49972. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49973. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49974. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49975. */
  49976. static Configuration: IDracoCompressionConfiguration;
  49977. /**
  49978. * Returns true if the decoder configuration is available.
  49979. */
  49980. static readonly DecoderAvailable: boolean;
  49981. /**
  49982. * Default number of workers to create when creating the draco compression object.
  49983. */
  49984. static DefaultNumWorkers: number;
  49985. private static GetDefaultNumWorkers;
  49986. private static _Default;
  49987. /**
  49988. * Default instance for the draco compression object.
  49989. */
  49990. static readonly Default: DracoCompression;
  49991. /**
  49992. * Constructor
  49993. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49994. */
  49995. constructor(numWorkers?: number);
  49996. /**
  49997. * Stop all async operations and release resources.
  49998. */
  49999. dispose(): void;
  50000. /**
  50001. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  50002. * @returns a promise that resolves when ready
  50003. */
  50004. whenReadyAsync(): Promise<void>;
  50005. /**
  50006. * Decode Draco compressed mesh data to vertex data.
  50007. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50008. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50009. * @returns A promise that resolves with the decoded vertex data
  50010. */
  50011. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  50012. [kind: string]: number;
  50013. }): Promise<VertexData>;
  50014. }
  50015. }
  50016. declare module BABYLON {
  50017. /**
  50018. * Class for building Constructive Solid Geometry
  50019. */
  50020. export class CSG {
  50021. private polygons;
  50022. /**
  50023. * The world matrix
  50024. */
  50025. matrix: Matrix;
  50026. /**
  50027. * Stores the position
  50028. */
  50029. position: Vector3;
  50030. /**
  50031. * Stores the rotation
  50032. */
  50033. rotation: Vector3;
  50034. /**
  50035. * Stores the rotation quaternion
  50036. */
  50037. rotationQuaternion: Nullable<Quaternion>;
  50038. /**
  50039. * Stores the scaling vector
  50040. */
  50041. scaling: Vector3;
  50042. /**
  50043. * Convert the Mesh to CSG
  50044. * @param mesh The Mesh to convert to CSG
  50045. * @returns A new CSG from the Mesh
  50046. */
  50047. static FromMesh(mesh: Mesh): CSG;
  50048. /**
  50049. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50050. * @param polygons Polygons used to construct a CSG solid
  50051. */
  50052. private static FromPolygons;
  50053. /**
  50054. * Clones, or makes a deep copy, of the CSG
  50055. * @returns A new CSG
  50056. */
  50057. clone(): CSG;
  50058. /**
  50059. * Unions this CSG with another CSG
  50060. * @param csg The CSG to union against this CSG
  50061. * @returns The unioned CSG
  50062. */
  50063. union(csg: CSG): CSG;
  50064. /**
  50065. * Unions this CSG with another CSG in place
  50066. * @param csg The CSG to union against this CSG
  50067. */
  50068. unionInPlace(csg: CSG): void;
  50069. /**
  50070. * Subtracts this CSG with another CSG
  50071. * @param csg The CSG to subtract against this CSG
  50072. * @returns A new CSG
  50073. */
  50074. subtract(csg: CSG): CSG;
  50075. /**
  50076. * Subtracts this CSG with another CSG in place
  50077. * @param csg The CSG to subtact against this CSG
  50078. */
  50079. subtractInPlace(csg: CSG): void;
  50080. /**
  50081. * Intersect this CSG with another CSG
  50082. * @param csg The CSG to intersect against this CSG
  50083. * @returns A new CSG
  50084. */
  50085. intersect(csg: CSG): CSG;
  50086. /**
  50087. * Intersects this CSG with another CSG in place
  50088. * @param csg The CSG to intersect against this CSG
  50089. */
  50090. intersectInPlace(csg: CSG): void;
  50091. /**
  50092. * Return a new CSG solid with solid and empty space switched. This solid is
  50093. * not modified.
  50094. * @returns A new CSG solid with solid and empty space switched
  50095. */
  50096. inverse(): CSG;
  50097. /**
  50098. * Inverses the CSG in place
  50099. */
  50100. inverseInPlace(): void;
  50101. /**
  50102. * This is used to keep meshes transformations so they can be restored
  50103. * when we build back a Babylon Mesh
  50104. * NB : All CSG operations are performed in world coordinates
  50105. * @param csg The CSG to copy the transform attributes from
  50106. * @returns This CSG
  50107. */
  50108. copyTransformAttributes(csg: CSG): CSG;
  50109. /**
  50110. * Build Raw mesh from CSG
  50111. * Coordinates here are in world space
  50112. * @param name The name of the mesh geometry
  50113. * @param scene The Scene
  50114. * @param keepSubMeshes Specifies if the submeshes should be kept
  50115. * @returns A new Mesh
  50116. */
  50117. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50118. /**
  50119. * Build Mesh from CSG taking material and transforms into account
  50120. * @param name The name of the Mesh
  50121. * @param material The material of the Mesh
  50122. * @param scene The Scene
  50123. * @param keepSubMeshes Specifies if submeshes should be kept
  50124. * @returns The new Mesh
  50125. */
  50126. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50127. }
  50128. }
  50129. declare module BABYLON {
  50130. /**
  50131. * Class used to create a trail following a mesh
  50132. */
  50133. export class TrailMesh extends Mesh {
  50134. private _generator;
  50135. private _autoStart;
  50136. private _running;
  50137. private _diameter;
  50138. private _length;
  50139. private _sectionPolygonPointsCount;
  50140. private _sectionVectors;
  50141. private _sectionNormalVectors;
  50142. private _beforeRenderObserver;
  50143. /**
  50144. * @constructor
  50145. * @param name The value used by scene.getMeshByName() to do a lookup.
  50146. * @param generator The mesh to generate a trail.
  50147. * @param scene The scene to add this mesh to.
  50148. * @param diameter Diameter of trailing mesh. Default is 1.
  50149. * @param length Length of trailing mesh. Default is 60.
  50150. * @param autoStart Automatically start trailing mesh. Default true.
  50151. */
  50152. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50153. /**
  50154. * "TrailMesh"
  50155. * @returns "TrailMesh"
  50156. */
  50157. getClassName(): string;
  50158. private _createMesh;
  50159. /**
  50160. * Start trailing mesh.
  50161. */
  50162. start(): void;
  50163. /**
  50164. * Stop trailing mesh.
  50165. */
  50166. stop(): void;
  50167. /**
  50168. * Update trailing mesh geometry.
  50169. */
  50170. update(): void;
  50171. /**
  50172. * Returns a new TrailMesh object.
  50173. * @param name is a string, the name given to the new mesh
  50174. * @param newGenerator use new generator object for cloned trail mesh
  50175. * @returns a new mesh
  50176. */
  50177. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50178. /**
  50179. * Serializes this trail mesh
  50180. * @param serializationObject object to write serialization to
  50181. */
  50182. serialize(serializationObject: any): void;
  50183. /**
  50184. * Parses a serialized trail mesh
  50185. * @param parsedMesh the serialized mesh
  50186. * @param scene the scene to create the trail mesh in
  50187. * @returns the created trail mesh
  50188. */
  50189. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50190. }
  50191. }
  50192. declare module BABYLON {
  50193. /**
  50194. * Class containing static functions to help procedurally build meshes
  50195. */
  50196. export class TiledBoxBuilder {
  50197. /**
  50198. * Creates a box mesh
  50199. * faceTiles sets the pattern, tile size and number of tiles for a face * * 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)
  50200. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50202. * * 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
  50203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50204. * @param name defines the name of the mesh
  50205. * @param options defines the options used to create the mesh
  50206. * @param scene defines the hosting scene
  50207. * @returns the box mesh
  50208. */
  50209. static CreateTiledBox(name: string, options: {
  50210. pattern?: number;
  50211. width?: number;
  50212. height?: number;
  50213. depth?: number;
  50214. tileSize?: number;
  50215. tileWidth?: number;
  50216. tileHeight?: number;
  50217. alignHorizontal?: number;
  50218. alignVertical?: number;
  50219. faceUV?: Vector4[];
  50220. faceColors?: Color4[];
  50221. sideOrientation?: number;
  50222. updatable?: boolean;
  50223. }, scene?: Nullable<Scene>): Mesh;
  50224. }
  50225. }
  50226. declare module BABYLON {
  50227. /**
  50228. * Class containing static functions to help procedurally build meshes
  50229. */
  50230. export class TorusKnotBuilder {
  50231. /**
  50232. * Creates a torus knot mesh
  50233. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50234. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50235. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50236. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50238. * * 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
  50239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50240. * @param name defines the name of the mesh
  50241. * @param options defines the options used to create the mesh
  50242. * @param scene defines the hosting scene
  50243. * @returns the torus knot mesh
  50244. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50245. */
  50246. static CreateTorusKnot(name: string, options: {
  50247. radius?: number;
  50248. tube?: number;
  50249. radialSegments?: number;
  50250. tubularSegments?: number;
  50251. p?: number;
  50252. q?: number;
  50253. updatable?: boolean;
  50254. sideOrientation?: number;
  50255. frontUVs?: Vector4;
  50256. backUVs?: Vector4;
  50257. }, scene: any): Mesh;
  50258. }
  50259. }
  50260. declare module BABYLON {
  50261. /**
  50262. * Polygon
  50263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50264. */
  50265. export class Polygon {
  50266. /**
  50267. * Creates a rectangle
  50268. * @param xmin bottom X coord
  50269. * @param ymin bottom Y coord
  50270. * @param xmax top X coord
  50271. * @param ymax top Y coord
  50272. * @returns points that make the resulting rectation
  50273. */
  50274. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50275. /**
  50276. * Creates a circle
  50277. * @param radius radius of circle
  50278. * @param cx scale in x
  50279. * @param cy scale in y
  50280. * @param numberOfSides number of sides that make up the circle
  50281. * @returns points that make the resulting circle
  50282. */
  50283. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50284. /**
  50285. * Creates a polygon from input string
  50286. * @param input Input polygon data
  50287. * @returns the parsed points
  50288. */
  50289. static Parse(input: string): Vector2[];
  50290. /**
  50291. * Starts building a polygon from x and y coordinates
  50292. * @param x x coordinate
  50293. * @param y y coordinate
  50294. * @returns the started path2
  50295. */
  50296. static StartingAt(x: number, y: number): Path2;
  50297. }
  50298. /**
  50299. * Builds a polygon
  50300. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50301. */
  50302. export class PolygonMeshBuilder {
  50303. private _points;
  50304. private _outlinepoints;
  50305. private _holes;
  50306. private _name;
  50307. private _scene;
  50308. private _epoints;
  50309. private _eholes;
  50310. private _addToepoint;
  50311. /**
  50312. * Babylon reference to the earcut plugin.
  50313. */
  50314. bjsEarcut: any;
  50315. /**
  50316. * Creates a PolygonMeshBuilder
  50317. * @param name name of the builder
  50318. * @param contours Path of the polygon
  50319. * @param scene scene to add to when creating the mesh
  50320. * @param earcutInjection can be used to inject your own earcut reference
  50321. */
  50322. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  50323. /**
  50324. * Adds a whole within the polygon
  50325. * @param hole Array of points defining the hole
  50326. * @returns this
  50327. */
  50328. addHole(hole: Vector2[]): PolygonMeshBuilder;
  50329. /**
  50330. * Creates the polygon
  50331. * @param updatable If the mesh should be updatable
  50332. * @param depth The depth of the mesh created
  50333. * @returns the created mesh
  50334. */
  50335. build(updatable?: boolean, depth?: number): Mesh;
  50336. /**
  50337. * Creates the polygon
  50338. * @param depth The depth of the mesh created
  50339. * @returns the created VertexData
  50340. */
  50341. buildVertexData(depth?: number): VertexData;
  50342. /**
  50343. * Adds a side to the polygon
  50344. * @param positions points that make the polygon
  50345. * @param normals normals of the polygon
  50346. * @param uvs uvs of the polygon
  50347. * @param indices indices of the polygon
  50348. * @param bounds bounds of the polygon
  50349. * @param points points of the polygon
  50350. * @param depth depth of the polygon
  50351. * @param flip flip of the polygon
  50352. */
  50353. private addSide;
  50354. }
  50355. }
  50356. declare module BABYLON {
  50357. /**
  50358. * Class containing static functions to help procedurally build meshes
  50359. */
  50360. export class PolygonBuilder {
  50361. /**
  50362. * Creates a polygon mesh
  50363. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50364. * * 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
  50365. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50367. * * 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)
  50368. * * Remember you can only change the shape positions, not their number when updating a polygon
  50369. * @param name defines the name of the mesh
  50370. * @param options defines the options used to create the mesh
  50371. * @param scene defines the hosting scene
  50372. * @param earcutInjection can be used to inject your own earcut reference
  50373. * @returns the polygon mesh
  50374. */
  50375. static CreatePolygon(name: string, options: {
  50376. shape: Vector3[];
  50377. holes?: Vector3[][];
  50378. depth?: number;
  50379. faceUV?: Vector4[];
  50380. faceColors?: Color4[];
  50381. updatable?: boolean;
  50382. sideOrientation?: number;
  50383. frontUVs?: Vector4;
  50384. backUVs?: Vector4;
  50385. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50386. /**
  50387. * Creates an extruded polygon mesh, with depth in the Y direction.
  50388. * * 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)
  50389. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50390. * @param name defines the name of the mesh
  50391. * @param options defines the options used to create the mesh
  50392. * @param scene defines the hosting scene
  50393. * @param earcutInjection can be used to inject your own earcut reference
  50394. * @returns the polygon mesh
  50395. */
  50396. static ExtrudePolygon(name: string, options: {
  50397. shape: Vector3[];
  50398. holes?: Vector3[][];
  50399. depth?: number;
  50400. faceUV?: Vector4[];
  50401. faceColors?: Color4[];
  50402. updatable?: boolean;
  50403. sideOrientation?: number;
  50404. frontUVs?: Vector4;
  50405. backUVs?: Vector4;
  50406. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50407. }
  50408. }
  50409. declare module BABYLON {
  50410. /**
  50411. * Class containing static functions to help procedurally build meshes
  50412. */
  50413. export class LatheBuilder {
  50414. /**
  50415. * Creates lathe mesh.
  50416. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  50417. * * 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
  50418. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  50419. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  50420. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  50421. * * 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
  50422. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  50423. * * 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
  50424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50425. * * 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
  50426. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50428. * @param name defines the name of the mesh
  50429. * @param options defines the options used to create the mesh
  50430. * @param scene defines the hosting scene
  50431. * @returns the lathe mesh
  50432. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  50433. */
  50434. static CreateLathe(name: string, options: {
  50435. shape: Vector3[];
  50436. radius?: number;
  50437. tessellation?: number;
  50438. clip?: number;
  50439. arc?: number;
  50440. closed?: boolean;
  50441. updatable?: boolean;
  50442. sideOrientation?: number;
  50443. frontUVs?: Vector4;
  50444. backUVs?: Vector4;
  50445. cap?: number;
  50446. invertUV?: boolean;
  50447. }, scene?: Nullable<Scene>): Mesh;
  50448. }
  50449. }
  50450. declare module BABYLON {
  50451. /**
  50452. * Class containing static functions to help procedurally build meshes
  50453. */
  50454. export class TiledPlaneBuilder {
  50455. /**
  50456. * Creates a tiled plane mesh
  50457. * * The parameter `pattern` will, depending on value, do nothing or
  50458. * * * flip (reflect about central vertical) alternate tiles across and up
  50459. * * * flip every tile on alternate rows
  50460. * * * rotate (180 degs) alternate tiles across and up
  50461. * * * rotate every tile on alternate rows
  50462. * * * flip and rotate alternate tiles across and up
  50463. * * * flip and rotate every tile on alternate rows
  50464. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  50465. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  50466. * * 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
  50467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50468. * * 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)
  50469. * * 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)
  50470. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50471. * @param name defines the name of the mesh
  50472. * @param options defines the options used to create the mesh
  50473. * @param scene defines the hosting scene
  50474. * @returns the box mesh
  50475. */
  50476. static CreateTiledPlane(name: string, options: {
  50477. pattern?: number;
  50478. tileSize?: number;
  50479. tileWidth?: number;
  50480. tileHeight?: number;
  50481. size?: number;
  50482. width?: number;
  50483. height?: number;
  50484. alignHorizontal?: number;
  50485. alignVertical?: number;
  50486. sideOrientation?: number;
  50487. frontUVs?: Vector4;
  50488. backUVs?: Vector4;
  50489. updatable?: boolean;
  50490. }, scene?: Nullable<Scene>): Mesh;
  50491. }
  50492. }
  50493. declare module BABYLON {
  50494. /**
  50495. * Class containing static functions to help procedurally build meshes
  50496. */
  50497. export class TubeBuilder {
  50498. /**
  50499. * Creates a tube mesh.
  50500. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50501. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50502. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50503. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50504. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50505. * * 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)
  50506. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50507. * * 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
  50508. * * 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
  50509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50510. * * 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
  50511. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50513. * @param name defines the name of the mesh
  50514. * @param options defines the options used to create the mesh
  50515. * @param scene defines the hosting scene
  50516. * @returns the tube mesh
  50517. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50518. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50519. */
  50520. static CreateTube(name: string, options: {
  50521. path: Vector3[];
  50522. radius?: number;
  50523. tessellation?: number;
  50524. radiusFunction?: {
  50525. (i: number, distance: number): number;
  50526. };
  50527. cap?: number;
  50528. arc?: number;
  50529. updatable?: boolean;
  50530. sideOrientation?: number;
  50531. frontUVs?: Vector4;
  50532. backUVs?: Vector4;
  50533. instance?: Mesh;
  50534. invertUV?: boolean;
  50535. }, scene?: Nullable<Scene>): Mesh;
  50536. }
  50537. }
  50538. declare module BABYLON {
  50539. /**
  50540. * Class containing static functions to help procedurally build meshes
  50541. */
  50542. export class IcoSphereBuilder {
  50543. /**
  50544. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50545. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50546. * * 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`)
  50547. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50548. * * 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
  50549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50550. * * 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
  50551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50552. * @param name defines the name of the mesh
  50553. * @param options defines the options used to create the mesh
  50554. * @param scene defines the hosting scene
  50555. * @returns the icosahedron mesh
  50556. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50557. */
  50558. static CreateIcoSphere(name: string, options: {
  50559. radius?: number;
  50560. radiusX?: number;
  50561. radiusY?: number;
  50562. radiusZ?: number;
  50563. flat?: boolean;
  50564. subdivisions?: number;
  50565. sideOrientation?: number;
  50566. frontUVs?: Vector4;
  50567. backUVs?: Vector4;
  50568. updatable?: boolean;
  50569. }, scene?: Nullable<Scene>): Mesh;
  50570. }
  50571. }
  50572. declare module BABYLON {
  50573. /**
  50574. * Class containing static functions to help procedurally build meshes
  50575. */
  50576. export class DecalBuilder {
  50577. /**
  50578. * Creates a decal mesh.
  50579. * 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
  50580. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50581. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50582. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50583. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50584. * @param name defines the name of the mesh
  50585. * @param sourceMesh defines the mesh where the decal must be applied
  50586. * @param options defines the options used to create the mesh
  50587. * @param scene defines the hosting scene
  50588. * @returns the decal mesh
  50589. * @see https://doc.babylonjs.com/how_to/decals
  50590. */
  50591. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50592. position?: Vector3;
  50593. normal?: Vector3;
  50594. size?: Vector3;
  50595. angle?: number;
  50596. }): Mesh;
  50597. }
  50598. }
  50599. declare module BABYLON {
  50600. /**
  50601. * Class containing static functions to help procedurally build meshes
  50602. */
  50603. export class MeshBuilder {
  50604. /**
  50605. * Creates a box mesh
  50606. * * The parameter `size` sets the size (float) of each box side (default 1)
  50607. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50608. * * 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)
  50609. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50610. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50611. * * 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
  50612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50613. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50614. * @param name defines the name of the mesh
  50615. * @param options defines the options used to create the mesh
  50616. * @param scene defines the hosting scene
  50617. * @returns the box mesh
  50618. */
  50619. static CreateBox(name: string, options: {
  50620. size?: number;
  50621. width?: number;
  50622. height?: number;
  50623. depth?: number;
  50624. faceUV?: Vector4[];
  50625. faceColors?: Color4[];
  50626. sideOrientation?: number;
  50627. frontUVs?: Vector4;
  50628. backUVs?: Vector4;
  50629. updatable?: boolean;
  50630. }, scene?: Nullable<Scene>): Mesh;
  50631. /**
  50632. * Creates a tiled box mesh
  50633. * * faceTiles sets the pattern, tile size and number of tiles for a face
  50634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50635. * @param name defines the name of the mesh
  50636. * @param options defines the options used to create the mesh
  50637. * @param scene defines the hosting scene
  50638. * @returns the tiled box mesh
  50639. */
  50640. static CreateTiledBox(name: string, options: {
  50641. pattern?: number;
  50642. size?: number;
  50643. width?: number;
  50644. height?: number;
  50645. depth: number;
  50646. tileSize?: number;
  50647. tileWidth?: number;
  50648. tileHeight?: number;
  50649. faceUV?: Vector4[];
  50650. faceColors?: Color4[];
  50651. alignHorizontal?: number;
  50652. alignVertical?: number;
  50653. sideOrientation?: number;
  50654. updatable?: boolean;
  50655. }, scene?: Nullable<Scene>): Mesh;
  50656. /**
  50657. * Creates a sphere mesh
  50658. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50659. * * 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`)
  50660. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50661. * * 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
  50662. * * 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)
  50663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50664. * * 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
  50665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50666. * @param name defines the name of the mesh
  50667. * @param options defines the options used to create the mesh
  50668. * @param scene defines the hosting scene
  50669. * @returns the sphere mesh
  50670. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50671. */
  50672. static CreateSphere(name: string, options: {
  50673. segments?: number;
  50674. diameter?: number;
  50675. diameterX?: number;
  50676. diameterY?: number;
  50677. diameterZ?: number;
  50678. arc?: number;
  50679. slice?: number;
  50680. sideOrientation?: number;
  50681. frontUVs?: Vector4;
  50682. backUVs?: Vector4;
  50683. updatable?: boolean;
  50684. }, scene?: Nullable<Scene>): Mesh;
  50685. /**
  50686. * Creates a plane polygonal mesh. By default, this is a disc
  50687. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  50688. * * 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
  50689. * * 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
  50690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50691. * * 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
  50692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50693. * @param name defines the name of the mesh
  50694. * @param options defines the options used to create the mesh
  50695. * @param scene defines the hosting scene
  50696. * @returns the plane polygonal mesh
  50697. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  50698. */
  50699. static CreateDisc(name: string, options: {
  50700. radius?: number;
  50701. tessellation?: number;
  50702. arc?: number;
  50703. updatable?: boolean;
  50704. sideOrientation?: number;
  50705. frontUVs?: Vector4;
  50706. backUVs?: Vector4;
  50707. }, scene?: Nullable<Scene>): Mesh;
  50708. /**
  50709. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  50710. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  50711. * * 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`)
  50712. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  50713. * * 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
  50714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50715. * * 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
  50716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50717. * @param name defines the name of the mesh
  50718. * @param options defines the options used to create the mesh
  50719. * @param scene defines the hosting scene
  50720. * @returns the icosahedron mesh
  50721. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  50722. */
  50723. static CreateIcoSphere(name: string, options: {
  50724. radius?: number;
  50725. radiusX?: number;
  50726. radiusY?: number;
  50727. radiusZ?: number;
  50728. flat?: boolean;
  50729. subdivisions?: number;
  50730. sideOrientation?: number;
  50731. frontUVs?: Vector4;
  50732. backUVs?: Vector4;
  50733. updatable?: boolean;
  50734. }, scene?: Nullable<Scene>): Mesh;
  50735. /**
  50736. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50737. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50738. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50739. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50740. * * 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
  50741. * * 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
  50742. * * 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
  50743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50744. * * 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
  50745. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50746. * * 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
  50747. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50748. * * 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
  50749. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50751. * @param name defines the name of the mesh
  50752. * @param options defines the options used to create the mesh
  50753. * @param scene defines the hosting scene
  50754. * @returns the ribbon mesh
  50755. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50756. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50757. */
  50758. static CreateRibbon(name: string, options: {
  50759. pathArray: Vector3[][];
  50760. closeArray?: boolean;
  50761. closePath?: boolean;
  50762. offset?: number;
  50763. updatable?: boolean;
  50764. sideOrientation?: number;
  50765. frontUVs?: Vector4;
  50766. backUVs?: Vector4;
  50767. instance?: Mesh;
  50768. invertUV?: boolean;
  50769. uvs?: Vector2[];
  50770. colors?: Color4[];
  50771. }, scene?: Nullable<Scene>): Mesh;
  50772. /**
  50773. * Creates a cylinder or a cone mesh
  50774. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50775. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50776. * * 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.
  50777. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50778. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50779. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50780. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50781. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50782. * * 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).
  50783. * * 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
  50784. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50785. * * 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
  50786. * * 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.
  50787. * * If `enclose` is false, a ring surface is one element.
  50788. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50789. * * 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
  50790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50791. * * 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
  50792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50793. * @param name defines the name of the mesh
  50794. * @param options defines the options used to create the mesh
  50795. * @param scene defines the hosting scene
  50796. * @returns the cylinder mesh
  50797. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50798. */
  50799. static CreateCylinder(name: string, options: {
  50800. height?: number;
  50801. diameterTop?: number;
  50802. diameterBottom?: number;
  50803. diameter?: number;
  50804. tessellation?: number;
  50805. subdivisions?: number;
  50806. arc?: number;
  50807. faceColors?: Color4[];
  50808. faceUV?: Vector4[];
  50809. updatable?: boolean;
  50810. hasRings?: boolean;
  50811. enclose?: boolean;
  50812. sideOrientation?: number;
  50813. frontUVs?: Vector4;
  50814. backUVs?: Vector4;
  50815. }, scene?: Nullable<Scene>): Mesh;
  50816. /**
  50817. * Creates a torus mesh
  50818. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50819. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50820. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50822. * * 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
  50823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50824. * @param name defines the name of the mesh
  50825. * @param options defines the options used to create the mesh
  50826. * @param scene defines the hosting scene
  50827. * @returns the torus mesh
  50828. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50829. */
  50830. static CreateTorus(name: string, options: {
  50831. diameter?: number;
  50832. thickness?: number;
  50833. tessellation?: number;
  50834. updatable?: boolean;
  50835. sideOrientation?: number;
  50836. frontUVs?: Vector4;
  50837. backUVs?: Vector4;
  50838. }, scene?: Nullable<Scene>): Mesh;
  50839. /**
  50840. * Creates a torus knot mesh
  50841. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50842. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50843. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50844. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50845. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50846. * * 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
  50847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50848. * @param name defines the name of the mesh
  50849. * @param options defines the options used to create the mesh
  50850. * @param scene defines the hosting scene
  50851. * @returns the torus knot mesh
  50852. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50853. */
  50854. static CreateTorusKnot(name: string, options: {
  50855. radius?: number;
  50856. tube?: number;
  50857. radialSegments?: number;
  50858. tubularSegments?: number;
  50859. p?: number;
  50860. q?: number;
  50861. updatable?: boolean;
  50862. sideOrientation?: number;
  50863. frontUVs?: Vector4;
  50864. backUVs?: Vector4;
  50865. }, scene?: Nullable<Scene>): Mesh;
  50866. /**
  50867. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50868. * * 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
  50869. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50870. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50871. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50872. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50873. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50874. * * 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
  50875. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50876. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50878. * @param name defines the name of the new line system
  50879. * @param options defines the options used to create the line system
  50880. * @param scene defines the hosting scene
  50881. * @returns a new line system mesh
  50882. */
  50883. static CreateLineSystem(name: string, options: {
  50884. lines: Vector3[][];
  50885. updatable?: boolean;
  50886. instance?: Nullable<LinesMesh>;
  50887. colors?: Nullable<Color4[][]>;
  50888. useVertexAlpha?: boolean;
  50889. }, scene: Nullable<Scene>): LinesMesh;
  50890. /**
  50891. * Creates a line mesh
  50892. * 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
  50893. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50894. * * The parameter `points` is an array successive Vector3
  50895. * * 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
  50896. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50897. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50898. * * When updating an instance, remember that only point positions can change, not the number of points
  50899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50901. * @param name defines the name of the new line system
  50902. * @param options defines the options used to create the line system
  50903. * @param scene defines the hosting scene
  50904. * @returns a new line mesh
  50905. */
  50906. static CreateLines(name: string, options: {
  50907. points: Vector3[];
  50908. updatable?: boolean;
  50909. instance?: Nullable<LinesMesh>;
  50910. colors?: Color4[];
  50911. useVertexAlpha?: boolean;
  50912. }, scene?: Nullable<Scene>): LinesMesh;
  50913. /**
  50914. * Creates a dashed line mesh
  50915. * * 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
  50916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50917. * * The parameter `points` is an array successive Vector3
  50918. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50919. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50920. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50921. * * 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
  50922. * * When updating an instance, remember that only point positions can change, not the number of points
  50923. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50924. * @param name defines the name of the mesh
  50925. * @param options defines the options used to create the mesh
  50926. * @param scene defines the hosting scene
  50927. * @returns the dashed line mesh
  50928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50929. */
  50930. static CreateDashedLines(name: string, options: {
  50931. points: Vector3[];
  50932. dashSize?: number;
  50933. gapSize?: number;
  50934. dashNb?: number;
  50935. updatable?: boolean;
  50936. instance?: LinesMesh;
  50937. }, scene?: Nullable<Scene>): LinesMesh;
  50938. /**
  50939. * 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.
  50940. * * 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.
  50941. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50942. * * 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.
  50943. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50944. * * 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
  50945. * * 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
  50946. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50948. * * 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
  50949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50951. * @param name defines the name of the mesh
  50952. * @param options defines the options used to create the mesh
  50953. * @param scene defines the hosting scene
  50954. * @returns the extruded shape mesh
  50955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50957. */
  50958. static ExtrudeShape(name: string, options: {
  50959. shape: Vector3[];
  50960. path: Vector3[];
  50961. scale?: number;
  50962. rotation?: number;
  50963. cap?: number;
  50964. updatable?: boolean;
  50965. sideOrientation?: number;
  50966. frontUVs?: Vector4;
  50967. backUVs?: Vector4;
  50968. instance?: Mesh;
  50969. invertUV?: boolean;
  50970. }, scene?: Nullable<Scene>): Mesh;
  50971. /**
  50972. * Creates an custom extruded shape mesh.
  50973. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50974. * * 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.
  50975. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50976. * * 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
  50977. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50978. * * 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
  50979. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50980. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50981. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50982. * * 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
  50983. * * 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
  50984. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50986. * * 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
  50987. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50989. * @param name defines the name of the mesh
  50990. * @param options defines the options used to create the mesh
  50991. * @param scene defines the hosting scene
  50992. * @returns the custom extruded shape mesh
  50993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50995. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50996. */
  50997. static ExtrudeShapeCustom(name: string, options: {
  50998. shape: Vector3[];
  50999. path: Vector3[];
  51000. scaleFunction?: any;
  51001. rotationFunction?: any;
  51002. ribbonCloseArray?: boolean;
  51003. ribbonClosePath?: boolean;
  51004. cap?: number;
  51005. updatable?: boolean;
  51006. sideOrientation?: number;
  51007. frontUVs?: Vector4;
  51008. backUVs?: Vector4;
  51009. instance?: Mesh;
  51010. invertUV?: boolean;
  51011. }, scene?: Nullable<Scene>): Mesh;
  51012. /**
  51013. * Creates lathe mesh.
  51014. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51015. * * 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
  51016. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51017. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51018. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51019. * * 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
  51020. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51021. * * 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
  51022. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51023. * * 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
  51024. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51025. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51026. * @param name defines the name of the mesh
  51027. * @param options defines the options used to create the mesh
  51028. * @param scene defines the hosting scene
  51029. * @returns the lathe mesh
  51030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51031. */
  51032. static CreateLathe(name: string, options: {
  51033. shape: Vector3[];
  51034. radius?: number;
  51035. tessellation?: number;
  51036. clip?: number;
  51037. arc?: number;
  51038. closed?: boolean;
  51039. updatable?: boolean;
  51040. sideOrientation?: number;
  51041. frontUVs?: Vector4;
  51042. backUVs?: Vector4;
  51043. cap?: number;
  51044. invertUV?: boolean;
  51045. }, scene?: Nullable<Scene>): Mesh;
  51046. /**
  51047. * Creates a tiled plane mesh
  51048. * * You can set a limited pattern arrangement with the tiles
  51049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51050. * * 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
  51051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51052. * @param name defines the name of the mesh
  51053. * @param options defines the options used to create the mesh
  51054. * @param scene defines the hosting scene
  51055. * @returns the plane mesh
  51056. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51057. */
  51058. static CreateTiledPlane(name: string, options: {
  51059. pattern?: number;
  51060. tileSize?: number;
  51061. tileWidth?: number;
  51062. tileHeight?: number;
  51063. size?: number;
  51064. width?: number;
  51065. height?: number;
  51066. alignHorizontal?: number;
  51067. alignVertical?: number;
  51068. sideOrientation?: number;
  51069. frontUVs?: Vector4;
  51070. backUVs?: Vector4;
  51071. updatable?: boolean;
  51072. }, scene?: Nullable<Scene>): Mesh;
  51073. /**
  51074. * Creates a plane mesh
  51075. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51076. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51077. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51079. * * 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
  51080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51081. * @param name defines the name of the mesh
  51082. * @param options defines the options used to create the mesh
  51083. * @param scene defines the hosting scene
  51084. * @returns the plane mesh
  51085. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51086. */
  51087. static CreatePlane(name: string, options: {
  51088. size?: number;
  51089. width?: number;
  51090. height?: number;
  51091. sideOrientation?: number;
  51092. frontUVs?: Vector4;
  51093. backUVs?: Vector4;
  51094. updatable?: boolean;
  51095. sourcePlane?: Plane;
  51096. }, scene?: Nullable<Scene>): Mesh;
  51097. /**
  51098. * Creates a ground mesh
  51099. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51100. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51102. * @param name defines the name of the mesh
  51103. * @param options defines the options used to create the mesh
  51104. * @param scene defines the hosting scene
  51105. * @returns the ground mesh
  51106. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51107. */
  51108. static CreateGround(name: string, options: {
  51109. width?: number;
  51110. height?: number;
  51111. subdivisions?: number;
  51112. subdivisionsX?: number;
  51113. subdivisionsY?: number;
  51114. updatable?: boolean;
  51115. }, scene?: Nullable<Scene>): Mesh;
  51116. /**
  51117. * Creates a tiled ground mesh
  51118. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51119. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51120. * * 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
  51121. * * 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
  51122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51123. * @param name defines the name of the mesh
  51124. * @param options defines the options used to create the mesh
  51125. * @param scene defines the hosting scene
  51126. * @returns the tiled ground mesh
  51127. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51128. */
  51129. static CreateTiledGround(name: string, options: {
  51130. xmin: number;
  51131. zmin: number;
  51132. xmax: number;
  51133. zmax: number;
  51134. subdivisions?: {
  51135. w: number;
  51136. h: number;
  51137. };
  51138. precision?: {
  51139. w: number;
  51140. h: number;
  51141. };
  51142. updatable?: boolean;
  51143. }, scene?: Nullable<Scene>): Mesh;
  51144. /**
  51145. * Creates a ground mesh from a height map
  51146. * * The parameter `url` sets the URL of the height map image resource.
  51147. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51148. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51149. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51150. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51151. * * 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.
  51152. * * 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).
  51153. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51155. * @param name defines the name of the mesh
  51156. * @param url defines the url to the height map
  51157. * @param options defines the options used to create the mesh
  51158. * @param scene defines the hosting scene
  51159. * @returns the ground mesh
  51160. * @see https://doc.babylonjs.com/babylon101/height_map
  51161. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51162. */
  51163. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51164. width?: number;
  51165. height?: number;
  51166. subdivisions?: number;
  51167. minHeight?: number;
  51168. maxHeight?: number;
  51169. colorFilter?: Color3;
  51170. alphaFilter?: number;
  51171. updatable?: boolean;
  51172. onReady?: (mesh: GroundMesh) => void;
  51173. }, scene?: Nullable<Scene>): GroundMesh;
  51174. /**
  51175. * Creates a polygon mesh
  51176. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51177. * * 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
  51178. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51179. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51180. * * 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)
  51181. * * Remember you can only change the shape positions, not their number when updating a polygon
  51182. * @param name defines the name of the mesh
  51183. * @param options defines the options used to create the mesh
  51184. * @param scene defines the hosting scene
  51185. * @param earcutInjection can be used to inject your own earcut reference
  51186. * @returns the polygon mesh
  51187. */
  51188. static CreatePolygon(name: string, options: {
  51189. shape: Vector3[];
  51190. holes?: Vector3[][];
  51191. depth?: number;
  51192. faceUV?: Vector4[];
  51193. faceColors?: Color4[];
  51194. updatable?: boolean;
  51195. sideOrientation?: number;
  51196. frontUVs?: Vector4;
  51197. backUVs?: Vector4;
  51198. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51199. /**
  51200. * Creates an extruded polygon mesh, with depth in the Y direction.
  51201. * * 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)
  51202. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51203. * @param name defines the name of the mesh
  51204. * @param options defines the options used to create the mesh
  51205. * @param scene defines the hosting scene
  51206. * @param earcutInjection can be used to inject your own earcut reference
  51207. * @returns the polygon mesh
  51208. */
  51209. static ExtrudePolygon(name: string, options: {
  51210. shape: Vector3[];
  51211. holes?: Vector3[][];
  51212. depth?: number;
  51213. faceUV?: Vector4[];
  51214. faceColors?: Color4[];
  51215. updatable?: boolean;
  51216. sideOrientation?: number;
  51217. frontUVs?: Vector4;
  51218. backUVs?: Vector4;
  51219. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51220. /**
  51221. * Creates a tube mesh.
  51222. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51223. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51224. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51225. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51226. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51227. * * 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)
  51228. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51229. * * 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
  51230. * * 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
  51231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51232. * * 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
  51233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51235. * @param name defines the name of the mesh
  51236. * @param options defines the options used to create the mesh
  51237. * @param scene defines the hosting scene
  51238. * @returns the tube mesh
  51239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51240. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51241. */
  51242. static CreateTube(name: string, options: {
  51243. path: Vector3[];
  51244. radius?: number;
  51245. tessellation?: number;
  51246. radiusFunction?: {
  51247. (i: number, distance: number): number;
  51248. };
  51249. cap?: number;
  51250. arc?: number;
  51251. updatable?: boolean;
  51252. sideOrientation?: number;
  51253. frontUVs?: Vector4;
  51254. backUVs?: Vector4;
  51255. instance?: Mesh;
  51256. invertUV?: boolean;
  51257. }, scene?: Nullable<Scene>): Mesh;
  51258. /**
  51259. * Creates a polyhedron mesh
  51260. * * 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
  51261. * * The parameter `size` (positive float, default 1) sets the polygon size
  51262. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51263. * * 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`
  51264. * * 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
  51265. * * 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)`)
  51266. * * 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
  51267. * * 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
  51268. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51269. * * 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
  51270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51271. * @param name defines the name of the mesh
  51272. * @param options defines the options used to create the mesh
  51273. * @param scene defines the hosting scene
  51274. * @returns the polyhedron mesh
  51275. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51276. */
  51277. static CreatePolyhedron(name: string, options: {
  51278. type?: number;
  51279. size?: number;
  51280. sizeX?: number;
  51281. sizeY?: number;
  51282. sizeZ?: number;
  51283. custom?: any;
  51284. faceUV?: Vector4[];
  51285. faceColors?: Color4[];
  51286. flat?: boolean;
  51287. updatable?: boolean;
  51288. sideOrientation?: number;
  51289. frontUVs?: Vector4;
  51290. backUVs?: Vector4;
  51291. }, scene?: Nullable<Scene>): Mesh;
  51292. /**
  51293. * Creates a decal mesh.
  51294. * 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
  51295. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51296. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51297. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51298. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51299. * @param name defines the name of the mesh
  51300. * @param sourceMesh defines the mesh where the decal must be applied
  51301. * @param options defines the options used to create the mesh
  51302. * @param scene defines the hosting scene
  51303. * @returns the decal mesh
  51304. * @see https://doc.babylonjs.com/how_to/decals
  51305. */
  51306. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51307. position?: Vector3;
  51308. normal?: Vector3;
  51309. size?: Vector3;
  51310. angle?: number;
  51311. }): Mesh;
  51312. }
  51313. }
  51314. declare module BABYLON {
  51315. /**
  51316. * A simplifier interface for future simplification implementations
  51317. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51318. */
  51319. export interface ISimplifier {
  51320. /**
  51321. * Simplification of a given mesh according to the given settings.
  51322. * Since this requires computation, it is assumed that the function runs async.
  51323. * @param settings The settings of the simplification, including quality and distance
  51324. * @param successCallback A callback that will be called after the mesh was simplified.
  51325. * @param errorCallback in case of an error, this callback will be called. optional.
  51326. */
  51327. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  51328. }
  51329. /**
  51330. * Expected simplification settings.
  51331. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  51332. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51333. */
  51334. export interface ISimplificationSettings {
  51335. /**
  51336. * Gets or sets the expected quality
  51337. */
  51338. quality: number;
  51339. /**
  51340. * Gets or sets the distance when this optimized version should be used
  51341. */
  51342. distance: number;
  51343. /**
  51344. * Gets an already optimized mesh
  51345. */
  51346. optimizeMesh?: boolean;
  51347. }
  51348. /**
  51349. * Class used to specify simplification options
  51350. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51351. */
  51352. export class SimplificationSettings implements ISimplificationSettings {
  51353. /** expected quality */
  51354. quality: number;
  51355. /** distance when this optimized version should be used */
  51356. distance: number;
  51357. /** already optimized mesh */
  51358. optimizeMesh?: boolean | undefined;
  51359. /**
  51360. * Creates a SimplificationSettings
  51361. * @param quality expected quality
  51362. * @param distance distance when this optimized version should be used
  51363. * @param optimizeMesh already optimized mesh
  51364. */
  51365. constructor(
  51366. /** expected quality */
  51367. quality: number,
  51368. /** distance when this optimized version should be used */
  51369. distance: number,
  51370. /** already optimized mesh */
  51371. optimizeMesh?: boolean | undefined);
  51372. }
  51373. /**
  51374. * Interface used to define a simplification task
  51375. */
  51376. export interface ISimplificationTask {
  51377. /**
  51378. * Array of settings
  51379. */
  51380. settings: Array<ISimplificationSettings>;
  51381. /**
  51382. * Simplification type
  51383. */
  51384. simplificationType: SimplificationType;
  51385. /**
  51386. * Mesh to simplify
  51387. */
  51388. mesh: Mesh;
  51389. /**
  51390. * Callback called on success
  51391. */
  51392. successCallback?: () => void;
  51393. /**
  51394. * Defines if parallel processing can be used
  51395. */
  51396. parallelProcessing: boolean;
  51397. }
  51398. /**
  51399. * Queue used to order the simplification tasks
  51400. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51401. */
  51402. export class SimplificationQueue {
  51403. private _simplificationArray;
  51404. /**
  51405. * Gets a boolean indicating that the process is still running
  51406. */
  51407. running: boolean;
  51408. /**
  51409. * Creates a new queue
  51410. */
  51411. constructor();
  51412. /**
  51413. * Adds a new simplification task
  51414. * @param task defines a task to add
  51415. */
  51416. addTask(task: ISimplificationTask): void;
  51417. /**
  51418. * Execute next task
  51419. */
  51420. executeNext(): void;
  51421. /**
  51422. * Execute a simplification task
  51423. * @param task defines the task to run
  51424. */
  51425. runSimplification(task: ISimplificationTask): void;
  51426. private getSimplifier;
  51427. }
  51428. /**
  51429. * The implemented types of simplification
  51430. * At the moment only Quadratic Error Decimation is implemented
  51431. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51432. */
  51433. export enum SimplificationType {
  51434. /** Quadratic error decimation */
  51435. QUADRATIC = 0
  51436. }
  51437. }
  51438. declare module BABYLON {
  51439. interface Scene {
  51440. /** @hidden (Backing field) */
  51441. _simplificationQueue: SimplificationQueue;
  51442. /**
  51443. * Gets or sets the simplification queue attached to the scene
  51444. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  51445. */
  51446. simplificationQueue: SimplificationQueue;
  51447. }
  51448. interface Mesh {
  51449. /**
  51450. * Simplify the mesh according to the given array of settings.
  51451. * Function will return immediately and will simplify async
  51452. * @param settings a collection of simplification settings
  51453. * @param parallelProcessing should all levels calculate parallel or one after the other
  51454. * @param simplificationType the type of simplification to run
  51455. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  51456. * @returns the current mesh
  51457. */
  51458. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  51459. }
  51460. /**
  51461. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  51462. * created in a scene
  51463. */
  51464. export class SimplicationQueueSceneComponent implements ISceneComponent {
  51465. /**
  51466. * The component name helpfull to identify the component in the list of scene components.
  51467. */
  51468. readonly name: string;
  51469. /**
  51470. * The scene the component belongs to.
  51471. */
  51472. scene: Scene;
  51473. /**
  51474. * Creates a new instance of the component for the given scene
  51475. * @param scene Defines the scene to register the component in
  51476. */
  51477. constructor(scene: Scene);
  51478. /**
  51479. * Registers the component in a given scene
  51480. */
  51481. register(): void;
  51482. /**
  51483. * Rebuilds the elements related to this component in case of
  51484. * context lost for instance.
  51485. */
  51486. rebuild(): void;
  51487. /**
  51488. * Disposes the component and the associated ressources
  51489. */
  51490. dispose(): void;
  51491. private _beforeCameraUpdate;
  51492. }
  51493. }
  51494. declare module BABYLON {
  51495. /**
  51496. * Class used to enable access to IndexedDB
  51497. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  51498. */
  51499. export class Database implements IOfflineProvider {
  51500. private _callbackManifestChecked;
  51501. private _currentSceneUrl;
  51502. private _db;
  51503. private _enableSceneOffline;
  51504. private _enableTexturesOffline;
  51505. private _manifestVersionFound;
  51506. private _mustUpdateRessources;
  51507. private _hasReachedQuota;
  51508. private _isSupported;
  51509. private _idbFactory;
  51510. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  51511. private static IsUASupportingBlobStorage;
  51512. /**
  51513. * Gets a boolean indicating if Database storate is enabled (off by default)
  51514. */
  51515. static IDBStorageEnabled: boolean;
  51516. /**
  51517. * Gets a boolean indicating if scene must be saved in the database
  51518. */
  51519. readonly enableSceneOffline: boolean;
  51520. /**
  51521. * Gets a boolean indicating if textures must be saved in the database
  51522. */
  51523. readonly enableTexturesOffline: boolean;
  51524. /**
  51525. * Creates a new Database
  51526. * @param urlToScene defines the url to load the scene
  51527. * @param callbackManifestChecked defines the callback to use when manifest is checked
  51528. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  51529. */
  51530. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  51531. private static _ParseURL;
  51532. private static _ReturnFullUrlLocation;
  51533. private _checkManifestFile;
  51534. /**
  51535. * Open the database and make it available
  51536. * @param successCallback defines the callback to call on success
  51537. * @param errorCallback defines the callback to call on error
  51538. */
  51539. open(successCallback: () => void, errorCallback: () => void): void;
  51540. /**
  51541. * Loads an image from the database
  51542. * @param url defines the url to load from
  51543. * @param image defines the target DOM image
  51544. */
  51545. loadImage(url: string, image: HTMLImageElement): void;
  51546. private _loadImageFromDBAsync;
  51547. private _saveImageIntoDBAsync;
  51548. private _checkVersionFromDB;
  51549. private _loadVersionFromDBAsync;
  51550. private _saveVersionIntoDBAsync;
  51551. /**
  51552. * Loads a file from database
  51553. * @param url defines the URL to load from
  51554. * @param sceneLoaded defines a callback to call on success
  51555. * @param progressCallBack defines a callback to call when progress changed
  51556. * @param errorCallback defines a callback to call on error
  51557. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  51558. */
  51559. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  51560. private _loadFileAsync;
  51561. private _saveFileAsync;
  51562. /**
  51563. * Validates if xhr data is correct
  51564. * @param xhr defines the request to validate
  51565. * @param dataType defines the expected data type
  51566. * @returns true if data is correct
  51567. */
  51568. private static _ValidateXHRData;
  51569. }
  51570. }
  51571. declare module BABYLON {
  51572. /** @hidden */
  51573. export var gpuUpdateParticlesPixelShader: {
  51574. name: string;
  51575. shader: string;
  51576. };
  51577. }
  51578. declare module BABYLON {
  51579. /** @hidden */
  51580. export var gpuUpdateParticlesVertexShader: {
  51581. name: string;
  51582. shader: string;
  51583. };
  51584. }
  51585. declare module BABYLON {
  51586. /** @hidden */
  51587. export var clipPlaneFragmentDeclaration2: {
  51588. name: string;
  51589. shader: string;
  51590. };
  51591. }
  51592. declare module BABYLON {
  51593. /** @hidden */
  51594. export var gpuRenderParticlesPixelShader: {
  51595. name: string;
  51596. shader: string;
  51597. };
  51598. }
  51599. declare module BABYLON {
  51600. /** @hidden */
  51601. export var clipPlaneVertexDeclaration2: {
  51602. name: string;
  51603. shader: string;
  51604. };
  51605. }
  51606. declare module BABYLON {
  51607. /** @hidden */
  51608. export var gpuRenderParticlesVertexShader: {
  51609. name: string;
  51610. shader: string;
  51611. };
  51612. }
  51613. declare module BABYLON {
  51614. /**
  51615. * This represents a GPU particle system in Babylon
  51616. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  51617. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  51618. */
  51619. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  51620. /**
  51621. * The layer mask we are rendering the particles through.
  51622. */
  51623. layerMask: number;
  51624. private _capacity;
  51625. private _activeCount;
  51626. private _currentActiveCount;
  51627. private _accumulatedCount;
  51628. private _renderEffect;
  51629. private _updateEffect;
  51630. private _buffer0;
  51631. private _buffer1;
  51632. private _spriteBuffer;
  51633. private _updateVAO;
  51634. private _renderVAO;
  51635. private _targetIndex;
  51636. private _sourceBuffer;
  51637. private _targetBuffer;
  51638. private _engine;
  51639. private _currentRenderId;
  51640. private _started;
  51641. private _stopped;
  51642. private _timeDelta;
  51643. private _randomTexture;
  51644. private _randomTexture2;
  51645. private _attributesStrideSize;
  51646. private _updateEffectOptions;
  51647. private _randomTextureSize;
  51648. private _actualFrame;
  51649. private readonly _rawTextureWidth;
  51650. /**
  51651. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  51652. */
  51653. static readonly IsSupported: boolean;
  51654. /**
  51655. * An event triggered when the system is disposed.
  51656. */
  51657. onDisposeObservable: Observable<GPUParticleSystem>;
  51658. /**
  51659. * Gets the maximum number of particles active at the same time.
  51660. * @returns The max number of active particles.
  51661. */
  51662. getCapacity(): number;
  51663. /**
  51664. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  51665. * to override the particles.
  51666. */
  51667. forceDepthWrite: boolean;
  51668. /**
  51669. * Gets or set the number of active particles
  51670. */
  51671. activeParticleCount: number;
  51672. private _preWarmDone;
  51673. /**
  51674. * Is this system ready to be used/rendered
  51675. * @return true if the system is ready
  51676. */
  51677. isReady(): boolean;
  51678. /**
  51679. * Gets if the system has been started. (Note: this will still be true after stop is called)
  51680. * @returns True if it has been started, otherwise false.
  51681. */
  51682. isStarted(): boolean;
  51683. /**
  51684. * Starts the particle system and begins to emit
  51685. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  51686. */
  51687. start(delay?: number): void;
  51688. /**
  51689. * Stops the particle system.
  51690. */
  51691. stop(): void;
  51692. /**
  51693. * Remove all active particles
  51694. */
  51695. reset(): void;
  51696. /**
  51697. * Returns the string "GPUParticleSystem"
  51698. * @returns a string containing the class name
  51699. */
  51700. getClassName(): string;
  51701. private _colorGradientsTexture;
  51702. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  51703. /**
  51704. * Adds a new color gradient
  51705. * @param gradient defines the gradient to use (between 0 and 1)
  51706. * @param color1 defines the color to affect to the specified gradient
  51707. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  51708. * @returns the current particle system
  51709. */
  51710. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  51711. /**
  51712. * Remove a specific color gradient
  51713. * @param gradient defines the gradient to remove
  51714. * @returns the current particle system
  51715. */
  51716. removeColorGradient(gradient: number): GPUParticleSystem;
  51717. private _angularSpeedGradientsTexture;
  51718. private _sizeGradientsTexture;
  51719. private _velocityGradientsTexture;
  51720. private _limitVelocityGradientsTexture;
  51721. private _dragGradientsTexture;
  51722. private _addFactorGradient;
  51723. /**
  51724. * Adds a new size gradient
  51725. * @param gradient defines the gradient to use (between 0 and 1)
  51726. * @param factor defines the size factor to affect to the specified gradient
  51727. * @returns the current particle system
  51728. */
  51729. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  51730. /**
  51731. * Remove a specific size gradient
  51732. * @param gradient defines the gradient to remove
  51733. * @returns the current particle system
  51734. */
  51735. removeSizeGradient(gradient: number): GPUParticleSystem;
  51736. /**
  51737. * Adds a new angular speed gradient
  51738. * @param gradient defines the gradient to use (between 0 and 1)
  51739. * @param factor defines the angular speed to affect to the specified gradient
  51740. * @returns the current particle system
  51741. */
  51742. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  51743. /**
  51744. * Remove a specific angular speed gradient
  51745. * @param gradient defines the gradient to remove
  51746. * @returns the current particle system
  51747. */
  51748. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  51749. /**
  51750. * Adds a new velocity gradient
  51751. * @param gradient defines the gradient to use (between 0 and 1)
  51752. * @param factor defines the velocity to affect to the specified gradient
  51753. * @returns the current particle system
  51754. */
  51755. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51756. /**
  51757. * Remove a specific velocity gradient
  51758. * @param gradient defines the gradient to remove
  51759. * @returns the current particle system
  51760. */
  51761. removeVelocityGradient(gradient: number): GPUParticleSystem;
  51762. /**
  51763. * Adds a new limit velocity gradient
  51764. * @param gradient defines the gradient to use (between 0 and 1)
  51765. * @param factor defines the limit velocity value to affect to the specified gradient
  51766. * @returns the current particle system
  51767. */
  51768. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  51769. /**
  51770. * Remove a specific limit velocity gradient
  51771. * @param gradient defines the gradient to remove
  51772. * @returns the current particle system
  51773. */
  51774. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  51775. /**
  51776. * Adds a new drag gradient
  51777. * @param gradient defines the gradient to use (between 0 and 1)
  51778. * @param factor defines the drag value to affect to the specified gradient
  51779. * @returns the current particle system
  51780. */
  51781. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  51782. /**
  51783. * Remove a specific drag gradient
  51784. * @param gradient defines the gradient to remove
  51785. * @returns the current particle system
  51786. */
  51787. removeDragGradient(gradient: number): GPUParticleSystem;
  51788. /**
  51789. * Not supported by GPUParticleSystem
  51790. * @param gradient defines the gradient to use (between 0 and 1)
  51791. * @param factor defines the emit rate value to affect to the specified gradient
  51792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51793. * @returns the current particle system
  51794. */
  51795. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51796. /**
  51797. * Not supported by GPUParticleSystem
  51798. * @param gradient defines the gradient to remove
  51799. * @returns the current particle system
  51800. */
  51801. removeEmitRateGradient(gradient: number): IParticleSystem;
  51802. /**
  51803. * Not supported by GPUParticleSystem
  51804. * @param gradient defines the gradient to use (between 0 and 1)
  51805. * @param factor defines the start size value to affect to the specified gradient
  51806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51807. * @returns the current particle system
  51808. */
  51809. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51810. /**
  51811. * Not supported by GPUParticleSystem
  51812. * @param gradient defines the gradient to remove
  51813. * @returns the current particle system
  51814. */
  51815. removeStartSizeGradient(gradient: number): IParticleSystem;
  51816. /**
  51817. * Not supported by GPUParticleSystem
  51818. * @param gradient defines the gradient to use (between 0 and 1)
  51819. * @param min defines the color remap minimal range
  51820. * @param max defines the color remap maximal range
  51821. * @returns the current particle system
  51822. */
  51823. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51824. /**
  51825. * Not supported by GPUParticleSystem
  51826. * @param gradient defines the gradient to remove
  51827. * @returns the current particle system
  51828. */
  51829. removeColorRemapGradient(): IParticleSystem;
  51830. /**
  51831. * Not supported by GPUParticleSystem
  51832. * @param gradient defines the gradient to use (between 0 and 1)
  51833. * @param min defines the alpha remap minimal range
  51834. * @param max defines the alpha remap maximal range
  51835. * @returns the current particle system
  51836. */
  51837. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  51838. /**
  51839. * Not supported by GPUParticleSystem
  51840. * @param gradient defines the gradient to remove
  51841. * @returns the current particle system
  51842. */
  51843. removeAlphaRemapGradient(): IParticleSystem;
  51844. /**
  51845. * Not supported by GPUParticleSystem
  51846. * @param gradient defines the gradient to use (between 0 and 1)
  51847. * @param color defines the color to affect to the specified gradient
  51848. * @returns the current particle system
  51849. */
  51850. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  51851. /**
  51852. * Not supported by GPUParticleSystem
  51853. * @param gradient defines the gradient to remove
  51854. * @returns the current particle system
  51855. */
  51856. removeRampGradient(): IParticleSystem;
  51857. /**
  51858. * Not supported by GPUParticleSystem
  51859. * @returns the list of ramp gradients
  51860. */
  51861. getRampGradients(): Nullable<Array<Color3Gradient>>;
  51862. /**
  51863. * Not supported by GPUParticleSystem
  51864. * Gets or sets a boolean indicating that ramp gradients must be used
  51865. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  51866. */
  51867. useRampGradients: boolean;
  51868. /**
  51869. * Not supported by GPUParticleSystem
  51870. * @param gradient defines the gradient to use (between 0 and 1)
  51871. * @param factor defines the life time factor to affect to the specified gradient
  51872. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  51873. * @returns the current particle system
  51874. */
  51875. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  51876. /**
  51877. * Not supported by GPUParticleSystem
  51878. * @param gradient defines the gradient to remove
  51879. * @returns the current particle system
  51880. */
  51881. removeLifeTimeGradient(gradient: number): IParticleSystem;
  51882. /**
  51883. * Instantiates a GPU particle system.
  51884. * 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.
  51885. * @param name The name of the particle system
  51886. * @param options The options used to create the system
  51887. * @param scene The scene the particle system belongs to
  51888. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  51889. */
  51890. constructor(name: string, options: Partial<{
  51891. capacity: number;
  51892. randomTextureSize: number;
  51893. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  51894. protected _reset(): void;
  51895. private _createUpdateVAO;
  51896. private _createRenderVAO;
  51897. private _initialize;
  51898. /** @hidden */
  51899. _recreateUpdateEffect(): void;
  51900. /** @hidden */
  51901. _recreateRenderEffect(): void;
  51902. /**
  51903. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  51904. * @param preWarm defines if we are in the pre-warmimg phase
  51905. */
  51906. animate(preWarm?: boolean): void;
  51907. private _createFactorGradientTexture;
  51908. private _createSizeGradientTexture;
  51909. private _createAngularSpeedGradientTexture;
  51910. private _createVelocityGradientTexture;
  51911. private _createLimitVelocityGradientTexture;
  51912. private _createDragGradientTexture;
  51913. private _createColorGradientTexture;
  51914. /**
  51915. * Renders the particle system in its current state
  51916. * @param preWarm defines if the system should only update the particles but not render them
  51917. * @returns the current number of particles
  51918. */
  51919. render(preWarm?: boolean): number;
  51920. /**
  51921. * Rebuilds the particle system
  51922. */
  51923. rebuild(): void;
  51924. private _releaseBuffers;
  51925. private _releaseVAOs;
  51926. /**
  51927. * Disposes the particle system and free the associated resources
  51928. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  51929. */
  51930. dispose(disposeTexture?: boolean): void;
  51931. /**
  51932. * Clones the particle system.
  51933. * @param name The name of the cloned object
  51934. * @param newEmitter The new emitter to use
  51935. * @returns the cloned particle system
  51936. */
  51937. clone(name: string, newEmitter: any): GPUParticleSystem;
  51938. /**
  51939. * Serializes the particle system to a JSON object.
  51940. * @returns the JSON object
  51941. */
  51942. serialize(): any;
  51943. /**
  51944. * Parses a JSON object to create a GPU particle system.
  51945. * @param parsedParticleSystem The JSON object to parse
  51946. * @param scene The scene to create the particle system in
  51947. * @param rootUrl The root url to use to load external dependencies like texture
  51948. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  51949. * @returns the parsed GPU particle system
  51950. */
  51951. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  51952. }
  51953. }
  51954. declare module BABYLON {
  51955. /**
  51956. * Represents a set of particle systems working together to create a specific effect
  51957. */
  51958. export class ParticleSystemSet implements IDisposable {
  51959. private _emitterCreationOptions;
  51960. private _emitterNode;
  51961. /**
  51962. * Gets the particle system list
  51963. */
  51964. systems: IParticleSystem[];
  51965. /**
  51966. * Gets the emitter node used with this set
  51967. */
  51968. readonly emitterNode: Nullable<TransformNode>;
  51969. /**
  51970. * Creates a new emitter mesh as a sphere
  51971. * @param options defines the options used to create the sphere
  51972. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  51973. * @param scene defines the hosting scene
  51974. */
  51975. setEmitterAsSphere(options: {
  51976. diameter: number;
  51977. segments: number;
  51978. color: Color3;
  51979. }, renderingGroupId: number, scene: Scene): void;
  51980. /**
  51981. * Starts all particle systems of the set
  51982. * @param emitter defines an optional mesh to use as emitter for the particle systems
  51983. */
  51984. start(emitter?: AbstractMesh): void;
  51985. /**
  51986. * Release all associated resources
  51987. */
  51988. dispose(): void;
  51989. /**
  51990. * Serialize the set into a JSON compatible object
  51991. * @returns a JSON compatible representation of the set
  51992. */
  51993. serialize(): any;
  51994. /**
  51995. * Parse a new ParticleSystemSet from a serialized source
  51996. * @param data defines a JSON compatible representation of the set
  51997. * @param scene defines the hosting scene
  51998. * @param gpu defines if we want GPU particles or CPU particles
  51999. * @returns a new ParticleSystemSet
  52000. */
  52001. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52002. }
  52003. }
  52004. declare module BABYLON {
  52005. /**
  52006. * This class is made for on one-liner static method to help creating particle system set.
  52007. */
  52008. export class ParticleHelper {
  52009. /**
  52010. * Gets or sets base Assets URL
  52011. */
  52012. static BaseAssetsUrl: string;
  52013. /**
  52014. * Create a default particle system that you can tweak
  52015. * @param emitter defines the emitter to use
  52016. * @param capacity defines the system capacity (default is 500 particles)
  52017. * @param scene defines the hosting scene
  52018. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52019. * @returns the new Particle system
  52020. */
  52021. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52022. /**
  52023. * This is the main static method (one-liner) of this helper to create different particle systems
  52024. * @param type This string represents the type to the particle system to create
  52025. * @param scene The scene where the particle system should live
  52026. * @param gpu If the system will use gpu
  52027. * @returns the ParticleSystemSet created
  52028. */
  52029. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52030. /**
  52031. * Static function used to export a particle system to a ParticleSystemSet variable.
  52032. * Please note that the emitter shape is not exported
  52033. * @param systems defines the particle systems to export
  52034. * @returns the created particle system set
  52035. */
  52036. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52037. }
  52038. }
  52039. declare module BABYLON {
  52040. interface Engine {
  52041. /**
  52042. * Create an effect to use with particle systems.
  52043. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52044. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52045. * @param uniformsNames defines a list of attribute names
  52046. * @param samplers defines an array of string used to represent textures
  52047. * @param defines defines the string containing the defines to use to compile the shaders
  52048. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52049. * @param onCompiled defines a function to call when the effect creation is successful
  52050. * @param onError defines a function to call when the effect creation has failed
  52051. * @returns the new Effect
  52052. */
  52053. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52054. }
  52055. interface Mesh {
  52056. /**
  52057. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52058. * @returns an array of IParticleSystem
  52059. */
  52060. getEmittedParticleSystems(): IParticleSystem[];
  52061. /**
  52062. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52063. * @returns an array of IParticleSystem
  52064. */
  52065. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52066. }
  52067. /**
  52068. * @hidden
  52069. */
  52070. export var _IDoNeedToBeInTheBuild: number;
  52071. }
  52072. declare module BABYLON {
  52073. interface Scene {
  52074. /** @hidden (Backing field) */
  52075. _physicsEngine: Nullable<IPhysicsEngine>;
  52076. /**
  52077. * Gets the current physics engine
  52078. * @returns a IPhysicsEngine or null if none attached
  52079. */
  52080. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52081. /**
  52082. * Enables physics to the current scene
  52083. * @param gravity defines the scene's gravity for the physics engine
  52084. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52085. * @return a boolean indicating if the physics engine was initialized
  52086. */
  52087. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52088. /**
  52089. * Disables and disposes the physics engine associated with the scene
  52090. */
  52091. disablePhysicsEngine(): void;
  52092. /**
  52093. * Gets a boolean indicating if there is an active physics engine
  52094. * @returns a boolean indicating if there is an active physics engine
  52095. */
  52096. isPhysicsEnabled(): boolean;
  52097. /**
  52098. * Deletes a physics compound impostor
  52099. * @param compound defines the compound to delete
  52100. */
  52101. deleteCompoundImpostor(compound: any): void;
  52102. /**
  52103. * An event triggered when physic simulation is about to be run
  52104. */
  52105. onBeforePhysicsObservable: Observable<Scene>;
  52106. /**
  52107. * An event triggered when physic simulation has been done
  52108. */
  52109. onAfterPhysicsObservable: Observable<Scene>;
  52110. }
  52111. interface AbstractMesh {
  52112. /** @hidden */
  52113. _physicsImpostor: Nullable<PhysicsImpostor>;
  52114. /**
  52115. * Gets or sets impostor used for physic simulation
  52116. * @see http://doc.babylonjs.com/features/physics_engine
  52117. */
  52118. physicsImpostor: Nullable<PhysicsImpostor>;
  52119. /**
  52120. * Gets the current physics impostor
  52121. * @see http://doc.babylonjs.com/features/physics_engine
  52122. * @returns a physics impostor or null
  52123. */
  52124. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52125. /** Apply a physic impulse to the mesh
  52126. * @param force defines the force to apply
  52127. * @param contactPoint defines where to apply the force
  52128. * @returns the current mesh
  52129. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52130. */
  52131. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52132. /**
  52133. * Creates a physic joint between two meshes
  52134. * @param otherMesh defines the other mesh to use
  52135. * @param pivot1 defines the pivot to use on this mesh
  52136. * @param pivot2 defines the pivot to use on the other mesh
  52137. * @param options defines additional options (can be plugin dependent)
  52138. * @returns the current mesh
  52139. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52140. */
  52141. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52142. /** @hidden */
  52143. _disposePhysicsObserver: Nullable<Observer<Node>>;
  52144. }
  52145. /**
  52146. * Defines the physics engine scene component responsible to manage a physics engine
  52147. */
  52148. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52149. /**
  52150. * The component name helpful to identify the component in the list of scene components.
  52151. */
  52152. readonly name: string;
  52153. /**
  52154. * The scene the component belongs to.
  52155. */
  52156. scene: Scene;
  52157. /**
  52158. * Creates a new instance of the component for the given scene
  52159. * @param scene Defines the scene to register the component in
  52160. */
  52161. constructor(scene: Scene);
  52162. /**
  52163. * Registers the component in a given scene
  52164. */
  52165. register(): void;
  52166. /**
  52167. * Rebuilds the elements related to this component in case of
  52168. * context lost for instance.
  52169. */
  52170. rebuild(): void;
  52171. /**
  52172. * Disposes the component and the associated ressources
  52173. */
  52174. dispose(): void;
  52175. }
  52176. }
  52177. declare module BABYLON {
  52178. /**
  52179. * A helper for physics simulations
  52180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52181. */
  52182. export class PhysicsHelper {
  52183. private _scene;
  52184. private _physicsEngine;
  52185. /**
  52186. * Initializes the Physics helper
  52187. * @param scene Babylon.js scene
  52188. */
  52189. constructor(scene: Scene);
  52190. /**
  52191. * Applies a radial explosion impulse
  52192. * @param origin the origin of the explosion
  52193. * @param radiusOrEventOptions the radius or the options of radial explosion
  52194. * @param strength the explosion strength
  52195. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52196. * @returns A physics radial explosion event, or null
  52197. */
  52198. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52199. /**
  52200. * Applies a radial explosion force
  52201. * @param origin the origin of the explosion
  52202. * @param radiusOrEventOptions the radius or the options of radial explosion
  52203. * @param strength the explosion strength
  52204. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52205. * @returns A physics radial explosion event, or null
  52206. */
  52207. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52208. /**
  52209. * Creates a gravitational field
  52210. * @param origin the origin of the explosion
  52211. * @param radiusOrEventOptions the radius or the options of radial explosion
  52212. * @param strength the explosion strength
  52213. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52214. * @returns A physics gravitational field event, or null
  52215. */
  52216. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52217. /**
  52218. * Creates a physics updraft event
  52219. * @param origin the origin of the updraft
  52220. * @param radiusOrEventOptions the radius or the options of the updraft
  52221. * @param strength the strength of the updraft
  52222. * @param height the height of the updraft
  52223. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52224. * @returns A physics updraft event, or null
  52225. */
  52226. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52227. /**
  52228. * Creates a physics vortex event
  52229. * @param origin the of the vortex
  52230. * @param radiusOrEventOptions the radius or the options of the vortex
  52231. * @param strength the strength of the vortex
  52232. * @param height the height of the vortex
  52233. * @returns a Physics vortex event, or null
  52234. * A physics vortex event or null
  52235. */
  52236. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52237. }
  52238. /**
  52239. * Represents a physics radial explosion event
  52240. */
  52241. class PhysicsRadialExplosionEvent {
  52242. private _scene;
  52243. private _options;
  52244. private _sphere;
  52245. private _dataFetched;
  52246. /**
  52247. * Initializes a radial explosioin event
  52248. * @param _scene BabylonJS scene
  52249. * @param _options The options for the vortex event
  52250. */
  52251. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52252. /**
  52253. * Returns the data related to the radial explosion event (sphere).
  52254. * @returns The radial explosion event data
  52255. */
  52256. getData(): PhysicsRadialExplosionEventData;
  52257. /**
  52258. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52259. * @param impostor A physics imposter
  52260. * @param origin the origin of the explosion
  52261. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  52262. */
  52263. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  52264. /**
  52265. * Triggers affecterd impostors callbacks
  52266. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  52267. */
  52268. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  52269. /**
  52270. * Disposes the sphere.
  52271. * @param force Specifies if the sphere should be disposed by force
  52272. */
  52273. dispose(force?: boolean): void;
  52274. /*** Helpers ***/
  52275. private _prepareSphere;
  52276. private _intersectsWithSphere;
  52277. }
  52278. /**
  52279. * Represents a gravitational field event
  52280. */
  52281. class PhysicsGravitationalFieldEvent {
  52282. private _physicsHelper;
  52283. private _scene;
  52284. private _origin;
  52285. private _options;
  52286. private _tickCallback;
  52287. private _sphere;
  52288. private _dataFetched;
  52289. /**
  52290. * Initializes the physics gravitational field event
  52291. * @param _physicsHelper A physics helper
  52292. * @param _scene BabylonJS scene
  52293. * @param _origin The origin position of the gravitational field event
  52294. * @param _options The options for the vortex event
  52295. */
  52296. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52297. /**
  52298. * Returns the data related to the gravitational field event (sphere).
  52299. * @returns A gravitational field event
  52300. */
  52301. getData(): PhysicsGravitationalFieldEventData;
  52302. /**
  52303. * Enables the gravitational field.
  52304. */
  52305. enable(): void;
  52306. /**
  52307. * Disables the gravitational field.
  52308. */
  52309. disable(): void;
  52310. /**
  52311. * Disposes the sphere.
  52312. * @param force The force to dispose from the gravitational field event
  52313. */
  52314. dispose(force?: boolean): void;
  52315. private _tick;
  52316. }
  52317. /**
  52318. * Represents a physics updraft event
  52319. */
  52320. class PhysicsUpdraftEvent {
  52321. private _scene;
  52322. private _origin;
  52323. private _options;
  52324. private _physicsEngine;
  52325. private _originTop;
  52326. private _originDirection;
  52327. private _tickCallback;
  52328. private _cylinder;
  52329. private _cylinderPosition;
  52330. private _dataFetched;
  52331. /**
  52332. * Initializes the physics updraft event
  52333. * @param _scene BabylonJS scene
  52334. * @param _origin The origin position of the updraft
  52335. * @param _options The options for the updraft event
  52336. */
  52337. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  52338. /**
  52339. * Returns the data related to the updraft event (cylinder).
  52340. * @returns A physics updraft event
  52341. */
  52342. getData(): PhysicsUpdraftEventData;
  52343. /**
  52344. * Enables the updraft.
  52345. */
  52346. enable(): void;
  52347. /**
  52348. * Disables the updraft.
  52349. */
  52350. disable(): void;
  52351. /**
  52352. * Disposes the cylinder.
  52353. * @param force Specifies if the updraft should be disposed by force
  52354. */
  52355. dispose(force?: boolean): void;
  52356. private getImpostorHitData;
  52357. private _tick;
  52358. /*** Helpers ***/
  52359. private _prepareCylinder;
  52360. private _intersectsWithCylinder;
  52361. }
  52362. /**
  52363. * Represents a physics vortex event
  52364. */
  52365. class PhysicsVortexEvent {
  52366. private _scene;
  52367. private _origin;
  52368. private _options;
  52369. private _physicsEngine;
  52370. private _originTop;
  52371. private _tickCallback;
  52372. private _cylinder;
  52373. private _cylinderPosition;
  52374. private _dataFetched;
  52375. /**
  52376. * Initializes the physics vortex event
  52377. * @param _scene The BabylonJS scene
  52378. * @param _origin The origin position of the vortex
  52379. * @param _options The options for the vortex event
  52380. */
  52381. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  52382. /**
  52383. * Returns the data related to the vortex event (cylinder).
  52384. * @returns The physics vortex event data
  52385. */
  52386. getData(): PhysicsVortexEventData;
  52387. /**
  52388. * Enables the vortex.
  52389. */
  52390. enable(): void;
  52391. /**
  52392. * Disables the cortex.
  52393. */
  52394. disable(): void;
  52395. /**
  52396. * Disposes the sphere.
  52397. * @param force
  52398. */
  52399. dispose(force?: boolean): void;
  52400. private getImpostorHitData;
  52401. private _tick;
  52402. /*** Helpers ***/
  52403. private _prepareCylinder;
  52404. private _intersectsWithCylinder;
  52405. }
  52406. /**
  52407. * Options fot the radial explosion event
  52408. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52409. */
  52410. export class PhysicsRadialExplosionEventOptions {
  52411. /**
  52412. * The radius of the sphere for the radial explosion.
  52413. */
  52414. radius: number;
  52415. /**
  52416. * The strenth of the explosion.
  52417. */
  52418. strength: number;
  52419. /**
  52420. * The strenght of the force in correspondence to the distance of the affected object
  52421. */
  52422. falloff: PhysicsRadialImpulseFalloff;
  52423. /**
  52424. * Sphere options for the radial explosion.
  52425. */
  52426. sphere: {
  52427. segments: number;
  52428. diameter: number;
  52429. };
  52430. /**
  52431. * Sphere options for the radial explosion.
  52432. */
  52433. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  52434. }
  52435. /**
  52436. * Options fot the updraft event
  52437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52438. */
  52439. export class PhysicsUpdraftEventOptions {
  52440. /**
  52441. * The radius of the cylinder for the vortex
  52442. */
  52443. radius: number;
  52444. /**
  52445. * The strenth of the updraft.
  52446. */
  52447. strength: number;
  52448. /**
  52449. * The height of the cylinder for the updraft.
  52450. */
  52451. height: number;
  52452. /**
  52453. * The mode for the the updraft.
  52454. */
  52455. updraftMode: PhysicsUpdraftMode;
  52456. }
  52457. /**
  52458. * Options fot the vortex event
  52459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52460. */
  52461. export class PhysicsVortexEventOptions {
  52462. /**
  52463. * The radius of the cylinder for the vortex
  52464. */
  52465. radius: number;
  52466. /**
  52467. * The strenth of the vortex.
  52468. */
  52469. strength: number;
  52470. /**
  52471. * The height of the cylinder for the vortex.
  52472. */
  52473. height: number;
  52474. /**
  52475. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  52476. */
  52477. centripetalForceThreshold: number;
  52478. /**
  52479. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  52480. */
  52481. centripetalForceMultiplier: number;
  52482. /**
  52483. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  52484. */
  52485. centrifugalForceMultiplier: number;
  52486. /**
  52487. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  52488. */
  52489. updraftForceMultiplier: number;
  52490. }
  52491. /**
  52492. * The strenght of the force in correspondence to the distance of the affected object
  52493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52494. */
  52495. export enum PhysicsRadialImpulseFalloff {
  52496. /** Defines that impulse is constant in strength across it's whole radius */
  52497. Constant = 0,
  52498. /** Defines that impulse gets weaker if it's further from the origin */
  52499. Linear = 1
  52500. }
  52501. /**
  52502. * The strength of the force in correspondence to the distance of the affected object
  52503. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52504. */
  52505. export enum PhysicsUpdraftMode {
  52506. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  52507. Center = 0,
  52508. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  52509. Perpendicular = 1
  52510. }
  52511. /**
  52512. * Interface for a physics hit data
  52513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52514. */
  52515. export interface PhysicsHitData {
  52516. /**
  52517. * The force applied at the contact point
  52518. */
  52519. force: Vector3;
  52520. /**
  52521. * The contact point
  52522. */
  52523. contactPoint: Vector3;
  52524. /**
  52525. * The distance from the origin to the contact point
  52526. */
  52527. distanceFromOrigin: number;
  52528. }
  52529. /**
  52530. * Interface for radial explosion event data
  52531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52532. */
  52533. export interface PhysicsRadialExplosionEventData {
  52534. /**
  52535. * A sphere used for the radial explosion event
  52536. */
  52537. sphere: Mesh;
  52538. }
  52539. /**
  52540. * Interface for gravitational field event data
  52541. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52542. */
  52543. export interface PhysicsGravitationalFieldEventData {
  52544. /**
  52545. * A sphere mesh used for the gravitational field event
  52546. */
  52547. sphere: Mesh;
  52548. }
  52549. /**
  52550. * Interface for updraft event data
  52551. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52552. */
  52553. export interface PhysicsUpdraftEventData {
  52554. /**
  52555. * A cylinder used for the updraft event
  52556. */
  52557. cylinder: Mesh;
  52558. }
  52559. /**
  52560. * Interface for vortex event data
  52561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52562. */
  52563. export interface PhysicsVortexEventData {
  52564. /**
  52565. * A cylinder used for the vortex event
  52566. */
  52567. cylinder: Mesh;
  52568. }
  52569. /**
  52570. * Interface for an affected physics impostor
  52571. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52572. */
  52573. export interface PhysicsAffectedImpostorWithData {
  52574. /**
  52575. * The impostor affected by the effect
  52576. */
  52577. impostor: PhysicsImpostor;
  52578. /**
  52579. * The data about the hit/horce from the explosion
  52580. */
  52581. hitData: PhysicsHitData;
  52582. }
  52583. }
  52584. declare module BABYLON {
  52585. /** @hidden */
  52586. export var blackAndWhitePixelShader: {
  52587. name: string;
  52588. shader: string;
  52589. };
  52590. }
  52591. declare module BABYLON {
  52592. /**
  52593. * Post process used to render in black and white
  52594. */
  52595. export class BlackAndWhitePostProcess extends PostProcess {
  52596. /**
  52597. * Linear about to convert he result to black and white (default: 1)
  52598. */
  52599. degree: number;
  52600. /**
  52601. * Creates a black and white post process
  52602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  52603. * @param name The name of the effect.
  52604. * @param options The required width/height ratio to downsize to before computing the render pass.
  52605. * @param camera The camera to apply the render pass to.
  52606. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52607. * @param engine The engine which the post process will be applied. (default: current engine)
  52608. * @param reusable If the post process can be reused on the same frame. (default: false)
  52609. */
  52610. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52611. }
  52612. }
  52613. declare module BABYLON {
  52614. /**
  52615. * This represents a set of one or more post processes in Babylon.
  52616. * A post process can be used to apply a shader to a texture after it is rendered.
  52617. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52618. */
  52619. export class PostProcessRenderEffect {
  52620. private _postProcesses;
  52621. private _getPostProcesses;
  52622. private _singleInstance;
  52623. private _cameras;
  52624. private _indicesForCamera;
  52625. /**
  52626. * Name of the effect
  52627. * @hidden
  52628. */
  52629. _name: string;
  52630. /**
  52631. * Instantiates a post process render effect.
  52632. * A post process can be used to apply a shader to a texture after it is rendered.
  52633. * @param engine The engine the effect is tied to
  52634. * @param name The name of the effect
  52635. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  52636. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  52637. */
  52638. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  52639. /**
  52640. * Checks if all the post processes in the effect are supported.
  52641. */
  52642. readonly isSupported: boolean;
  52643. /**
  52644. * Updates the current state of the effect
  52645. * @hidden
  52646. */
  52647. _update(): void;
  52648. /**
  52649. * Attaches the effect on cameras
  52650. * @param cameras The camera to attach to.
  52651. * @hidden
  52652. */
  52653. _attachCameras(cameras: Camera): void;
  52654. /**
  52655. * Attaches the effect on cameras
  52656. * @param cameras The camera to attach to.
  52657. * @hidden
  52658. */
  52659. _attachCameras(cameras: Camera[]): void;
  52660. /**
  52661. * Detaches the effect on cameras
  52662. * @param cameras The camera to detatch from.
  52663. * @hidden
  52664. */
  52665. _detachCameras(cameras: Camera): void;
  52666. /**
  52667. * Detatches the effect on cameras
  52668. * @param cameras The camera to detatch from.
  52669. * @hidden
  52670. */
  52671. _detachCameras(cameras: Camera[]): void;
  52672. /**
  52673. * Enables the effect on given cameras
  52674. * @param cameras The camera to enable.
  52675. * @hidden
  52676. */
  52677. _enable(cameras: Camera): void;
  52678. /**
  52679. * Enables the effect on given cameras
  52680. * @param cameras The camera to enable.
  52681. * @hidden
  52682. */
  52683. _enable(cameras: Nullable<Camera[]>): void;
  52684. /**
  52685. * Disables the effect on the given cameras
  52686. * @param cameras The camera to disable.
  52687. * @hidden
  52688. */
  52689. _disable(cameras: Camera): void;
  52690. /**
  52691. * Disables the effect on the given cameras
  52692. * @param cameras The camera to disable.
  52693. * @hidden
  52694. */
  52695. _disable(cameras: Nullable<Camera[]>): void;
  52696. /**
  52697. * Gets a list of the post processes contained in the effect.
  52698. * @param camera The camera to get the post processes on.
  52699. * @returns The list of the post processes in the effect.
  52700. */
  52701. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  52702. }
  52703. }
  52704. declare module BABYLON {
  52705. /** @hidden */
  52706. export var extractHighlightsPixelShader: {
  52707. name: string;
  52708. shader: string;
  52709. };
  52710. }
  52711. declare module BABYLON {
  52712. /**
  52713. * 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.
  52714. */
  52715. export class ExtractHighlightsPostProcess extends PostProcess {
  52716. /**
  52717. * The luminance threshold, pixels below this value will be set to black.
  52718. */
  52719. threshold: number;
  52720. /** @hidden */
  52721. _exposure: number;
  52722. /**
  52723. * Post process which has the input texture to be used when performing highlight extraction
  52724. * @hidden
  52725. */
  52726. _inputPostProcess: Nullable<PostProcess>;
  52727. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52728. }
  52729. }
  52730. declare module BABYLON {
  52731. /** @hidden */
  52732. export var bloomMergePixelShader: {
  52733. name: string;
  52734. shader: string;
  52735. };
  52736. }
  52737. declare module BABYLON {
  52738. /**
  52739. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  52740. */
  52741. export class BloomMergePostProcess extends PostProcess {
  52742. /** Weight of the bloom to be added to the original input. */
  52743. weight: number;
  52744. /**
  52745. * Creates a new instance of @see BloomMergePostProcess
  52746. * @param name The name of the effect.
  52747. * @param originalFromInput Post process which's input will be used for the merge.
  52748. * @param blurred Blurred highlights post process which's output will be used.
  52749. * @param weight Weight of the bloom to be added to the original input.
  52750. * @param options The required width/height ratio to downsize to before computing the render pass.
  52751. * @param camera The camera to apply the render pass to.
  52752. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52753. * @param engine The engine which the post process will be applied. (default: current engine)
  52754. * @param reusable If the post process can be reused on the same frame. (default: false)
  52755. * @param textureType Type of textures used when performing the post process. (default: 0)
  52756. * @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)
  52757. */
  52758. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  52759. /** Weight of the bloom to be added to the original input. */
  52760. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52761. }
  52762. }
  52763. declare module BABYLON {
  52764. /**
  52765. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  52766. */
  52767. export class BloomEffect extends PostProcessRenderEffect {
  52768. private bloomScale;
  52769. /**
  52770. * @hidden Internal
  52771. */
  52772. _effects: Array<PostProcess>;
  52773. /**
  52774. * @hidden Internal
  52775. */
  52776. _downscale: ExtractHighlightsPostProcess;
  52777. private _blurX;
  52778. private _blurY;
  52779. private _merge;
  52780. /**
  52781. * The luminance threshold to find bright areas of the image to bloom.
  52782. */
  52783. threshold: number;
  52784. /**
  52785. * The strength of the bloom.
  52786. */
  52787. weight: number;
  52788. /**
  52789. * Specifies the size of the bloom blur kernel, relative to the final output size
  52790. */
  52791. kernel: number;
  52792. /**
  52793. * Creates a new instance of @see BloomEffect
  52794. * @param scene The scene the effect belongs to.
  52795. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  52796. * @param bloomKernel The size of the kernel to be used when applying the blur.
  52797. * @param bloomWeight The the strength of bloom.
  52798. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52799. * @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)
  52800. */
  52801. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  52802. /**
  52803. * Disposes each of the internal effects for a given camera.
  52804. * @param camera The camera to dispose the effect on.
  52805. */
  52806. disposeEffects(camera: Camera): void;
  52807. /**
  52808. * @hidden Internal
  52809. */
  52810. _updateEffects(): void;
  52811. /**
  52812. * Internal
  52813. * @returns if all the contained post processes are ready.
  52814. * @hidden
  52815. */
  52816. _isReady(): boolean;
  52817. }
  52818. }
  52819. declare module BABYLON {
  52820. /** @hidden */
  52821. export var chromaticAberrationPixelShader: {
  52822. name: string;
  52823. shader: string;
  52824. };
  52825. }
  52826. declare module BABYLON {
  52827. /**
  52828. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  52829. */
  52830. export class ChromaticAberrationPostProcess extends PostProcess {
  52831. /**
  52832. * The amount of seperation of rgb channels (default: 30)
  52833. */
  52834. aberrationAmount: number;
  52835. /**
  52836. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  52837. */
  52838. radialIntensity: number;
  52839. /**
  52840. * 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))
  52841. */
  52842. direction: Vector2;
  52843. /**
  52844. * 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))
  52845. */
  52846. centerPosition: Vector2;
  52847. /**
  52848. * Creates a new instance ChromaticAberrationPostProcess
  52849. * @param name The name of the effect.
  52850. * @param screenWidth The width of the screen to apply the effect on.
  52851. * @param screenHeight The height of the screen to apply the effect on.
  52852. * @param options The required width/height ratio to downsize to before computing the render pass.
  52853. * @param camera The camera to apply the render pass to.
  52854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52855. * @param engine The engine which the post process will be applied. (default: current engine)
  52856. * @param reusable If the post process can be reused on the same frame. (default: false)
  52857. * @param textureType Type of textures used when performing the post process. (default: 0)
  52858. * @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)
  52859. */
  52860. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52861. }
  52862. }
  52863. declare module BABYLON {
  52864. /** @hidden */
  52865. export var circleOfConfusionPixelShader: {
  52866. name: string;
  52867. shader: string;
  52868. };
  52869. }
  52870. declare module BABYLON {
  52871. /**
  52872. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  52873. */
  52874. export class CircleOfConfusionPostProcess extends PostProcess {
  52875. /**
  52876. * 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.
  52877. */
  52878. lensSize: number;
  52879. /**
  52880. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52881. */
  52882. fStop: number;
  52883. /**
  52884. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52885. */
  52886. focusDistance: number;
  52887. /**
  52888. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  52889. */
  52890. focalLength: number;
  52891. private _depthTexture;
  52892. /**
  52893. * Creates a new instance CircleOfConfusionPostProcess
  52894. * @param name The name of the effect.
  52895. * @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.
  52896. * @param options The required width/height ratio to downsize to before computing the render pass.
  52897. * @param camera The camera to apply the render pass to.
  52898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52899. * @param engine The engine which the post process will be applied. (default: current engine)
  52900. * @param reusable If the post process can be reused on the same frame. (default: false)
  52901. * @param textureType Type of textures used when performing the post process. (default: 0)
  52902. * @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)
  52903. */
  52904. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52905. /**
  52906. * 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.
  52907. */
  52908. depthTexture: RenderTargetTexture;
  52909. }
  52910. }
  52911. declare module BABYLON {
  52912. /** @hidden */
  52913. export var colorCorrectionPixelShader: {
  52914. name: string;
  52915. shader: string;
  52916. };
  52917. }
  52918. declare module BABYLON {
  52919. /**
  52920. *
  52921. * This post-process allows the modification of rendered colors by using
  52922. * a 'look-up table' (LUT). This effect is also called Color Grading.
  52923. *
  52924. * The object needs to be provided an url to a texture containing the color
  52925. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  52926. * Use an image editing software to tweak the LUT to match your needs.
  52927. *
  52928. * For an example of a color LUT, see here:
  52929. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  52930. * For explanations on color grading, see here:
  52931. * @see http://udn.epicgames.com/Three/ColorGrading.html
  52932. *
  52933. */
  52934. export class ColorCorrectionPostProcess extends PostProcess {
  52935. private _colorTableTexture;
  52936. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52937. }
  52938. }
  52939. declare module BABYLON {
  52940. /** @hidden */
  52941. export var convolutionPixelShader: {
  52942. name: string;
  52943. shader: string;
  52944. };
  52945. }
  52946. declare module BABYLON {
  52947. /**
  52948. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  52949. * input texture to perform effects such as edge detection or sharpening
  52950. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52951. */
  52952. export class ConvolutionPostProcess extends PostProcess {
  52953. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52954. kernel: number[];
  52955. /**
  52956. * Creates a new instance ConvolutionPostProcess
  52957. * @param name The name of the effect.
  52958. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  52959. * @param options The required width/height ratio to downsize to before computing the render pass.
  52960. * @param camera The camera to apply the render pass to.
  52961. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52962. * @param engine The engine which the post process will be applied. (default: current engine)
  52963. * @param reusable If the post process can be reused on the same frame. (default: false)
  52964. * @param textureType Type of textures used when performing the post process. (default: 0)
  52965. */
  52966. constructor(name: string,
  52967. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  52968. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52969. /**
  52970. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52971. */
  52972. static EdgeDetect0Kernel: number[];
  52973. /**
  52974. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52975. */
  52976. static EdgeDetect1Kernel: number[];
  52977. /**
  52978. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52979. */
  52980. static EdgeDetect2Kernel: number[];
  52981. /**
  52982. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52983. */
  52984. static SharpenKernel: number[];
  52985. /**
  52986. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52987. */
  52988. static EmbossKernel: number[];
  52989. /**
  52990. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  52991. */
  52992. static GaussianKernel: number[];
  52993. }
  52994. }
  52995. declare module BABYLON {
  52996. /**
  52997. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  52998. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  52999. * based on samples that have a large difference in distance than the center pixel.
  53000. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53001. */
  53002. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53003. direction: Vector2;
  53004. /**
  53005. * Creates a new instance CircleOfConfusionPostProcess
  53006. * @param name The name of the effect.
  53007. * @param scene The scene the effect belongs to.
  53008. * @param direction The direction the blur should be applied.
  53009. * @param kernel The size of the kernel used to blur.
  53010. * @param options The required width/height ratio to downsize to before computing the render pass.
  53011. * @param camera The camera to apply the render pass to.
  53012. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53013. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53014. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53015. * @param engine The engine which the post process will be applied. (default: current engine)
  53016. * @param reusable If the post process can be reused on the same frame. (default: false)
  53017. * @param textureType Type of textures used when performing the post process. (default: 0)
  53018. * @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)
  53019. */
  53020. 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);
  53021. }
  53022. }
  53023. declare module BABYLON {
  53024. /** @hidden */
  53025. export var depthOfFieldMergePixelShader: {
  53026. name: string;
  53027. shader: string;
  53028. };
  53029. }
  53030. declare module BABYLON {
  53031. /**
  53032. * Options to be set when merging outputs from the default pipeline.
  53033. */
  53034. export class DepthOfFieldMergePostProcessOptions {
  53035. /**
  53036. * The original image to merge on top of
  53037. */
  53038. originalFromInput: PostProcess;
  53039. /**
  53040. * Parameters to perform the merge of the depth of field effect
  53041. */
  53042. depthOfField?: {
  53043. circleOfConfusion: PostProcess;
  53044. blurSteps: Array<PostProcess>;
  53045. };
  53046. /**
  53047. * Parameters to perform the merge of bloom effect
  53048. */
  53049. bloom?: {
  53050. blurred: PostProcess;
  53051. weight: number;
  53052. };
  53053. }
  53054. /**
  53055. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53056. */
  53057. export class DepthOfFieldMergePostProcess extends PostProcess {
  53058. private blurSteps;
  53059. /**
  53060. * Creates a new instance of DepthOfFieldMergePostProcess
  53061. * @param name The name of the effect.
  53062. * @param originalFromInput Post process which's input will be used for the merge.
  53063. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53064. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53065. * @param options The required width/height ratio to downsize to before computing the render pass.
  53066. * @param camera The camera to apply the render pass to.
  53067. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53068. * @param engine The engine which the post process will be applied. (default: current engine)
  53069. * @param reusable If the post process can be reused on the same frame. (default: false)
  53070. * @param textureType Type of textures used when performing the post process. (default: 0)
  53071. * @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)
  53072. */
  53073. 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);
  53074. /**
  53075. * Updates the effect with the current post process compile time values and recompiles the shader.
  53076. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53077. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53078. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53079. * @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
  53080. * @param onCompiled Called when the shader has been compiled.
  53081. * @param onError Called if there is an error when compiling a shader.
  53082. */
  53083. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53084. }
  53085. }
  53086. declare module BABYLON {
  53087. /**
  53088. * Specifies the level of max blur that should be applied when using the depth of field effect
  53089. */
  53090. export enum DepthOfFieldEffectBlurLevel {
  53091. /**
  53092. * Subtle blur
  53093. */
  53094. Low = 0,
  53095. /**
  53096. * Medium blur
  53097. */
  53098. Medium = 1,
  53099. /**
  53100. * Large blur
  53101. */
  53102. High = 2
  53103. }
  53104. /**
  53105. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53106. */
  53107. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53108. private _circleOfConfusion;
  53109. /**
  53110. * @hidden Internal, blurs from high to low
  53111. */
  53112. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53113. private _depthOfFieldBlurY;
  53114. private _dofMerge;
  53115. /**
  53116. * @hidden Internal post processes in depth of field effect
  53117. */
  53118. _effects: Array<PostProcess>;
  53119. /**
  53120. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53121. */
  53122. focalLength: number;
  53123. /**
  53124. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53125. */
  53126. fStop: number;
  53127. /**
  53128. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53129. */
  53130. focusDistance: number;
  53131. /**
  53132. * 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.
  53133. */
  53134. lensSize: number;
  53135. /**
  53136. * Creates a new instance DepthOfFieldEffect
  53137. * @param scene The scene the effect belongs to.
  53138. * @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.
  53139. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53140. * @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)
  53141. */
  53142. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53143. /**
  53144. * Get the current class name of the current effet
  53145. * @returns "DepthOfFieldEffect"
  53146. */
  53147. getClassName(): string;
  53148. /**
  53149. * 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.
  53150. */
  53151. depthTexture: RenderTargetTexture;
  53152. /**
  53153. * Disposes each of the internal effects for a given camera.
  53154. * @param camera The camera to dispose the effect on.
  53155. */
  53156. disposeEffects(camera: Camera): void;
  53157. /**
  53158. * @hidden Internal
  53159. */
  53160. _updateEffects(): void;
  53161. /**
  53162. * Internal
  53163. * @returns if all the contained post processes are ready.
  53164. * @hidden
  53165. */
  53166. _isReady(): boolean;
  53167. }
  53168. }
  53169. declare module BABYLON {
  53170. /** @hidden */
  53171. export var displayPassPixelShader: {
  53172. name: string;
  53173. shader: string;
  53174. };
  53175. }
  53176. declare module BABYLON {
  53177. /**
  53178. * DisplayPassPostProcess which produces an output the same as it's input
  53179. */
  53180. export class DisplayPassPostProcess extends PostProcess {
  53181. /**
  53182. * Creates the DisplayPassPostProcess
  53183. * @param name The name of the effect.
  53184. * @param options The required width/height ratio to downsize to before computing the render pass.
  53185. * @param camera The camera to apply the render pass to.
  53186. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53187. * @param engine The engine which the post process will be applied. (default: current engine)
  53188. * @param reusable If the post process can be reused on the same frame. (default: false)
  53189. */
  53190. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53191. }
  53192. }
  53193. declare module BABYLON {
  53194. /** @hidden */
  53195. export var filterPixelShader: {
  53196. name: string;
  53197. shader: string;
  53198. };
  53199. }
  53200. declare module BABYLON {
  53201. /**
  53202. * Applies a kernel filter to the image
  53203. */
  53204. export class FilterPostProcess extends PostProcess {
  53205. /** The matrix to be applied to the image */
  53206. kernelMatrix: Matrix;
  53207. /**
  53208. *
  53209. * @param name The name of the effect.
  53210. * @param kernelMatrix The matrix to be applied to the image
  53211. * @param options The required width/height ratio to downsize to before computing the render pass.
  53212. * @param camera The camera to apply the render pass to.
  53213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53214. * @param engine The engine which the post process will be applied. (default: current engine)
  53215. * @param reusable If the post process can be reused on the same frame. (default: false)
  53216. */
  53217. constructor(name: string,
  53218. /** The matrix to be applied to the image */
  53219. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53220. }
  53221. }
  53222. declare module BABYLON {
  53223. /** @hidden */
  53224. export var fxaaPixelShader: {
  53225. name: string;
  53226. shader: string;
  53227. };
  53228. }
  53229. declare module BABYLON {
  53230. /** @hidden */
  53231. export var fxaaVertexShader: {
  53232. name: string;
  53233. shader: string;
  53234. };
  53235. }
  53236. declare module BABYLON {
  53237. /**
  53238. * Fxaa post process
  53239. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53240. */
  53241. export class FxaaPostProcess extends PostProcess {
  53242. /** @hidden */
  53243. texelWidth: number;
  53244. /** @hidden */
  53245. texelHeight: number;
  53246. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53247. private _getDefines;
  53248. }
  53249. }
  53250. declare module BABYLON {
  53251. /** @hidden */
  53252. export var grainPixelShader: {
  53253. name: string;
  53254. shader: string;
  53255. };
  53256. }
  53257. declare module BABYLON {
  53258. /**
  53259. * The GrainPostProcess adds noise to the image at mid luminance levels
  53260. */
  53261. export class GrainPostProcess extends PostProcess {
  53262. /**
  53263. * The intensity of the grain added (default: 30)
  53264. */
  53265. intensity: number;
  53266. /**
  53267. * If the grain should be randomized on every frame
  53268. */
  53269. animated: boolean;
  53270. /**
  53271. * Creates a new instance of @see GrainPostProcess
  53272. * @param name The name of the effect.
  53273. * @param options The required width/height ratio to downsize to before computing the render pass.
  53274. * @param camera The camera to apply the render pass to.
  53275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53276. * @param engine The engine which the post process will be applied. (default: current engine)
  53277. * @param reusable If the post process can be reused on the same frame. (default: false)
  53278. * @param textureType Type of textures used when performing the post process. (default: 0)
  53279. * @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)
  53280. */
  53281. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53282. }
  53283. }
  53284. declare module BABYLON {
  53285. /** @hidden */
  53286. export var highlightsPixelShader: {
  53287. name: string;
  53288. shader: string;
  53289. };
  53290. }
  53291. declare module BABYLON {
  53292. /**
  53293. * Extracts highlights from the image
  53294. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53295. */
  53296. export class HighlightsPostProcess extends PostProcess {
  53297. /**
  53298. * Extracts highlights from the image
  53299. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53300. * @param name The name of the effect.
  53301. * @param options The required width/height ratio to downsize to before computing the render pass.
  53302. * @param camera The camera to apply the render pass to.
  53303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53304. * @param engine The engine which the post process will be applied. (default: current engine)
  53305. * @param reusable If the post process can be reused on the same frame. (default: false)
  53306. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53307. */
  53308. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53309. }
  53310. }
  53311. declare module BABYLON {
  53312. /** @hidden */
  53313. export var mrtFragmentDeclaration: {
  53314. name: string;
  53315. shader: string;
  53316. };
  53317. }
  53318. declare module BABYLON {
  53319. /** @hidden */
  53320. export var geometryPixelShader: {
  53321. name: string;
  53322. shader: string;
  53323. };
  53324. }
  53325. declare module BABYLON {
  53326. /** @hidden */
  53327. export var geometryVertexShader: {
  53328. name: string;
  53329. shader: string;
  53330. };
  53331. }
  53332. declare module BABYLON {
  53333. /** @hidden */
  53334. interface ISavedTransformationMatrix {
  53335. world: Matrix;
  53336. viewProjection: Matrix;
  53337. }
  53338. /**
  53339. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  53340. */
  53341. export class GeometryBufferRenderer {
  53342. /**
  53343. * Constant used to retrieve the position texture index in the G-Buffer textures array
  53344. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  53345. */
  53346. static readonly POSITION_TEXTURE_TYPE: number;
  53347. /**
  53348. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  53349. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  53350. */
  53351. static readonly VELOCITY_TEXTURE_TYPE: number;
  53352. /**
  53353. * Dictionary used to store the previous transformation matrices of each rendered mesh
  53354. * in order to compute objects velocities when enableVelocity is set to "true"
  53355. * @hidden
  53356. */
  53357. _previousTransformationMatrices: {
  53358. [index: number]: ISavedTransformationMatrix;
  53359. };
  53360. /**
  53361. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  53362. * in order to compute objects velocities when enableVelocity is set to "true"
  53363. * @hidden
  53364. */
  53365. _previousBonesTransformationMatrices: {
  53366. [index: number]: Float32Array;
  53367. };
  53368. /**
  53369. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  53370. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  53371. */
  53372. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  53373. private _scene;
  53374. private _multiRenderTarget;
  53375. private _ratio;
  53376. private _enablePosition;
  53377. private _enableVelocity;
  53378. private _positionIndex;
  53379. private _velocityIndex;
  53380. protected _effect: Effect;
  53381. protected _cachedDefines: string;
  53382. /**
  53383. * Set the render list (meshes to be rendered) used in the G buffer.
  53384. */
  53385. renderList: Mesh[];
  53386. /**
  53387. * Gets wether or not G buffer are supported by the running hardware.
  53388. * This requires draw buffer supports
  53389. */
  53390. readonly isSupported: boolean;
  53391. /**
  53392. * Returns the index of the given texture type in the G-Buffer textures array
  53393. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  53394. * @returns the index of the given texture type in the G-Buffer textures array
  53395. */
  53396. getTextureIndex(textureType: number): number;
  53397. /**
  53398. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  53399. */
  53400. /**
  53401. * Sets whether or not objects positions are enabled for the G buffer.
  53402. */
  53403. enablePosition: boolean;
  53404. /**
  53405. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  53406. */
  53407. /**
  53408. * Sets wether or not objects velocities are enabled for the G buffer.
  53409. */
  53410. enableVelocity: boolean;
  53411. /**
  53412. * Gets the scene associated with the buffer.
  53413. */
  53414. readonly scene: Scene;
  53415. /**
  53416. * Gets the ratio used by the buffer during its creation.
  53417. * How big is the buffer related to the main canvas.
  53418. */
  53419. readonly ratio: number;
  53420. /** @hidden */
  53421. static _SceneComponentInitialization: (scene: Scene) => void;
  53422. /**
  53423. * Creates a new G Buffer for the scene
  53424. * @param scene The scene the buffer belongs to
  53425. * @param ratio How big is the buffer related to the main canvas.
  53426. */
  53427. constructor(scene: Scene, ratio?: number);
  53428. /**
  53429. * Checks wether everything is ready to render a submesh to the G buffer.
  53430. * @param subMesh the submesh to check readiness for
  53431. * @param useInstances is the mesh drawn using instance or not
  53432. * @returns true if ready otherwise false
  53433. */
  53434. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53435. /**
  53436. * Gets the current underlying G Buffer.
  53437. * @returns the buffer
  53438. */
  53439. getGBuffer(): MultiRenderTarget;
  53440. /**
  53441. * Gets the number of samples used to render the buffer (anti aliasing).
  53442. */
  53443. /**
  53444. * Sets the number of samples used to render the buffer (anti aliasing).
  53445. */
  53446. samples: number;
  53447. /**
  53448. * Disposes the renderer and frees up associated resources.
  53449. */
  53450. dispose(): void;
  53451. protected _createRenderTargets(): void;
  53452. private _copyBonesTransformationMatrices;
  53453. }
  53454. }
  53455. declare module BABYLON {
  53456. interface Scene {
  53457. /** @hidden (Backing field) */
  53458. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53459. /**
  53460. * Gets or Sets the current geometry buffer associated to the scene.
  53461. */
  53462. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  53463. /**
  53464. * Enables a GeometryBufferRender and associates it with the scene
  53465. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  53466. * @returns the GeometryBufferRenderer
  53467. */
  53468. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  53469. /**
  53470. * Disables the GeometryBufferRender associated with the scene
  53471. */
  53472. disableGeometryBufferRenderer(): void;
  53473. }
  53474. /**
  53475. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  53476. * in several rendering techniques.
  53477. */
  53478. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  53479. /**
  53480. * The component name helpful to identify the component in the list of scene components.
  53481. */
  53482. readonly name: string;
  53483. /**
  53484. * The scene the component belongs to.
  53485. */
  53486. scene: Scene;
  53487. /**
  53488. * Creates a new instance of the component for the given scene
  53489. * @param scene Defines the scene to register the component in
  53490. */
  53491. constructor(scene: Scene);
  53492. /**
  53493. * Registers the component in a given scene
  53494. */
  53495. register(): void;
  53496. /**
  53497. * Rebuilds the elements related to this component in case of
  53498. * context lost for instance.
  53499. */
  53500. rebuild(): void;
  53501. /**
  53502. * Disposes the component and the associated ressources
  53503. */
  53504. dispose(): void;
  53505. private _gatherRenderTargets;
  53506. }
  53507. }
  53508. declare module BABYLON {
  53509. /** @hidden */
  53510. export var motionBlurPixelShader: {
  53511. name: string;
  53512. shader: string;
  53513. };
  53514. }
  53515. declare module BABYLON {
  53516. /**
  53517. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  53518. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  53519. * As an example, all you have to do is to create the post-process:
  53520. * var mb = new BABYLON.MotionBlurPostProcess(
  53521. * 'mb', // The name of the effect.
  53522. * scene, // The scene containing the objects to blur according to their velocity.
  53523. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  53524. * camera // The camera to apply the render pass to.
  53525. * );
  53526. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  53527. */
  53528. export class MotionBlurPostProcess extends PostProcess {
  53529. /**
  53530. * Defines how much the image is blurred by the movement. Default value is equal to 1
  53531. */
  53532. motionStrength: number;
  53533. /**
  53534. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  53535. */
  53536. /**
  53537. * Sets the number of iterations to be used for motion blur quality
  53538. */
  53539. motionBlurSamples: number;
  53540. private _motionBlurSamples;
  53541. private _geometryBufferRenderer;
  53542. /**
  53543. * Creates a new instance MotionBlurPostProcess
  53544. * @param name The name of the effect.
  53545. * @param scene The scene containing the objects to blur according to their velocity.
  53546. * @param options The required width/height ratio to downsize to before computing the render pass.
  53547. * @param camera The camera to apply the render pass to.
  53548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53549. * @param engine The engine which the post process will be applied. (default: current engine)
  53550. * @param reusable If the post process can be reused on the same frame. (default: false)
  53551. * @param textureType Type of textures used when performing the post process. (default: 0)
  53552. * @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)
  53553. */
  53554. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53555. /**
  53556. * Excludes the given skinned mesh from computing bones velocities.
  53557. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  53558. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  53559. */
  53560. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  53561. /**
  53562. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  53563. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  53564. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  53565. */
  53566. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  53567. /**
  53568. * Disposes the post process.
  53569. * @param camera The camera to dispose the post process on.
  53570. */
  53571. dispose(camera?: Camera): void;
  53572. }
  53573. }
  53574. declare module BABYLON {
  53575. /** @hidden */
  53576. export var refractionPixelShader: {
  53577. name: string;
  53578. shader: string;
  53579. };
  53580. }
  53581. declare module BABYLON {
  53582. /**
  53583. * Post process which applies a refractin texture
  53584. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53585. */
  53586. export class RefractionPostProcess extends PostProcess {
  53587. /** the base color of the refraction (used to taint the rendering) */
  53588. color: Color3;
  53589. /** simulated refraction depth */
  53590. depth: number;
  53591. /** the coefficient of the base color (0 to remove base color tainting) */
  53592. colorLevel: number;
  53593. private _refTexture;
  53594. private _ownRefractionTexture;
  53595. /**
  53596. * Gets or sets the refraction texture
  53597. * Please note that you are responsible for disposing the texture if you set it manually
  53598. */
  53599. refractionTexture: Texture;
  53600. /**
  53601. * Initializes the RefractionPostProcess
  53602. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  53603. * @param name The name of the effect.
  53604. * @param refractionTextureUrl Url of the refraction texture to use
  53605. * @param color the base color of the refraction (used to taint the rendering)
  53606. * @param depth simulated refraction depth
  53607. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  53608. * @param camera The camera to apply the render pass to.
  53609. * @param options The required width/height ratio to downsize to before computing the render pass.
  53610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53611. * @param engine The engine which the post process will be applied. (default: current engine)
  53612. * @param reusable If the post process can be reused on the same frame. (default: false)
  53613. */
  53614. constructor(name: string, refractionTextureUrl: string,
  53615. /** the base color of the refraction (used to taint the rendering) */
  53616. color: Color3,
  53617. /** simulated refraction depth */
  53618. depth: number,
  53619. /** the coefficient of the base color (0 to remove base color tainting) */
  53620. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53621. /**
  53622. * Disposes of the post process
  53623. * @param camera Camera to dispose post process on
  53624. */
  53625. dispose(camera: Camera): void;
  53626. }
  53627. }
  53628. declare module BABYLON {
  53629. /** @hidden */
  53630. export var sharpenPixelShader: {
  53631. name: string;
  53632. shader: string;
  53633. };
  53634. }
  53635. declare module BABYLON {
  53636. /**
  53637. * The SharpenPostProcess applies a sharpen kernel to every pixel
  53638. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53639. */
  53640. export class SharpenPostProcess extends PostProcess {
  53641. /**
  53642. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  53643. */
  53644. colorAmount: number;
  53645. /**
  53646. * How much sharpness should be applied (default: 0.3)
  53647. */
  53648. edgeAmount: number;
  53649. /**
  53650. * Creates a new instance ConvolutionPostProcess
  53651. * @param name The name of the effect.
  53652. * @param options The required width/height ratio to downsize to before computing the render pass.
  53653. * @param camera The camera to apply the render pass to.
  53654. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53655. * @param engine The engine which the post process will be applied. (default: current engine)
  53656. * @param reusable If the post process can be reused on the same frame. (default: false)
  53657. * @param textureType Type of textures used when performing the post process. (default: 0)
  53658. * @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)
  53659. */
  53660. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53661. }
  53662. }
  53663. declare module BABYLON {
  53664. /**
  53665. * PostProcessRenderPipeline
  53666. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53667. */
  53668. export class PostProcessRenderPipeline {
  53669. private engine;
  53670. private _renderEffects;
  53671. private _renderEffectsForIsolatedPass;
  53672. /**
  53673. * List of inspectable custom properties (used by the Inspector)
  53674. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  53675. */
  53676. inspectableCustomProperties: IInspectable[];
  53677. /**
  53678. * @hidden
  53679. */
  53680. protected _cameras: Camera[];
  53681. /** @hidden */
  53682. _name: string;
  53683. /**
  53684. * Gets pipeline name
  53685. */
  53686. readonly name: string;
  53687. /**
  53688. * Initializes a PostProcessRenderPipeline
  53689. * @param engine engine to add the pipeline to
  53690. * @param name name of the pipeline
  53691. */
  53692. constructor(engine: Engine, name: string);
  53693. /**
  53694. * Gets the class name
  53695. * @returns "PostProcessRenderPipeline"
  53696. */
  53697. getClassName(): string;
  53698. /**
  53699. * If all the render effects in the pipeline are supported
  53700. */
  53701. readonly isSupported: boolean;
  53702. /**
  53703. * Adds an effect to the pipeline
  53704. * @param renderEffect the effect to add
  53705. */
  53706. addEffect(renderEffect: PostProcessRenderEffect): void;
  53707. /** @hidden */
  53708. _rebuild(): void;
  53709. /** @hidden */
  53710. _enableEffect(renderEffectName: string, cameras: Camera): void;
  53711. /** @hidden */
  53712. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  53713. /** @hidden */
  53714. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53715. /** @hidden */
  53716. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  53717. /** @hidden */
  53718. _attachCameras(cameras: Camera, unique: boolean): void;
  53719. /** @hidden */
  53720. _attachCameras(cameras: Camera[], unique: boolean): void;
  53721. /** @hidden */
  53722. _detachCameras(cameras: Camera): void;
  53723. /** @hidden */
  53724. _detachCameras(cameras: Nullable<Camera[]>): void;
  53725. /** @hidden */
  53726. _update(): void;
  53727. /** @hidden */
  53728. _reset(): void;
  53729. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  53730. /**
  53731. * Disposes of the pipeline
  53732. */
  53733. dispose(): void;
  53734. }
  53735. }
  53736. declare module BABYLON {
  53737. /**
  53738. * PostProcessRenderPipelineManager class
  53739. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53740. */
  53741. export class PostProcessRenderPipelineManager {
  53742. private _renderPipelines;
  53743. /**
  53744. * Initializes a PostProcessRenderPipelineManager
  53745. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53746. */
  53747. constructor();
  53748. /**
  53749. * Gets the list of supported render pipelines
  53750. */
  53751. readonly supportedPipelines: PostProcessRenderPipeline[];
  53752. /**
  53753. * Adds a pipeline to the manager
  53754. * @param renderPipeline The pipeline to add
  53755. */
  53756. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53757. /**
  53758. * Attaches a camera to the pipeline
  53759. * @param renderPipelineName The name of the pipeline to attach to
  53760. * @param cameras the camera to attach
  53761. * @param unique if the camera can be attached multiple times to the pipeline
  53762. */
  53763. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53764. /**
  53765. * Detaches a camera from the pipeline
  53766. * @param renderPipelineName The name of the pipeline to detach from
  53767. * @param cameras the camera to detach
  53768. */
  53769. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53770. /**
  53771. * Enables an effect by name on a pipeline
  53772. * @param renderPipelineName the name of the pipeline to enable the effect in
  53773. * @param renderEffectName the name of the effect to enable
  53774. * @param cameras the cameras that the effect should be enabled on
  53775. */
  53776. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53777. /**
  53778. * Disables an effect by name on a pipeline
  53779. * @param renderPipelineName the name of the pipeline to disable the effect in
  53780. * @param renderEffectName the name of the effect to disable
  53781. * @param cameras the cameras that the effect should be disabled on
  53782. */
  53783. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53784. /**
  53785. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53786. */
  53787. update(): void;
  53788. /** @hidden */
  53789. _rebuild(): void;
  53790. /**
  53791. * Disposes of the manager and pipelines
  53792. */
  53793. dispose(): void;
  53794. }
  53795. }
  53796. declare module BABYLON {
  53797. interface Scene {
  53798. /** @hidden (Backing field) */
  53799. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53800. /**
  53801. * Gets the postprocess render pipeline manager
  53802. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53803. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53804. */
  53805. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53806. }
  53807. /**
  53808. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53809. */
  53810. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53811. /**
  53812. * The component name helpfull to identify the component in the list of scene components.
  53813. */
  53814. readonly name: string;
  53815. /**
  53816. * The scene the component belongs to.
  53817. */
  53818. scene: Scene;
  53819. /**
  53820. * Creates a new instance of the component for the given scene
  53821. * @param scene Defines the scene to register the component in
  53822. */
  53823. constructor(scene: Scene);
  53824. /**
  53825. * Registers the component in a given scene
  53826. */
  53827. register(): void;
  53828. /**
  53829. * Rebuilds the elements related to this component in case of
  53830. * context lost for instance.
  53831. */
  53832. rebuild(): void;
  53833. /**
  53834. * Disposes the component and the associated ressources
  53835. */
  53836. dispose(): void;
  53837. private _gatherRenderTargets;
  53838. }
  53839. }
  53840. declare module BABYLON {
  53841. /**
  53842. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  53843. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53844. */
  53845. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53846. private _scene;
  53847. private _camerasToBeAttached;
  53848. /**
  53849. * ID of the sharpen post process,
  53850. */
  53851. private readonly SharpenPostProcessId;
  53852. /**
  53853. * @ignore
  53854. * ID of the image processing post process;
  53855. */
  53856. readonly ImageProcessingPostProcessId: string;
  53857. /**
  53858. * @ignore
  53859. * ID of the Fast Approximate Anti-Aliasing post process;
  53860. */
  53861. readonly FxaaPostProcessId: string;
  53862. /**
  53863. * ID of the chromatic aberration post process,
  53864. */
  53865. private readonly ChromaticAberrationPostProcessId;
  53866. /**
  53867. * ID of the grain post process
  53868. */
  53869. private readonly GrainPostProcessId;
  53870. /**
  53871. * Sharpen post process which will apply a sharpen convolution to enhance edges
  53872. */
  53873. sharpen: SharpenPostProcess;
  53874. private _sharpenEffect;
  53875. private bloom;
  53876. /**
  53877. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  53878. */
  53879. depthOfField: DepthOfFieldEffect;
  53880. /**
  53881. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53882. */
  53883. fxaa: FxaaPostProcess;
  53884. /**
  53885. * Image post processing pass used to perform operations such as tone mapping or color grading.
  53886. */
  53887. imageProcessing: ImageProcessingPostProcess;
  53888. /**
  53889. * Chromatic aberration post process which will shift rgb colors in the image
  53890. */
  53891. chromaticAberration: ChromaticAberrationPostProcess;
  53892. private _chromaticAberrationEffect;
  53893. /**
  53894. * Grain post process which add noise to the image
  53895. */
  53896. grain: GrainPostProcess;
  53897. private _grainEffect;
  53898. /**
  53899. * Glow post process which adds a glow to emissive areas of the image
  53900. */
  53901. private _glowLayer;
  53902. /**
  53903. * Animations which can be used to tweak settings over a period of time
  53904. */
  53905. animations: Animation[];
  53906. private _imageProcessingConfigurationObserver;
  53907. private _sharpenEnabled;
  53908. private _bloomEnabled;
  53909. private _depthOfFieldEnabled;
  53910. private _depthOfFieldBlurLevel;
  53911. private _fxaaEnabled;
  53912. private _imageProcessingEnabled;
  53913. private _defaultPipelineTextureType;
  53914. private _bloomScale;
  53915. private _chromaticAberrationEnabled;
  53916. private _grainEnabled;
  53917. private _buildAllowed;
  53918. /**
  53919. * Gets active scene
  53920. */
  53921. readonly scene: Scene;
  53922. /**
  53923. * Enable or disable the sharpen process from the pipeline
  53924. */
  53925. sharpenEnabled: boolean;
  53926. private _resizeObserver;
  53927. private _hardwareScaleLevel;
  53928. private _bloomKernel;
  53929. /**
  53930. * Specifies the size of the bloom blur kernel, relative to the final output size
  53931. */
  53932. bloomKernel: number;
  53933. /**
  53934. * Specifies the weight of the bloom in the final rendering
  53935. */
  53936. private _bloomWeight;
  53937. /**
  53938. * Specifies the luma threshold for the area that will be blurred by the bloom
  53939. */
  53940. private _bloomThreshold;
  53941. private _hdr;
  53942. /**
  53943. * The strength of the bloom.
  53944. */
  53945. bloomWeight: number;
  53946. /**
  53947. * The strength of the bloom.
  53948. */
  53949. bloomThreshold: number;
  53950. /**
  53951. * The scale of the bloom, lower value will provide better performance.
  53952. */
  53953. bloomScale: number;
  53954. /**
  53955. * Enable or disable the bloom from the pipeline
  53956. */
  53957. bloomEnabled: boolean;
  53958. private _rebuildBloom;
  53959. /**
  53960. * If the depth of field is enabled.
  53961. */
  53962. depthOfFieldEnabled: boolean;
  53963. /**
  53964. * Blur level of the depth of field effect. (Higher blur will effect performance)
  53965. */
  53966. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  53967. /**
  53968. * If the anti aliasing is enabled.
  53969. */
  53970. fxaaEnabled: boolean;
  53971. private _samples;
  53972. /**
  53973. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53974. */
  53975. samples: number;
  53976. /**
  53977. * If image processing is enabled.
  53978. */
  53979. imageProcessingEnabled: boolean;
  53980. /**
  53981. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  53982. */
  53983. glowLayerEnabled: boolean;
  53984. /**
  53985. * Gets the glow layer (or null if not defined)
  53986. */
  53987. readonly glowLayer: Nullable<GlowLayer>;
  53988. /**
  53989. * Enable or disable the chromaticAberration process from the pipeline
  53990. */
  53991. chromaticAberrationEnabled: boolean;
  53992. /**
  53993. * Enable or disable the grain process from the pipeline
  53994. */
  53995. grainEnabled: boolean;
  53996. /**
  53997. * @constructor
  53998. * @param name - The rendering pipeline name (default: "")
  53999. * @param hdr - If high dynamic range textures should be used (default: true)
  54000. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54001. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54002. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54003. */
  54004. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54005. /**
  54006. * Get the class name
  54007. * @returns "DefaultRenderingPipeline"
  54008. */
  54009. getClassName(): string;
  54010. /**
  54011. * Force the compilation of the entire pipeline.
  54012. */
  54013. prepare(): void;
  54014. private _hasCleared;
  54015. private _prevPostProcess;
  54016. private _prevPrevPostProcess;
  54017. private _setAutoClearAndTextureSharing;
  54018. private _depthOfFieldSceneObserver;
  54019. private _buildPipeline;
  54020. private _disposePostProcesses;
  54021. /**
  54022. * Adds a camera to the pipeline
  54023. * @param camera the camera to be added
  54024. */
  54025. addCamera(camera: Camera): void;
  54026. /**
  54027. * Removes a camera from the pipeline
  54028. * @param camera the camera to remove
  54029. */
  54030. removeCamera(camera: Camera): void;
  54031. /**
  54032. * Dispose of the pipeline and stop all post processes
  54033. */
  54034. dispose(): void;
  54035. /**
  54036. * Serialize the rendering pipeline (Used when exporting)
  54037. * @returns the serialized object
  54038. */
  54039. serialize(): any;
  54040. /**
  54041. * Parse the serialized pipeline
  54042. * @param source Source pipeline.
  54043. * @param scene The scene to load the pipeline to.
  54044. * @param rootUrl The URL of the serialized pipeline.
  54045. * @returns An instantiated pipeline from the serialized object.
  54046. */
  54047. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54048. }
  54049. }
  54050. declare module BABYLON {
  54051. /** @hidden */
  54052. export var lensHighlightsPixelShader: {
  54053. name: string;
  54054. shader: string;
  54055. };
  54056. }
  54057. declare module BABYLON {
  54058. /** @hidden */
  54059. export var depthOfFieldPixelShader: {
  54060. name: string;
  54061. shader: string;
  54062. };
  54063. }
  54064. declare module BABYLON {
  54065. /**
  54066. * BABYLON.JS Chromatic Aberration GLSL Shader
  54067. * Author: Olivier Guyot
  54068. * Separates very slightly R, G and B colors on the edges of the screen
  54069. * Inspired by Francois Tarlier & Martins Upitis
  54070. */
  54071. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54072. /**
  54073. * @ignore
  54074. * The chromatic aberration PostProcess id in the pipeline
  54075. */
  54076. LensChromaticAberrationEffect: string;
  54077. /**
  54078. * @ignore
  54079. * The highlights enhancing PostProcess id in the pipeline
  54080. */
  54081. HighlightsEnhancingEffect: string;
  54082. /**
  54083. * @ignore
  54084. * The depth-of-field PostProcess id in the pipeline
  54085. */
  54086. LensDepthOfFieldEffect: string;
  54087. private _scene;
  54088. private _depthTexture;
  54089. private _grainTexture;
  54090. private _chromaticAberrationPostProcess;
  54091. private _highlightsPostProcess;
  54092. private _depthOfFieldPostProcess;
  54093. private _edgeBlur;
  54094. private _grainAmount;
  54095. private _chromaticAberration;
  54096. private _distortion;
  54097. private _highlightsGain;
  54098. private _highlightsThreshold;
  54099. private _dofDistance;
  54100. private _dofAperture;
  54101. private _dofDarken;
  54102. private _dofPentagon;
  54103. private _blurNoise;
  54104. /**
  54105. * @constructor
  54106. *
  54107. * Effect parameters are as follow:
  54108. * {
  54109. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54110. * edge_blur: number; // from 0 to x (1 for realism)
  54111. * distortion: number; // from 0 to x (1 for realism)
  54112. * grain_amount: number; // from 0 to 1
  54113. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54114. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54115. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54116. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54117. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54118. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54119. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54120. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54121. * }
  54122. * Note: if an effect parameter is unset, effect is disabled
  54123. *
  54124. * @param name The rendering pipeline name
  54125. * @param parameters - An object containing all parameters (see above)
  54126. * @param scene The scene linked to this pipeline
  54127. * @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)
  54128. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54129. */
  54130. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54131. /**
  54132. * Get the class name
  54133. * @returns "LensRenderingPipeline"
  54134. */
  54135. getClassName(): string;
  54136. /**
  54137. * Gets associated scene
  54138. */
  54139. readonly scene: Scene;
  54140. /**
  54141. * Gets or sets the edge blur
  54142. */
  54143. edgeBlur: number;
  54144. /**
  54145. * Gets or sets the grain amount
  54146. */
  54147. grainAmount: number;
  54148. /**
  54149. * Gets or sets the chromatic aberration amount
  54150. */
  54151. chromaticAberration: number;
  54152. /**
  54153. * Gets or sets the depth of field aperture
  54154. */
  54155. dofAperture: number;
  54156. /**
  54157. * Gets or sets the edge distortion
  54158. */
  54159. edgeDistortion: number;
  54160. /**
  54161. * Gets or sets the depth of field distortion
  54162. */
  54163. dofDistortion: number;
  54164. /**
  54165. * Gets or sets the darken out of focus amount
  54166. */
  54167. darkenOutOfFocus: number;
  54168. /**
  54169. * Gets or sets a boolean indicating if blur noise is enabled
  54170. */
  54171. blurNoise: boolean;
  54172. /**
  54173. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  54174. */
  54175. pentagonBokeh: boolean;
  54176. /**
  54177. * Gets or sets the highlight grain amount
  54178. */
  54179. highlightsGain: number;
  54180. /**
  54181. * Gets or sets the highlight threshold
  54182. */
  54183. highlightsThreshold: number;
  54184. /**
  54185. * Sets the amount of blur at the edges
  54186. * @param amount blur amount
  54187. */
  54188. setEdgeBlur(amount: number): void;
  54189. /**
  54190. * Sets edge blur to 0
  54191. */
  54192. disableEdgeBlur(): void;
  54193. /**
  54194. * Sets the amout of grain
  54195. * @param amount Amount of grain
  54196. */
  54197. setGrainAmount(amount: number): void;
  54198. /**
  54199. * Set grain amount to 0
  54200. */
  54201. disableGrain(): void;
  54202. /**
  54203. * Sets the chromatic aberration amount
  54204. * @param amount amount of chromatic aberration
  54205. */
  54206. setChromaticAberration(amount: number): void;
  54207. /**
  54208. * Sets chromatic aberration amount to 0
  54209. */
  54210. disableChromaticAberration(): void;
  54211. /**
  54212. * Sets the EdgeDistortion amount
  54213. * @param amount amount of EdgeDistortion
  54214. */
  54215. setEdgeDistortion(amount: number): void;
  54216. /**
  54217. * Sets edge distortion to 0
  54218. */
  54219. disableEdgeDistortion(): void;
  54220. /**
  54221. * Sets the FocusDistance amount
  54222. * @param amount amount of FocusDistance
  54223. */
  54224. setFocusDistance(amount: number): void;
  54225. /**
  54226. * Disables depth of field
  54227. */
  54228. disableDepthOfField(): void;
  54229. /**
  54230. * Sets the Aperture amount
  54231. * @param amount amount of Aperture
  54232. */
  54233. setAperture(amount: number): void;
  54234. /**
  54235. * Sets the DarkenOutOfFocus amount
  54236. * @param amount amount of DarkenOutOfFocus
  54237. */
  54238. setDarkenOutOfFocus(amount: number): void;
  54239. private _pentagonBokehIsEnabled;
  54240. /**
  54241. * Creates a pentagon bokeh effect
  54242. */
  54243. enablePentagonBokeh(): void;
  54244. /**
  54245. * Disables the pentagon bokeh effect
  54246. */
  54247. disablePentagonBokeh(): void;
  54248. /**
  54249. * Enables noise blur
  54250. */
  54251. enableNoiseBlur(): void;
  54252. /**
  54253. * Disables noise blur
  54254. */
  54255. disableNoiseBlur(): void;
  54256. /**
  54257. * Sets the HighlightsGain amount
  54258. * @param amount amount of HighlightsGain
  54259. */
  54260. setHighlightsGain(amount: number): void;
  54261. /**
  54262. * Sets the HighlightsThreshold amount
  54263. * @param amount amount of HighlightsThreshold
  54264. */
  54265. setHighlightsThreshold(amount: number): void;
  54266. /**
  54267. * Disables highlights
  54268. */
  54269. disableHighlights(): void;
  54270. /**
  54271. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54272. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54273. */
  54274. dispose(disableDepthRender?: boolean): void;
  54275. private _createChromaticAberrationPostProcess;
  54276. private _createHighlightsPostProcess;
  54277. private _createDepthOfFieldPostProcess;
  54278. private _createGrainTexture;
  54279. }
  54280. }
  54281. declare module BABYLON {
  54282. /** @hidden */
  54283. export var ssao2PixelShader: {
  54284. name: string;
  54285. shader: string;
  54286. };
  54287. }
  54288. declare module BABYLON {
  54289. /** @hidden */
  54290. export var ssaoCombinePixelShader: {
  54291. name: string;
  54292. shader: string;
  54293. };
  54294. }
  54295. declare module BABYLON {
  54296. /**
  54297. * Render pipeline to produce ssao effect
  54298. */
  54299. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54300. /**
  54301. * @ignore
  54302. * The PassPostProcess id in the pipeline that contains the original scene color
  54303. */
  54304. SSAOOriginalSceneColorEffect: string;
  54305. /**
  54306. * @ignore
  54307. * The SSAO PostProcess id in the pipeline
  54308. */
  54309. SSAORenderEffect: string;
  54310. /**
  54311. * @ignore
  54312. * The horizontal blur PostProcess id in the pipeline
  54313. */
  54314. SSAOBlurHRenderEffect: string;
  54315. /**
  54316. * @ignore
  54317. * The vertical blur PostProcess id in the pipeline
  54318. */
  54319. SSAOBlurVRenderEffect: string;
  54320. /**
  54321. * @ignore
  54322. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54323. */
  54324. SSAOCombineRenderEffect: string;
  54325. /**
  54326. * The output strength of the SSAO post-process. Default value is 1.0.
  54327. */
  54328. totalStrength: number;
  54329. /**
  54330. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54331. */
  54332. maxZ: number;
  54333. /**
  54334. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54335. */
  54336. minZAspect: number;
  54337. private _samples;
  54338. /**
  54339. * Number of samples used for the SSAO calculations. Default value is 8
  54340. */
  54341. samples: number;
  54342. private _textureSamples;
  54343. /**
  54344. * Number of samples to use for antialiasing
  54345. */
  54346. textureSamples: number;
  54347. /**
  54348. * Ratio object used for SSAO ratio and blur ratio
  54349. */
  54350. private _ratio;
  54351. /**
  54352. * Dynamically generated sphere sampler.
  54353. */
  54354. private _sampleSphere;
  54355. /**
  54356. * Blur filter offsets
  54357. */
  54358. private _samplerOffsets;
  54359. private _expensiveBlur;
  54360. /**
  54361. * If bilateral blur should be used
  54362. */
  54363. expensiveBlur: boolean;
  54364. /**
  54365. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  54366. */
  54367. radius: number;
  54368. /**
  54369. * The base color of the SSAO post-process
  54370. * The final result is "base + ssao" between [0, 1]
  54371. */
  54372. base: number;
  54373. /**
  54374. * Support test.
  54375. */
  54376. static readonly IsSupported: boolean;
  54377. private _scene;
  54378. private _depthTexture;
  54379. private _normalTexture;
  54380. private _randomTexture;
  54381. private _originalColorPostProcess;
  54382. private _ssaoPostProcess;
  54383. private _blurHPostProcess;
  54384. private _blurVPostProcess;
  54385. private _ssaoCombinePostProcess;
  54386. private _firstUpdate;
  54387. /**
  54388. * Gets active scene
  54389. */
  54390. readonly scene: Scene;
  54391. /**
  54392. * @constructor
  54393. * @param name The rendering pipeline name
  54394. * @param scene The scene linked to this pipeline
  54395. * @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 }
  54396. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54397. */
  54398. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54399. /**
  54400. * Get the class name
  54401. * @returns "SSAO2RenderingPipeline"
  54402. */
  54403. getClassName(): string;
  54404. /**
  54405. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54406. */
  54407. dispose(disableGeometryBufferRenderer?: boolean): void;
  54408. private _createBlurPostProcess;
  54409. /** @hidden */
  54410. _rebuild(): void;
  54411. private _bits;
  54412. private _radicalInverse_VdC;
  54413. private _hammersley;
  54414. private _hemisphereSample_uniform;
  54415. private _generateHemisphere;
  54416. private _createSSAOPostProcess;
  54417. private _createSSAOCombinePostProcess;
  54418. private _createRandomTexture;
  54419. /**
  54420. * Serialize the rendering pipeline (Used when exporting)
  54421. * @returns the serialized object
  54422. */
  54423. serialize(): any;
  54424. /**
  54425. * Parse the serialized pipeline
  54426. * @param source Source pipeline.
  54427. * @param scene The scene to load the pipeline to.
  54428. * @param rootUrl The URL of the serialized pipeline.
  54429. * @returns An instantiated pipeline from the serialized object.
  54430. */
  54431. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  54432. }
  54433. }
  54434. declare module BABYLON {
  54435. /** @hidden */
  54436. export var ssaoPixelShader: {
  54437. name: string;
  54438. shader: string;
  54439. };
  54440. }
  54441. declare module BABYLON {
  54442. /**
  54443. * Render pipeline to produce ssao effect
  54444. */
  54445. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  54446. /**
  54447. * @ignore
  54448. * The PassPostProcess id in the pipeline that contains the original scene color
  54449. */
  54450. SSAOOriginalSceneColorEffect: string;
  54451. /**
  54452. * @ignore
  54453. * The SSAO PostProcess id in the pipeline
  54454. */
  54455. SSAORenderEffect: string;
  54456. /**
  54457. * @ignore
  54458. * The horizontal blur PostProcess id in the pipeline
  54459. */
  54460. SSAOBlurHRenderEffect: string;
  54461. /**
  54462. * @ignore
  54463. * The vertical blur PostProcess id in the pipeline
  54464. */
  54465. SSAOBlurVRenderEffect: string;
  54466. /**
  54467. * @ignore
  54468. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54469. */
  54470. SSAOCombineRenderEffect: string;
  54471. /**
  54472. * The output strength of the SSAO post-process. Default value is 1.0.
  54473. */
  54474. totalStrength: number;
  54475. /**
  54476. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  54477. */
  54478. radius: number;
  54479. /**
  54480. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  54481. * Must not be equal to fallOff and superior to fallOff.
  54482. * Default value is 0.0075
  54483. */
  54484. area: number;
  54485. /**
  54486. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  54487. * Must not be equal to area and inferior to area.
  54488. * Default value is 0.000001
  54489. */
  54490. fallOff: number;
  54491. /**
  54492. * The base color of the SSAO post-process
  54493. * The final result is "base + ssao" between [0, 1]
  54494. */
  54495. base: number;
  54496. private _scene;
  54497. private _depthTexture;
  54498. private _randomTexture;
  54499. private _originalColorPostProcess;
  54500. private _ssaoPostProcess;
  54501. private _blurHPostProcess;
  54502. private _blurVPostProcess;
  54503. private _ssaoCombinePostProcess;
  54504. private _firstUpdate;
  54505. /**
  54506. * Gets active scene
  54507. */
  54508. readonly scene: Scene;
  54509. /**
  54510. * @constructor
  54511. * @param name - The rendering pipeline name
  54512. * @param scene - The scene linked to this pipeline
  54513. * @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 }
  54514. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  54515. */
  54516. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  54517. /**
  54518. * Get the class name
  54519. * @returns "SSAORenderingPipeline"
  54520. */
  54521. getClassName(): string;
  54522. /**
  54523. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  54524. */
  54525. dispose(disableDepthRender?: boolean): void;
  54526. private _createBlurPostProcess;
  54527. /** @hidden */
  54528. _rebuild(): void;
  54529. private _createSSAOPostProcess;
  54530. private _createSSAOCombinePostProcess;
  54531. private _createRandomTexture;
  54532. }
  54533. }
  54534. declare module BABYLON {
  54535. /** @hidden */
  54536. export var standardPixelShader: {
  54537. name: string;
  54538. shader: string;
  54539. };
  54540. }
  54541. declare module BABYLON {
  54542. /**
  54543. * Standard rendering pipeline
  54544. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54545. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  54546. */
  54547. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54548. /**
  54549. * Public members
  54550. */
  54551. /**
  54552. * Post-process which contains the original scene color before the pipeline applies all the effects
  54553. */
  54554. originalPostProcess: Nullable<PostProcess>;
  54555. /**
  54556. * Post-process used to down scale an image x4
  54557. */
  54558. downSampleX4PostProcess: Nullable<PostProcess>;
  54559. /**
  54560. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  54561. */
  54562. brightPassPostProcess: Nullable<PostProcess>;
  54563. /**
  54564. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  54565. */
  54566. blurHPostProcesses: PostProcess[];
  54567. /**
  54568. * Post-process array storing all the vertical blur post-processes used by the pipeline
  54569. */
  54570. blurVPostProcesses: PostProcess[];
  54571. /**
  54572. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  54573. */
  54574. textureAdderPostProcess: Nullable<PostProcess>;
  54575. /**
  54576. * Post-process used to create volumetric lighting effect
  54577. */
  54578. volumetricLightPostProcess: Nullable<PostProcess>;
  54579. /**
  54580. * Post-process used to smooth the previous volumetric light post-process on the X axis
  54581. */
  54582. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  54583. /**
  54584. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  54585. */
  54586. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  54587. /**
  54588. * Post-process used to merge the volumetric light effect and the real scene color
  54589. */
  54590. volumetricLightMergePostProces: Nullable<PostProcess>;
  54591. /**
  54592. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  54593. */
  54594. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  54595. /**
  54596. * Base post-process used to calculate the average luminance of the final image for HDR
  54597. */
  54598. luminancePostProcess: Nullable<PostProcess>;
  54599. /**
  54600. * Post-processes used to create down sample post-processes in order to get
  54601. * the average luminance of the final image for HDR
  54602. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  54603. */
  54604. luminanceDownSamplePostProcesses: PostProcess[];
  54605. /**
  54606. * Post-process used to create a HDR effect (light adaptation)
  54607. */
  54608. hdrPostProcess: Nullable<PostProcess>;
  54609. /**
  54610. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  54611. */
  54612. textureAdderFinalPostProcess: Nullable<PostProcess>;
  54613. /**
  54614. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  54615. */
  54616. lensFlareFinalPostProcess: Nullable<PostProcess>;
  54617. /**
  54618. * Post-process used to merge the final HDR post-process and the real scene color
  54619. */
  54620. hdrFinalPostProcess: Nullable<PostProcess>;
  54621. /**
  54622. * Post-process used to create a lens flare effect
  54623. */
  54624. lensFlarePostProcess: Nullable<PostProcess>;
  54625. /**
  54626. * Post-process that merges the result of the lens flare post-process and the real scene color
  54627. */
  54628. lensFlareComposePostProcess: Nullable<PostProcess>;
  54629. /**
  54630. * Post-process used to create a motion blur effect
  54631. */
  54632. motionBlurPostProcess: Nullable<PostProcess>;
  54633. /**
  54634. * Post-process used to create a depth of field effect
  54635. */
  54636. depthOfFieldPostProcess: Nullable<PostProcess>;
  54637. /**
  54638. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54639. */
  54640. fxaaPostProcess: Nullable<FxaaPostProcess>;
  54641. /**
  54642. * Represents the brightness threshold in order to configure the illuminated surfaces
  54643. */
  54644. brightThreshold: number;
  54645. /**
  54646. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  54647. */
  54648. blurWidth: number;
  54649. /**
  54650. * Sets if the blur for highlighted surfaces must be only horizontal
  54651. */
  54652. horizontalBlur: boolean;
  54653. /**
  54654. * Gets the overall exposure used by the pipeline
  54655. */
  54656. /**
  54657. * Sets the overall exposure used by the pipeline
  54658. */
  54659. exposure: number;
  54660. /**
  54661. * Texture used typically to simulate "dirty" on camera lens
  54662. */
  54663. lensTexture: Nullable<Texture>;
  54664. /**
  54665. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  54666. */
  54667. volumetricLightCoefficient: number;
  54668. /**
  54669. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  54670. */
  54671. volumetricLightPower: number;
  54672. /**
  54673. * Used the set the blur intensity to smooth the volumetric lights
  54674. */
  54675. volumetricLightBlurScale: number;
  54676. /**
  54677. * Light (spot or directional) used to generate the volumetric lights rays
  54678. * The source light must have a shadow generate so the pipeline can get its
  54679. * depth map
  54680. */
  54681. sourceLight: Nullable<SpotLight | DirectionalLight>;
  54682. /**
  54683. * For eye adaptation, represents the minimum luminance the eye can see
  54684. */
  54685. hdrMinimumLuminance: number;
  54686. /**
  54687. * For eye adaptation, represents the decrease luminance speed
  54688. */
  54689. hdrDecreaseRate: number;
  54690. /**
  54691. * For eye adaptation, represents the increase luminance speed
  54692. */
  54693. hdrIncreaseRate: number;
  54694. /**
  54695. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54696. */
  54697. /**
  54698. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  54699. */
  54700. hdrAutoExposure: boolean;
  54701. /**
  54702. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  54703. */
  54704. lensColorTexture: Nullable<Texture>;
  54705. /**
  54706. * The overall strengh for the lens flare effect
  54707. */
  54708. lensFlareStrength: number;
  54709. /**
  54710. * Dispersion coefficient for lens flare ghosts
  54711. */
  54712. lensFlareGhostDispersal: number;
  54713. /**
  54714. * Main lens flare halo width
  54715. */
  54716. lensFlareHaloWidth: number;
  54717. /**
  54718. * Based on the lens distortion effect, defines how much the lens flare result
  54719. * is distorted
  54720. */
  54721. lensFlareDistortionStrength: number;
  54722. /**
  54723. * Lens star texture must be used to simulate rays on the flares and is available
  54724. * in the documentation
  54725. */
  54726. lensStarTexture: Nullable<Texture>;
  54727. /**
  54728. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  54729. * flare effect by taking account of the dirt texture
  54730. */
  54731. lensFlareDirtTexture: Nullable<Texture>;
  54732. /**
  54733. * Represents the focal length for the depth of field effect
  54734. */
  54735. depthOfFieldDistance: number;
  54736. /**
  54737. * Represents the blur intensity for the blurred part of the depth of field effect
  54738. */
  54739. depthOfFieldBlurWidth: number;
  54740. /**
  54741. * Gets how much the image is blurred by the movement while using the motion blur post-process
  54742. */
  54743. /**
  54744. * Sets how much the image is blurred by the movement while using the motion blur post-process
  54745. */
  54746. motionStrength: number;
  54747. /**
  54748. * Gets wether or not the motion blur post-process is object based or screen based.
  54749. */
  54750. /**
  54751. * Sets wether or not the motion blur post-process should be object based or screen based
  54752. */
  54753. objectBasedMotionBlur: boolean;
  54754. /**
  54755. * List of animations for the pipeline (IAnimatable implementation)
  54756. */
  54757. animations: Animation[];
  54758. /**
  54759. * Private members
  54760. */
  54761. private _scene;
  54762. private _currentDepthOfFieldSource;
  54763. private _basePostProcess;
  54764. private _fixedExposure;
  54765. private _currentExposure;
  54766. private _hdrAutoExposure;
  54767. private _hdrCurrentLuminance;
  54768. private _motionStrength;
  54769. private _isObjectBasedMotionBlur;
  54770. private _floatTextureType;
  54771. private _ratio;
  54772. private _bloomEnabled;
  54773. private _depthOfFieldEnabled;
  54774. private _vlsEnabled;
  54775. private _lensFlareEnabled;
  54776. private _hdrEnabled;
  54777. private _motionBlurEnabled;
  54778. private _fxaaEnabled;
  54779. private _motionBlurSamples;
  54780. private _volumetricLightStepsCount;
  54781. private _samples;
  54782. /**
  54783. * @ignore
  54784. * Specifies if the bloom pipeline is enabled
  54785. */
  54786. BloomEnabled: boolean;
  54787. /**
  54788. * @ignore
  54789. * Specifies if the depth of field pipeline is enabed
  54790. */
  54791. DepthOfFieldEnabled: boolean;
  54792. /**
  54793. * @ignore
  54794. * Specifies if the lens flare pipeline is enabed
  54795. */
  54796. LensFlareEnabled: boolean;
  54797. /**
  54798. * @ignore
  54799. * Specifies if the HDR pipeline is enabled
  54800. */
  54801. HDREnabled: boolean;
  54802. /**
  54803. * @ignore
  54804. * Specifies if the volumetric lights scattering effect is enabled
  54805. */
  54806. VLSEnabled: boolean;
  54807. /**
  54808. * @ignore
  54809. * Specifies if the motion blur effect is enabled
  54810. */
  54811. MotionBlurEnabled: boolean;
  54812. /**
  54813. * Specifies if anti-aliasing is enabled
  54814. */
  54815. fxaaEnabled: boolean;
  54816. /**
  54817. * Specifies the number of steps used to calculate the volumetric lights
  54818. * Typically in interval [50, 200]
  54819. */
  54820. volumetricLightStepsCount: number;
  54821. /**
  54822. * Specifies the number of samples used for the motion blur effect
  54823. * Typically in interval [16, 64]
  54824. */
  54825. motionBlurSamples: number;
  54826. /**
  54827. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54828. */
  54829. samples: number;
  54830. /**
  54831. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  54832. * @constructor
  54833. * @param name The rendering pipeline name
  54834. * @param scene The scene linked to this pipeline
  54835. * @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)
  54836. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  54837. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54838. */
  54839. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  54840. private _buildPipeline;
  54841. private _createDownSampleX4PostProcess;
  54842. private _createBrightPassPostProcess;
  54843. private _createBlurPostProcesses;
  54844. private _createTextureAdderPostProcess;
  54845. private _createVolumetricLightPostProcess;
  54846. private _createLuminancePostProcesses;
  54847. private _createHdrPostProcess;
  54848. private _createLensFlarePostProcess;
  54849. private _createDepthOfFieldPostProcess;
  54850. private _createMotionBlurPostProcess;
  54851. private _getDepthTexture;
  54852. private _disposePostProcesses;
  54853. /**
  54854. * Dispose of the pipeline and stop all post processes
  54855. */
  54856. dispose(): void;
  54857. /**
  54858. * Serialize the rendering pipeline (Used when exporting)
  54859. * @returns the serialized object
  54860. */
  54861. serialize(): any;
  54862. /**
  54863. * Parse the serialized pipeline
  54864. * @param source Source pipeline.
  54865. * @param scene The scene to load the pipeline to.
  54866. * @param rootUrl The URL of the serialized pipeline.
  54867. * @returns An instantiated pipeline from the serialized object.
  54868. */
  54869. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  54870. /**
  54871. * Luminance steps
  54872. */
  54873. static LuminanceSteps: number;
  54874. }
  54875. }
  54876. declare module BABYLON {
  54877. /** @hidden */
  54878. export var tonemapPixelShader: {
  54879. name: string;
  54880. shader: string;
  54881. };
  54882. }
  54883. declare module BABYLON {
  54884. /** Defines operator used for tonemapping */
  54885. export enum TonemappingOperator {
  54886. /** Hable */
  54887. Hable = 0,
  54888. /** Reinhard */
  54889. Reinhard = 1,
  54890. /** HejiDawson */
  54891. HejiDawson = 2,
  54892. /** Photographic */
  54893. Photographic = 3
  54894. }
  54895. /**
  54896. * Defines a post process to apply tone mapping
  54897. */
  54898. export class TonemapPostProcess extends PostProcess {
  54899. private _operator;
  54900. /** Defines the required exposure adjustement */
  54901. exposureAdjustment: number;
  54902. /**
  54903. * Creates a new TonemapPostProcess
  54904. * @param name defines the name of the postprocess
  54905. * @param _operator defines the operator to use
  54906. * @param exposureAdjustment defines the required exposure adjustement
  54907. * @param camera defines the camera to use (can be null)
  54908. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  54909. * @param engine defines the hosting engine (can be ignore if camera is set)
  54910. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54911. */
  54912. constructor(name: string, _operator: TonemappingOperator,
  54913. /** Defines the required exposure adjustement */
  54914. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  54915. }
  54916. }
  54917. declare module BABYLON {
  54918. /** @hidden */
  54919. export var depthVertexShader: {
  54920. name: string;
  54921. shader: string;
  54922. };
  54923. }
  54924. declare module BABYLON {
  54925. /** @hidden */
  54926. export var volumetricLightScatteringPixelShader: {
  54927. name: string;
  54928. shader: string;
  54929. };
  54930. }
  54931. declare module BABYLON {
  54932. /** @hidden */
  54933. export var volumetricLightScatteringPassPixelShader: {
  54934. name: string;
  54935. shader: string;
  54936. };
  54937. }
  54938. declare module BABYLON {
  54939. /**
  54940. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  54941. */
  54942. export class VolumetricLightScatteringPostProcess extends PostProcess {
  54943. private _volumetricLightScatteringPass;
  54944. private _volumetricLightScatteringRTT;
  54945. private _viewPort;
  54946. private _screenCoordinates;
  54947. private _cachedDefines;
  54948. /**
  54949. * If not undefined, the mesh position is computed from the attached node position
  54950. */
  54951. attachedNode: {
  54952. position: Vector3;
  54953. };
  54954. /**
  54955. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  54956. */
  54957. customMeshPosition: Vector3;
  54958. /**
  54959. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  54960. */
  54961. useCustomMeshPosition: boolean;
  54962. /**
  54963. * If the post-process should inverse the light scattering direction
  54964. */
  54965. invert: boolean;
  54966. /**
  54967. * The internal mesh used by the post-process
  54968. */
  54969. mesh: Mesh;
  54970. /**
  54971. * @hidden
  54972. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  54973. */
  54974. useDiffuseColor: boolean;
  54975. /**
  54976. * Array containing the excluded meshes not rendered in the internal pass
  54977. */
  54978. excludedMeshes: AbstractMesh[];
  54979. /**
  54980. * Controls the overall intensity of the post-process
  54981. */
  54982. exposure: number;
  54983. /**
  54984. * Dissipates each sample's contribution in range [0, 1]
  54985. */
  54986. decay: number;
  54987. /**
  54988. * Controls the overall intensity of each sample
  54989. */
  54990. weight: number;
  54991. /**
  54992. * Controls the density of each sample
  54993. */
  54994. density: number;
  54995. /**
  54996. * @constructor
  54997. * @param name The post-process name
  54998. * @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)
  54999. * @param camera The camera that the post-process will be attached to
  55000. * @param mesh The mesh used to create the light scattering
  55001. * @param samples The post-process quality, default 100
  55002. * @param samplingModeThe post-process filtering mode
  55003. * @param engine The babylon engine
  55004. * @param reusable If the post-process is reusable
  55005. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55006. */
  55007. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55008. /**
  55009. * Returns the string "VolumetricLightScatteringPostProcess"
  55010. * @returns "VolumetricLightScatteringPostProcess"
  55011. */
  55012. getClassName(): string;
  55013. private _isReady;
  55014. /**
  55015. * Sets the new light position for light scattering effect
  55016. * @param position The new custom light position
  55017. */
  55018. setCustomMeshPosition(position: Vector3): void;
  55019. /**
  55020. * Returns the light position for light scattering effect
  55021. * @return Vector3 The custom light position
  55022. */
  55023. getCustomMeshPosition(): Vector3;
  55024. /**
  55025. * Disposes the internal assets and detaches the post-process from the camera
  55026. */
  55027. dispose(camera: Camera): void;
  55028. /**
  55029. * Returns the render target texture used by the post-process
  55030. * @return the render target texture used by the post-process
  55031. */
  55032. getPass(): RenderTargetTexture;
  55033. private _meshExcluded;
  55034. private _createPass;
  55035. private _updateMeshScreenCoordinates;
  55036. /**
  55037. * Creates a default mesh for the Volumeric Light Scattering post-process
  55038. * @param name The mesh name
  55039. * @param scene The scene where to create the mesh
  55040. * @return the default mesh
  55041. */
  55042. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55043. }
  55044. }
  55045. declare module BABYLON {
  55046. interface Scene {
  55047. /** @hidden (Backing field) */
  55048. _boundingBoxRenderer: BoundingBoxRenderer;
  55049. /** @hidden (Backing field) */
  55050. _forceShowBoundingBoxes: boolean;
  55051. /**
  55052. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55053. */
  55054. forceShowBoundingBoxes: boolean;
  55055. /**
  55056. * Gets the bounding box renderer associated with the scene
  55057. * @returns a BoundingBoxRenderer
  55058. */
  55059. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55060. }
  55061. interface AbstractMesh {
  55062. /** @hidden (Backing field) */
  55063. _showBoundingBox: boolean;
  55064. /**
  55065. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55066. */
  55067. showBoundingBox: boolean;
  55068. }
  55069. /**
  55070. * Component responsible of rendering the bounding box of the meshes in a scene.
  55071. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55072. */
  55073. export class BoundingBoxRenderer implements ISceneComponent {
  55074. /**
  55075. * The component name helpfull to identify the component in the list of scene components.
  55076. */
  55077. readonly name: string;
  55078. /**
  55079. * The scene the component belongs to.
  55080. */
  55081. scene: Scene;
  55082. /**
  55083. * Color of the bounding box lines placed in front of an object
  55084. */
  55085. frontColor: Color3;
  55086. /**
  55087. * Color of the bounding box lines placed behind an object
  55088. */
  55089. backColor: Color3;
  55090. /**
  55091. * Defines if the renderer should show the back lines or not
  55092. */
  55093. showBackLines: boolean;
  55094. /**
  55095. * @hidden
  55096. */
  55097. renderList: SmartArray<BoundingBox>;
  55098. private _colorShader;
  55099. private _vertexBuffers;
  55100. private _indexBuffer;
  55101. /**
  55102. * Instantiates a new bounding box renderer in a scene.
  55103. * @param scene the scene the renderer renders in
  55104. */
  55105. constructor(scene: Scene);
  55106. /**
  55107. * Registers the component in a given scene
  55108. */
  55109. register(): void;
  55110. private _evaluateSubMesh;
  55111. private _activeMesh;
  55112. private _prepareRessources;
  55113. private _createIndexBuffer;
  55114. /**
  55115. * Rebuilds the elements related to this component in case of
  55116. * context lost for instance.
  55117. */
  55118. rebuild(): void;
  55119. /**
  55120. * @hidden
  55121. */
  55122. reset(): void;
  55123. /**
  55124. * Render the bounding boxes of a specific rendering group
  55125. * @param renderingGroupId defines the rendering group to render
  55126. */
  55127. render(renderingGroupId: number): void;
  55128. /**
  55129. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55130. * @param mesh Define the mesh to render the occlusion bounding box for
  55131. */
  55132. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55133. /**
  55134. * Dispose and release the resources attached to this renderer.
  55135. */
  55136. dispose(): void;
  55137. }
  55138. }
  55139. declare module BABYLON {
  55140. /** @hidden */
  55141. export var depthPixelShader: {
  55142. name: string;
  55143. shader: string;
  55144. };
  55145. }
  55146. declare module BABYLON {
  55147. /**
  55148. * This represents a depth renderer in Babylon.
  55149. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55150. */
  55151. export class DepthRenderer {
  55152. private _scene;
  55153. private _depthMap;
  55154. private _effect;
  55155. private _cachedDefines;
  55156. private _camera;
  55157. /**
  55158. * Specifiess that the depth renderer will only be used within
  55159. * the camera it is created for.
  55160. * This can help forcing its rendering during the camera processing.
  55161. */
  55162. useOnlyInActiveCamera: boolean;
  55163. /** @hidden */
  55164. static _SceneComponentInitialization: (scene: Scene) => void;
  55165. /**
  55166. * Instantiates a depth renderer
  55167. * @param scene The scene the renderer belongs to
  55168. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55169. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55170. */
  55171. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55172. /**
  55173. * Creates the depth rendering effect and checks if the effect is ready.
  55174. * @param subMesh The submesh to be used to render the depth map of
  55175. * @param useInstances If multiple world instances should be used
  55176. * @returns if the depth renderer is ready to render the depth map
  55177. */
  55178. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55179. /**
  55180. * Gets the texture which the depth map will be written to.
  55181. * @returns The depth map texture
  55182. */
  55183. getDepthMap(): RenderTargetTexture;
  55184. /**
  55185. * Disposes of the depth renderer.
  55186. */
  55187. dispose(): void;
  55188. }
  55189. }
  55190. declare module BABYLON {
  55191. interface Scene {
  55192. /** @hidden (Backing field) */
  55193. _depthRenderer: {
  55194. [id: string]: DepthRenderer;
  55195. };
  55196. /**
  55197. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55198. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55199. * @returns the created depth renderer
  55200. */
  55201. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55202. /**
  55203. * Disables a depth renderer for a given camera
  55204. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55205. */
  55206. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55207. }
  55208. /**
  55209. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55210. * in several rendering techniques.
  55211. */
  55212. export class DepthRendererSceneComponent implements ISceneComponent {
  55213. /**
  55214. * The component name helpfull to identify the component in the list of scene components.
  55215. */
  55216. readonly name: string;
  55217. /**
  55218. * The scene the component belongs to.
  55219. */
  55220. scene: Scene;
  55221. /**
  55222. * Creates a new instance of the component for the given scene
  55223. * @param scene Defines the scene to register the component in
  55224. */
  55225. constructor(scene: Scene);
  55226. /**
  55227. * Registers the component in a given scene
  55228. */
  55229. register(): void;
  55230. /**
  55231. * Rebuilds the elements related to this component in case of
  55232. * context lost for instance.
  55233. */
  55234. rebuild(): void;
  55235. /**
  55236. * Disposes the component and the associated ressources
  55237. */
  55238. dispose(): void;
  55239. private _gatherRenderTargets;
  55240. private _gatherActiveCameraRenderTargets;
  55241. }
  55242. }
  55243. declare module BABYLON {
  55244. /** @hidden */
  55245. export var outlinePixelShader: {
  55246. name: string;
  55247. shader: string;
  55248. };
  55249. }
  55250. declare module BABYLON {
  55251. /** @hidden */
  55252. export var outlineVertexShader: {
  55253. name: string;
  55254. shader: string;
  55255. };
  55256. }
  55257. declare module BABYLON {
  55258. interface Scene {
  55259. /** @hidden */
  55260. _outlineRenderer: OutlineRenderer;
  55261. /**
  55262. * Gets the outline renderer associated with the scene
  55263. * @returns a OutlineRenderer
  55264. */
  55265. getOutlineRenderer(): OutlineRenderer;
  55266. }
  55267. interface AbstractMesh {
  55268. /** @hidden (Backing field) */
  55269. _renderOutline: boolean;
  55270. /**
  55271. * Gets or sets a boolean indicating if the outline must be rendered as well
  55272. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55273. */
  55274. renderOutline: boolean;
  55275. /** @hidden (Backing field) */
  55276. _renderOverlay: boolean;
  55277. /**
  55278. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55279. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55280. */
  55281. renderOverlay: boolean;
  55282. }
  55283. /**
  55284. * This class is responsible to draw bothe outline/overlay of meshes.
  55285. * It should not be used directly but through the available method on mesh.
  55286. */
  55287. export class OutlineRenderer implements ISceneComponent {
  55288. /**
  55289. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  55290. */
  55291. private static _StencilReference;
  55292. /**
  55293. * The name of the component. Each component must have a unique name.
  55294. */
  55295. name: string;
  55296. /**
  55297. * The scene the component belongs to.
  55298. */
  55299. scene: Scene;
  55300. /**
  55301. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55302. */
  55303. zOffset: number;
  55304. private _engine;
  55305. private _effect;
  55306. private _cachedDefines;
  55307. private _savedDepthWrite;
  55308. /**
  55309. * Instantiates a new outline renderer. (There could be only one per scene).
  55310. * @param scene Defines the scene it belongs to
  55311. */
  55312. constructor(scene: Scene);
  55313. /**
  55314. * Register the component to one instance of a scene.
  55315. */
  55316. register(): void;
  55317. /**
  55318. * Rebuilds the elements related to this component in case of
  55319. * context lost for instance.
  55320. */
  55321. rebuild(): void;
  55322. /**
  55323. * Disposes the component and the associated ressources.
  55324. */
  55325. dispose(): void;
  55326. /**
  55327. * Renders the outline in the canvas.
  55328. * @param subMesh Defines the sumesh to render
  55329. * @param batch Defines the batch of meshes in case of instances
  55330. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55331. */
  55332. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55333. /**
  55334. * Returns whether or not the outline renderer is ready for a given submesh.
  55335. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55336. * @param subMesh Defines the submesh to check readyness for
  55337. * @param useInstances Defines wheter wee are trying to render instances or not
  55338. * @returns true if ready otherwise false
  55339. */
  55340. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55341. private _beforeRenderingMesh;
  55342. private _afterRenderingMesh;
  55343. }
  55344. }
  55345. declare module BABYLON {
  55346. /**
  55347. * Defines the list of states available for a task inside a AssetsManager
  55348. */
  55349. export enum AssetTaskState {
  55350. /**
  55351. * Initialization
  55352. */
  55353. INIT = 0,
  55354. /**
  55355. * Running
  55356. */
  55357. RUNNING = 1,
  55358. /**
  55359. * Done
  55360. */
  55361. DONE = 2,
  55362. /**
  55363. * Error
  55364. */
  55365. ERROR = 3
  55366. }
  55367. /**
  55368. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  55369. */
  55370. export abstract class AbstractAssetTask {
  55371. /**
  55372. * Task name
  55373. */ name: string;
  55374. /**
  55375. * Callback called when the task is successful
  55376. */
  55377. onSuccess: (task: any) => void;
  55378. /**
  55379. * Callback called when the task is not successful
  55380. */
  55381. onError: (task: any, message?: string, exception?: any) => void;
  55382. /**
  55383. * Creates a new AssetsManager
  55384. * @param name defines the name of the task
  55385. */
  55386. constructor(
  55387. /**
  55388. * Task name
  55389. */ name: string);
  55390. private _isCompleted;
  55391. private _taskState;
  55392. private _errorObject;
  55393. /**
  55394. * Get if the task is completed
  55395. */
  55396. readonly isCompleted: boolean;
  55397. /**
  55398. * Gets the current state of the task
  55399. */
  55400. readonly taskState: AssetTaskState;
  55401. /**
  55402. * Gets the current error object (if task is in error)
  55403. */
  55404. readonly errorObject: {
  55405. message?: string;
  55406. exception?: any;
  55407. };
  55408. /**
  55409. * Internal only
  55410. * @hidden
  55411. */
  55412. _setErrorObject(message?: string, exception?: any): void;
  55413. /**
  55414. * Execute the current task
  55415. * @param scene defines the scene where you want your assets to be loaded
  55416. * @param onSuccess is a callback called when the task is successfully executed
  55417. * @param onError is a callback called if an error occurs
  55418. */
  55419. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55420. /**
  55421. * Execute the current task
  55422. * @param scene defines the scene where you want your assets to be loaded
  55423. * @param onSuccess is a callback called when the task is successfully executed
  55424. * @param onError is a callback called if an error occurs
  55425. */
  55426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55427. /**
  55428. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  55429. * This can be used with failed tasks that have the reason for failure fixed.
  55430. */
  55431. reset(): void;
  55432. private onErrorCallback;
  55433. private onDoneCallback;
  55434. }
  55435. /**
  55436. * Define the interface used by progress events raised during assets loading
  55437. */
  55438. export interface IAssetsProgressEvent {
  55439. /**
  55440. * Defines the number of remaining tasks to process
  55441. */
  55442. remainingCount: number;
  55443. /**
  55444. * Defines the total number of tasks
  55445. */
  55446. totalCount: number;
  55447. /**
  55448. * Defines the task that was just processed
  55449. */
  55450. task: AbstractAssetTask;
  55451. }
  55452. /**
  55453. * Class used to share progress information about assets loading
  55454. */
  55455. export class AssetsProgressEvent implements IAssetsProgressEvent {
  55456. /**
  55457. * Defines the number of remaining tasks to process
  55458. */
  55459. remainingCount: number;
  55460. /**
  55461. * Defines the total number of tasks
  55462. */
  55463. totalCount: number;
  55464. /**
  55465. * Defines the task that was just processed
  55466. */
  55467. task: AbstractAssetTask;
  55468. /**
  55469. * Creates a AssetsProgressEvent
  55470. * @param remainingCount defines the number of remaining tasks to process
  55471. * @param totalCount defines the total number of tasks
  55472. * @param task defines the task that was just processed
  55473. */
  55474. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  55475. }
  55476. /**
  55477. * Define a task used by AssetsManager to load meshes
  55478. */
  55479. export class MeshAssetTask extends AbstractAssetTask {
  55480. /**
  55481. * Defines the name of the task
  55482. */
  55483. name: string;
  55484. /**
  55485. * Defines the list of mesh's names you want to load
  55486. */
  55487. meshesNames: any;
  55488. /**
  55489. * Defines the root url to use as a base to load your meshes and associated resources
  55490. */
  55491. rootUrl: string;
  55492. /**
  55493. * Defines the filename of the scene to load from
  55494. */
  55495. sceneFilename: string;
  55496. /**
  55497. * Gets the list of loaded meshes
  55498. */
  55499. loadedMeshes: Array<AbstractMesh>;
  55500. /**
  55501. * Gets the list of loaded particle systems
  55502. */
  55503. loadedParticleSystems: Array<IParticleSystem>;
  55504. /**
  55505. * Gets the list of loaded skeletons
  55506. */
  55507. loadedSkeletons: Array<Skeleton>;
  55508. /**
  55509. * Gets the list of loaded animation groups
  55510. */
  55511. loadedAnimationGroups: Array<AnimationGroup>;
  55512. /**
  55513. * Callback called when the task is successful
  55514. */
  55515. onSuccess: (task: MeshAssetTask) => void;
  55516. /**
  55517. * Callback called when the task is successful
  55518. */
  55519. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  55520. /**
  55521. * Creates a new MeshAssetTask
  55522. * @param name defines the name of the task
  55523. * @param meshesNames defines the list of mesh's names you want to load
  55524. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  55525. * @param sceneFilename defines the filename of the scene to load from
  55526. */
  55527. constructor(
  55528. /**
  55529. * Defines the name of the task
  55530. */
  55531. name: string,
  55532. /**
  55533. * Defines the list of mesh's names you want to load
  55534. */
  55535. meshesNames: any,
  55536. /**
  55537. * Defines the root url to use as a base to load your meshes and associated resources
  55538. */
  55539. rootUrl: string,
  55540. /**
  55541. * Defines the filename of the scene to load from
  55542. */
  55543. sceneFilename: string);
  55544. /**
  55545. * Execute the current task
  55546. * @param scene defines the scene where you want your assets to be loaded
  55547. * @param onSuccess is a callback called when the task is successfully executed
  55548. * @param onError is a callback called if an error occurs
  55549. */
  55550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55551. }
  55552. /**
  55553. * Define a task used by AssetsManager to load text content
  55554. */
  55555. export class TextFileAssetTask extends AbstractAssetTask {
  55556. /**
  55557. * Defines the name of the task
  55558. */
  55559. name: string;
  55560. /**
  55561. * Defines the location of the file to load
  55562. */
  55563. url: string;
  55564. /**
  55565. * Gets the loaded text string
  55566. */
  55567. text: string;
  55568. /**
  55569. * Callback called when the task is successful
  55570. */
  55571. onSuccess: (task: TextFileAssetTask) => void;
  55572. /**
  55573. * Callback called when the task is successful
  55574. */
  55575. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  55576. /**
  55577. * Creates a new TextFileAssetTask object
  55578. * @param name defines the name of the task
  55579. * @param url defines the location of the file to load
  55580. */
  55581. constructor(
  55582. /**
  55583. * Defines the name of the task
  55584. */
  55585. name: string,
  55586. /**
  55587. * Defines the location of the file to load
  55588. */
  55589. url: string);
  55590. /**
  55591. * Execute the current task
  55592. * @param scene defines the scene where you want your assets to be loaded
  55593. * @param onSuccess is a callback called when the task is successfully executed
  55594. * @param onError is a callback called if an error occurs
  55595. */
  55596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55597. }
  55598. /**
  55599. * Define a task used by AssetsManager to load binary data
  55600. */
  55601. export class BinaryFileAssetTask extends AbstractAssetTask {
  55602. /**
  55603. * Defines the name of the task
  55604. */
  55605. name: string;
  55606. /**
  55607. * Defines the location of the file to load
  55608. */
  55609. url: string;
  55610. /**
  55611. * Gets the lodaded data (as an array buffer)
  55612. */
  55613. data: ArrayBuffer;
  55614. /**
  55615. * Callback called when the task is successful
  55616. */
  55617. onSuccess: (task: BinaryFileAssetTask) => void;
  55618. /**
  55619. * Callback called when the task is successful
  55620. */
  55621. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  55622. /**
  55623. * Creates a new BinaryFileAssetTask object
  55624. * @param name defines the name of the new task
  55625. * @param url defines the location of the file to load
  55626. */
  55627. constructor(
  55628. /**
  55629. * Defines the name of the task
  55630. */
  55631. name: string,
  55632. /**
  55633. * Defines the location of the file to load
  55634. */
  55635. url: string);
  55636. /**
  55637. * Execute the current task
  55638. * @param scene defines the scene where you want your assets to be loaded
  55639. * @param onSuccess is a callback called when the task is successfully executed
  55640. * @param onError is a callback called if an error occurs
  55641. */
  55642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55643. }
  55644. /**
  55645. * Define a task used by AssetsManager to load images
  55646. */
  55647. export class ImageAssetTask extends AbstractAssetTask {
  55648. /**
  55649. * Defines the name of the task
  55650. */
  55651. name: string;
  55652. /**
  55653. * Defines the location of the image to load
  55654. */
  55655. url: string;
  55656. /**
  55657. * Gets the loaded images
  55658. */
  55659. image: HTMLImageElement;
  55660. /**
  55661. * Callback called when the task is successful
  55662. */
  55663. onSuccess: (task: ImageAssetTask) => void;
  55664. /**
  55665. * Callback called when the task is successful
  55666. */
  55667. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  55668. /**
  55669. * Creates a new ImageAssetTask
  55670. * @param name defines the name of the task
  55671. * @param url defines the location of the image to load
  55672. */
  55673. constructor(
  55674. /**
  55675. * Defines the name of the task
  55676. */
  55677. name: string,
  55678. /**
  55679. * Defines the location of the image to load
  55680. */
  55681. url: string);
  55682. /**
  55683. * Execute the current task
  55684. * @param scene defines the scene where you want your assets to be loaded
  55685. * @param onSuccess is a callback called when the task is successfully executed
  55686. * @param onError is a callback called if an error occurs
  55687. */
  55688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55689. }
  55690. /**
  55691. * Defines the interface used by texture loading tasks
  55692. */
  55693. export interface ITextureAssetTask<TEX extends BaseTexture> {
  55694. /**
  55695. * Gets the loaded texture
  55696. */
  55697. texture: TEX;
  55698. }
  55699. /**
  55700. * Define a task used by AssetsManager to load 2D textures
  55701. */
  55702. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  55703. /**
  55704. * Defines the name of the task
  55705. */
  55706. name: string;
  55707. /**
  55708. * Defines the location of the file to load
  55709. */
  55710. url: string;
  55711. /**
  55712. * Defines if mipmap should not be generated (default is false)
  55713. */
  55714. noMipmap?: boolean | undefined;
  55715. /**
  55716. * Defines if texture must be inverted on Y axis (default is false)
  55717. */
  55718. invertY?: boolean | undefined;
  55719. /**
  55720. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55721. */
  55722. samplingMode: number;
  55723. /**
  55724. * Gets the loaded texture
  55725. */
  55726. texture: Texture;
  55727. /**
  55728. * Callback called when the task is successful
  55729. */
  55730. onSuccess: (task: TextureAssetTask) => void;
  55731. /**
  55732. * Callback called when the task is successful
  55733. */
  55734. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  55735. /**
  55736. * Creates a new TextureAssetTask object
  55737. * @param name defines the name of the task
  55738. * @param url defines the location of the file to load
  55739. * @param noMipmap defines if mipmap should not be generated (default is false)
  55740. * @param invertY defines if texture must be inverted on Y axis (default is false)
  55741. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55742. */
  55743. constructor(
  55744. /**
  55745. * Defines the name of the task
  55746. */
  55747. name: string,
  55748. /**
  55749. * Defines the location of the file to load
  55750. */
  55751. url: string,
  55752. /**
  55753. * Defines if mipmap should not be generated (default is false)
  55754. */
  55755. noMipmap?: boolean | undefined,
  55756. /**
  55757. * Defines if texture must be inverted on Y axis (default is false)
  55758. */
  55759. invertY?: boolean | undefined,
  55760. /**
  55761. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  55762. */
  55763. samplingMode?: number);
  55764. /**
  55765. * Execute the current task
  55766. * @param scene defines the scene where you want your assets to be loaded
  55767. * @param onSuccess is a callback called when the task is successfully executed
  55768. * @param onError is a callback called if an error occurs
  55769. */
  55770. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55771. }
  55772. /**
  55773. * Define a task used by AssetsManager to load cube textures
  55774. */
  55775. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  55776. /**
  55777. * Defines the name of the task
  55778. */
  55779. name: string;
  55780. /**
  55781. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55782. */
  55783. url: string;
  55784. /**
  55785. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55786. */
  55787. extensions?: string[] | undefined;
  55788. /**
  55789. * Defines if mipmaps should not be generated (default is false)
  55790. */
  55791. noMipmap?: boolean | undefined;
  55792. /**
  55793. * Defines the explicit list of files (undefined by default)
  55794. */
  55795. files?: string[] | undefined;
  55796. /**
  55797. * Gets the loaded texture
  55798. */
  55799. texture: CubeTexture;
  55800. /**
  55801. * Callback called when the task is successful
  55802. */
  55803. onSuccess: (task: CubeTextureAssetTask) => void;
  55804. /**
  55805. * Callback called when the task is successful
  55806. */
  55807. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  55808. /**
  55809. * Creates a new CubeTextureAssetTask
  55810. * @param name defines the name of the task
  55811. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55812. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55813. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55814. * @param files defines the explicit list of files (undefined by default)
  55815. */
  55816. constructor(
  55817. /**
  55818. * Defines the name of the task
  55819. */
  55820. name: string,
  55821. /**
  55822. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  55823. */
  55824. url: string,
  55825. /**
  55826. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  55827. */
  55828. extensions?: string[] | undefined,
  55829. /**
  55830. * Defines if mipmaps should not be generated (default is false)
  55831. */
  55832. noMipmap?: boolean | undefined,
  55833. /**
  55834. * Defines the explicit list of files (undefined by default)
  55835. */
  55836. files?: string[] | undefined);
  55837. /**
  55838. * Execute the current task
  55839. * @param scene defines the scene where you want your assets to be loaded
  55840. * @param onSuccess is a callback called when the task is successfully executed
  55841. * @param onError is a callback called if an error occurs
  55842. */
  55843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55844. }
  55845. /**
  55846. * Define a task used by AssetsManager to load HDR cube textures
  55847. */
  55848. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  55849. /**
  55850. * Defines the name of the task
  55851. */
  55852. name: string;
  55853. /**
  55854. * Defines the location of the file to load
  55855. */
  55856. url: string;
  55857. /**
  55858. * Defines the desired size (the more it increases the longer the generation will be)
  55859. */
  55860. size: number;
  55861. /**
  55862. * Defines if mipmaps should not be generated (default is false)
  55863. */
  55864. noMipmap: boolean;
  55865. /**
  55866. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55867. */
  55868. generateHarmonics: boolean;
  55869. /**
  55870. * 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)
  55871. */
  55872. gammaSpace: boolean;
  55873. /**
  55874. * Internal Use Only
  55875. */
  55876. reserved: boolean;
  55877. /**
  55878. * Gets the loaded texture
  55879. */
  55880. texture: HDRCubeTexture;
  55881. /**
  55882. * Callback called when the task is successful
  55883. */
  55884. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  55885. /**
  55886. * Callback called when the task is successful
  55887. */
  55888. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  55889. /**
  55890. * Creates a new HDRCubeTextureAssetTask object
  55891. * @param name defines the name of the task
  55892. * @param url defines the location of the file to load
  55893. * @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.
  55894. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55895. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55896. * @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)
  55897. * @param reserved Internal use only
  55898. */
  55899. constructor(
  55900. /**
  55901. * Defines the name of the task
  55902. */
  55903. name: string,
  55904. /**
  55905. * Defines the location of the file to load
  55906. */
  55907. url: string,
  55908. /**
  55909. * Defines the desired size (the more it increases the longer the generation will be)
  55910. */
  55911. size: number,
  55912. /**
  55913. * Defines if mipmaps should not be generated (default is false)
  55914. */
  55915. noMipmap?: boolean,
  55916. /**
  55917. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  55918. */
  55919. generateHarmonics?: boolean,
  55920. /**
  55921. * 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)
  55922. */
  55923. gammaSpace?: boolean,
  55924. /**
  55925. * Internal Use Only
  55926. */
  55927. reserved?: boolean);
  55928. /**
  55929. * Execute the current task
  55930. * @param scene defines the scene where you want your assets to be loaded
  55931. * @param onSuccess is a callback called when the task is successfully executed
  55932. * @param onError is a callback called if an error occurs
  55933. */
  55934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  55935. }
  55936. /**
  55937. * Define a task used by AssetsManager to load Equirectangular cube textures
  55938. */
  55939. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  55940. /**
  55941. * Defines the name of the task
  55942. */
  55943. name: string;
  55944. /**
  55945. * Defines the location of the file to load
  55946. */
  55947. url: string;
  55948. /**
  55949. * Defines the desired size (the more it increases the longer the generation will be)
  55950. */
  55951. size: number;
  55952. /**
  55953. * Defines if mipmaps should not be generated (default is false)
  55954. */
  55955. noMipmap: boolean;
  55956. /**
  55957. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  55958. * but the standard material would require them in Gamma space) (default is true)
  55959. */
  55960. gammaSpace: boolean;
  55961. /**
  55962. * Gets the loaded texture
  55963. */
  55964. texture: EquiRectangularCubeTexture;
  55965. /**
  55966. * Callback called when the task is successful
  55967. */
  55968. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  55969. /**
  55970. * Callback called when the task is successful
  55971. */
  55972. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  55973. /**
  55974. * Creates a new EquiRectangularCubeTextureAssetTask object
  55975. * @param name defines the name of the task
  55976. * @param url defines the location of the file to load
  55977. * @param size defines the desired size (the more it increases the longer the generation will be)
  55978. * If the size is omitted this implies you are using a preprocessed cubemap.
  55979. * @param noMipmap defines if mipmaps should not be generated (default is false)
  55980. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  55981. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  55982. * (default is true)
  55983. */
  55984. constructor(
  55985. /**
  55986. * Defines the name of the task
  55987. */
  55988. name: string,
  55989. /**
  55990. * Defines the location of the file to load
  55991. */
  55992. url: string,
  55993. /**
  55994. * Defines the desired size (the more it increases the longer the generation will be)
  55995. */
  55996. size: number,
  55997. /**
  55998. * Defines if mipmaps should not be generated (default is false)
  55999. */
  56000. noMipmap?: boolean,
  56001. /**
  56002. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  56003. * but the standard material would require them in Gamma space) (default is true)
  56004. */
  56005. gammaSpace?: boolean);
  56006. /**
  56007. * Execute the current task
  56008. * @param scene defines the scene where you want your assets to be loaded
  56009. * @param onSuccess is a callback called when the task is successfully executed
  56010. * @param onError is a callback called if an error occurs
  56011. */
  56012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56013. }
  56014. /**
  56015. * This class can be used to easily import assets into a scene
  56016. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56017. */
  56018. export class AssetsManager {
  56019. private _scene;
  56020. private _isLoading;
  56021. protected _tasks: AbstractAssetTask[];
  56022. protected _waitingTasksCount: number;
  56023. protected _totalTasksCount: number;
  56024. /**
  56025. * Callback called when all tasks are processed
  56026. */
  56027. onFinish: (tasks: AbstractAssetTask[]) => void;
  56028. /**
  56029. * Callback called when a task is successful
  56030. */
  56031. onTaskSuccess: (task: AbstractAssetTask) => void;
  56032. /**
  56033. * Callback called when a task had an error
  56034. */
  56035. onTaskError: (task: AbstractAssetTask) => void;
  56036. /**
  56037. * Callback called when a task is done (whatever the result is)
  56038. */
  56039. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56040. /**
  56041. * Observable called when all tasks are processed
  56042. */
  56043. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56044. /**
  56045. * Observable called when a task had an error
  56046. */
  56047. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56048. /**
  56049. * Observable called when all tasks were executed
  56050. */
  56051. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56052. /**
  56053. * Observable called when a task is done (whatever the result is)
  56054. */
  56055. onProgressObservable: Observable<IAssetsProgressEvent>;
  56056. /**
  56057. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56059. */
  56060. useDefaultLoadingScreen: boolean;
  56061. /**
  56062. * Creates a new AssetsManager
  56063. * @param scene defines the scene to work on
  56064. */
  56065. constructor(scene: Scene);
  56066. /**
  56067. * Add a MeshAssetTask to the list of active tasks
  56068. * @param taskName defines the name of the new task
  56069. * @param meshesNames defines the name of meshes to load
  56070. * @param rootUrl defines the root url to use to locate files
  56071. * @param sceneFilename defines the filename of the scene file
  56072. * @returns a new MeshAssetTask object
  56073. */
  56074. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56075. /**
  56076. * Add a TextFileAssetTask to the list of active tasks
  56077. * @param taskName defines the name of the new task
  56078. * @param url defines the url of the file to load
  56079. * @returns a new TextFileAssetTask object
  56080. */
  56081. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56082. /**
  56083. * Add a BinaryFileAssetTask to the list of active tasks
  56084. * @param taskName defines the name of the new task
  56085. * @param url defines the url of the file to load
  56086. * @returns a new BinaryFileAssetTask object
  56087. */
  56088. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56089. /**
  56090. * Add a ImageAssetTask to the list of active tasks
  56091. * @param taskName defines the name of the new task
  56092. * @param url defines the url of the file to load
  56093. * @returns a new ImageAssetTask object
  56094. */
  56095. addImageTask(taskName: string, url: string): ImageAssetTask;
  56096. /**
  56097. * Add a TextureAssetTask to the list of active tasks
  56098. * @param taskName defines the name of the new task
  56099. * @param url defines the url of the file to load
  56100. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56101. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56102. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56103. * @returns a new TextureAssetTask object
  56104. */
  56105. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56106. /**
  56107. * Add a CubeTextureAssetTask to the list of active tasks
  56108. * @param taskName defines the name of the new task
  56109. * @param url defines the url of the file to load
  56110. * @param extensions defines the extension to use to load the cube map (can be null)
  56111. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56112. * @param files defines the list of files to load (can be null)
  56113. * @returns a new CubeTextureAssetTask object
  56114. */
  56115. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56116. /**
  56117. *
  56118. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56119. * @param taskName defines the name of the new task
  56120. * @param url defines the url of the file to load
  56121. * @param size defines the size you want for the cubemap (can be null)
  56122. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56123. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56124. * @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)
  56125. * @param reserved Internal use only
  56126. * @returns a new HDRCubeTextureAssetTask object
  56127. */
  56128. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56129. /**
  56130. *
  56131. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  56132. * @param taskName defines the name of the new task
  56133. * @param url defines the url of the file to load
  56134. * @param size defines the size you want for the cubemap (can be null)
  56135. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56136. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56137. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56138. * @returns a new EquiRectangularCubeTextureAssetTask object
  56139. */
  56140. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  56141. /**
  56142. * Remove a task from the assets manager.
  56143. * @param task the task to remove
  56144. */
  56145. removeTask(task: AbstractAssetTask): void;
  56146. private _decreaseWaitingTasksCount;
  56147. private _runTask;
  56148. /**
  56149. * Reset the AssetsManager and remove all tasks
  56150. * @return the current instance of the AssetsManager
  56151. */
  56152. reset(): AssetsManager;
  56153. /**
  56154. * Start the loading process
  56155. * @return the current instance of the AssetsManager
  56156. */
  56157. load(): AssetsManager;
  56158. /**
  56159. * Start the loading process as an async operation
  56160. * @return a promise returning the list of failed tasks
  56161. */
  56162. loadAsync(): Promise<void>;
  56163. }
  56164. }
  56165. declare module BABYLON {
  56166. /**
  56167. * Wrapper class for promise with external resolve and reject.
  56168. */
  56169. export class Deferred<T> {
  56170. /**
  56171. * The promise associated with this deferred object.
  56172. */
  56173. readonly promise: Promise<T>;
  56174. private _resolve;
  56175. private _reject;
  56176. /**
  56177. * The resolve method of the promise associated with this deferred object.
  56178. */
  56179. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56180. /**
  56181. * The reject method of the promise associated with this deferred object.
  56182. */
  56183. readonly reject: (reason?: any) => void;
  56184. /**
  56185. * Constructor for this deferred object.
  56186. */
  56187. constructor();
  56188. }
  56189. }
  56190. declare module BABYLON {
  56191. /**
  56192. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56193. */
  56194. export class MeshExploder {
  56195. private _centerMesh;
  56196. private _meshes;
  56197. private _meshesOrigins;
  56198. private _toCenterVectors;
  56199. private _scaledDirection;
  56200. private _newPosition;
  56201. private _centerPosition;
  56202. /**
  56203. * Explodes meshes from a center mesh.
  56204. * @param meshes The meshes to explode.
  56205. * @param centerMesh The mesh to be center of explosion.
  56206. */
  56207. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  56208. private _setCenterMesh;
  56209. /**
  56210. * Get class name
  56211. * @returns "MeshExploder"
  56212. */
  56213. getClassName(): string;
  56214. /**
  56215. * "Exploded meshes"
  56216. * @returns Array of meshes with the centerMesh at index 0.
  56217. */
  56218. getMeshes(): Array<Mesh>;
  56219. /**
  56220. * Explodes meshes giving a specific direction
  56221. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  56222. */
  56223. explode(direction?: number): void;
  56224. }
  56225. }
  56226. declare module BABYLON {
  56227. /**
  56228. * Class used to help managing file picking and drag'n'drop
  56229. */
  56230. export class FilesInput {
  56231. /**
  56232. * List of files ready to be loaded
  56233. */
  56234. static readonly FilesToLoad: {
  56235. [key: string]: File;
  56236. };
  56237. /**
  56238. * Callback called when a file is processed
  56239. */
  56240. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56241. private _engine;
  56242. private _currentScene;
  56243. private _sceneLoadedCallback;
  56244. private _progressCallback;
  56245. private _additionalRenderLoopLogicCallback;
  56246. private _textureLoadingCallback;
  56247. private _startingProcessingFilesCallback;
  56248. private _onReloadCallback;
  56249. private _errorCallback;
  56250. private _elementToMonitor;
  56251. private _sceneFileToLoad;
  56252. private _filesToLoad;
  56253. /**
  56254. * Creates a new FilesInput
  56255. * @param engine defines the rendering engine
  56256. * @param scene defines the hosting scene
  56257. * @param sceneLoadedCallback callback called when scene is loaded
  56258. * @param progressCallback callback called to track progress
  56259. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56260. * @param textureLoadingCallback callback called when a texture is loading
  56261. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56262. * @param onReloadCallback callback called when a reload is requested
  56263. * @param errorCallback callback call if an error occurs
  56264. */
  56265. 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);
  56266. private _dragEnterHandler;
  56267. private _dragOverHandler;
  56268. private _dropHandler;
  56269. /**
  56270. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56271. * @param elementToMonitor defines the DOM element to track
  56272. */
  56273. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56274. /**
  56275. * Release all associated resources
  56276. */
  56277. dispose(): void;
  56278. private renderFunction;
  56279. private drag;
  56280. private drop;
  56281. private _traverseFolder;
  56282. private _processFiles;
  56283. /**
  56284. * Load files from a drop event
  56285. * @param event defines the drop event to use as source
  56286. */
  56287. loadFiles(event: any): void;
  56288. private _processReload;
  56289. /**
  56290. * Reload the current scene from the loaded files
  56291. */
  56292. reload(): void;
  56293. }
  56294. }
  56295. declare module BABYLON {
  56296. /**
  56297. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56298. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56299. */
  56300. export class SceneOptimization {
  56301. /**
  56302. * Defines the priority of this optimization (0 by default which means first in the list)
  56303. */
  56304. priority: number;
  56305. /**
  56306. * Gets a string describing the action executed by the current optimization
  56307. * @returns description string
  56308. */
  56309. getDescription(): string;
  56310. /**
  56311. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56312. * @param scene defines the current scene where to apply this optimization
  56313. * @param optimizer defines the current optimizer
  56314. * @returns true if everything that can be done was applied
  56315. */
  56316. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56317. /**
  56318. * Creates the SceneOptimization object
  56319. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56320. * @param desc defines the description associated with the optimization
  56321. */
  56322. constructor(
  56323. /**
  56324. * Defines the priority of this optimization (0 by default which means first in the list)
  56325. */
  56326. priority?: number);
  56327. }
  56328. /**
  56329. * Defines an optimization used to reduce the size of render target textures
  56330. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56331. */
  56332. export class TextureOptimization extends SceneOptimization {
  56333. /**
  56334. * Defines the priority of this optimization (0 by default which means first in the list)
  56335. */
  56336. priority: number;
  56337. /**
  56338. * 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
  56339. */
  56340. maximumSize: number;
  56341. /**
  56342. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56343. */
  56344. step: number;
  56345. /**
  56346. * Gets a string describing the action executed by the current optimization
  56347. * @returns description string
  56348. */
  56349. getDescription(): string;
  56350. /**
  56351. * Creates the TextureOptimization object
  56352. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56353. * @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
  56354. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56355. */
  56356. constructor(
  56357. /**
  56358. * Defines the priority of this optimization (0 by default which means first in the list)
  56359. */
  56360. priority?: number,
  56361. /**
  56362. * 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
  56363. */
  56364. maximumSize?: number,
  56365. /**
  56366. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56367. */
  56368. step?: number);
  56369. /**
  56370. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56371. * @param scene defines the current scene where to apply this optimization
  56372. * @param optimizer defines the current optimizer
  56373. * @returns true if everything that can be done was applied
  56374. */
  56375. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56376. }
  56377. /**
  56378. * Defines an optimization used to increase or decrease the rendering resolution
  56379. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56380. */
  56381. export class HardwareScalingOptimization extends SceneOptimization {
  56382. /**
  56383. * Defines the priority of this optimization (0 by default which means first in the list)
  56384. */
  56385. priority: number;
  56386. /**
  56387. * Defines the maximum scale to use (2 by default)
  56388. */
  56389. maximumScale: number;
  56390. /**
  56391. * Defines the step to use between two passes (0.5 by default)
  56392. */
  56393. step: number;
  56394. private _currentScale;
  56395. private _directionOffset;
  56396. /**
  56397. * Gets a string describing the action executed by the current optimization
  56398. * @return description string
  56399. */
  56400. getDescription(): string;
  56401. /**
  56402. * Creates the HardwareScalingOptimization object
  56403. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56404. * @param maximumScale defines the maximum scale to use (2 by default)
  56405. * @param step defines the step to use between two passes (0.5 by default)
  56406. */
  56407. constructor(
  56408. /**
  56409. * Defines the priority of this optimization (0 by default which means first in the list)
  56410. */
  56411. priority?: number,
  56412. /**
  56413. * Defines the maximum scale to use (2 by default)
  56414. */
  56415. maximumScale?: number,
  56416. /**
  56417. * Defines the step to use between two passes (0.5 by default)
  56418. */
  56419. step?: number);
  56420. /**
  56421. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56422. * @param scene defines the current scene where to apply this optimization
  56423. * @param optimizer defines the current optimizer
  56424. * @returns true if everything that can be done was applied
  56425. */
  56426. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56427. }
  56428. /**
  56429. * Defines an optimization used to remove shadows
  56430. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56431. */
  56432. export class ShadowsOptimization extends SceneOptimization {
  56433. /**
  56434. * Gets a string describing the action executed by the current optimization
  56435. * @return description string
  56436. */
  56437. getDescription(): string;
  56438. /**
  56439. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56440. * @param scene defines the current scene where to apply this optimization
  56441. * @param optimizer defines the current optimizer
  56442. * @returns true if everything that can be done was applied
  56443. */
  56444. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56445. }
  56446. /**
  56447. * Defines an optimization used to turn post-processes off
  56448. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56449. */
  56450. export class PostProcessesOptimization extends SceneOptimization {
  56451. /**
  56452. * Gets a string describing the action executed by the current optimization
  56453. * @return description string
  56454. */
  56455. getDescription(): string;
  56456. /**
  56457. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56458. * @param scene defines the current scene where to apply this optimization
  56459. * @param optimizer defines the current optimizer
  56460. * @returns true if everything that can be done was applied
  56461. */
  56462. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56463. }
  56464. /**
  56465. * Defines an optimization used to turn lens flares off
  56466. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56467. */
  56468. export class LensFlaresOptimization extends SceneOptimization {
  56469. /**
  56470. * Gets a string describing the action executed by the current optimization
  56471. * @return description string
  56472. */
  56473. getDescription(): string;
  56474. /**
  56475. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56476. * @param scene defines the current scene where to apply this optimization
  56477. * @param optimizer defines the current optimizer
  56478. * @returns true if everything that can be done was applied
  56479. */
  56480. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56481. }
  56482. /**
  56483. * Defines an optimization based on user defined callback.
  56484. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56485. */
  56486. export class CustomOptimization extends SceneOptimization {
  56487. /**
  56488. * Callback called to apply the custom optimization.
  56489. */
  56490. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  56491. /**
  56492. * Callback called to get custom description
  56493. */
  56494. onGetDescription: () => string;
  56495. /**
  56496. * Gets a string describing the action executed by the current optimization
  56497. * @returns description string
  56498. */
  56499. getDescription(): string;
  56500. /**
  56501. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56502. * @param scene defines the current scene where to apply this optimization
  56503. * @param optimizer defines the current optimizer
  56504. * @returns true if everything that can be done was applied
  56505. */
  56506. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56507. }
  56508. /**
  56509. * Defines an optimization used to turn particles off
  56510. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56511. */
  56512. export class ParticlesOptimization extends SceneOptimization {
  56513. /**
  56514. * Gets a string describing the action executed by the current optimization
  56515. * @return description string
  56516. */
  56517. getDescription(): string;
  56518. /**
  56519. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56520. * @param scene defines the current scene where to apply this optimization
  56521. * @param optimizer defines the current optimizer
  56522. * @returns true if everything that can be done was applied
  56523. */
  56524. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56525. }
  56526. /**
  56527. * Defines an optimization used to turn render targets off
  56528. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56529. */
  56530. export class RenderTargetsOptimization extends SceneOptimization {
  56531. /**
  56532. * Gets a string describing the action executed by the current optimization
  56533. * @return description string
  56534. */
  56535. getDescription(): string;
  56536. /**
  56537. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56538. * @param scene defines the current scene where to apply this optimization
  56539. * @param optimizer defines the current optimizer
  56540. * @returns true if everything that can be done was applied
  56541. */
  56542. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56543. }
  56544. /**
  56545. * Defines an optimization used to merge meshes with compatible materials
  56546. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56547. */
  56548. export class MergeMeshesOptimization extends SceneOptimization {
  56549. private static _UpdateSelectionTree;
  56550. /**
  56551. * Gets or sets a boolean which defines if optimization octree has to be updated
  56552. */
  56553. /**
  56554. * Gets or sets a boolean which defines if optimization octree has to be updated
  56555. */
  56556. static UpdateSelectionTree: boolean;
  56557. /**
  56558. * Gets a string describing the action executed by the current optimization
  56559. * @return description string
  56560. */
  56561. getDescription(): string;
  56562. private _canBeMerged;
  56563. /**
  56564. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56565. * @param scene defines the current scene where to apply this optimization
  56566. * @param optimizer defines the current optimizer
  56567. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  56568. * @returns true if everything that can be done was applied
  56569. */
  56570. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  56571. }
  56572. /**
  56573. * Defines a list of options used by SceneOptimizer
  56574. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56575. */
  56576. export class SceneOptimizerOptions {
  56577. /**
  56578. * Defines the target frame rate to reach (60 by default)
  56579. */
  56580. targetFrameRate: number;
  56581. /**
  56582. * Defines the interval between two checkes (2000ms by default)
  56583. */
  56584. trackerDuration: number;
  56585. /**
  56586. * Gets the list of optimizations to apply
  56587. */
  56588. optimizations: SceneOptimization[];
  56589. /**
  56590. * Creates a new list of options used by SceneOptimizer
  56591. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  56592. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  56593. */
  56594. constructor(
  56595. /**
  56596. * Defines the target frame rate to reach (60 by default)
  56597. */
  56598. targetFrameRate?: number,
  56599. /**
  56600. * Defines the interval between two checkes (2000ms by default)
  56601. */
  56602. trackerDuration?: number);
  56603. /**
  56604. * Add a new optimization
  56605. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  56606. * @returns the current SceneOptimizerOptions
  56607. */
  56608. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  56609. /**
  56610. * Add a new custom optimization
  56611. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  56612. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  56613. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56614. * @returns the current SceneOptimizerOptions
  56615. */
  56616. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  56617. /**
  56618. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  56619. * @param targetFrameRate defines the target frame rate (60 by default)
  56620. * @returns a SceneOptimizerOptions object
  56621. */
  56622. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56623. /**
  56624. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  56625. * @param targetFrameRate defines the target frame rate (60 by default)
  56626. * @returns a SceneOptimizerOptions object
  56627. */
  56628. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56629. /**
  56630. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  56631. * @param targetFrameRate defines the target frame rate (60 by default)
  56632. * @returns a SceneOptimizerOptions object
  56633. */
  56634. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  56635. }
  56636. /**
  56637. * Class used to run optimizations in order to reach a target frame rate
  56638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56639. */
  56640. export class SceneOptimizer implements IDisposable {
  56641. private _isRunning;
  56642. private _options;
  56643. private _scene;
  56644. private _currentPriorityLevel;
  56645. private _targetFrameRate;
  56646. private _trackerDuration;
  56647. private _currentFrameRate;
  56648. private _sceneDisposeObserver;
  56649. private _improvementMode;
  56650. /**
  56651. * Defines an observable called when the optimizer reaches the target frame rate
  56652. */
  56653. onSuccessObservable: Observable<SceneOptimizer>;
  56654. /**
  56655. * Defines an observable called when the optimizer enables an optimization
  56656. */
  56657. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  56658. /**
  56659. * Defines an observable called when the optimizer is not able to reach the target frame rate
  56660. */
  56661. onFailureObservable: Observable<SceneOptimizer>;
  56662. /**
  56663. * Gets a boolean indicating if the optimizer is in improvement mode
  56664. */
  56665. readonly isInImprovementMode: boolean;
  56666. /**
  56667. * Gets the current priority level (0 at start)
  56668. */
  56669. readonly currentPriorityLevel: number;
  56670. /**
  56671. * Gets the current frame rate checked by the SceneOptimizer
  56672. */
  56673. readonly currentFrameRate: number;
  56674. /**
  56675. * Gets or sets the current target frame rate (60 by default)
  56676. */
  56677. /**
  56678. * Gets or sets the current target frame rate (60 by default)
  56679. */
  56680. targetFrameRate: number;
  56681. /**
  56682. * Gets or sets the current interval between two checks (every 2000ms by default)
  56683. */
  56684. /**
  56685. * Gets or sets the current interval between two checks (every 2000ms by default)
  56686. */
  56687. trackerDuration: number;
  56688. /**
  56689. * Gets the list of active optimizations
  56690. */
  56691. readonly optimizations: SceneOptimization[];
  56692. /**
  56693. * Creates a new SceneOptimizer
  56694. * @param scene defines the scene to work on
  56695. * @param options defines the options to use with the SceneOptimizer
  56696. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  56697. * @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)
  56698. */
  56699. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  56700. /**
  56701. * Stops the current optimizer
  56702. */
  56703. stop(): void;
  56704. /**
  56705. * Reset the optimizer to initial step (current priority level = 0)
  56706. */
  56707. reset(): void;
  56708. /**
  56709. * Start the optimizer. By default it will try to reach a specific framerate
  56710. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  56711. */
  56712. start(): void;
  56713. private _checkCurrentState;
  56714. /**
  56715. * Release all resources
  56716. */
  56717. dispose(): void;
  56718. /**
  56719. * Helper function to create a SceneOptimizer with one single line of code
  56720. * @param scene defines the scene to work on
  56721. * @param options defines the options to use with the SceneOptimizer
  56722. * @param onSuccess defines a callback to call on success
  56723. * @param onFailure defines a callback to call on failure
  56724. * @returns the new SceneOptimizer object
  56725. */
  56726. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  56727. }
  56728. }
  56729. declare module BABYLON {
  56730. /**
  56731. * Class used to serialize a scene into a string
  56732. */
  56733. export class SceneSerializer {
  56734. /**
  56735. * Clear cache used by a previous serialization
  56736. */
  56737. static ClearCache(): void;
  56738. /**
  56739. * Serialize a scene into a JSON compatible object
  56740. * @param scene defines the scene to serialize
  56741. * @returns a JSON compatible object
  56742. */
  56743. static Serialize(scene: Scene): any;
  56744. /**
  56745. * Serialize a mesh into a JSON compatible object
  56746. * @param toSerialize defines the mesh to serialize
  56747. * @param withParents defines if parents must be serialized as well
  56748. * @param withChildren defines if children must be serialized as well
  56749. * @returns a JSON compatible object
  56750. */
  56751. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  56752. }
  56753. }
  56754. declare module BABYLON {
  56755. /**
  56756. * Class used to host texture specific utilities
  56757. */
  56758. export class TextureTools {
  56759. /**
  56760. * Uses the GPU to create a copy texture rescaled at a given size
  56761. * @param texture Texture to copy from
  56762. * @param width defines the desired width
  56763. * @param height defines the desired height
  56764. * @param useBilinearMode defines if bilinear mode has to be used
  56765. * @return the generated texture
  56766. */
  56767. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  56768. }
  56769. }
  56770. declare module BABYLON {
  56771. /**
  56772. * This represents the different options avilable for the video capture.
  56773. */
  56774. export interface VideoRecorderOptions {
  56775. /** Defines the mime type of the video */
  56776. mimeType: string;
  56777. /** Defines the video the video should be recorded at */
  56778. fps: number;
  56779. /** Defines the chunk size for the recording data */
  56780. recordChunckSize: number;
  56781. /** The audio tracks to attach to the record */
  56782. audioTracks?: MediaStreamTrack[];
  56783. }
  56784. /**
  56785. * This can helps recording videos from BabylonJS.
  56786. * This is based on the available WebRTC functionalities of the browser.
  56787. *
  56788. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  56789. */
  56790. export class VideoRecorder {
  56791. private static readonly _defaultOptions;
  56792. /**
  56793. * Returns wehther or not the VideoRecorder is available in your browser.
  56794. * @param engine Defines the Babylon Engine to check the support for
  56795. * @returns true if supported otherwise false
  56796. */
  56797. static IsSupported(engine: Engine): boolean;
  56798. private readonly _options;
  56799. private _canvas;
  56800. private _mediaRecorder;
  56801. private _recordedChunks;
  56802. private _fileName;
  56803. private _resolve;
  56804. private _reject;
  56805. /**
  56806. * True wether a recording is already in progress.
  56807. */
  56808. readonly isRecording: boolean;
  56809. /**
  56810. * Create a new VideoCapture object which can help converting what you see in Babylon to
  56811. * a video file.
  56812. * @param engine Defines the BabylonJS Engine you wish to record
  56813. * @param options Defines options that can be used to customized the capture
  56814. */
  56815. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  56816. /**
  56817. * Stops the current recording before the default capture timeout passed in the startRecording
  56818. * functions.
  56819. */
  56820. stopRecording(): void;
  56821. /**
  56822. * Starts recording the canvas for a max duration specified in parameters.
  56823. * @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.
  56824. * @param maxDuration Defines the maximum recording time in seconds.
  56825. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  56826. * @return a promise callback at the end of the recording with the video data in Blob.
  56827. */
  56828. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  56829. /**
  56830. * Releases internal resources used during the recording.
  56831. */
  56832. dispose(): void;
  56833. private _handleDataAvailable;
  56834. private _handleError;
  56835. private _handleStop;
  56836. }
  56837. }
  56838. declare module BABYLON {
  56839. /**
  56840. * Class containing a set of static utilities functions for screenshots
  56841. */
  56842. export class ScreenshotTools {
  56843. /**
  56844. * Captures a screenshot of the current rendering
  56845. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56846. * @param engine defines the rendering engine
  56847. * @param camera defines the source camera
  56848. * @param size This parameter can be set to a single number or to an object with the
  56849. * following (optional) properties: precision, width, height. If a single number is passed,
  56850. * it will be used for both width and height. If an object is passed, the screenshot size
  56851. * will be derived from the parameters. The precision property is a multiplier allowing
  56852. * rendering at a higher or lower resolution
  56853. * @param successCallback defines the callback receives a single parameter which contains the
  56854. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56855. * src parameter of an <img> to display it
  56856. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  56857. * Check your browser for supported MIME types
  56858. */
  56859. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  56860. /**
  56861. * Generates an image screenshot from the specified camera.
  56862. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  56863. * @param engine The engine to use for rendering
  56864. * @param camera The camera to use for rendering
  56865. * @param size This parameter can be set to a single number or to an object with the
  56866. * following (optional) properties: precision, width, height. If a single number is passed,
  56867. * it will be used for both width and height. If an object is passed, the screenshot size
  56868. * will be derived from the parameters. The precision property is a multiplier allowing
  56869. * rendering at a higher or lower resolution
  56870. * @param successCallback The callback receives a single parameter which contains the
  56871. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  56872. * src parameter of an <img> to display it
  56873. * @param mimeType The MIME type of the screenshot image (default: image/png).
  56874. * Check your browser for supported MIME types
  56875. * @param samples Texture samples (default: 1)
  56876. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  56877. * @param fileName A name for for the downloaded file.
  56878. */
  56879. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  56880. }
  56881. }
  56882. declare module BABYLON {
  56883. /**
  56884. * A cursor which tracks a point on a path
  56885. */
  56886. export class PathCursor {
  56887. private path;
  56888. /**
  56889. * Stores path cursor callbacks for when an onchange event is triggered
  56890. */
  56891. private _onchange;
  56892. /**
  56893. * The value of the path cursor
  56894. */
  56895. value: number;
  56896. /**
  56897. * The animation array of the path cursor
  56898. */
  56899. animations: Animation[];
  56900. /**
  56901. * Initializes the path cursor
  56902. * @param path The path to track
  56903. */
  56904. constructor(path: Path2);
  56905. /**
  56906. * Gets the cursor point on the path
  56907. * @returns A point on the path cursor at the cursor location
  56908. */
  56909. getPoint(): Vector3;
  56910. /**
  56911. * Moves the cursor ahead by the step amount
  56912. * @param step The amount to move the cursor forward
  56913. * @returns This path cursor
  56914. */
  56915. moveAhead(step?: number): PathCursor;
  56916. /**
  56917. * Moves the cursor behind by the step amount
  56918. * @param step The amount to move the cursor back
  56919. * @returns This path cursor
  56920. */
  56921. moveBack(step?: number): PathCursor;
  56922. /**
  56923. * Moves the cursor by the step amount
  56924. * If the step amount is greater than one, an exception is thrown
  56925. * @param step The amount to move the cursor
  56926. * @returns This path cursor
  56927. */
  56928. move(step: number): PathCursor;
  56929. /**
  56930. * Ensures that the value is limited between zero and one
  56931. * @returns This path cursor
  56932. */
  56933. private ensureLimits;
  56934. /**
  56935. * Runs onchange callbacks on change (used by the animation engine)
  56936. * @returns This path cursor
  56937. */
  56938. private raiseOnChange;
  56939. /**
  56940. * Executes a function on change
  56941. * @param f A path cursor onchange callback
  56942. * @returns This path cursor
  56943. */
  56944. onchange(f: (cursor: PathCursor) => void): PathCursor;
  56945. }
  56946. }
  56947. declare module BABYLON {
  56948. /** @hidden */
  56949. export var blurPixelShader: {
  56950. name: string;
  56951. shader: string;
  56952. };
  56953. }
  56954. declare module BABYLON {
  56955. /** @hidden */
  56956. export var bones300Declaration: {
  56957. name: string;
  56958. shader: string;
  56959. };
  56960. }
  56961. declare module BABYLON {
  56962. /** @hidden */
  56963. export var instances300Declaration: {
  56964. name: string;
  56965. shader: string;
  56966. };
  56967. }
  56968. declare module BABYLON {
  56969. /** @hidden */
  56970. export var pointCloudVertexDeclaration: {
  56971. name: string;
  56972. shader: string;
  56973. };
  56974. }
  56975. // Mixins
  56976. interface Window {
  56977. mozIndexedDB: IDBFactory;
  56978. webkitIndexedDB: IDBFactory;
  56979. msIndexedDB: IDBFactory;
  56980. webkitURL: typeof URL;
  56981. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  56982. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  56983. WebGLRenderingContext: WebGLRenderingContext;
  56984. MSGesture: MSGesture;
  56985. CANNON: any;
  56986. AudioContext: AudioContext;
  56987. webkitAudioContext: AudioContext;
  56988. PointerEvent: any;
  56989. Math: Math;
  56990. Uint8Array: Uint8ArrayConstructor;
  56991. Float32Array: Float32ArrayConstructor;
  56992. mozURL: typeof URL;
  56993. msURL: typeof URL;
  56994. VRFrameData: any; // WebVR, from specs 1.1
  56995. DracoDecoderModule: any;
  56996. setImmediate(handler: (...args: any[]) => void): number;
  56997. }
  56998. interface HTMLCanvasElement {
  56999. requestPointerLock(): void;
  57000. msRequestPointerLock?(): void;
  57001. mozRequestPointerLock?(): void;
  57002. webkitRequestPointerLock?(): void;
  57003. /** Track wether a record is in progress */
  57004. isRecording: boolean;
  57005. /** Capture Stream method defined by some browsers */
  57006. captureStream(fps?: number): MediaStream;
  57007. }
  57008. interface CanvasRenderingContext2D {
  57009. msImageSmoothingEnabled: boolean;
  57010. }
  57011. interface MouseEvent {
  57012. mozMovementX: number;
  57013. mozMovementY: number;
  57014. webkitMovementX: number;
  57015. webkitMovementY: number;
  57016. msMovementX: number;
  57017. msMovementY: number;
  57018. }
  57019. interface Navigator {
  57020. mozGetVRDevices: (any: any) => any;
  57021. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57022. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57023. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57024. webkitGetGamepads(): Gamepad[];
  57025. msGetGamepads(): Gamepad[];
  57026. webkitGamepads(): Gamepad[];
  57027. }
  57028. interface HTMLVideoElement {
  57029. mozSrcObject: any;
  57030. }
  57031. interface Math {
  57032. fround(x: number): number;
  57033. imul(a: number, b: number): number;
  57034. }
  57035. interface WebGLRenderingContext {
  57036. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57037. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57038. vertexAttribDivisor(index: number, divisor: number): void;
  57039. createVertexArray(): any;
  57040. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57041. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57042. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57043. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57044. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57045. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57046. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57047. // Queries
  57048. createQuery(): WebGLQuery;
  57049. deleteQuery(query: WebGLQuery): void;
  57050. beginQuery(target: number, query: WebGLQuery): void;
  57051. endQuery(target: number): void;
  57052. getQueryParameter(query: WebGLQuery, pname: number): any;
  57053. getQuery(target: number, pname: number): any;
  57054. MAX_SAMPLES: number;
  57055. RGBA8: number;
  57056. READ_FRAMEBUFFER: number;
  57057. DRAW_FRAMEBUFFER: number;
  57058. UNIFORM_BUFFER: number;
  57059. HALF_FLOAT_OES: number;
  57060. RGBA16F: number;
  57061. RGBA32F: number;
  57062. R32F: number;
  57063. RG32F: number;
  57064. RGB32F: number;
  57065. R16F: number;
  57066. RG16F: number;
  57067. RGB16F: number;
  57068. RED: number;
  57069. RG: number;
  57070. R8: number;
  57071. RG8: number;
  57072. UNSIGNED_INT_24_8: number;
  57073. DEPTH24_STENCIL8: number;
  57074. /* Multiple Render Targets */
  57075. drawBuffers(buffers: number[]): void;
  57076. readBuffer(src: number): void;
  57077. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57078. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57079. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57080. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57081. // Occlusion Query
  57082. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57083. ANY_SAMPLES_PASSED: number;
  57084. QUERY_RESULT_AVAILABLE: number;
  57085. QUERY_RESULT: number;
  57086. }
  57087. interface WebGLProgram {
  57088. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57089. }
  57090. interface EXT_disjoint_timer_query {
  57091. QUERY_COUNTER_BITS_EXT: number;
  57092. TIME_ELAPSED_EXT: number;
  57093. TIMESTAMP_EXT: number;
  57094. GPU_DISJOINT_EXT: number;
  57095. QUERY_RESULT_EXT: number;
  57096. QUERY_RESULT_AVAILABLE_EXT: number;
  57097. queryCounterEXT(query: WebGLQuery, target: number): void;
  57098. createQueryEXT(): WebGLQuery;
  57099. beginQueryEXT(target: number, query: WebGLQuery): void;
  57100. endQueryEXT(target: number): void;
  57101. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57102. deleteQueryEXT(query: WebGLQuery): void;
  57103. }
  57104. interface WebGLUniformLocation {
  57105. _currentState: any;
  57106. }
  57107. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57108. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57109. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57110. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57111. interface WebGLRenderingContext {
  57112. readonly RASTERIZER_DISCARD: number;
  57113. readonly DEPTH_COMPONENT24: number;
  57114. readonly TEXTURE_3D: number;
  57115. readonly TEXTURE_2D_ARRAY: number;
  57116. readonly TEXTURE_COMPARE_FUNC: number;
  57117. readonly TEXTURE_COMPARE_MODE: number;
  57118. readonly COMPARE_REF_TO_TEXTURE: number;
  57119. readonly TEXTURE_WRAP_R: number;
  57120. readonly HALF_FLOAT: number;
  57121. readonly RGB8: number;
  57122. readonly RED_INTEGER: number;
  57123. readonly RG_INTEGER: number;
  57124. readonly RGB_INTEGER: number;
  57125. readonly RGBA_INTEGER: number;
  57126. readonly R8_SNORM: number;
  57127. readonly RG8_SNORM: number;
  57128. readonly RGB8_SNORM: number;
  57129. readonly RGBA8_SNORM: number;
  57130. readonly R8I: number;
  57131. readonly RG8I: number;
  57132. readonly RGB8I: number;
  57133. readonly RGBA8I: number;
  57134. readonly R8UI: number;
  57135. readonly RG8UI: number;
  57136. readonly RGB8UI: number;
  57137. readonly RGBA8UI: number;
  57138. readonly R16I: number;
  57139. readonly RG16I: number;
  57140. readonly RGB16I: number;
  57141. readonly RGBA16I: number;
  57142. readonly R16UI: number;
  57143. readonly RG16UI: number;
  57144. readonly RGB16UI: number;
  57145. readonly RGBA16UI: number;
  57146. readonly R32I: number;
  57147. readonly RG32I: number;
  57148. readonly RGB32I: number;
  57149. readonly RGBA32I: number;
  57150. readonly R32UI: number;
  57151. readonly RG32UI: number;
  57152. readonly RGB32UI: number;
  57153. readonly RGBA32UI: number;
  57154. readonly RGB10_A2UI: number;
  57155. readonly R11F_G11F_B10F: number;
  57156. readonly RGB9_E5: number;
  57157. readonly RGB10_A2: number;
  57158. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57159. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57160. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57161. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57162. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57163. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57164. 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;
  57165. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57166. readonly TRANSFORM_FEEDBACK: number;
  57167. readonly INTERLEAVED_ATTRIBS: number;
  57168. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57169. createTransformFeedback(): WebGLTransformFeedback;
  57170. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57171. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57172. beginTransformFeedback(primitiveMode: number): void;
  57173. endTransformFeedback(): void;
  57174. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57175. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57176. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57177. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57178. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57179. }
  57180. interface ImageBitmap {
  57181. readonly width: number;
  57182. readonly height: number;
  57183. close(): void;
  57184. }
  57185. interface WebGLQuery extends WebGLObject {
  57186. }
  57187. declare var WebGLQuery: {
  57188. prototype: WebGLQuery;
  57189. new(): WebGLQuery;
  57190. };
  57191. interface WebGLSampler extends WebGLObject {
  57192. }
  57193. declare var WebGLSampler: {
  57194. prototype: WebGLSampler;
  57195. new(): WebGLSampler;
  57196. };
  57197. interface WebGLSync extends WebGLObject {
  57198. }
  57199. declare var WebGLSync: {
  57200. prototype: WebGLSync;
  57201. new(): WebGLSync;
  57202. };
  57203. interface WebGLTransformFeedback extends WebGLObject {
  57204. }
  57205. declare var WebGLTransformFeedback: {
  57206. prototype: WebGLTransformFeedback;
  57207. new(): WebGLTransformFeedback;
  57208. };
  57209. interface WebGLVertexArrayObject extends WebGLObject {
  57210. }
  57211. declare var WebGLVertexArrayObject: {
  57212. prototype: WebGLVertexArrayObject;
  57213. new(): WebGLVertexArrayObject;
  57214. };
  57215. // Type definitions for WebVR API
  57216. // Project: https://w3c.github.io/webvr/
  57217. // Definitions by: six a <https://github.com/lostfictions>
  57218. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57219. interface VRDisplay extends EventTarget {
  57220. /**
  57221. * Dictionary of capabilities describing the VRDisplay.
  57222. */
  57223. readonly capabilities: VRDisplayCapabilities;
  57224. /**
  57225. * z-depth defining the far plane of the eye view frustum
  57226. * enables mapping of values in the render target depth
  57227. * attachment to scene coordinates. Initially set to 10000.0.
  57228. */
  57229. depthFar: number;
  57230. /**
  57231. * z-depth defining the near plane of the eye view frustum
  57232. * enables mapping of values in the render target depth
  57233. * attachment to scene coordinates. Initially set to 0.01.
  57234. */
  57235. depthNear: number;
  57236. /**
  57237. * An identifier for this distinct VRDisplay. Used as an
  57238. * association point in the Gamepad API.
  57239. */
  57240. readonly displayId: number;
  57241. /**
  57242. * A display name, a user-readable name identifying it.
  57243. */
  57244. readonly displayName: string;
  57245. readonly isConnected: boolean;
  57246. readonly isPresenting: boolean;
  57247. /**
  57248. * If this VRDisplay supports room-scale experiences, the optional
  57249. * stage attribute contains details on the room-scale parameters.
  57250. */
  57251. readonly stageParameters: VRStageParameters | null;
  57252. /**
  57253. * Passing the value returned by `requestAnimationFrame` to
  57254. * `cancelAnimationFrame` will unregister the callback.
  57255. * @param handle Define the hanle of the request to cancel
  57256. */
  57257. cancelAnimationFrame(handle: number): void;
  57258. /**
  57259. * Stops presenting to the VRDisplay.
  57260. * @returns a promise to know when it stopped
  57261. */
  57262. exitPresent(): Promise<void>;
  57263. /**
  57264. * Return the current VREyeParameters for the given eye.
  57265. * @param whichEye Define the eye we want the parameter for
  57266. * @returns the eye parameters
  57267. */
  57268. getEyeParameters(whichEye: string): VREyeParameters;
  57269. /**
  57270. * Populates the passed VRFrameData with the information required to render
  57271. * the current frame.
  57272. * @param frameData Define the data structure to populate
  57273. * @returns true if ok otherwise false
  57274. */
  57275. getFrameData(frameData: VRFrameData): boolean;
  57276. /**
  57277. * Get the layers currently being presented.
  57278. * @returns the list of VR layers
  57279. */
  57280. getLayers(): VRLayer[];
  57281. /**
  57282. * Return a VRPose containing the future predicted pose of the VRDisplay
  57283. * when the current frame will be presented. The value returned will not
  57284. * change until JavaScript has returned control to the browser.
  57285. *
  57286. * The VRPose will contain the position, orientation, velocity,
  57287. * and acceleration of each of these properties.
  57288. * @returns the pose object
  57289. */
  57290. getPose(): VRPose;
  57291. /**
  57292. * Return the current instantaneous pose of the VRDisplay, with no
  57293. * prediction applied.
  57294. * @returns the current instantaneous pose
  57295. */
  57296. getImmediatePose(): VRPose;
  57297. /**
  57298. * The callback passed to `requestAnimationFrame` will be called
  57299. * any time a new frame should be rendered. When the VRDisplay is
  57300. * presenting the callback will be called at the native refresh
  57301. * rate of the HMD. When not presenting this function acts
  57302. * identically to how window.requestAnimationFrame acts. Content should
  57303. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57304. * asynchronously from other displays and at differing refresh rates.
  57305. * @param callback Define the eaction to run next frame
  57306. * @returns the request handle it
  57307. */
  57308. requestAnimationFrame(callback: FrameRequestCallback): number;
  57309. /**
  57310. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57311. * Repeat calls while already presenting will update the VRLayers being displayed.
  57312. * @param layers Define the list of layer to present
  57313. * @returns a promise to know when the request has been fulfilled
  57314. */
  57315. requestPresent(layers: VRLayer[]): Promise<void>;
  57316. /**
  57317. * Reset the pose for this display, treating its current position and
  57318. * orientation as the "origin/zero" values. VRPose.position,
  57319. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57320. * updated when calling resetPose(). This should be called in only
  57321. * sitting-space experiences.
  57322. */
  57323. resetPose(): void;
  57324. /**
  57325. * The VRLayer provided to the VRDisplay will be captured and presented
  57326. * in the HMD. Calling this function has the same effect on the source
  57327. * canvas as any other operation that uses its source image, and canvases
  57328. * created without preserveDrawingBuffer set to true will be cleared.
  57329. * @param pose Define the pose to submit
  57330. */
  57331. submitFrame(pose?: VRPose): void;
  57332. }
  57333. declare var VRDisplay: {
  57334. prototype: VRDisplay;
  57335. new(): VRDisplay;
  57336. };
  57337. interface VRLayer {
  57338. leftBounds?: number[] | Float32Array | null;
  57339. rightBounds?: number[] | Float32Array | null;
  57340. source?: HTMLCanvasElement | null;
  57341. }
  57342. interface VRDisplayCapabilities {
  57343. readonly canPresent: boolean;
  57344. readonly hasExternalDisplay: boolean;
  57345. readonly hasOrientation: boolean;
  57346. readonly hasPosition: boolean;
  57347. readonly maxLayers: number;
  57348. }
  57349. interface VREyeParameters {
  57350. /** @deprecated */
  57351. readonly fieldOfView: VRFieldOfView;
  57352. readonly offset: Float32Array;
  57353. readonly renderHeight: number;
  57354. readonly renderWidth: number;
  57355. }
  57356. interface VRFieldOfView {
  57357. readonly downDegrees: number;
  57358. readonly leftDegrees: number;
  57359. readonly rightDegrees: number;
  57360. readonly upDegrees: number;
  57361. }
  57362. interface VRFrameData {
  57363. readonly leftProjectionMatrix: Float32Array;
  57364. readonly leftViewMatrix: Float32Array;
  57365. readonly pose: VRPose;
  57366. readonly rightProjectionMatrix: Float32Array;
  57367. readonly rightViewMatrix: Float32Array;
  57368. readonly timestamp: number;
  57369. }
  57370. interface VRPose {
  57371. readonly angularAcceleration: Float32Array | null;
  57372. readonly angularVelocity: Float32Array | null;
  57373. readonly linearAcceleration: Float32Array | null;
  57374. readonly linearVelocity: Float32Array | null;
  57375. readonly orientation: Float32Array | null;
  57376. readonly position: Float32Array | null;
  57377. readonly timestamp: number;
  57378. }
  57379. interface VRStageParameters {
  57380. sittingToStandingTransform?: Float32Array;
  57381. sizeX?: number;
  57382. sizeY?: number;
  57383. }
  57384. interface Navigator {
  57385. getVRDisplays(): Promise<VRDisplay[]>;
  57386. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  57387. }
  57388. interface Window {
  57389. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  57390. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  57391. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  57392. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57393. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  57394. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  57395. }
  57396. interface Gamepad {
  57397. readonly displayId: number;
  57398. }
  57399. interface XRDevice {
  57400. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  57401. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  57402. }
  57403. interface XRSession {
  57404. getInputSources(): Array<any>;
  57405. baseLayer: XRWebGLLayer;
  57406. requestFrameOfReference(type: string): Promise<void>;
  57407. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  57408. end(): Promise<void>;
  57409. requestAnimationFrame: Function;
  57410. addEventListener: Function;
  57411. }
  57412. interface XRSessionCreationOptions {
  57413. outputContext?: WebGLRenderingContext | null;
  57414. immersive?: boolean;
  57415. environmentIntegration?: boolean;
  57416. }
  57417. interface XRLayer {
  57418. getViewport: Function;
  57419. framebufferWidth: number;
  57420. framebufferHeight: number;
  57421. }
  57422. interface XRView {
  57423. projectionMatrix: Float32Array;
  57424. }
  57425. interface XRFrame {
  57426. getDevicePose: Function;
  57427. getInputPose: Function;
  57428. views: Array<XRView>;
  57429. baseLayer: XRLayer;
  57430. }
  57431. interface XRFrameOfReference {
  57432. }
  57433. interface XRWebGLLayer extends XRLayer {
  57434. framebuffer: WebGLFramebuffer;
  57435. }
  57436. declare var XRWebGLLayer: {
  57437. prototype: XRWebGLLayer;
  57438. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  57439. };