babylon.d.ts 2.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */
  1821. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1822. /**
  1823. * Unproject from screen space to object space
  1824. * @param source defines the screen space Vector3 to use
  1825. * @param viewportWidth defines the current width of the viewport
  1826. * @param viewportHeight defines the current height of the viewport
  1827. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1828. * @param transform defines the transform (view x projection) matrix to use
  1829. * @returns the new Vector3
  1830. */
  1831. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1832. /**
  1833. * Unproject from screen space to object space
  1834. * @param source defines the screen space Vector3 to use
  1835. * @param viewportWidth defines the current width of the viewport
  1836. * @param viewportHeight defines the current height of the viewport
  1837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1838. * @param view defines the view matrix to use
  1839. * @param projection defines the projection matrix to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1843. /**
  1844. * Unproject from screen space to object space
  1845. * @param source defines the screen space Vector3 to use
  1846. * @param viewportWidth defines the current width of the viewport
  1847. * @param viewportHeight defines the current height of the viewport
  1848. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1849. * @param view defines the view matrix to use
  1850. * @param projection defines the projection matrix to use
  1851. * @param result defines the Vector3 where to store the result
  1852. */
  1853. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param sourceX defines the screen space x coordinate to use
  1857. * @param sourceY defines the screen space y coordinate to use
  1858. * @param sourceZ defines the screen space z coordinate to use
  1859. * @param viewportWidth defines the current width of the viewport
  1860. * @param viewportHeight defines the current height of the viewport
  1861. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1862. * @param view defines the view matrix to use
  1863. * @param projection defines the projection matrix to use
  1864. * @param result defines the Vector3 where to store the result
  1865. */
  1866. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1867. /**
  1868. * Gets the minimal coordinate values between two Vector3
  1869. * @param left defines the first operand
  1870. * @param right defines the second operand
  1871. * @returns the new Vector3
  1872. */
  1873. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1874. /**
  1875. * Gets the maximal coordinate values between two Vector3
  1876. * @param left defines the first operand
  1877. * @param right defines the second operand
  1878. * @returns the new Vector3
  1879. */
  1880. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1881. /**
  1882. * Returns the distance between the vectors "value1" and "value2"
  1883. * @param value1 defines the first operand
  1884. * @param value2 defines the second operand
  1885. * @returns the distance
  1886. */
  1887. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1888. /**
  1889. * Returns the squared distance between the vectors "value1" and "value2"
  1890. * @param value1 defines the first operand
  1891. * @param value2 defines the second operand
  1892. * @returns the squared distance
  1893. */
  1894. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1895. /**
  1896. * Returns a new Vector3 located at the center between "value1" and "value2"
  1897. * @param value1 defines the first operand
  1898. * @param value2 defines the second operand
  1899. * @returns the new Vector3
  1900. */
  1901. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1902. /**
  1903. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1904. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1905. * to something in order to rotate it from its local system to the given target system
  1906. * Note: axis1, axis2 and axis3 are normalized during this operation
  1907. * @param axis1 defines the first axis
  1908. * @param axis2 defines the second axis
  1909. * @param axis3 defines the third axis
  1910. * @returns a new Vector3
  1911. */
  1912. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1913. /**
  1914. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1915. * @param axis1 defines the first axis
  1916. * @param axis2 defines the second axis
  1917. * @param axis3 defines the third axis
  1918. * @param ref defines the Vector3 where to store the result
  1919. */
  1920. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1921. }
  1922. /**
  1923. * Vector4 class created for EulerAngle class conversion to Quaternion
  1924. */
  1925. export class Vector4 {
  1926. /** x value of the vector */
  1927. x: number;
  1928. /** y value of the vector */
  1929. y: number;
  1930. /** z value of the vector */
  1931. z: number;
  1932. /** w value of the vector */
  1933. w: number;
  1934. /**
  1935. * Creates a Vector4 object from the given floats.
  1936. * @param x x value of the vector
  1937. * @param y y value of the vector
  1938. * @param z z value of the vector
  1939. * @param w w value of the vector
  1940. */
  1941. constructor(
  1942. /** x value of the vector */
  1943. x: number,
  1944. /** y value of the vector */
  1945. y: number,
  1946. /** z value of the vector */
  1947. z: number,
  1948. /** w value of the vector */
  1949. w: number);
  1950. /**
  1951. * Returns the string with the Vector4 coordinates.
  1952. * @returns a string containing all the vector values
  1953. */
  1954. toString(): string;
  1955. /**
  1956. * Returns the string "Vector4".
  1957. * @returns "Vector4"
  1958. */
  1959. getClassName(): string;
  1960. /**
  1961. * Returns the Vector4 hash code.
  1962. * @returns a unique hash code
  1963. */
  1964. getHashCode(): number;
  1965. /**
  1966. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1967. * @returns the resulting array
  1968. */
  1969. asArray(): number[];
  1970. /**
  1971. * Populates the given array from the given index with the Vector4 coordinates.
  1972. * @param array array to populate
  1973. * @param index index of the array to start at (default: 0)
  1974. * @returns the Vector4.
  1975. */
  1976. toArray(array: FloatArray, index?: number): Vector4;
  1977. /**
  1978. * Adds the given vector to the current Vector4.
  1979. * @param otherVector the vector to add
  1980. * @returns the updated Vector4.
  1981. */
  1982. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1983. /**
  1984. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1985. * @param otherVector the vector to add
  1986. * @returns the resulting vector
  1987. */
  1988. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1989. /**
  1990. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1991. * @param otherVector the vector to add
  1992. * @param result the vector to store the result
  1993. * @returns the current Vector4.
  1994. */
  1995. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1996. /**
  1997. * Subtract in place the given vector from the current Vector4.
  1998. * @param otherVector the vector to subtract
  1999. * @returns the updated Vector4.
  2000. */
  2001. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2002. /**
  2003. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the new vector with the result
  2006. */
  2007. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2010. * @param otherVector the vector to subtract
  2011. * @param result the vector to store the result
  2012. * @returns the current Vector4.
  2013. */
  2014. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2015. /**
  2016. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2017. */
  2018. /**
  2019. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2020. * @param x value to subtract
  2021. * @param y value to subtract
  2022. * @param z value to subtract
  2023. * @param w value to subtract
  2024. * @returns new vector containing the result
  2025. */
  2026. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2027. /**
  2028. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2029. * @param x value to subtract
  2030. * @param y value to subtract
  2031. * @param z value to subtract
  2032. * @param w value to subtract
  2033. * @param result the vector to store the result in
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2039. * @returns a new vector with the negated values
  2040. */
  2041. negate(): Vector4;
  2042. /**
  2043. * Multiplies the current Vector4 coordinates by scale (float).
  2044. * @param scale the number to scale with
  2045. * @returns the updated Vector4.
  2046. */
  2047. scaleInPlace(scale: number): Vector4;
  2048. /**
  2049. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2050. * @param scale the number to scale with
  2051. * @returns a new vector with the result
  2052. */
  2053. scale(scale: number): Vector4;
  2054. /**
  2055. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2056. * @param scale the number to scale with
  2057. * @param result a vector to store the result in
  2058. * @returns the current Vector4.
  2059. */
  2060. scaleToRef(scale: number, result: Vector4): Vector4;
  2061. /**
  2062. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2063. * @param scale defines the scale factor
  2064. * @param result defines the Vector4 object where to store the result
  2065. * @returns the unmodified current Vector4
  2066. */
  2067. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2068. /**
  2069. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2070. * @param otherVector the vector to compare against
  2071. * @returns true if they are equal
  2072. */
  2073. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2074. /**
  2075. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2076. * @param otherVector vector to compare against
  2077. * @param epsilon (Default: very small number)
  2078. * @returns true if they are equal
  2079. */
  2080. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2081. /**
  2082. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2083. * @param x x value to compare against
  2084. * @param y y value to compare against
  2085. * @param z z value to compare against
  2086. * @param w w value to compare against
  2087. * @returns true if equal
  2088. */
  2089. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2090. /**
  2091. * Multiplies in place the current Vector4 by the given one.
  2092. * @param otherVector vector to multiple with
  2093. * @returns the updated Vector4.
  2094. */
  2095. multiplyInPlace(otherVector: Vector4): Vector4;
  2096. /**
  2097. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2098. * @param otherVector vector to multiple with
  2099. * @returns resulting new vector
  2100. */
  2101. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2102. /**
  2103. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2104. * @param otherVector vector to multiple with
  2105. * @param result vector to store the result
  2106. * @returns the current Vector4.
  2107. */
  2108. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2109. /**
  2110. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2111. * @param x x value multiply with
  2112. * @param y y value multiply with
  2113. * @param z z value multiply with
  2114. * @param w w value multiply with
  2115. * @returns resulting new vector
  2116. */
  2117. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2120. * @param otherVector vector to devide with
  2121. * @returns resulting new vector
  2122. */
  2123. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2126. * @param otherVector vector to devide with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Divides the current Vector3 coordinates by the given ones.
  2133. * @param otherVector vector to devide with
  2134. * @returns the updated Vector3.
  2135. */
  2136. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2137. /**
  2138. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2139. * @param other defines the second operand
  2140. * @returns the current updated Vector4
  2141. */
  2142. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2143. /**
  2144. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2145. * @param other defines the second operand
  2146. * @returns the current updated Vector4
  2147. */
  2148. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Gets a new Vector4 from current Vector4 floored values
  2151. * @returns a new Vector4
  2152. */
  2153. floor(): Vector4;
  2154. /**
  2155. * Gets a new Vector4 from current Vector3 floored values
  2156. * @returns a new Vector4
  2157. */
  2158. fract(): Vector4;
  2159. /**
  2160. * Returns the Vector4 length (float).
  2161. * @returns the length
  2162. */
  2163. length(): number;
  2164. /**
  2165. * Returns the Vector4 squared length (float).
  2166. * @returns the length squared
  2167. */
  2168. lengthSquared(): number;
  2169. /**
  2170. * Normalizes in place the Vector4.
  2171. * @returns the updated Vector4.
  2172. */
  2173. normalize(): Vector4;
  2174. /**
  2175. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2176. * @returns this converted to a new vector3
  2177. */
  2178. toVector3(): Vector3;
  2179. /**
  2180. * Returns a new Vector4 copied from the current one.
  2181. * @returns the new cloned vector
  2182. */
  2183. clone(): Vector4;
  2184. /**
  2185. * Updates the current Vector4 with the given one coordinates.
  2186. * @param source the source vector to copy from
  2187. * @returns the updated Vector4.
  2188. */
  2189. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2190. /**
  2191. * Updates the current Vector4 coordinates with the given floats.
  2192. * @param x float to copy from
  2193. * @param y float to copy from
  2194. * @param z float to copy from
  2195. * @param w float to copy from
  2196. * @returns the updated Vector4.
  2197. */
  2198. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2199. /**
  2200. * Updates the current Vector4 coordinates with the given floats.
  2201. * @param x float to set from
  2202. * @param y float to set from
  2203. * @param z float to set from
  2204. * @param w float to set from
  2205. * @returns the updated Vector4.
  2206. */
  2207. set(x: number, y: number, z: number, w: number): Vector4;
  2208. /**
  2209. * Copies the given float to the current Vector3 coordinates
  2210. * @param v defines the x, y, z and w coordinates of the operand
  2211. * @returns the current updated Vector3
  2212. */
  2213. setAll(v: number): Vector4;
  2214. /**
  2215. * Returns a new Vector4 set from the starting index of the given array.
  2216. * @param array the array to pull values from
  2217. * @param offset the offset into the array to start at
  2218. * @returns the new vector
  2219. */
  2220. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2221. /**
  2222. * Updates the given vector "result" from the starting index of the given array.
  2223. * @param array the array to pull values from
  2224. * @param offset the offset into the array to start at
  2225. * @param result the vector to store the result in
  2226. */
  2227. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2228. /**
  2229. * Updates the given vector "result" from the starting index of the given Float32Array.
  2230. * @param array the array to pull values from
  2231. * @param offset the offset into the array to start at
  2232. * @param result the vector to store the result in
  2233. */
  2234. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2235. /**
  2236. * Updates the given vector "result" coordinates from the given floats.
  2237. * @param x float to set from
  2238. * @param y float to set from
  2239. * @param z float to set from
  2240. * @param w float to set from
  2241. * @param result the vector to the floats in
  2242. */
  2243. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2244. /**
  2245. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2246. * @returns the new vector
  2247. */
  2248. static Zero(): Vector4;
  2249. /**
  2250. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2251. * @returns the new vector
  2252. */
  2253. static One(): Vector4;
  2254. /**
  2255. * Returns a new normalized Vector4 from the given one.
  2256. * @param vector the vector to normalize
  2257. * @returns the vector
  2258. */
  2259. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2260. /**
  2261. * Updates the given vector "result" from the normalization of the given one.
  2262. * @param vector the vector to normalize
  2263. * @param result the vector to store the result in
  2264. */
  2265. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2266. /**
  2267. * Returns a vector with the minimum values from the left and right vectors
  2268. * @param left left vector to minimize
  2269. * @param right right vector to minimize
  2270. * @returns a new vector with the minimum of the left and right vector values
  2271. */
  2272. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2273. /**
  2274. * Returns a vector with the maximum values from the left and right vectors
  2275. * @param left left vector to maximize
  2276. * @param right right vector to maximize
  2277. * @returns a new vector with the maximum of the left and right vector values
  2278. */
  2279. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2280. /**
  2281. * Returns the distance (float) between the vectors "value1" and "value2".
  2282. * @param value1 value to calulate the distance between
  2283. * @param value2 value to calulate the distance between
  2284. * @return the distance between the two vectors
  2285. */
  2286. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2287. /**
  2288. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2289. * @param value1 value to calulate the distance between
  2290. * @param value2 value to calulate the distance between
  2291. * @return the distance between the two vectors squared
  2292. */
  2293. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2294. /**
  2295. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2296. * @param value1 value to calulate the center between
  2297. * @param value2 value to calulate the center between
  2298. * @return the center between the two vectors
  2299. */
  2300. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2303. * This methods computes transformed normalized direction vectors only.
  2304. * @param vector the vector to transform
  2305. * @param transformation the transformation matrix to apply
  2306. * @returns the new vector
  2307. */
  2308. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2309. /**
  2310. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2311. * This methods computes transformed normalized direction vectors only.
  2312. * @param vector the vector to transform
  2313. * @param transformation the transformation matrix to apply
  2314. * @param result the vector to store the result in
  2315. */
  2316. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2317. /**
  2318. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2319. * This methods computes transformed normalized direction vectors only.
  2320. * @param x value to transform
  2321. * @param y value to transform
  2322. * @param z value to transform
  2323. * @param w value to transform
  2324. * @param transformation the transformation matrix to apply
  2325. * @param result the vector to store the results in
  2326. */
  2327. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2328. /**
  2329. * Creates a new Vector4 from a Vector3
  2330. * @param source defines the source data
  2331. * @param w defines the 4th component (default is 0)
  2332. * @returns a new Vector4
  2333. */
  2334. static FromVector3(source: Vector3, w?: number): Vector4;
  2335. }
  2336. /**
  2337. * Interface for the size containing width and height
  2338. */
  2339. export interface ISize {
  2340. /**
  2341. * Width
  2342. */
  2343. width: number;
  2344. /**
  2345. * Heighht
  2346. */
  2347. height: number;
  2348. }
  2349. /**
  2350. * Size containing widht and height
  2351. */
  2352. export class Size implements ISize {
  2353. /**
  2354. * Width
  2355. */
  2356. width: number;
  2357. /**
  2358. * Height
  2359. */
  2360. height: number;
  2361. /**
  2362. * Creates a Size object from the given width and height (floats).
  2363. * @param width width of the new size
  2364. * @param height height of the new size
  2365. */
  2366. constructor(width: number, height: number);
  2367. /**
  2368. * Returns a string with the Size width and height
  2369. * @returns a string with the Size width and height
  2370. */
  2371. toString(): string;
  2372. /**
  2373. * "Size"
  2374. * @returns the string "Size"
  2375. */
  2376. getClassName(): string;
  2377. /**
  2378. * Returns the Size hash code.
  2379. * @returns a hash code for a unique width and height
  2380. */
  2381. getHashCode(): number;
  2382. /**
  2383. * Updates the current size from the given one.
  2384. * @param src the given size
  2385. */
  2386. copyFrom(src: Size): void;
  2387. /**
  2388. * Updates in place the current Size from the given floats.
  2389. * @param width width of the new size
  2390. * @param height height of the new size
  2391. * @returns the updated Size.
  2392. */
  2393. copyFromFloats(width: number, height: number): Size;
  2394. /**
  2395. * Updates in place the current Size from the given floats.
  2396. * @param width width to set
  2397. * @param height height to set
  2398. * @returns the updated Size.
  2399. */
  2400. set(width: number, height: number): Size;
  2401. /**
  2402. * Multiplies the width and height by numbers
  2403. * @param w factor to multiple the width by
  2404. * @param h factor to multiple the height by
  2405. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2406. */
  2407. multiplyByFloats(w: number, h: number): Size;
  2408. /**
  2409. * Clones the size
  2410. * @returns a new Size copied from the given one.
  2411. */
  2412. clone(): Size;
  2413. /**
  2414. * True if the current Size and the given one width and height are strictly equal.
  2415. * @param other the other size to compare against
  2416. * @returns True if the current Size and the given one width and height are strictly equal.
  2417. */
  2418. equals(other: Size): boolean;
  2419. /**
  2420. * The surface of the Size : width * height (float).
  2421. */
  2422. readonly surface: number;
  2423. /**
  2424. * Create a new size of zero
  2425. * @returns a new Size set to (0.0, 0.0)
  2426. */
  2427. static Zero(): Size;
  2428. /**
  2429. * Sums the width and height of two sizes
  2430. * @param otherSize size to add to this size
  2431. * @returns a new Size set as the addition result of the current Size and the given one.
  2432. */
  2433. add(otherSize: Size): Size;
  2434. /**
  2435. * Subtracts the width and height of two
  2436. * @param otherSize size to subtract to this size
  2437. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2438. */
  2439. subtract(otherSize: Size): Size;
  2440. /**
  2441. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2442. * @param start starting size to lerp between
  2443. * @param end end size to lerp between
  2444. * @param amount amount to lerp between the start and end values
  2445. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2446. */
  2447. static Lerp(start: Size, end: Size, amount: number): Size;
  2448. }
  2449. /**
  2450. * Class used to store quaternion data
  2451. * @see https://en.wikipedia.org/wiki/Quaternion
  2452. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2453. */
  2454. export class Quaternion {
  2455. /** defines the first component (0 by default) */
  2456. x: number;
  2457. /** defines the second component (0 by default) */
  2458. y: number;
  2459. /** defines the third component (0 by default) */
  2460. z: number;
  2461. /** defines the fourth component (1.0 by default) */
  2462. w: number;
  2463. /**
  2464. * Creates a new Quaternion from the given floats
  2465. * @param x defines the first component (0 by default)
  2466. * @param y defines the second component (0 by default)
  2467. * @param z defines the third component (0 by default)
  2468. * @param w defines the fourth component (1.0 by default)
  2469. */
  2470. constructor(
  2471. /** defines the first component (0 by default) */
  2472. x?: number,
  2473. /** defines the second component (0 by default) */
  2474. y?: number,
  2475. /** defines the third component (0 by default) */
  2476. z?: number,
  2477. /** defines the fourth component (1.0 by default) */
  2478. w?: number);
  2479. /**
  2480. * Gets a string representation for the current quaternion
  2481. * @returns a string with the Quaternion coordinates
  2482. */
  2483. toString(): string;
  2484. /**
  2485. * Gets the class name of the quaternion
  2486. * @returns the string "Quaternion"
  2487. */
  2488. getClassName(): string;
  2489. /**
  2490. * Gets a hash code for this quaternion
  2491. * @returns the quaternion hash code
  2492. */
  2493. getHashCode(): number;
  2494. /**
  2495. * Copy the quaternion to an array
  2496. * @returns a new array populated with 4 elements from the quaternion coordinates
  2497. */
  2498. asArray(): number[];
  2499. /**
  2500. * Check if two quaternions are equals
  2501. * @param otherQuaternion defines the second operand
  2502. * @return true if the current quaternion and the given one coordinates are strictly equals
  2503. */
  2504. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2505. /**
  2506. * Clone the current quaternion
  2507. * @returns a new quaternion copied from the current one
  2508. */
  2509. clone(): Quaternion;
  2510. /**
  2511. * Copy a quaternion to the current one
  2512. * @param other defines the other quaternion
  2513. * @returns the updated current quaternion
  2514. */
  2515. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2516. /**
  2517. * Updates the current quaternion with the given float coordinates
  2518. * @param x defines the x coordinate
  2519. * @param y defines the y coordinate
  2520. * @param z defines the z coordinate
  2521. * @param w defines the w coordinate
  2522. * @returns the updated current quaternion
  2523. */
  2524. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2525. /**
  2526. * Updates the current quaternion from the given float coordinates
  2527. * @param x defines the x coordinate
  2528. * @param y defines the y coordinate
  2529. * @param z defines the z coordinate
  2530. * @param w defines the w coordinate
  2531. * @returns the updated current quaternion
  2532. */
  2533. set(x: number, y: number, z: number, w: number): Quaternion;
  2534. /**
  2535. * Adds two quaternions
  2536. * @param other defines the second operand
  2537. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2538. */
  2539. add(other: DeepImmutable<Quaternion>): Quaternion;
  2540. /**
  2541. * Add a quaternion to the current one
  2542. * @param other defines the quaternion to add
  2543. * @returns the current quaternion
  2544. */
  2545. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2546. /**
  2547. * Subtract two quaternions
  2548. * @param other defines the second operand
  2549. * @returns a new quaternion as the subtraction result of the given one from the current one
  2550. */
  2551. subtract(other: Quaternion): Quaternion;
  2552. /**
  2553. * Multiplies the current quaternion by a scale factor
  2554. * @param value defines the scale factor
  2555. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2556. */
  2557. scale(value: number): Quaternion;
  2558. /**
  2559. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2560. * @param scale defines the scale factor
  2561. * @param result defines the Quaternion object where to store the result
  2562. * @returns the unmodified current quaternion
  2563. */
  2564. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2565. /**
  2566. * Multiplies in place the current quaternion by a scale factor
  2567. * @param value defines the scale factor
  2568. * @returns the current modified quaternion
  2569. */
  2570. scaleInPlace(value: number): Quaternion;
  2571. /**
  2572. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2573. * @param scale defines the scale factor
  2574. * @param result defines the Quaternion object where to store the result
  2575. * @returns the unmodified current quaternion
  2576. */
  2577. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2578. /**
  2579. * Multiplies two quaternions
  2580. * @param q1 defines the second operand
  2581. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2582. */
  2583. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2584. /**
  2585. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2586. * @param q1 defines the second operand
  2587. * @param result defines the target quaternion
  2588. * @returns the current quaternion
  2589. */
  2590. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2591. /**
  2592. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2593. * @param q1 defines the second operand
  2594. * @returns the currentupdated quaternion
  2595. */
  2596. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2597. /**
  2598. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2599. * @param ref defines the target quaternion
  2600. * @returns the current quaternion
  2601. */
  2602. conjugateToRef(ref: Quaternion): Quaternion;
  2603. /**
  2604. * Conjugates in place (1-q) the current quaternion
  2605. * @returns the current updated quaternion
  2606. */
  2607. conjugateInPlace(): Quaternion;
  2608. /**
  2609. * Conjugates in place (1-q) the current quaternion
  2610. * @returns a new quaternion
  2611. */
  2612. conjugate(): Quaternion;
  2613. /**
  2614. * Gets length of current quaternion
  2615. * @returns the quaternion length (float)
  2616. */
  2617. length(): number;
  2618. /**
  2619. * Normalize in place the current quaternion
  2620. * @returns the current updated quaternion
  2621. */
  2622. normalize(): Quaternion;
  2623. /**
  2624. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2625. * @param order is a reserved parameter and is ignore for now
  2626. * @returns a new Vector3 containing the Euler angles
  2627. */
  2628. toEulerAngles(order?: string): Vector3;
  2629. /**
  2630. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2631. * @param result defines the vector which will be filled with the Euler angles
  2632. * @param order is a reserved parameter and is ignore for now
  2633. * @returns the current unchanged quaternion
  2634. */
  2635. toEulerAnglesToRef(result: Vector3): Quaternion;
  2636. /**
  2637. * Updates the given rotation matrix with the current quaternion values
  2638. * @param result defines the target matrix
  2639. * @returns the current unchanged quaternion
  2640. */
  2641. toRotationMatrix(result: Matrix): Quaternion;
  2642. /**
  2643. * Updates the current quaternion from the given rotation matrix values
  2644. * @param matrix defines the source matrix
  2645. * @returns the current updated quaternion
  2646. */
  2647. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2648. /**
  2649. * Creates a new quaternion from a rotation matrix
  2650. * @param matrix defines the source matrix
  2651. * @returns a new quaternion created from the given rotation matrix values
  2652. */
  2653. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2654. /**
  2655. * Updates the given quaternion with the given rotation matrix values
  2656. * @param matrix defines the source matrix
  2657. * @param result defines the target quaternion
  2658. */
  2659. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2660. /**
  2661. * Returns the dot product (float) between the quaternions "left" and "right"
  2662. * @param left defines the left operand
  2663. * @param right defines the right operand
  2664. * @returns the dot product
  2665. */
  2666. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2667. /**
  2668. * Checks if the two quaternions are close to each other
  2669. * @param quat0 defines the first quaternion to check
  2670. * @param quat1 defines the second quaternion to check
  2671. * @returns true if the two quaternions are close to each other
  2672. */
  2673. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2674. /**
  2675. * Creates an empty quaternion
  2676. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2677. */
  2678. static Zero(): Quaternion;
  2679. /**
  2680. * Inverse a given quaternion
  2681. * @param q defines the source quaternion
  2682. * @returns a new quaternion as the inverted current quaternion
  2683. */
  2684. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2685. /**
  2686. * Inverse a given quaternion
  2687. * @param q defines the source quaternion
  2688. * @param result the quaternion the result will be stored in
  2689. * @returns the result quaternion
  2690. */
  2691. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2692. /**
  2693. * Creates an identity quaternion
  2694. * @returns the identity quaternion
  2695. */
  2696. static Identity(): Quaternion;
  2697. /**
  2698. * Gets a boolean indicating if the given quaternion is identity
  2699. * @param quaternion defines the quaternion to check
  2700. * @returns true if the quaternion is identity
  2701. */
  2702. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2703. /**
  2704. * Creates a quaternion from a rotation around an axis
  2705. * @param axis defines the axis to use
  2706. * @param angle defines the angle to use
  2707. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2708. */
  2709. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2710. /**
  2711. * Creates a rotation around an axis and stores it into the given quaternion
  2712. * @param axis defines the axis to use
  2713. * @param angle defines the angle to use
  2714. * @param result defines the target quaternion
  2715. * @returns the target quaternion
  2716. */
  2717. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from data stored into an array
  2720. * @param array defines the data source
  2721. * @param offset defines the offset in the source array where the data starts
  2722. * @returns a new quaternion
  2723. */
  2724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2725. /**
  2726. * Create a quaternion from Euler rotation angles
  2727. * @param x Pitch
  2728. * @param y Yaw
  2729. * @param z Roll
  2730. * @returns the new Quaternion
  2731. */
  2732. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2733. /**
  2734. * Updates a quaternion from Euler rotation angles
  2735. * @param x Pitch
  2736. * @param y Yaw
  2737. * @param z Roll
  2738. * @param result the quaternion to store the result
  2739. * @returns the updated quaternion
  2740. */
  2741. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2742. /**
  2743. * Create a quaternion from Euler rotation vector
  2744. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2745. * @returns the new Quaternion
  2746. */
  2747. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2748. /**
  2749. * Updates a quaternion from Euler rotation vector
  2750. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2751. * @param result the quaternion to store the result
  2752. * @returns the updated quaternion
  2753. */
  2754. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2755. /**
  2756. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2757. * @param yaw defines the rotation around Y axis
  2758. * @param pitch defines the rotation around X axis
  2759. * @param roll defines the rotation around Z axis
  2760. * @returns the new quaternion
  2761. */
  2762. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2763. /**
  2764. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2765. * @param yaw defines the rotation around Y axis
  2766. * @param pitch defines the rotation around X axis
  2767. * @param roll defines the rotation around Z axis
  2768. * @param result defines the target quaternion
  2769. */
  2770. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2771. /**
  2772. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2773. * @param alpha defines the rotation around first axis
  2774. * @param beta defines the rotation around second axis
  2775. * @param gamma defines the rotation around third axis
  2776. * @returns the new quaternion
  2777. */
  2778. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2779. /**
  2780. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2781. * @param alpha defines the rotation around first axis
  2782. * @param beta defines the rotation around second axis
  2783. * @param gamma defines the rotation around third axis
  2784. * @param result defines the target quaternion
  2785. */
  2786. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2787. /**
  2788. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2789. * @param axis1 defines the first axis
  2790. * @param axis2 defines the second axis
  2791. * @param axis3 defines the third axis
  2792. * @returns the new quaternion
  2793. */
  2794. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2795. /**
  2796. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2797. * @param axis1 defines the first axis
  2798. * @param axis2 defines the second axis
  2799. * @param axis3 defines the third axis
  2800. * @param ref defines the target quaternion
  2801. */
  2802. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2803. /**
  2804. * Interpolates between two quaternions
  2805. * @param left defines first quaternion
  2806. * @param right defines second quaternion
  2807. * @param amount defines the gradient to use
  2808. * @returns the new interpolated quaternion
  2809. */
  2810. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2811. /**
  2812. * Interpolates between two quaternions and stores it into a target quaternion
  2813. * @param left defines first quaternion
  2814. * @param right defines second quaternion
  2815. * @param amount defines the gradient to use
  2816. * @param result defines the target quaternion
  2817. */
  2818. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2819. /**
  2820. * Interpolate between two quaternions using Hermite interpolation
  2821. * @param value1 defines first quaternion
  2822. * @param tangent1 defines the incoming tangent
  2823. * @param value2 defines second quaternion
  2824. * @param tangent2 defines the outgoing tangent
  2825. * @param amount defines the target quaternion
  2826. * @returns the new interpolated quaternion
  2827. */
  2828. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2829. }
  2830. /**
  2831. * Class used to store matrix data (4x4)
  2832. */
  2833. export class Matrix {
  2834. private static _updateFlagSeed;
  2835. private static _identityReadOnly;
  2836. private _isIdentity;
  2837. private _isIdentityDirty;
  2838. private _isIdentity3x2;
  2839. private _isIdentity3x2Dirty;
  2840. /**
  2841. * Gets the update flag of the matrix which is an unique number for the matrix.
  2842. * It will be incremented every time the matrix data change.
  2843. * You can use it to speed the comparison between two versions of the same matrix.
  2844. */
  2845. updateFlag: number;
  2846. private readonly _m;
  2847. /**
  2848. * Gets the internal data of the matrix
  2849. */
  2850. readonly m: DeepImmutable<Float32Array>;
  2851. /** @hidden */
  2852. _markAsUpdated(): void;
  2853. /** @hidden */
  2854. private _updateIdentityStatus;
  2855. /**
  2856. * Creates an empty matrix (filled with zeros)
  2857. */
  2858. constructor();
  2859. /**
  2860. * Check if the current matrix is identity
  2861. * @returns true is the matrix is the identity matrix
  2862. */
  2863. isIdentity(): boolean;
  2864. /**
  2865. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2866. * @returns true is the matrix is the identity matrix
  2867. */
  2868. isIdentityAs3x2(): boolean;
  2869. /**
  2870. * Gets the determinant of the matrix
  2871. * @returns the matrix determinant
  2872. */
  2873. determinant(): number;
  2874. /**
  2875. * Returns the matrix as a Float32Array
  2876. * @returns the matrix underlying array
  2877. */
  2878. toArray(): DeepImmutable<Float32Array>;
  2879. /**
  2880. * Returns the matrix as a Float32Array
  2881. * @returns the matrix underlying array.
  2882. */
  2883. asArray(): DeepImmutable<Float32Array>;
  2884. /**
  2885. * Inverts the current matrix in place
  2886. * @returns the current inverted matrix
  2887. */
  2888. invert(): Matrix;
  2889. /**
  2890. * Sets all the matrix elements to zero
  2891. * @returns the current matrix
  2892. */
  2893. reset(): Matrix;
  2894. /**
  2895. * Adds the current matrix with a second one
  2896. * @param other defines the matrix to add
  2897. * @returns a new matrix as the addition of the current matrix and the given one
  2898. */
  2899. add(other: DeepImmutable<Matrix>): Matrix;
  2900. /**
  2901. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2902. * @param other defines the matrix to add
  2903. * @param result defines the target matrix
  2904. * @returns the current matrix
  2905. */
  2906. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2907. /**
  2908. * Adds in place the given matrix to the current matrix
  2909. * @param other defines the second operand
  2910. * @returns the current updated matrix
  2911. */
  2912. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2913. /**
  2914. * Sets the given matrix to the current inverted Matrix
  2915. * @param other defines the target matrix
  2916. * @returns the unmodified current matrix
  2917. */
  2918. invertToRef(other: Matrix): Matrix;
  2919. /**
  2920. * add a value at the specified position in the current Matrix
  2921. * @param index the index of the value within the matrix. between 0 and 15.
  2922. * @param value the value to be added
  2923. * @returns the current updated matrix
  2924. */
  2925. addAtIndex(index: number, value: number): Matrix;
  2926. /**
  2927. * mutiply the specified position in the current Matrix by a value
  2928. * @param index the index of the value within the matrix. between 0 and 15.
  2929. * @param value the value to be added
  2930. * @returns the current updated matrix
  2931. */
  2932. multiplyAtIndex(index: number, value: number): Matrix;
  2933. /**
  2934. * Inserts the translation vector (using 3 floats) in the current matrix
  2935. * @param x defines the 1st component of the translation
  2936. * @param y defines the 2nd component of the translation
  2937. * @param z defines the 3rd component of the translation
  2938. * @returns the current updated matrix
  2939. */
  2940. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2941. /**
  2942. * Inserts the translation vector in the current matrix
  2943. * @param vector3 defines the translation to insert
  2944. * @returns the current updated matrix
  2945. */
  2946. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2947. /**
  2948. * Gets the translation value of the current matrix
  2949. * @returns a new Vector3 as the extracted translation from the matrix
  2950. */
  2951. getTranslation(): Vector3;
  2952. /**
  2953. * Fill a Vector3 with the extracted translation from the matrix
  2954. * @param result defines the Vector3 where to store the translation
  2955. * @returns the current matrix
  2956. */
  2957. getTranslationToRef(result: Vector3): Matrix;
  2958. /**
  2959. * Remove rotation and scaling part from the matrix
  2960. * @returns the updated matrix
  2961. */
  2962. removeRotationAndScaling(): Matrix;
  2963. /**
  2964. * Multiply two matrices
  2965. * @param other defines the second operand
  2966. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2967. */
  2968. multiply(other: DeepImmutable<Matrix>): Matrix;
  2969. /**
  2970. * Copy the current matrix from the given one
  2971. * @param other defines the source matrix
  2972. * @returns the current updated matrix
  2973. */
  2974. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Populates the given array from the starting index with the current matrix values
  2977. * @param array defines the target array
  2978. * @param offset defines the offset in the target array where to start storing values
  2979. * @returns the current matrix
  2980. */
  2981. copyToArray(array: Float32Array, offset?: number): Matrix;
  2982. /**
  2983. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2984. * @param other defines the second operand
  2985. * @param result defines the matrix where to store the multiplication
  2986. * @returns the current matrix
  2987. */
  2988. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2989. /**
  2990. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2991. * @param other defines the second operand
  2992. * @param result defines the array where to store the multiplication
  2993. * @param offset defines the offset in the target array where to start storing values
  2994. * @returns the current matrix
  2995. */
  2996. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2997. /**
  2998. * Check equality between this matrix and a second one
  2999. * @param value defines the second matrix to compare
  3000. * @returns true is the current matrix and the given one values are strictly equal
  3001. */
  3002. equals(value: DeepImmutable<Matrix>): boolean;
  3003. /**
  3004. * Clone the current matrix
  3005. * @returns a new matrix from the current matrix
  3006. */
  3007. clone(): Matrix;
  3008. /**
  3009. * Returns the name of the current matrix class
  3010. * @returns the string "Matrix"
  3011. */
  3012. getClassName(): string;
  3013. /**
  3014. * Gets the hash code of the current matrix
  3015. * @returns the hash code
  3016. */
  3017. getHashCode(): number;
  3018. /**
  3019. * Decomposes the current Matrix into a translation, rotation and scaling components
  3020. * @param scale defines the scale vector3 given as a reference to update
  3021. * @param rotation defines the rotation quaternion given as a reference to update
  3022. * @param translation defines the translation vector3 given as a reference to update
  3023. * @returns true if operation was successful
  3024. */
  3025. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3026. /**
  3027. * Gets specific row of the matrix
  3028. * @param index defines the number of the row to get
  3029. * @returns the index-th row of the current matrix as a new Vector4
  3030. */
  3031. getRow(index: number): Nullable<Vector4>;
  3032. /**
  3033. * Sets the index-th row of the current matrix to the vector4 values
  3034. * @param index defines the number of the row to set
  3035. * @param row defines the target vector4
  3036. * @returns the updated current matrix
  3037. */
  3038. setRow(index: number, row: Vector4): Matrix;
  3039. /**
  3040. * Compute the transpose of the matrix
  3041. * @returns the new transposed matrix
  3042. */
  3043. transpose(): Matrix;
  3044. /**
  3045. * Compute the transpose of the matrix and store it in a given matrix
  3046. * @param result defines the target matrix
  3047. * @returns the current matrix
  3048. */
  3049. transposeToRef(result: Matrix): Matrix;
  3050. /**
  3051. * Sets the index-th row of the current matrix with the given 4 x float values
  3052. * @param index defines the row index
  3053. * @param x defines the x component to set
  3054. * @param y defines the y component to set
  3055. * @param z defines the z component to set
  3056. * @param w defines the w component to set
  3057. * @returns the updated current matrix
  3058. */
  3059. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3060. /**
  3061. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3062. * @param scale defines the scale factor
  3063. * @returns a new matrix
  3064. */
  3065. scale(scale: number): Matrix;
  3066. /**
  3067. * Scale the current matrix values by a factor to a given result matrix
  3068. * @param scale defines the scale factor
  3069. * @param result defines the matrix to store the result
  3070. * @returns the current matrix
  3071. */
  3072. scaleToRef(scale: number, result: Matrix): Matrix;
  3073. /**
  3074. * Scale the current matrix values by a factor and add the result to a given matrix
  3075. * @param scale defines the scale factor
  3076. * @param result defines the Matrix to store the result
  3077. * @returns the current matrix
  3078. */
  3079. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3080. /**
  3081. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3082. * @param ref matrix to store the result
  3083. */
  3084. toNormalMatrix(ref: Matrix): void;
  3085. /**
  3086. * Gets only rotation part of the current matrix
  3087. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3088. */
  3089. getRotationMatrix(): Matrix;
  3090. /**
  3091. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3092. * @param result defines the target matrix to store data to
  3093. * @returns the current matrix
  3094. */
  3095. getRotationMatrixToRef(result: Matrix): Matrix;
  3096. /**
  3097. * Toggles model matrix from being right handed to left handed in place and vice versa
  3098. */
  3099. toggleModelMatrixHandInPlace(): void;
  3100. /**
  3101. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3102. */
  3103. toggleProjectionMatrixHandInPlace(): void;
  3104. /**
  3105. * Creates a matrix from an array
  3106. * @param array defines the source array
  3107. * @param offset defines an offset in the source array
  3108. * @returns a new Matrix set from the starting index of the given array
  3109. */
  3110. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3111. /**
  3112. * Copy the content of an array into a given matrix
  3113. * @param array defines the source array
  3114. * @param offset defines an offset in the source array
  3115. * @param result defines the target matrix
  3116. */
  3117. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3118. /**
  3119. * Stores an array into a matrix after having multiplied each component by a given factor
  3120. * @param array defines the source array
  3121. * @param offset defines the offset in the source array
  3122. * @param scale defines the scaling factor
  3123. * @param result defines the target matrix
  3124. */
  3125. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3126. /**
  3127. * Gets an identity matrix that must not be updated
  3128. */
  3129. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3130. /**
  3131. * Stores a list of values (16) inside a given matrix
  3132. * @param initialM11 defines 1st value of 1st row
  3133. * @param initialM12 defines 2nd value of 1st row
  3134. * @param initialM13 defines 3rd value of 1st row
  3135. * @param initialM14 defines 4th value of 1st row
  3136. * @param initialM21 defines 1st value of 2nd row
  3137. * @param initialM22 defines 2nd value of 2nd row
  3138. * @param initialM23 defines 3rd value of 2nd row
  3139. * @param initialM24 defines 4th value of 2nd row
  3140. * @param initialM31 defines 1st value of 3rd row
  3141. * @param initialM32 defines 2nd value of 3rd row
  3142. * @param initialM33 defines 3rd value of 3rd row
  3143. * @param initialM34 defines 4th value of 3rd row
  3144. * @param initialM41 defines 1st value of 4th row
  3145. * @param initialM42 defines 2nd value of 4th row
  3146. * @param initialM43 defines 3rd value of 4th row
  3147. * @param initialM44 defines 4th value of 4th row
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3151. /**
  3152. * Creates new matrix from a list of values (16)
  3153. * @param initialM11 defines 1st value of 1st row
  3154. * @param initialM12 defines 2nd value of 1st row
  3155. * @param initialM13 defines 3rd value of 1st row
  3156. * @param initialM14 defines 4th value of 1st row
  3157. * @param initialM21 defines 1st value of 2nd row
  3158. * @param initialM22 defines 2nd value of 2nd row
  3159. * @param initialM23 defines 3rd value of 2nd row
  3160. * @param initialM24 defines 4th value of 2nd row
  3161. * @param initialM31 defines 1st value of 3rd row
  3162. * @param initialM32 defines 2nd value of 3rd row
  3163. * @param initialM33 defines 3rd value of 3rd row
  3164. * @param initialM34 defines 4th value of 3rd row
  3165. * @param initialM41 defines 1st value of 4th row
  3166. * @param initialM42 defines 2nd value of 4th row
  3167. * @param initialM43 defines 3rd value of 4th row
  3168. * @param initialM44 defines 4th value of 4th row
  3169. * @returns the new matrix
  3170. */
  3171. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3172. /**
  3173. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3174. * @param scale defines the scale vector3
  3175. * @param rotation defines the rotation quaternion
  3176. * @param translation defines the translation vector3
  3177. * @returns a new matrix
  3178. */
  3179. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3180. /**
  3181. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3182. * @param scale defines the scale vector3
  3183. * @param rotation defines the rotation quaternion
  3184. * @param translation defines the translation vector3
  3185. * @param result defines the target matrix
  3186. */
  3187. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3188. /**
  3189. * Creates a new identity matrix
  3190. * @returns a new identity matrix
  3191. */
  3192. static Identity(): Matrix;
  3193. /**
  3194. * Creates a new identity matrix and stores the result in a given matrix
  3195. * @param result defines the target matrix
  3196. */
  3197. static IdentityToRef(result: Matrix): void;
  3198. /**
  3199. * Creates a new zero matrix
  3200. * @returns a new zero matrix
  3201. */
  3202. static Zero(): Matrix;
  3203. /**
  3204. * Creates a new rotation matrix for "angle" radians around the X axis
  3205. * @param angle defines the angle (in radians) to use
  3206. * @return the new matrix
  3207. */
  3208. static RotationX(angle: number): Matrix;
  3209. /**
  3210. * Creates a new matrix as the invert of a given matrix
  3211. * @param source defines the source matrix
  3212. * @returns the new matrix
  3213. */
  3214. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3215. /**
  3216. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3217. * @param angle defines the angle (in radians) to use
  3218. * @param result defines the target matrix
  3219. */
  3220. static RotationXToRef(angle: number, result: Matrix): void;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the Y axis
  3223. * @param angle defines the angle (in radians) to use
  3224. * @return the new matrix
  3225. */
  3226. static RotationY(angle: number): Matrix;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3229. * @param angle defines the angle (in radians) to use
  3230. * @param result defines the target matrix
  3231. */
  3232. static RotationYToRef(angle: number, result: Matrix): void;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Z axis
  3235. * @param angle defines the angle (in radians) to use
  3236. * @return the new matrix
  3237. */
  3238. static RotationZ(angle: number): Matrix;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3241. * @param angle defines the angle (in radians) to use
  3242. * @param result defines the target matrix
  3243. */
  3244. static RotationZToRef(angle: number, result: Matrix): void;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the given axis
  3247. * @param axis defines the axis to use
  3248. * @param angle defines the angle (in radians) to use
  3249. * @return the new matrix
  3250. */
  3251. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3252. /**
  3253. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3254. * @param axis defines the axis to use
  3255. * @param angle defines the angle (in radians) to use
  3256. * @param result defines the target matrix
  3257. */
  3258. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3259. /**
  3260. * Creates a rotation matrix
  3261. * @param yaw defines the yaw angle in radians (Y axis)
  3262. * @param pitch defines the pitch angle in radians (X axis)
  3263. * @param roll defines the roll angle in radians (X axis)
  3264. * @returns the new rotation matrix
  3265. */
  3266. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3267. /**
  3268. * Creates a rotation matrix and stores it in a given matrix
  3269. * @param yaw defines the yaw angle in radians (Y axis)
  3270. * @param pitch defines the pitch angle in radians (X axis)
  3271. * @param roll defines the roll angle in radians (X axis)
  3272. * @param result defines the target matrix
  3273. */
  3274. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3275. /**
  3276. * Creates a scaling matrix
  3277. * @param x defines the scale factor on X axis
  3278. * @param y defines the scale factor on Y axis
  3279. * @param z defines the scale factor on Z axis
  3280. * @returns the new matrix
  3281. */
  3282. static Scaling(x: number, y: number, z: number): Matrix;
  3283. /**
  3284. * Creates a scaling matrix and stores it in a given matrix
  3285. * @param x defines the scale factor on X axis
  3286. * @param y defines the scale factor on Y axis
  3287. * @param z defines the scale factor on Z axis
  3288. * @param result defines the target matrix
  3289. */
  3290. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3291. /**
  3292. * Creates a translation matrix
  3293. * @param x defines the translation on X axis
  3294. * @param y defines the translation on Y axis
  3295. * @param z defines the translationon Z axis
  3296. * @returns the new matrix
  3297. */
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. /**
  3300. * Creates a translation matrix and stores it in a given matrix
  3301. * @param x defines the translation on X axis
  3302. * @param y defines the translation on Y axis
  3303. * @param z defines the translationon Z axis
  3304. * @param result defines the target matrix
  3305. */
  3306. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3307. /**
  3308. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3309. * @param startValue defines the start value
  3310. * @param endValue defines the end value
  3311. * @param gradient defines the gradient factor
  3312. * @returns the new matrix
  3313. */
  3314. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3315. /**
  3316. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3317. * @param startValue defines the start value
  3318. * @param endValue defines the end value
  3319. * @param gradient defines the gradient factor
  3320. * @param result defines the Matrix object where to store data
  3321. */
  3322. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3323. /**
  3324. * Builds a new matrix whose values are computed by:
  3325. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3326. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3327. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3328. * @param startValue defines the first matrix
  3329. * @param endValue defines the second matrix
  3330. * @param gradient defines the gradient between the two matrices
  3331. * @returns the new matrix
  3332. */
  3333. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3334. /**
  3335. * Update a matrix to values which are computed by:
  3336. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3337. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3338. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3339. * @param startValue defines the first matrix
  3340. * @param endValue defines the second matrix
  3341. * @param gradient defines the gradient between the two matrices
  3342. * @param result defines the target matrix
  3343. */
  3344. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3345. /**
  3346. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3347. * This function works in left handed mode
  3348. * @param eye defines the final position of the entity
  3349. * @param target defines where the entity should look at
  3350. * @param up defines the up vector for the entity
  3351. * @returns the new matrix
  3352. */
  3353. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3354. /**
  3355. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3356. * This function works in left handed mode
  3357. * @param eye defines the final position of the entity
  3358. * @param target defines where the entity should look at
  3359. * @param up defines the up vector for the entity
  3360. * @param result defines the target matrix
  3361. */
  3362. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in right handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in right handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Create a left-handed orthographic projection matrix
  3383. * @param width defines the viewport width
  3384. * @param height defines the viewport height
  3385. * @param znear defines the near clip plane
  3386. * @param zfar defines the far clip plane
  3387. * @returns a new matrix as a left-handed orthographic projection matrix
  3388. */
  3389. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3390. /**
  3391. * Store a left-handed orthographic projection to a given matrix
  3392. * @param width defines the viewport width
  3393. * @param height defines the viewport height
  3394. * @param znear defines the near clip plane
  3395. * @param zfar defines the far clip plane
  3396. * @param result defines the target matrix
  3397. */
  3398. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param left defines the viewport left coordinate
  3402. * @param right defines the viewport right coordinate
  3403. * @param bottom defines the viewport bottom coordinate
  3404. * @param top defines the viewport top coordinate
  3405. * @param znear defines the near clip plane
  3406. * @param zfar defines the far clip plane
  3407. * @returns a new matrix as a left-handed orthographic projection matrix
  3408. */
  3409. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3410. /**
  3411. * Stores a left-handed orthographic projection into a given matrix
  3412. * @param left defines the viewport left coordinate
  3413. * @param right defines the viewport right coordinate
  3414. * @param bottom defines the viewport bottom coordinate
  3415. * @param top defines the viewport top coordinate
  3416. * @param znear defines the near clip plane
  3417. * @param zfar defines the far clip plane
  3418. * @param result defines the target matrix
  3419. */
  3420. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3421. /**
  3422. * Creates a right-handed orthographic projection matrix
  3423. * @param left defines the viewport left coordinate
  3424. * @param right defines the viewport right coordinate
  3425. * @param bottom defines the viewport bottom coordinate
  3426. * @param top defines the viewport top coordinate
  3427. * @param znear defines the near clip plane
  3428. * @param zfar defines the far clip plane
  3429. * @returns a new matrix as a right-handed orthographic projection matrix
  3430. */
  3431. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3432. /**
  3433. * Stores a right-handed orthographic projection into a given matrix
  3434. * @param left defines the viewport left coordinate
  3435. * @param right defines the viewport right coordinate
  3436. * @param bottom defines the viewport bottom coordinate
  3437. * @param top defines the viewport top coordinate
  3438. * @param znear defines the near clip plane
  3439. * @param zfar defines the far clip plane
  3440. * @param result defines the target matrix
  3441. */
  3442. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3443. /**
  3444. * Creates a left-handed perspective projection matrix
  3445. * @param width defines the viewport width
  3446. * @param height defines the viewport height
  3447. * @param znear defines the near clip plane
  3448. * @param zfar defines the far clip plane
  3449. * @returns a new matrix as a left-handed perspective projection matrix
  3450. */
  3451. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3452. /**
  3453. * Creates a left-handed perspective projection matrix
  3454. * @param fov defines the horizontal field of view
  3455. * @param aspect defines the aspect ratio
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @returns a new matrix as a left-handed perspective projection matrix
  3459. */
  3460. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3461. /**
  3462. * Stores a left-handed perspective projection into a given matrix
  3463. * @param fov defines the horizontal field of view
  3464. * @param aspect defines the aspect ratio
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @param result defines the target matrix
  3468. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3469. */
  3470. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3471. /**
  3472. * Creates a right-handed perspective projection matrix
  3473. * @param fov defines the horizontal field of view
  3474. * @param aspect defines the aspect ratio
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @returns a new matrix as a right-handed perspective projection matrix
  3478. */
  3479. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3480. /**
  3481. * Stores a right-handed perspective projection into a given matrix
  3482. * @param fov defines the horizontal field of view
  3483. * @param aspect defines the aspect ratio
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @param result defines the target matrix
  3487. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3488. */
  3489. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3490. /**
  3491. * Stores a perspective projection for WebVR info a given matrix
  3492. * @param fov defines the field of view
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @param result defines the target matrix
  3496. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3497. */
  3498. static PerspectiveFovWebVRToRef(fov: {
  3499. upDegrees: number;
  3500. downDegrees: number;
  3501. leftDegrees: number;
  3502. rightDegrees: number;
  3503. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3504. /**
  3505. * Computes a complete transformation matrix
  3506. * @param viewport defines the viewport to use
  3507. * @param world defines the world matrix
  3508. * @param view defines the view matrix
  3509. * @param projection defines the projection matrix
  3510. * @param zmin defines the near clip plane
  3511. * @param zmax defines the far clip plane
  3512. * @returns the transformation matrix
  3513. */
  3514. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3515. /**
  3516. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3517. * @param matrix defines the matrix to use
  3518. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3519. */
  3520. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3521. /**
  3522. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3523. * @param matrix defines the matrix to use
  3524. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3525. */
  3526. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3527. /**
  3528. * Compute the transpose of a given matrix
  3529. * @param matrix defines the matrix to transpose
  3530. * @returns the new matrix
  3531. */
  3532. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3533. /**
  3534. * Compute the transpose of a matrix and store it in a target matrix
  3535. * @param matrix defines the matrix to transpose
  3536. * @param result defines the target matrix
  3537. */
  3538. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3539. /**
  3540. * Computes a reflection matrix from a plane
  3541. * @param plane defines the reflection plane
  3542. * @returns a new matrix
  3543. */
  3544. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3545. /**
  3546. * Computes a reflection matrix from a plane
  3547. * @param plane defines the reflection plane
  3548. * @param result defines the target matrix
  3549. */
  3550. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3551. /**
  3552. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3553. * @param xaxis defines the value of the 1st axis
  3554. * @param yaxis defines the value of the 2nd axis
  3555. * @param zaxis defines the value of the 3rd axis
  3556. * @param result defines the target matrix
  3557. */
  3558. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3559. /**
  3560. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3561. * @param quat defines the quaternion to use
  3562. * @param result defines the target matrix
  3563. */
  3564. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3565. }
  3566. /**
  3567. * Represens a plane by the equation ax + by + cz + d = 0
  3568. */
  3569. export class Plane {
  3570. /**
  3571. * Normal of the plane (a,b,c)
  3572. */
  3573. normal: Vector3;
  3574. /**
  3575. * d component of the plane
  3576. */
  3577. d: number;
  3578. /**
  3579. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3580. * @param a a component of the plane
  3581. * @param b b component of the plane
  3582. * @param c c component of the plane
  3583. * @param d d component of the plane
  3584. */
  3585. constructor(a: number, b: number, c: number, d: number);
  3586. /**
  3587. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3588. */
  3589. asArray(): number[];
  3590. /**
  3591. * @returns a new plane copied from the current Plane.
  3592. */
  3593. clone(): Plane;
  3594. /**
  3595. * @returns the string "Plane".
  3596. */
  3597. getClassName(): string;
  3598. /**
  3599. * @returns the Plane hash code.
  3600. */
  3601. getHashCode(): number;
  3602. /**
  3603. * Normalize the current Plane in place.
  3604. * @returns the updated Plane.
  3605. */
  3606. normalize(): Plane;
  3607. /**
  3608. * Applies a transformation the plane and returns the result
  3609. * @param transformation the transformation matrix to be applied to the plane
  3610. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3611. */
  3612. transform(transformation: DeepImmutable<Matrix>): Plane;
  3613. /**
  3614. * Calcualtte the dot product between the point and the plane normal
  3615. * @param point point to calculate the dot product with
  3616. * @returns the dot product (float) of the point coordinates and the plane normal.
  3617. */
  3618. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3619. /**
  3620. * Updates the current Plane from the plane defined by the three given points.
  3621. * @param point1 one of the points used to contruct the plane
  3622. * @param point2 one of the points used to contruct the plane
  3623. * @param point3 one of the points used to contruct the plane
  3624. * @returns the updated Plane.
  3625. */
  3626. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3627. /**
  3628. * Checks if the plane is facing a given direction
  3629. * @param direction the direction to check if the plane is facing
  3630. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3631. * @returns True is the vector "direction" is the same side than the plane normal.
  3632. */
  3633. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3634. /**
  3635. * Calculates the distance to a point
  3636. * @param point point to calculate distance to
  3637. * @returns the signed distance (float) from the given point to the Plane.
  3638. */
  3639. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3640. /**
  3641. * Creates a plane from an array
  3642. * @param array the array to create a plane from
  3643. * @returns a new Plane from the given array.
  3644. */
  3645. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3646. /**
  3647. * Creates a plane from three points
  3648. * @param point1 point used to create the plane
  3649. * @param point2 point used to create the plane
  3650. * @param point3 point used to create the plane
  3651. * @returns a new Plane defined by the three given points.
  3652. */
  3653. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3654. /**
  3655. * Creates a plane from an origin point and a normal
  3656. * @param origin origin of the plane to be constructed
  3657. * @param normal normal of the plane to be constructed
  3658. * @returns a new Plane the normal vector to this plane at the given origin point.
  3659. * Note : the vector "normal" is updated because normalized.
  3660. */
  3661. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3662. /**
  3663. * Calculates the distance from a plane and a point
  3664. * @param origin origin of the plane to be constructed
  3665. * @param normal normal of the plane to be constructed
  3666. * @param point point to calculate distance to
  3667. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3668. */
  3669. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3670. }
  3671. /**
  3672. * Class used to represent a viewport on screen
  3673. */
  3674. export class Viewport {
  3675. /** viewport left coordinate */
  3676. x: number;
  3677. /** viewport top coordinate */
  3678. y: number;
  3679. /**viewport width */
  3680. width: number;
  3681. /** viewport height */
  3682. height: number;
  3683. /**
  3684. * Creates a Viewport object located at (x, y) and sized (width, height)
  3685. * @param x defines viewport left coordinate
  3686. * @param y defines viewport top coordinate
  3687. * @param width defines the viewport width
  3688. * @param height defines the viewport height
  3689. */
  3690. constructor(
  3691. /** viewport left coordinate */
  3692. x: number,
  3693. /** viewport top coordinate */
  3694. y: number,
  3695. /**viewport width */
  3696. width: number,
  3697. /** viewport height */
  3698. height: number);
  3699. /**
  3700. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3701. * @param renderWidth defines the rendering width
  3702. * @param renderHeight defines the rendering height
  3703. * @returns a new Viewport
  3704. */
  3705. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3706. /**
  3707. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3708. * @param renderWidth defines the rendering width
  3709. * @param renderHeight defines the rendering height
  3710. * @param ref defines the target viewport
  3711. * @returns the current viewport
  3712. */
  3713. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3714. /**
  3715. * Returns a new Viewport copied from the current one
  3716. * @returns a new Viewport
  3717. */
  3718. clone(): Viewport;
  3719. }
  3720. /**
  3721. * Reprasents a camera frustum
  3722. */
  3723. export class Frustum {
  3724. /**
  3725. * Gets the planes representing the frustum
  3726. * @param transform matrix to be applied to the returned planes
  3727. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3728. */
  3729. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3730. /**
  3731. * Gets the near frustum plane transformed by the transform matrix
  3732. * @param transform transformation matrix to be applied to the resulting frustum plane
  3733. * @param frustumPlane the resuling frustum plane
  3734. */
  3735. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3736. /**
  3737. * Gets the far frustum plane transformed by the transform matrix
  3738. * @param transform transformation matrix to be applied to the resulting frustum plane
  3739. * @param frustumPlane the resuling frustum plane
  3740. */
  3741. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3742. /**
  3743. * Gets the left frustum plane transformed by the transform matrix
  3744. * @param transform transformation matrix to be applied to the resulting frustum plane
  3745. * @param frustumPlane the resuling frustum plane
  3746. */
  3747. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3748. /**
  3749. * Gets the right frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the top frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the bottom frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3768. * @param transform transformation matrix to be applied to the resulting frustum planes
  3769. * @param frustumPlanes the resuling frustum planes
  3770. */
  3771. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3772. }
  3773. /** Defines supported spaces */
  3774. export enum Space {
  3775. /** Local (object) space */
  3776. LOCAL = 0,
  3777. /** World space */
  3778. WORLD = 1,
  3779. /** Bone space */
  3780. BONE = 2
  3781. }
  3782. /** Defines the 3 main axes */
  3783. export class Axis {
  3784. /** X axis */
  3785. static X: Vector3;
  3786. /** Y axis */
  3787. static Y: Vector3;
  3788. /** Z axis */
  3789. static Z: Vector3;
  3790. }
  3791. /** Class used to represent a Bezier curve */
  3792. export class BezierCurve {
  3793. /**
  3794. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3795. * @param t defines the time
  3796. * @param x1 defines the left coordinate on X axis
  3797. * @param y1 defines the left coordinate on Y axis
  3798. * @param x2 defines the right coordinate on X axis
  3799. * @param y2 defines the right coordinate on Y axis
  3800. * @returns the interpolated value
  3801. */
  3802. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3803. }
  3804. /**
  3805. * Defines potential orientation for back face culling
  3806. */
  3807. export enum Orientation {
  3808. /**
  3809. * Clockwise
  3810. */
  3811. CW = 0,
  3812. /** Counter clockwise */
  3813. CCW = 1
  3814. }
  3815. /**
  3816. * Defines angle representation
  3817. */
  3818. export class Angle {
  3819. private _radians;
  3820. /**
  3821. * Creates an Angle object of "radians" radians (float).
  3822. * @param radians the angle in radians
  3823. */
  3824. constructor(radians: number);
  3825. /**
  3826. * Get value in degrees
  3827. * @returns the Angle value in degrees (float)
  3828. */
  3829. degrees(): number;
  3830. /**
  3831. * Get value in radians
  3832. * @returns the Angle value in radians (float)
  3833. */
  3834. radians(): number;
  3835. /**
  3836. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3837. * @param a defines first vector
  3838. * @param b defines second vector
  3839. * @returns a new Angle
  3840. */
  3841. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3842. /**
  3843. * Gets a new Angle object from the given float in radians
  3844. * @param radians defines the angle value in radians
  3845. * @returns a new Angle
  3846. */
  3847. static FromRadians(radians: number): Angle;
  3848. /**
  3849. * Gets a new Angle object from the given float in degrees
  3850. * @param degrees defines the angle value in degrees
  3851. * @returns a new Angle
  3852. */
  3853. static FromDegrees(degrees: number): Angle;
  3854. }
  3855. /**
  3856. * This represents an arc in a 2d space.
  3857. */
  3858. export class Arc2 {
  3859. /** Defines the start point of the arc */
  3860. startPoint: Vector2;
  3861. /** Defines the mid point of the arc */
  3862. midPoint: Vector2;
  3863. /** Defines the end point of the arc */
  3864. endPoint: Vector2;
  3865. /**
  3866. * Defines the center point of the arc.
  3867. */
  3868. centerPoint: Vector2;
  3869. /**
  3870. * Defines the radius of the arc.
  3871. */
  3872. radius: number;
  3873. /**
  3874. * Defines the angle of the arc (from mid point to end point).
  3875. */
  3876. angle: Angle;
  3877. /**
  3878. * Defines the start angle of the arc (from start point to middle point).
  3879. */
  3880. startAngle: Angle;
  3881. /**
  3882. * Defines the orientation of the arc (clock wise/counter clock wise).
  3883. */
  3884. orientation: Orientation;
  3885. /**
  3886. * Creates an Arc object from the three given points : start, middle and end.
  3887. * @param startPoint Defines the start point of the arc
  3888. * @param midPoint Defines the midlle point of the arc
  3889. * @param endPoint Defines the end point of the arc
  3890. */
  3891. constructor(
  3892. /** Defines the start point of the arc */
  3893. startPoint: Vector2,
  3894. /** Defines the mid point of the arc */
  3895. midPoint: Vector2,
  3896. /** Defines the end point of the arc */
  3897. endPoint: Vector2);
  3898. }
  3899. /**
  3900. * Represents a 2D path made up of multiple 2D points
  3901. */
  3902. export class Path2 {
  3903. private _points;
  3904. private _length;
  3905. /**
  3906. * If the path start and end point are the same
  3907. */
  3908. closed: boolean;
  3909. /**
  3910. * Creates a Path2 object from the starting 2D coordinates x and y.
  3911. * @param x the starting points x value
  3912. * @param y the starting points y value
  3913. */
  3914. constructor(x: number, y: number);
  3915. /**
  3916. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3917. * @param x the added points x value
  3918. * @param y the added points y value
  3919. * @returns the updated Path2.
  3920. */
  3921. addLineTo(x: number, y: number): Path2;
  3922. /**
  3923. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3924. * @param midX middle point x value
  3925. * @param midY middle point y value
  3926. * @param endX end point x value
  3927. * @param endY end point y value
  3928. * @param numberOfSegments (default: 36)
  3929. * @returns the updated Path2.
  3930. */
  3931. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3932. /**
  3933. * Closes the Path2.
  3934. * @returns the Path2.
  3935. */
  3936. close(): Path2;
  3937. /**
  3938. * Gets the sum of the distance between each sequential point in the path
  3939. * @returns the Path2 total length (float).
  3940. */
  3941. length(): number;
  3942. /**
  3943. * Gets the points which construct the path
  3944. * @returns the Path2 internal array of points.
  3945. */
  3946. getPoints(): Vector2[];
  3947. /**
  3948. * Retreives the point at the distance aways from the starting point
  3949. * @param normalizedLengthPosition the length along the path to retreive the point from
  3950. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3951. */
  3952. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3953. /**
  3954. * Creates a new path starting from an x and y position
  3955. * @param x starting x value
  3956. * @param y starting y value
  3957. * @returns a new Path2 starting at the coordinates (x, y).
  3958. */
  3959. static StartingAt(x: number, y: number): Path2;
  3960. }
  3961. /**
  3962. * Represents a 3D path made up of multiple 3D points
  3963. */
  3964. export class Path3D {
  3965. /**
  3966. * an array of Vector3, the curve axis of the Path3D
  3967. */
  3968. path: Vector3[];
  3969. private _curve;
  3970. private _distances;
  3971. private _tangents;
  3972. private _normals;
  3973. private _binormals;
  3974. private _raw;
  3975. /**
  3976. * new Path3D(path, normal, raw)
  3977. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3978. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3979. * @param path an array of Vector3, the curve axis of the Path3D
  3980. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3981. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3982. */
  3983. constructor(
  3984. /**
  3985. * an array of Vector3, the curve axis of the Path3D
  3986. */
  3987. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3988. /**
  3989. * Returns the Path3D array of successive Vector3 designing its curve.
  3990. * @returns the Path3D array of successive Vector3 designing its curve.
  3991. */
  3992. getCurve(): Vector3[];
  3993. /**
  3994. * Returns an array populated with tangent vectors on each Path3D curve point.
  3995. * @returns an array populated with tangent vectors on each Path3D curve point.
  3996. */
  3997. getTangents(): Vector3[];
  3998. /**
  3999. * Returns an array populated with normal vectors on each Path3D curve point.
  4000. * @returns an array populated with normal vectors on each Path3D curve point.
  4001. */
  4002. getNormals(): Vector3[];
  4003. /**
  4004. * Returns an array populated with binormal vectors on each Path3D curve point.
  4005. * @returns an array populated with binormal vectors on each Path3D curve point.
  4006. */
  4007. getBinormals(): Vector3[];
  4008. /**
  4009. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4010. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4011. */
  4012. getDistances(): number[];
  4013. /**
  4014. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4015. * @param path path which all values are copied into the curves points
  4016. * @param firstNormal which should be projected onto the curve
  4017. * @returns the same object updated.
  4018. */
  4019. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4020. private _compute;
  4021. private _getFirstNonNullVector;
  4022. private _getLastNonNullVector;
  4023. private _normalVector;
  4024. }
  4025. /**
  4026. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4027. * A Curve3 is designed from a series of successive Vector3.
  4028. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4029. */
  4030. export class Curve3 {
  4031. private _points;
  4032. private _length;
  4033. /**
  4034. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4035. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4036. * @param v1 (Vector3) the control point
  4037. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4038. * @param nbPoints (integer) the wanted number of points in the curve
  4039. * @returns the created Curve3
  4040. */
  4041. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4042. /**
  4043. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4044. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4045. * @param v1 (Vector3) the first control point
  4046. * @param v2 (Vector3) the second control point
  4047. * @param v3 (Vector3) the end point of the Cubic Bezier
  4048. * @param nbPoints (integer) the wanted number of points in the curve
  4049. * @returns the created Curve3
  4050. */
  4051. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4052. /**
  4053. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4054. * @param p1 (Vector3) the origin point of the Hermite Spline
  4055. * @param t1 (Vector3) the tangent vector at the origin point
  4056. * @param p2 (Vector3) the end point of the Hermite Spline
  4057. * @param t2 (Vector3) the tangent vector at the end point
  4058. * @param nbPoints (integer) the wanted number of points in the curve
  4059. * @returns the created Curve3
  4060. */
  4061. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4062. /**
  4063. * Returns a Curve3 object along a CatmullRom Spline curve :
  4064. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4065. * @param nbPoints (integer) the wanted number of points between each curve control points
  4066. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4070. /**
  4071. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4072. * A Curve3 is designed from a series of successive Vector3.
  4073. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4074. * @param points points which make up the curve
  4075. */
  4076. constructor(points: Vector3[]);
  4077. /**
  4078. * @returns the Curve3 stored array of successive Vector3
  4079. */
  4080. getPoints(): Vector3[];
  4081. /**
  4082. * @returns the computed length (float) of the curve.
  4083. */
  4084. length(): number;
  4085. /**
  4086. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4087. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4088. * curveA and curveB keep unchanged.
  4089. * @param curve the curve to continue from this curve
  4090. * @returns the newly constructed curve
  4091. */
  4092. continue(curve: DeepImmutable<Curve3>): Curve3;
  4093. private _computeLength;
  4094. }
  4095. /**
  4096. * Contains position and normal vectors for a vertex
  4097. */
  4098. export class PositionNormalVertex {
  4099. /** the position of the vertex (defaut: 0,0,0) */
  4100. position: Vector3;
  4101. /** the normal of the vertex (defaut: 0,1,0) */
  4102. normal: Vector3;
  4103. /**
  4104. * Creates a PositionNormalVertex
  4105. * @param position the position of the vertex (defaut: 0,0,0)
  4106. * @param normal the normal of the vertex (defaut: 0,1,0)
  4107. */
  4108. constructor(
  4109. /** the position of the vertex (defaut: 0,0,0) */
  4110. position?: Vector3,
  4111. /** the normal of the vertex (defaut: 0,1,0) */
  4112. normal?: Vector3);
  4113. /**
  4114. * Clones the PositionNormalVertex
  4115. * @returns the cloned PositionNormalVertex
  4116. */
  4117. clone(): PositionNormalVertex;
  4118. }
  4119. /**
  4120. * Contains position, normal and uv vectors for a vertex
  4121. */
  4122. export class PositionNormalTextureVertex {
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position: Vector3;
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal: Vector3;
  4127. /** the uv of the vertex (default: 0,0) */
  4128. uv: Vector2;
  4129. /**
  4130. * Creates a PositionNormalTextureVertex
  4131. * @param position the position of the vertex (defaut: 0,0,0)
  4132. * @param normal the normal of the vertex (defaut: 0,1,0)
  4133. * @param uv the uv of the vertex (default: 0,0)
  4134. */
  4135. constructor(
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position?: Vector3,
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal?: Vector3,
  4140. /** the uv of the vertex (default: 0,0) */
  4141. uv?: Vector2);
  4142. /**
  4143. * Clones the PositionNormalTextureVertex
  4144. * @returns the cloned PositionNormalTextureVertex
  4145. */
  4146. clone(): PositionNormalTextureVertex;
  4147. }
  4148. /**
  4149. * @hidden
  4150. */
  4151. export class Tmp {
  4152. static Color3: Color3[];
  4153. static Color4: Color4[];
  4154. static Vector2: Vector2[];
  4155. static Vector3: Vector3[];
  4156. static Vector4: Vector4[];
  4157. static Quaternion: Quaternion[];
  4158. static Matrix: Matrix[];
  4159. }
  4160. }
  4161. declare module BABYLON {
  4162. /**
  4163. * Class used to enable access to offline support
  4164. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4165. */
  4166. export interface IOfflineProvider {
  4167. /**
  4168. * Gets a boolean indicating if scene must be saved in the database
  4169. */
  4170. enableSceneOffline: boolean;
  4171. /**
  4172. * Gets a boolean indicating if textures must be saved in the database
  4173. */
  4174. enableTexturesOffline: boolean;
  4175. /**
  4176. * Open the offline support and make it available
  4177. * @param successCallback defines the callback to call on success
  4178. * @param errorCallback defines the callback to call on error
  4179. */
  4180. open(successCallback: () => void, errorCallback: () => void): void;
  4181. /**
  4182. * Loads an image from the offline support
  4183. * @param url defines the url to load from
  4184. * @param image defines the target DOM image
  4185. */
  4186. loadImage(url: string, image: HTMLImageElement): void;
  4187. /**
  4188. * Loads a file from offline support
  4189. * @param url defines the URL to load from
  4190. * @param sceneLoaded defines a callback to call on success
  4191. * @param progressCallBack defines a callback to call when progress changed
  4192. * @param errorCallback defines a callback to call on error
  4193. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4194. */
  4195. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * A class serves as a medium between the observable and its observers
  4201. */
  4202. export class EventState {
  4203. /**
  4204. * Create a new EventState
  4205. * @param mask defines the mask associated with this state
  4206. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4207. * @param target defines the original target of the state
  4208. * @param currentTarget defines the current target of the state
  4209. */
  4210. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4211. /**
  4212. * Initialize the current event state
  4213. * @param mask defines the mask associated with this state
  4214. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4215. * @param target defines the original target of the state
  4216. * @param currentTarget defines the current target of the state
  4217. * @returns the current event state
  4218. */
  4219. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4220. /**
  4221. * An Observer can set this property to true to prevent subsequent observers of being notified
  4222. */
  4223. skipNextObservers: boolean;
  4224. /**
  4225. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4226. */
  4227. mask: number;
  4228. /**
  4229. * The object that originally notified the event
  4230. */
  4231. target?: any;
  4232. /**
  4233. * The current object in the bubbling phase
  4234. */
  4235. currentTarget?: any;
  4236. /**
  4237. * This will be populated with the return value of the last function that was executed.
  4238. * If it is the first function in the callback chain it will be the event data.
  4239. */
  4240. lastReturnValue?: any;
  4241. }
  4242. /**
  4243. * Represent an Observer registered to a given Observable object.
  4244. */
  4245. export class Observer<T> {
  4246. /**
  4247. * Defines the callback to call when the observer is notified
  4248. */
  4249. callback: (eventData: T, eventState: EventState) => void;
  4250. /**
  4251. * Defines the mask of the observer (used to filter notifications)
  4252. */
  4253. mask: number;
  4254. /**
  4255. * Defines the current scope used to restore the JS context
  4256. */
  4257. scope: any;
  4258. /** @hidden */
  4259. _willBeUnregistered: boolean;
  4260. /**
  4261. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4262. */
  4263. unregisterOnNextCall: boolean;
  4264. /**
  4265. * Creates a new observer
  4266. * @param callback defines the callback to call when the observer is notified
  4267. * @param mask defines the mask of the observer (used to filter notifications)
  4268. * @param scope defines the current scope used to restore the JS context
  4269. */
  4270. constructor(
  4271. /**
  4272. * Defines the callback to call when the observer is notified
  4273. */
  4274. callback: (eventData: T, eventState: EventState) => void,
  4275. /**
  4276. * Defines the mask of the observer (used to filter notifications)
  4277. */
  4278. mask: number,
  4279. /**
  4280. * Defines the current scope used to restore the JS context
  4281. */
  4282. scope?: any);
  4283. }
  4284. /**
  4285. * Represent a list of observers registered to multiple Observables object.
  4286. */
  4287. export class MultiObserver<T> {
  4288. private _observers;
  4289. private _observables;
  4290. /**
  4291. * Release associated resources
  4292. */
  4293. dispose(): void;
  4294. /**
  4295. * Raise a callback when one of the observable will notify
  4296. * @param observables defines a list of observables to watch
  4297. * @param callback defines the callback to call on notification
  4298. * @param mask defines the mask used to filter notifications
  4299. * @param scope defines the current scope used to restore the JS context
  4300. * @returns the new MultiObserver
  4301. */
  4302. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4303. }
  4304. /**
  4305. * The Observable class is a simple implementation of the Observable pattern.
  4306. *
  4307. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4308. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4309. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4310. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4311. */
  4312. export class Observable<T> {
  4313. private _observers;
  4314. private _eventState;
  4315. private _onObserverAdded;
  4316. /**
  4317. * Creates a new observable
  4318. * @param onObserverAdded defines a callback to call when a new observer is added
  4319. */
  4320. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4321. /**
  4322. * Create a new Observer with the specified callback
  4323. * @param callback the callback that will be executed for that Observer
  4324. * @param mask the mask used to filter observers
  4325. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4326. * @param scope optional scope for the callback to be called from
  4327. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4328. * @returns the new observer created for the callback
  4329. */
  4330. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4331. /**
  4332. * Create a new Observer with the specified callback and unregisters after the next notification
  4333. * @param callback the callback that will be executed for that Observer
  4334. * @returns the new observer created for the callback
  4335. */
  4336. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4337. /**
  4338. * Remove an Observer from the Observable object
  4339. * @param observer the instance of the Observer to remove
  4340. * @returns false if it doesn't belong to this Observable
  4341. */
  4342. remove(observer: Nullable<Observer<T>>): boolean;
  4343. /**
  4344. * Remove a callback from the Observable object
  4345. * @param callback the callback to remove
  4346. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4347. * @returns false if it doesn't belong to this Observable
  4348. */
  4349. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4350. private _deferUnregister;
  4351. private _remove;
  4352. /**
  4353. * Notify all Observers by calling their respective callback with the given data
  4354. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4355. * @param eventData defines the data to send to all observers
  4356. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4357. * @param target defines the original target of the state
  4358. * @param currentTarget defines the current target of the state
  4359. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4360. */
  4361. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4362. /**
  4363. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4364. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4365. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4366. * and it is crucial that all callbacks will be executed.
  4367. * The order of the callbacks is kept, callbacks are not executed parallel.
  4368. *
  4369. * @param eventData The data to be sent to each callback
  4370. * @param mask is used to filter observers defaults to -1
  4371. * @param target defines the callback target (see EventState)
  4372. * @param currentTarget defines he current object in the bubbling phase
  4373. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4374. */
  4375. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4376. /**
  4377. * Notify a specific observer
  4378. * @param observer defines the observer to notify
  4379. * @param eventData defines the data to be sent to each callback
  4380. * @param mask is used to filter observers defaults to -1
  4381. */
  4382. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4383. /**
  4384. * Gets a boolean indicating if the observable has at least one observer
  4385. * @returns true is the Observable has at least one Observer registered
  4386. */
  4387. hasObservers(): boolean;
  4388. /**
  4389. * Clear the list of observers
  4390. */
  4391. clear(): void;
  4392. /**
  4393. * Clone the current observable
  4394. * @returns a new observable
  4395. */
  4396. clone(): Observable<T>;
  4397. /**
  4398. * Does this observable handles observer registered with a given mask
  4399. * @param mask defines the mask to be tested
  4400. * @return whether or not one observer registered with the given mask is handeled
  4401. **/
  4402. hasSpecificMask(mask?: number): boolean;
  4403. }
  4404. }
  4405. declare module BABYLON {
  4406. /**
  4407. * Class used to help managing file picking and drag'n'drop
  4408. * File Storage
  4409. */
  4410. export class FilesInputStore {
  4411. /**
  4412. * List of files ready to be loaded
  4413. */
  4414. static FilesToLoad: {
  4415. [key: string]: File;
  4416. };
  4417. }
  4418. }
  4419. declare module BABYLON {
  4420. /** Defines the cross module used constants to avoid circular dependncies */
  4421. export class Constants {
  4422. /** Defines that alpha blending is disabled */
  4423. static readonly ALPHA_DISABLE: number;
  4424. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4425. static readonly ALPHA_ADD: number;
  4426. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4427. static readonly ALPHA_COMBINE: number;
  4428. /** Defines that alpha blending to DEST - SRC * DEST */
  4429. static readonly ALPHA_SUBTRACT: number;
  4430. /** Defines that alpha blending to SRC * DEST */
  4431. static readonly ALPHA_MULTIPLY: number;
  4432. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4433. static readonly ALPHA_MAXIMIZED: number;
  4434. /** Defines that alpha blending to SRC + DEST */
  4435. static readonly ALPHA_ONEONE: number;
  4436. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4437. static readonly ALPHA_PREMULTIPLIED: number;
  4438. /**
  4439. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4440. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4441. */
  4442. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4443. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4444. static readonly ALPHA_INTERPOLATE: number;
  4445. /**
  4446. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4447. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4448. */
  4449. static readonly ALPHA_SCREENMODE: number;
  4450. /** Defines that the ressource is not delayed*/
  4451. static readonly DELAYLOADSTATE_NONE: number;
  4452. /** Defines that the ressource was successfully delay loaded */
  4453. static readonly DELAYLOADSTATE_LOADED: number;
  4454. /** Defines that the ressource is currently delay loading */
  4455. static readonly DELAYLOADSTATE_LOADING: number;
  4456. /** Defines that the ressource is delayed and has not started loading */
  4457. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4458. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4459. static readonly NEVER: number;
  4460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4461. static readonly ALWAYS: number;
  4462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4463. static readonly LESS: number;
  4464. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4465. static readonly EQUAL: number;
  4466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4467. static readonly LEQUAL: number;
  4468. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4469. static readonly GREATER: number;
  4470. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4471. static readonly GEQUAL: number;
  4472. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4473. static readonly NOTEQUAL: number;
  4474. /** Passed to stencilOperation to specify that stencil value must be kept */
  4475. static readonly KEEP: number;
  4476. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4477. static readonly REPLACE: number;
  4478. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4479. static readonly INCR: number;
  4480. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4481. static readonly DECR: number;
  4482. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4483. static readonly INVERT: number;
  4484. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4485. static readonly INCR_WRAP: number;
  4486. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4487. static readonly DECR_WRAP: number;
  4488. /** Texture is not repeating outside of 0..1 UVs */
  4489. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4490. /** Texture is repeating outside of 0..1 UVs */
  4491. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4492. /** Texture is repeating and mirrored */
  4493. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4494. /** ALPHA */
  4495. static readonly TEXTUREFORMAT_ALPHA: number;
  4496. /** LUMINANCE */
  4497. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4498. /** LUMINANCE_ALPHA */
  4499. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4500. /** RGB */
  4501. static readonly TEXTUREFORMAT_RGB: number;
  4502. /** RGBA */
  4503. static readonly TEXTUREFORMAT_RGBA: number;
  4504. /** RED */
  4505. static readonly TEXTUREFORMAT_RED: number;
  4506. /** RED (2nd reference) */
  4507. static readonly TEXTUREFORMAT_R: number;
  4508. /** RG */
  4509. static readonly TEXTUREFORMAT_RG: number;
  4510. /** RED_INTEGER */
  4511. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4512. /** RED_INTEGER (2nd reference) */
  4513. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4514. /** RG_INTEGER */
  4515. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4516. /** RGB_INTEGER */
  4517. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4518. /** RGBA_INTEGER */
  4519. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4520. /** UNSIGNED_BYTE */
  4521. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4522. /** UNSIGNED_BYTE (2nd reference) */
  4523. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4524. /** FLOAT */
  4525. static readonly TEXTURETYPE_FLOAT: number;
  4526. /** HALF_FLOAT */
  4527. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4528. /** BYTE */
  4529. static readonly TEXTURETYPE_BYTE: number;
  4530. /** SHORT */
  4531. static readonly TEXTURETYPE_SHORT: number;
  4532. /** UNSIGNED_SHORT */
  4533. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4534. /** INT */
  4535. static readonly TEXTURETYPE_INT: number;
  4536. /** UNSIGNED_INT */
  4537. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4538. /** UNSIGNED_SHORT_4_4_4_4 */
  4539. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4540. /** UNSIGNED_SHORT_5_5_5_1 */
  4541. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4542. /** UNSIGNED_SHORT_5_6_5 */
  4543. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4544. /** UNSIGNED_INT_2_10_10_10_REV */
  4545. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4546. /** UNSIGNED_INT_24_8 */
  4547. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4548. /** UNSIGNED_INT_10F_11F_11F_REV */
  4549. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4550. /** UNSIGNED_INT_5_9_9_9_REV */
  4551. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4552. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4553. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4554. /** nearest is mag = nearest and min = nearest and mip = linear */
  4555. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4556. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4557. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4558. /** Trilinear is mag = linear and min = linear and mip = linear */
  4559. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4560. /** nearest is mag = nearest and min = nearest and mip = linear */
  4561. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4563. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4564. /** Trilinear is mag = linear and min = linear and mip = linear */
  4565. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4566. /** mag = nearest and min = nearest and mip = nearest */
  4567. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4568. /** mag = nearest and min = linear and mip = nearest */
  4569. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4570. /** mag = nearest and min = linear and mip = linear */
  4571. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4572. /** mag = nearest and min = linear and mip = none */
  4573. static readonly TEXTURE_NEAREST_LINEAR: number;
  4574. /** mag = nearest and min = nearest and mip = none */
  4575. static readonly TEXTURE_NEAREST_NEAREST: number;
  4576. /** mag = linear and min = nearest and mip = nearest */
  4577. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4578. /** mag = linear and min = nearest and mip = linear */
  4579. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4580. /** mag = linear and min = linear and mip = none */
  4581. static readonly TEXTURE_LINEAR_LINEAR: number;
  4582. /** mag = linear and min = nearest and mip = none */
  4583. static readonly TEXTURE_LINEAR_NEAREST: number;
  4584. /** Explicit coordinates mode */
  4585. static readonly TEXTURE_EXPLICIT_MODE: number;
  4586. /** Spherical coordinates mode */
  4587. static readonly TEXTURE_SPHERICAL_MODE: number;
  4588. /** Planar coordinates mode */
  4589. static readonly TEXTURE_PLANAR_MODE: number;
  4590. /** Cubic coordinates mode */
  4591. static readonly TEXTURE_CUBIC_MODE: number;
  4592. /** Projection coordinates mode */
  4593. static readonly TEXTURE_PROJECTION_MODE: number;
  4594. /** Skybox coordinates mode */
  4595. static readonly TEXTURE_SKYBOX_MODE: number;
  4596. /** Inverse Cubic coordinates mode */
  4597. static readonly TEXTURE_INVCUBIC_MODE: number;
  4598. /** Equirectangular coordinates mode */
  4599. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4600. /** Equirectangular Fixed coordinates mode */
  4601. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4602. /** Equirectangular Fixed Mirrored coordinates mode */
  4603. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4604. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4605. static readonly SCALEMODE_FLOOR: number;
  4606. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4607. static readonly SCALEMODE_NEAREST: number;
  4608. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4609. static readonly SCALEMODE_CEILING: number;
  4610. /**
  4611. * The dirty texture flag value
  4612. */
  4613. static readonly MATERIAL_TextureDirtyFlag: number;
  4614. /**
  4615. * The dirty light flag value
  4616. */
  4617. static readonly MATERIAL_LightDirtyFlag: number;
  4618. /**
  4619. * The dirty fresnel flag value
  4620. */
  4621. static readonly MATERIAL_FresnelDirtyFlag: number;
  4622. /**
  4623. * The dirty attribute flag value
  4624. */
  4625. static readonly MATERIAL_AttributesDirtyFlag: number;
  4626. /**
  4627. * The dirty misc flag value
  4628. */
  4629. static readonly MATERIAL_MiscDirtyFlag: number;
  4630. /**
  4631. * The all dirty flag value
  4632. */
  4633. static readonly MATERIAL_AllDirtyFlag: number;
  4634. /**
  4635. * Returns the triangle fill mode
  4636. */
  4637. static readonly MATERIAL_TriangleFillMode: number;
  4638. /**
  4639. * Returns the wireframe mode
  4640. */
  4641. static readonly MATERIAL_WireFrameFillMode: number;
  4642. /**
  4643. * Returns the point fill mode
  4644. */
  4645. static readonly MATERIAL_PointFillMode: number;
  4646. /**
  4647. * Returns the point list draw mode
  4648. */
  4649. static readonly MATERIAL_PointListDrawMode: number;
  4650. /**
  4651. * Returns the line list draw mode
  4652. */
  4653. static readonly MATERIAL_LineListDrawMode: number;
  4654. /**
  4655. * Returns the line loop draw mode
  4656. */
  4657. static readonly MATERIAL_LineLoopDrawMode: number;
  4658. /**
  4659. * Returns the line strip draw mode
  4660. */
  4661. static readonly MATERIAL_LineStripDrawMode: number;
  4662. /**
  4663. * Returns the triangle strip draw mode
  4664. */
  4665. static readonly MATERIAL_TriangleStripDrawMode: number;
  4666. /**
  4667. * Returns the triangle fan draw mode
  4668. */
  4669. static readonly MATERIAL_TriangleFanDrawMode: number;
  4670. /**
  4671. * Stores the clock-wise side orientation
  4672. */
  4673. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4674. /**
  4675. * Stores the counter clock-wise side orientation
  4676. */
  4677. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4678. /**
  4679. * Nothing
  4680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4681. */
  4682. static readonly ACTION_NothingTrigger: number;
  4683. /**
  4684. * On pick
  4685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4686. */
  4687. static readonly ACTION_OnPickTrigger: number;
  4688. /**
  4689. * On left pick
  4690. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4691. */
  4692. static readonly ACTION_OnLeftPickTrigger: number;
  4693. /**
  4694. * On right pick
  4695. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4696. */
  4697. static readonly ACTION_OnRightPickTrigger: number;
  4698. /**
  4699. * On center pick
  4700. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4701. */
  4702. static readonly ACTION_OnCenterPickTrigger: number;
  4703. /**
  4704. * On pick down
  4705. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4706. */
  4707. static readonly ACTION_OnPickDownTrigger: number;
  4708. /**
  4709. * On double pick
  4710. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4711. */
  4712. static readonly ACTION_OnDoublePickTrigger: number;
  4713. /**
  4714. * On pick up
  4715. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4716. */
  4717. static readonly ACTION_OnPickUpTrigger: number;
  4718. /**
  4719. * On pick out.
  4720. * This trigger will only be raised if you also declared a OnPickDown
  4721. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4722. */
  4723. static readonly ACTION_OnPickOutTrigger: number;
  4724. /**
  4725. * On long press
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_OnLongPressTrigger: number;
  4729. /**
  4730. * On pointer over
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPointerOverTrigger: number;
  4734. /**
  4735. * On pointer out
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnPointerOutTrigger: number;
  4739. /**
  4740. * On every frame
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnEveryFrameTrigger: number;
  4744. /**
  4745. * On intersection enter
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4749. /**
  4750. * On intersection exit
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnIntersectionExitTrigger: number;
  4754. /**
  4755. * On key down
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnKeyDownTrigger: number;
  4759. /**
  4760. * On key up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnKeyUpTrigger: number;
  4764. /**
  4765. * Billboard mode will only apply to Y axis
  4766. */
  4767. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4768. /**
  4769. * Billboard mode will apply to all axes
  4770. */
  4771. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4772. /**
  4773. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4774. */
  4775. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4776. /**
  4777. * Gets or sets base Assets URL
  4778. */
  4779. static readonly PARTICLES_BaseAssetsUrl: string;
  4780. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4781. * Test order :
  4782. * Is the bounding sphere outside the frustum ?
  4783. * If not, are the bounding box vertices outside the frustum ?
  4784. * It not, then the cullable object is in the frustum.
  4785. */
  4786. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4787. /** Culling strategy : Bounding Sphere Only.
  4788. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4789. * It's also less accurate than the standard because some not visible objects can still be selected.
  4790. * Test : is the bounding sphere outside the frustum ?
  4791. * If not, then the cullable object is in the frustum.
  4792. */
  4793. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4794. /** Culling strategy : Optimistic Inclusion.
  4795. * This in an inclusion test first, then the standard exclusion test.
  4796. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4797. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4798. * Anyway, it's as accurate as the standard strategy.
  4799. * Test :
  4800. * Is the cullable object bounding sphere center in the frustum ?
  4801. * If not, apply the default culling strategy.
  4802. */
  4803. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4804. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4805. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4806. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4807. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4808. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4809. * Test :
  4810. * Is the cullable object bounding sphere center in the frustum ?
  4811. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4812. */
  4813. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4814. /**
  4815. * No logging while loading
  4816. */
  4817. static readonly SCENELOADER_NO_LOGGING: number;
  4818. /**
  4819. * Minimal logging while loading
  4820. */
  4821. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4822. /**
  4823. * Summary logging while loading
  4824. */
  4825. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4826. /**
  4827. * Detailled logging while loading
  4828. */
  4829. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4830. }
  4831. }
  4832. declare module BABYLON {
  4833. /**
  4834. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4835. * Babylon.js
  4836. */
  4837. export class DomManagement {
  4838. /**
  4839. * Checks if the window object exists
  4840. * @returns true if the window object exists
  4841. */
  4842. static IsWindowObjectExist(): boolean;
  4843. /**
  4844. * Extracts text content from a DOM element hierarchy
  4845. * @param element defines the root element
  4846. * @returns a string
  4847. */
  4848. static GetDOMTextContent(element: HTMLElement): string;
  4849. }
  4850. }
  4851. declare module BABYLON {
  4852. /**
  4853. * Logger used througouht the application to allow configuration of
  4854. * the log level required for the messages.
  4855. */
  4856. export class Logger {
  4857. /**
  4858. * No log
  4859. */
  4860. static readonly NoneLogLevel: number;
  4861. /**
  4862. * Only message logs
  4863. */
  4864. static readonly MessageLogLevel: number;
  4865. /**
  4866. * Only warning logs
  4867. */
  4868. static readonly WarningLogLevel: number;
  4869. /**
  4870. * Only error logs
  4871. */
  4872. static readonly ErrorLogLevel: number;
  4873. /**
  4874. * All logs
  4875. */
  4876. static readonly AllLogLevel: number;
  4877. private static _LogCache;
  4878. /**
  4879. * Gets a value indicating the number of loading errors
  4880. * @ignorenaming
  4881. */
  4882. static errorsCount: number;
  4883. /**
  4884. * Callback called when a new log is added
  4885. */
  4886. static OnNewCacheEntry: (entry: string) => void;
  4887. private static _AddLogEntry;
  4888. private static _FormatMessage;
  4889. private static _LogDisabled;
  4890. private static _LogEnabled;
  4891. private static _WarnDisabled;
  4892. private static _WarnEnabled;
  4893. private static _ErrorDisabled;
  4894. private static _ErrorEnabled;
  4895. /**
  4896. * Log a message to the console
  4897. */
  4898. static Log: (message: string) => void;
  4899. /**
  4900. * Write a warning message to the console
  4901. */
  4902. static Warn: (message: string) => void;
  4903. /**
  4904. * Write an error message to the console
  4905. */
  4906. static Error: (message: string) => void;
  4907. /**
  4908. * Gets current log cache (list of logs)
  4909. */
  4910. static readonly LogCache: string;
  4911. /**
  4912. * Clears the log cache
  4913. */
  4914. static ClearLogCache(): void;
  4915. /**
  4916. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4917. */
  4918. static LogLevels: number;
  4919. }
  4920. }
  4921. declare module BABYLON {
  4922. /** @hidden */
  4923. export class _TypeStore {
  4924. /** @hidden */
  4925. static RegisteredTypes: {
  4926. [key: string]: Object;
  4927. };
  4928. /** @hidden */
  4929. static GetClass(fqdn: string): any;
  4930. }
  4931. }
  4932. declare module BABYLON {
  4933. /**
  4934. * Class containing a set of static utilities functions for deep copy.
  4935. */
  4936. export class DeepCopier {
  4937. /**
  4938. * Tries to copy an object by duplicating every property
  4939. * @param source defines the source object
  4940. * @param destination defines the target object
  4941. * @param doNotCopyList defines a list of properties to avoid
  4942. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4943. */
  4944. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4945. }
  4946. }
  4947. declare module BABYLON {
  4948. /**
  4949. * Class containing a set of static utilities functions for precision date
  4950. */
  4951. export class PrecisionDate {
  4952. /**
  4953. * Gets either window.performance.now() if supported or Date.now() else
  4954. */
  4955. static readonly Now: number;
  4956. }
  4957. }
  4958. declare module BABYLON {
  4959. /** @hidden */
  4960. export class _DevTools {
  4961. static WarnImport(name: string): string;
  4962. }
  4963. }
  4964. declare module BABYLON {
  4965. /**
  4966. * Class used to evalaute queries containing `and` and `or` operators
  4967. */
  4968. export class AndOrNotEvaluator {
  4969. /**
  4970. * Evaluate a query
  4971. * @param query defines the query to evaluate
  4972. * @param evaluateCallback defines the callback used to filter result
  4973. * @returns true if the query matches
  4974. */
  4975. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4976. private static _HandleParenthesisContent;
  4977. private static _SimplifyNegation;
  4978. }
  4979. }
  4980. declare module BABYLON {
  4981. /**
  4982. * Class used to store custom tags
  4983. */
  4984. export class Tags {
  4985. /**
  4986. * Adds support for tags on the given object
  4987. * @param obj defines the object to use
  4988. */
  4989. static EnableFor(obj: any): void;
  4990. /**
  4991. * Removes tags support
  4992. * @param obj defines the object to use
  4993. */
  4994. static DisableFor(obj: any): void;
  4995. /**
  4996. * Gets a boolean indicating if the given object has tags
  4997. * @param obj defines the object to use
  4998. * @returns a boolean
  4999. */
  5000. static HasTags(obj: any): boolean;
  5001. /**
  5002. * Gets the tags available on a given object
  5003. * @param obj defines the object to use
  5004. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5005. * @returns the tags
  5006. */
  5007. static GetTags(obj: any, asString?: boolean): any;
  5008. /**
  5009. * Adds tags to an object
  5010. * @param obj defines the object to use
  5011. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5012. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5013. */
  5014. static AddTagsTo(obj: any, tagsString: string): void;
  5015. /**
  5016. * @hidden
  5017. */
  5018. static _AddTagTo(obj: any, tag: string): void;
  5019. /**
  5020. * Removes specific tags from a specific object
  5021. * @param obj defines the object to use
  5022. * @param tagsString defines the tags to remove
  5023. */
  5024. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5025. /**
  5026. * @hidden
  5027. */
  5028. static _RemoveTagFrom(obj: any, tag: string): void;
  5029. /**
  5030. * Defines if tags hosted on an object match a given query
  5031. * @param obj defines the object to use
  5032. * @param tagsQuery defines the tag query
  5033. * @returns a boolean
  5034. */
  5035. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * Manages the defines for the Material
  5041. */
  5042. export class MaterialDefines {
  5043. private _keys;
  5044. private _isDirty;
  5045. /** @hidden */
  5046. _renderId: number;
  5047. /** @hidden */
  5048. _areLightsDirty: boolean;
  5049. /** @hidden */
  5050. _areAttributesDirty: boolean;
  5051. /** @hidden */
  5052. _areTexturesDirty: boolean;
  5053. /** @hidden */
  5054. _areFresnelDirty: boolean;
  5055. /** @hidden */
  5056. _areMiscDirty: boolean;
  5057. /** @hidden */
  5058. _areImageProcessingDirty: boolean;
  5059. /** @hidden */
  5060. _normals: boolean;
  5061. /** @hidden */
  5062. _uvs: boolean;
  5063. /** @hidden */
  5064. _needNormals: boolean;
  5065. /** @hidden */
  5066. _needUVs: boolean;
  5067. /**
  5068. * Specifies if the material needs to be re-calculated
  5069. */
  5070. readonly isDirty: boolean;
  5071. /**
  5072. * Marks the material to indicate that it has been re-calculated
  5073. */
  5074. markAsProcessed(): void;
  5075. /**
  5076. * Marks the material to indicate that it needs to be re-calculated
  5077. */
  5078. markAsUnprocessed(): void;
  5079. /**
  5080. * Marks the material to indicate all of its defines need to be re-calculated
  5081. */
  5082. markAllAsDirty(): void;
  5083. /**
  5084. * Marks the material to indicate that image processing needs to be re-calculated
  5085. */
  5086. markAsImageProcessingDirty(): void;
  5087. /**
  5088. * Marks the material to indicate the lights need to be re-calculated
  5089. */
  5090. markAsLightDirty(): void;
  5091. /**
  5092. * Marks the attribute state as changed
  5093. */
  5094. markAsAttributesDirty(): void;
  5095. /**
  5096. * Marks the texture state as changed
  5097. */
  5098. markAsTexturesDirty(): void;
  5099. /**
  5100. * Marks the fresnel state as changed
  5101. */
  5102. markAsFresnelDirty(): void;
  5103. /**
  5104. * Marks the misc state as changed
  5105. */
  5106. markAsMiscDirty(): void;
  5107. /**
  5108. * Rebuilds the material defines
  5109. */
  5110. rebuild(): void;
  5111. /**
  5112. * Specifies if two material defines are equal
  5113. * @param other - A material define instance to compare to
  5114. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5115. */
  5116. isEqual(other: MaterialDefines): boolean;
  5117. /**
  5118. * Clones this instance's defines to another instance
  5119. * @param other - material defines to clone values to
  5120. */
  5121. cloneTo(other: MaterialDefines): void;
  5122. /**
  5123. * Resets the material define values
  5124. */
  5125. reset(): void;
  5126. /**
  5127. * Converts the material define values to a string
  5128. * @returns - String of material define information
  5129. */
  5130. toString(): string;
  5131. }
  5132. }
  5133. declare module BABYLON {
  5134. /**
  5135. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5136. */
  5137. export class PerformanceMonitor {
  5138. private _enabled;
  5139. private _rollingFrameTime;
  5140. private _lastFrameTimeMs;
  5141. /**
  5142. * constructor
  5143. * @param frameSampleSize The number of samples required to saturate the sliding window
  5144. */
  5145. constructor(frameSampleSize?: number);
  5146. /**
  5147. * Samples current frame
  5148. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5149. */
  5150. sampleFrame(timeMs?: number): void;
  5151. /**
  5152. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5153. */
  5154. readonly averageFrameTime: number;
  5155. /**
  5156. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5157. */
  5158. readonly averageFrameTimeVariance: number;
  5159. /**
  5160. * Returns the frame time of the most recent frame
  5161. */
  5162. readonly instantaneousFrameTime: number;
  5163. /**
  5164. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5165. */
  5166. readonly averageFPS: number;
  5167. /**
  5168. * Returns the average framerate in frames per second using the most recent frame time
  5169. */
  5170. readonly instantaneousFPS: number;
  5171. /**
  5172. * Returns true if enough samples have been taken to completely fill the sliding window
  5173. */
  5174. readonly isSaturated: boolean;
  5175. /**
  5176. * Enables contributions to the sliding window sample set
  5177. */
  5178. enable(): void;
  5179. /**
  5180. * Disables contributions to the sliding window sample set
  5181. * Samples will not be interpolated over the disabled period
  5182. */
  5183. disable(): void;
  5184. /**
  5185. * Returns true if sampling is enabled
  5186. */
  5187. readonly isEnabled: boolean;
  5188. /**
  5189. * Resets performance monitor
  5190. */
  5191. reset(): void;
  5192. }
  5193. /**
  5194. * RollingAverage
  5195. *
  5196. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5197. */
  5198. export class RollingAverage {
  5199. /**
  5200. * Current average
  5201. */
  5202. average: number;
  5203. /**
  5204. * Current variance
  5205. */
  5206. variance: number;
  5207. protected _samples: Array<number>;
  5208. protected _sampleCount: number;
  5209. protected _pos: number;
  5210. protected _m2: number;
  5211. /**
  5212. * constructor
  5213. * @param length The number of samples required to saturate the sliding window
  5214. */
  5215. constructor(length: number);
  5216. /**
  5217. * Adds a sample to the sample set
  5218. * @param v The sample value
  5219. */
  5220. add(v: number): void;
  5221. /**
  5222. * Returns previously added values or null if outside of history or outside the sliding window domain
  5223. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5224. * @return Value previously recorded with add() or null if outside of range
  5225. */
  5226. history(i: number): number;
  5227. /**
  5228. * Returns true if enough samples have been taken to completely fill the sliding window
  5229. * @return true if sample-set saturated
  5230. */
  5231. isSaturated(): boolean;
  5232. /**
  5233. * Resets the rolling average (equivalent to 0 samples taken so far)
  5234. */
  5235. reset(): void;
  5236. /**
  5237. * Wraps a value around the sample range boundaries
  5238. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5239. * @return Wrapped position in sample range
  5240. */
  5241. protected _wrapPosition(i: number): number;
  5242. }
  5243. }
  5244. declare module BABYLON {
  5245. /**
  5246. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5247. * The underlying implementation relies on an associative array to ensure the best performances.
  5248. * The value can be anything including 'null' but except 'undefined'
  5249. */
  5250. export class StringDictionary<T> {
  5251. /**
  5252. * This will clear this dictionary and copy the content from the 'source' one.
  5253. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5254. * @param source the dictionary to take the content from and copy to this dictionary
  5255. */
  5256. copyFrom(source: StringDictionary<T>): void;
  5257. /**
  5258. * Get a value based from its key
  5259. * @param key the given key to get the matching value from
  5260. * @return the value if found, otherwise undefined is returned
  5261. */
  5262. get(key: string): T | undefined;
  5263. /**
  5264. * Get a value from its key or add it if it doesn't exist.
  5265. * This method will ensure you that a given key/data will be present in the dictionary.
  5266. * @param key the given key to get the matching value from
  5267. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5268. * The factory will only be invoked if there's no data for the given key.
  5269. * @return the value corresponding to the key.
  5270. */
  5271. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5272. /**
  5273. * Get a value from its key if present in the dictionary otherwise add it
  5274. * @param key the key to get the value from
  5275. * @param val if there's no such key/value pair in the dictionary add it with this value
  5276. * @return the value corresponding to the key
  5277. */
  5278. getOrAdd(key: string, val: T): T;
  5279. /**
  5280. * Check if there's a given key in the dictionary
  5281. * @param key the key to check for
  5282. * @return true if the key is present, false otherwise
  5283. */
  5284. contains(key: string): boolean;
  5285. /**
  5286. * Add a new key and its corresponding value
  5287. * @param key the key to add
  5288. * @param value the value corresponding to the key
  5289. * @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
  5290. */
  5291. add(key: string, value: T): boolean;
  5292. /**
  5293. * Update a specific value associated to a key
  5294. * @param key defines the key to use
  5295. * @param value defines the value to store
  5296. * @returns true if the value was updated (or false if the key was not found)
  5297. */
  5298. set(key: string, value: T): boolean;
  5299. /**
  5300. * Get the element of the given key and remove it from the dictionary
  5301. * @param key defines the key to search
  5302. * @returns the value associated with the key or null if not found
  5303. */
  5304. getAndRemove(key: string): Nullable<T>;
  5305. /**
  5306. * Remove a key/value from the dictionary.
  5307. * @param key the key to remove
  5308. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5309. */
  5310. remove(key: string): boolean;
  5311. /**
  5312. * Clear the whole content of the dictionary
  5313. */
  5314. clear(): void;
  5315. /**
  5316. * Gets the current count
  5317. */
  5318. readonly count: number;
  5319. /**
  5320. * Execute a callback on each key/val of the dictionary.
  5321. * Note that you can remove any element in this dictionary in the callback implementation
  5322. * @param callback the callback to execute on a given key/value pair
  5323. */
  5324. forEach(callback: (key: string, val: T) => void): void;
  5325. /**
  5326. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5327. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5328. * Note that you can remove any element in this dictionary in the callback implementation
  5329. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5330. * @returns the first item
  5331. */
  5332. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5333. private _count;
  5334. private _data;
  5335. }
  5336. }
  5337. declare module BABYLON {
  5338. /**
  5339. * Helper class that provides a small promise polyfill
  5340. */
  5341. export class PromisePolyfill {
  5342. /**
  5343. * Static function used to check if the polyfill is required
  5344. * If this is the case then the function will inject the polyfill to window.Promise
  5345. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5346. */
  5347. static Apply(force?: boolean): void;
  5348. }
  5349. }
  5350. declare module BABYLON {
  5351. /**
  5352. * Class used to store data that will be store in GPU memory
  5353. */
  5354. export class Buffer {
  5355. private _engine;
  5356. private _buffer;
  5357. /** @hidden */
  5358. _data: Nullable<DataArray>;
  5359. private _updatable;
  5360. private _instanced;
  5361. /**
  5362. * Gets the byte stride.
  5363. */
  5364. readonly byteStride: number;
  5365. /**
  5366. * Constructor
  5367. * @param engine the engine
  5368. * @param data the data to use for this buffer
  5369. * @param updatable whether the data is updatable
  5370. * @param stride the stride (optional)
  5371. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5372. * @param instanced whether the buffer is instanced (optional)
  5373. * @param useBytes set to true if the stride in in bytes (optional)
  5374. */
  5375. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5376. /**
  5377. * Create a new VertexBuffer based on the current buffer
  5378. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5379. * @param offset defines offset in the buffer (0 by default)
  5380. * @param size defines the size in floats of attributes (position is 3 for instance)
  5381. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5382. * @param instanced defines if the vertex buffer contains indexed data
  5383. * @param useBytes defines if the offset and stride are in bytes
  5384. * @returns the new vertex buffer
  5385. */
  5386. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5387. /**
  5388. * Gets a boolean indicating if the Buffer is updatable?
  5389. * @returns true if the buffer is updatable
  5390. */
  5391. isUpdatable(): boolean;
  5392. /**
  5393. * Gets current buffer's data
  5394. * @returns a DataArray or null
  5395. */
  5396. getData(): Nullable<DataArray>;
  5397. /**
  5398. * Gets underlying native buffer
  5399. * @returns underlying native buffer
  5400. */
  5401. getBuffer(): Nullable<WebGLBuffer>;
  5402. /**
  5403. * Gets the stride in float32 units (i.e. byte stride / 4).
  5404. * May not be an integer if the byte stride is not divisible by 4.
  5405. * DEPRECATED. Use byteStride instead.
  5406. * @returns the stride in float32 units
  5407. */
  5408. getStrideSize(): number;
  5409. /**
  5410. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5411. * @param data defines the data to store
  5412. */
  5413. create(data?: Nullable<DataArray>): void;
  5414. /** @hidden */
  5415. _rebuild(): void;
  5416. /**
  5417. * Update current buffer data
  5418. * @param data defines the data to store
  5419. */
  5420. update(data: DataArray): void;
  5421. /**
  5422. * Updates the data directly.
  5423. * @param data the new data
  5424. * @param offset the new offset
  5425. * @param vertexCount the vertex count (optional)
  5426. * @param useBytes set to true if the offset is in bytes
  5427. */
  5428. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5429. /**
  5430. * Release all resources
  5431. */
  5432. dispose(): void;
  5433. }
  5434. /**
  5435. * Specialized buffer used to store vertex data
  5436. */
  5437. export class VertexBuffer {
  5438. /** @hidden */
  5439. _buffer: Buffer;
  5440. private _kind;
  5441. private _size;
  5442. private _ownsBuffer;
  5443. private _instanced;
  5444. private _instanceDivisor;
  5445. /**
  5446. * The byte type.
  5447. */
  5448. static readonly BYTE: number;
  5449. /**
  5450. * The unsigned byte type.
  5451. */
  5452. static readonly UNSIGNED_BYTE: number;
  5453. /**
  5454. * The short type.
  5455. */
  5456. static readonly SHORT: number;
  5457. /**
  5458. * The unsigned short type.
  5459. */
  5460. static readonly UNSIGNED_SHORT: number;
  5461. /**
  5462. * The integer type.
  5463. */
  5464. static readonly INT: number;
  5465. /**
  5466. * The unsigned integer type.
  5467. */
  5468. static readonly UNSIGNED_INT: number;
  5469. /**
  5470. * The float type.
  5471. */
  5472. static readonly FLOAT: number;
  5473. /**
  5474. * Gets or sets the instance divisor when in instanced mode
  5475. */
  5476. instanceDivisor: number;
  5477. /**
  5478. * Gets the byte stride.
  5479. */
  5480. readonly byteStride: number;
  5481. /**
  5482. * Gets the byte offset.
  5483. */
  5484. readonly byteOffset: number;
  5485. /**
  5486. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5487. */
  5488. readonly normalized: boolean;
  5489. /**
  5490. * Gets the data type of each component in the array.
  5491. */
  5492. readonly type: number;
  5493. /**
  5494. * Constructor
  5495. * @param engine the engine
  5496. * @param data the data to use for this vertex buffer
  5497. * @param kind the vertex buffer kind
  5498. * @param updatable whether the data is updatable
  5499. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5500. * @param stride the stride (optional)
  5501. * @param instanced whether the buffer is instanced (optional)
  5502. * @param offset the offset of the data (optional)
  5503. * @param size the number of components (optional)
  5504. * @param type the type of the component (optional)
  5505. * @param normalized whether the data contains normalized data (optional)
  5506. * @param useBytes set to true if stride and offset are in bytes (optional)
  5507. */
  5508. 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);
  5509. /** @hidden */
  5510. _rebuild(): void;
  5511. /**
  5512. * Returns the kind of the VertexBuffer (string)
  5513. * @returns a string
  5514. */
  5515. getKind(): string;
  5516. /**
  5517. * Gets a boolean indicating if the VertexBuffer is updatable?
  5518. * @returns true if the buffer is updatable
  5519. */
  5520. isUpdatable(): boolean;
  5521. /**
  5522. * Gets current buffer's data
  5523. * @returns a DataArray or null
  5524. */
  5525. getData(): Nullable<DataArray>;
  5526. /**
  5527. * Gets underlying native buffer
  5528. * @returns underlying native buffer
  5529. */
  5530. getBuffer(): Nullable<WebGLBuffer>;
  5531. /**
  5532. * Gets the stride in float32 units (i.e. byte stride / 4).
  5533. * May not be an integer if the byte stride is not divisible by 4.
  5534. * DEPRECATED. Use byteStride instead.
  5535. * @returns the stride in float32 units
  5536. */
  5537. getStrideSize(): number;
  5538. /**
  5539. * Returns the offset as a multiple of the type byte length.
  5540. * DEPRECATED. Use byteOffset instead.
  5541. * @returns the offset in bytes
  5542. */
  5543. getOffset(): number;
  5544. /**
  5545. * Returns the number of components per vertex attribute (integer)
  5546. * @returns the size in float
  5547. */
  5548. getSize(): number;
  5549. /**
  5550. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5551. * @returns true if this buffer is instanced
  5552. */
  5553. getIsInstanced(): boolean;
  5554. /**
  5555. * Returns the instancing divisor, zero for non-instanced (integer).
  5556. * @returns a number
  5557. */
  5558. getInstanceDivisor(): number;
  5559. /**
  5560. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5561. * @param data defines the data to store
  5562. */
  5563. create(data?: DataArray): void;
  5564. /**
  5565. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5566. * This function will create a new buffer if the current one is not updatable
  5567. * @param data defines the data to store
  5568. */
  5569. update(data: DataArray): void;
  5570. /**
  5571. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5572. * Returns the directly updated WebGLBuffer.
  5573. * @param data the new data
  5574. * @param offset the new offset
  5575. * @param useBytes set to true if the offset is in bytes
  5576. */
  5577. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5578. /**
  5579. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5580. */
  5581. dispose(): void;
  5582. /**
  5583. * Enumerates each value of this vertex buffer as numbers.
  5584. * @param count the number of values to enumerate
  5585. * @param callback the callback function called for each value
  5586. */
  5587. forEach(count: number, callback: (value: number, index: number) => void): void;
  5588. /**
  5589. * Positions
  5590. */
  5591. static readonly PositionKind: string;
  5592. /**
  5593. * Normals
  5594. */
  5595. static readonly NormalKind: string;
  5596. /**
  5597. * Tangents
  5598. */
  5599. static readonly TangentKind: string;
  5600. /**
  5601. * Texture coordinates
  5602. */
  5603. static readonly UVKind: string;
  5604. /**
  5605. * Texture coordinates 2
  5606. */
  5607. static readonly UV2Kind: string;
  5608. /**
  5609. * Texture coordinates 3
  5610. */
  5611. static readonly UV3Kind: string;
  5612. /**
  5613. * Texture coordinates 4
  5614. */
  5615. static readonly UV4Kind: string;
  5616. /**
  5617. * Texture coordinates 5
  5618. */
  5619. static readonly UV5Kind: string;
  5620. /**
  5621. * Texture coordinates 6
  5622. */
  5623. static readonly UV6Kind: string;
  5624. /**
  5625. * Colors
  5626. */
  5627. static readonly ColorKind: string;
  5628. /**
  5629. * Matrix indices (for bones)
  5630. */
  5631. static readonly MatricesIndicesKind: string;
  5632. /**
  5633. * Matrix weights (for bones)
  5634. */
  5635. static readonly MatricesWeightsKind: string;
  5636. /**
  5637. * Additional matrix indices (for bones)
  5638. */
  5639. static readonly MatricesIndicesExtraKind: string;
  5640. /**
  5641. * Additional matrix weights (for bones)
  5642. */
  5643. static readonly MatricesWeightsExtraKind: string;
  5644. /**
  5645. * Deduces the stride given a kind.
  5646. * @param kind The kind string to deduce
  5647. * @returns The deduced stride
  5648. */
  5649. static DeduceStride(kind: string): number;
  5650. /**
  5651. * Gets the byte length of the given type.
  5652. * @param type the type
  5653. * @returns the number of bytes
  5654. */
  5655. static GetTypeByteLength(type: number): number;
  5656. /**
  5657. * Enumerates each value of the given parameters as numbers.
  5658. * @param data the data to enumerate
  5659. * @param byteOffset the byte offset of the data
  5660. * @param byteStride the byte stride of the data
  5661. * @param componentCount the number of components per element
  5662. * @param componentType the type of the component
  5663. * @param count the total number of components
  5664. * @param normalized whether the data is normalized
  5665. * @param callback the callback function called for each value
  5666. */
  5667. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5668. private static _GetFloatValue;
  5669. }
  5670. }
  5671. declare module BABYLON {
  5672. /**
  5673. * Class representing spherical polynomial coefficients to the 3rd degree
  5674. */
  5675. export class SphericalPolynomial {
  5676. /**
  5677. * The x coefficients of the spherical polynomial
  5678. */
  5679. x: Vector3;
  5680. /**
  5681. * The y coefficients of the spherical polynomial
  5682. */
  5683. y: Vector3;
  5684. /**
  5685. * The z coefficients of the spherical polynomial
  5686. */
  5687. z: Vector3;
  5688. /**
  5689. * The xx coefficients of the spherical polynomial
  5690. */
  5691. xx: Vector3;
  5692. /**
  5693. * The yy coefficients of the spherical polynomial
  5694. */
  5695. yy: Vector3;
  5696. /**
  5697. * The zz coefficients of the spherical polynomial
  5698. */
  5699. zz: Vector3;
  5700. /**
  5701. * The xy coefficients of the spherical polynomial
  5702. */
  5703. xy: Vector3;
  5704. /**
  5705. * The yz coefficients of the spherical polynomial
  5706. */
  5707. yz: Vector3;
  5708. /**
  5709. * The zx coefficients of the spherical polynomial
  5710. */
  5711. zx: Vector3;
  5712. /**
  5713. * Adds an ambient color to the spherical polynomial
  5714. * @param color the color to add
  5715. */
  5716. addAmbient(color: Color3): void;
  5717. /**
  5718. * Scales the spherical polynomial by the given amount
  5719. * @param scale the amount to scale
  5720. */
  5721. scale(scale: number): void;
  5722. /**
  5723. * Gets the spherical polynomial from harmonics
  5724. * @param harmonics the spherical harmonics
  5725. * @returns the spherical polynomial
  5726. */
  5727. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5728. /**
  5729. * Constructs a spherical polynomial from an array.
  5730. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5731. * @returns the spherical polynomial
  5732. */
  5733. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5734. }
  5735. /**
  5736. * Class representing spherical harmonics coefficients to the 3rd degree
  5737. */
  5738. export class SphericalHarmonics {
  5739. /**
  5740. * The l0,0 coefficients of the spherical harmonics
  5741. */
  5742. l00: Vector3;
  5743. /**
  5744. * The l1,-1 coefficients of the spherical harmonics
  5745. */
  5746. l1_1: Vector3;
  5747. /**
  5748. * The l1,0 coefficients of the spherical harmonics
  5749. */
  5750. l10: Vector3;
  5751. /**
  5752. * The l1,1 coefficients of the spherical harmonics
  5753. */
  5754. l11: Vector3;
  5755. /**
  5756. * The l2,-2 coefficients of the spherical harmonics
  5757. */
  5758. l2_2: Vector3;
  5759. /**
  5760. * The l2,-1 coefficients of the spherical harmonics
  5761. */
  5762. l2_1: Vector3;
  5763. /**
  5764. * The l2,0 coefficients of the spherical harmonics
  5765. */
  5766. l20: Vector3;
  5767. /**
  5768. * The l2,1 coefficients of the spherical harmonics
  5769. */
  5770. l21: Vector3;
  5771. /**
  5772. * The l2,2 coefficients of the spherical harmonics
  5773. */
  5774. lL22: Vector3;
  5775. /**
  5776. * Adds a light to the spherical harmonics
  5777. * @param direction the direction of the light
  5778. * @param color the color of the light
  5779. * @param deltaSolidAngle the delta solid angle of the light
  5780. */
  5781. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5782. /**
  5783. * Scales the spherical harmonics by the given amount
  5784. * @param scale the amount to scale
  5785. */
  5786. scale(scale: number): void;
  5787. /**
  5788. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5789. *
  5790. * ```
  5791. * E_lm = A_l * L_lm
  5792. * ```
  5793. *
  5794. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5795. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5796. * the scaling factors are given in equation 9.
  5797. */
  5798. convertIncidentRadianceToIrradiance(): void;
  5799. /**
  5800. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5801. *
  5802. * ```
  5803. * L = (1/pi) * E * rho
  5804. * ```
  5805. *
  5806. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5807. */
  5808. convertIrradianceToLambertianRadiance(): void;
  5809. /**
  5810. * Gets the spherical harmonics from polynomial
  5811. * @param polynomial the spherical polynomial
  5812. * @returns the spherical harmonics
  5813. */
  5814. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5815. /**
  5816. * Constructs a spherical harmonics from an array.
  5817. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5818. * @returns the spherical harmonics
  5819. */
  5820. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5821. }
  5822. }
  5823. declare module BABYLON {
  5824. /**
  5825. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5826. */
  5827. export interface CubeMapInfo {
  5828. /**
  5829. * The pixel array for the front face.
  5830. * This is stored in format, left to right, up to down format.
  5831. */
  5832. front: Nullable<ArrayBufferView>;
  5833. /**
  5834. * The pixel array for the back face.
  5835. * This is stored in format, left to right, up to down format.
  5836. */
  5837. back: Nullable<ArrayBufferView>;
  5838. /**
  5839. * The pixel array for the left face.
  5840. * This is stored in format, left to right, up to down format.
  5841. */
  5842. left: Nullable<ArrayBufferView>;
  5843. /**
  5844. * The pixel array for the right face.
  5845. * This is stored in format, left to right, up to down format.
  5846. */
  5847. right: Nullable<ArrayBufferView>;
  5848. /**
  5849. * The pixel array for the up face.
  5850. * This is stored in format, left to right, up to down format.
  5851. */
  5852. up: Nullable<ArrayBufferView>;
  5853. /**
  5854. * The pixel array for the down face.
  5855. * This is stored in format, left to right, up to down format.
  5856. */
  5857. down: Nullable<ArrayBufferView>;
  5858. /**
  5859. * The size of the cubemap stored.
  5860. *
  5861. * Each faces will be size * size pixels.
  5862. */
  5863. size: number;
  5864. /**
  5865. * The format of the texture.
  5866. *
  5867. * RGBA, RGB.
  5868. */
  5869. format: number;
  5870. /**
  5871. * The type of the texture data.
  5872. *
  5873. * UNSIGNED_INT, FLOAT.
  5874. */
  5875. type: number;
  5876. /**
  5877. * Specifies whether the texture is in gamma space.
  5878. */
  5879. gammaSpace: boolean;
  5880. }
  5881. /**
  5882. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5883. */
  5884. export class PanoramaToCubeMapTools {
  5885. private static FACE_FRONT;
  5886. private static FACE_BACK;
  5887. private static FACE_RIGHT;
  5888. private static FACE_LEFT;
  5889. private static FACE_DOWN;
  5890. private static FACE_UP;
  5891. /**
  5892. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5893. *
  5894. * @param float32Array The source data.
  5895. * @param inputWidth The width of the input panorama.
  5896. * @param inputHeight The height of the input panorama.
  5897. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5898. * @return The cubemap data
  5899. */
  5900. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5901. private static CreateCubemapTexture;
  5902. private static CalcProjectionSpherical;
  5903. }
  5904. }
  5905. declare module BABYLON {
  5906. /**
  5907. * Helper class dealing with the extraction of spherical polynomial dataArray
  5908. * from a cube map.
  5909. */
  5910. export class CubeMapToSphericalPolynomialTools {
  5911. private static FileFaces;
  5912. /**
  5913. * Converts a texture to the according Spherical Polynomial data.
  5914. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5915. *
  5916. * @param texture The texture to extract the information from.
  5917. * @return The Spherical Polynomial data.
  5918. */
  5919. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5920. /**
  5921. * Converts a cubemap to the according Spherical Polynomial data.
  5922. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5923. *
  5924. * @param cubeInfo The Cube map to extract the information from.
  5925. * @return The Spherical Polynomial data.
  5926. */
  5927. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5928. }
  5929. }
  5930. declare module BABYLON {
  5931. /**
  5932. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5933. * during the life time of the application.
  5934. */
  5935. export class EngineStore {
  5936. /** Gets the list of created engines */
  5937. static Instances: Engine[];
  5938. /**
  5939. * Gets the latest created engine
  5940. */
  5941. static readonly LastCreatedEngine: Nullable<Engine>;
  5942. /**
  5943. * Gets the latest created scene
  5944. */
  5945. static readonly LastCreatedScene: Nullable<Scene>;
  5946. }
  5947. }
  5948. declare module BABYLON {
  5949. /**
  5950. * Define options used to create a render target texture
  5951. */
  5952. export class RenderTargetCreationOptions {
  5953. /**
  5954. * Specifies is mipmaps must be generated
  5955. */
  5956. generateMipMaps?: boolean;
  5957. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5958. generateDepthBuffer?: boolean;
  5959. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5960. generateStencilBuffer?: boolean;
  5961. /** Defines texture type (int by default) */
  5962. type?: number;
  5963. /** Defines sampling mode (trilinear by default) */
  5964. samplingMode?: number;
  5965. /** Defines format (RGBA by default) */
  5966. format?: number;
  5967. }
  5968. }
  5969. declare module BABYLON {
  5970. /**
  5971. * @hidden
  5972. **/
  5973. export class _AlphaState {
  5974. private _isAlphaBlendDirty;
  5975. private _isBlendFunctionParametersDirty;
  5976. private _isBlendEquationParametersDirty;
  5977. private _isBlendConstantsDirty;
  5978. private _alphaBlend;
  5979. private _blendFunctionParameters;
  5980. private _blendEquationParameters;
  5981. private _blendConstants;
  5982. /**
  5983. * Initializes the state.
  5984. */
  5985. constructor();
  5986. readonly isDirty: boolean;
  5987. alphaBlend: boolean;
  5988. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5989. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5990. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5991. reset(): void;
  5992. apply(gl: WebGLRenderingContext): void;
  5993. }
  5994. }
  5995. declare module BABYLON {
  5996. /**
  5997. * @hidden
  5998. **/
  5999. export class _DepthCullingState {
  6000. private _isDepthTestDirty;
  6001. private _isDepthMaskDirty;
  6002. private _isDepthFuncDirty;
  6003. private _isCullFaceDirty;
  6004. private _isCullDirty;
  6005. private _isZOffsetDirty;
  6006. private _isFrontFaceDirty;
  6007. private _depthTest;
  6008. private _depthMask;
  6009. private _depthFunc;
  6010. private _cull;
  6011. private _cullFace;
  6012. private _zOffset;
  6013. private _frontFace;
  6014. /**
  6015. * Initializes the state.
  6016. */
  6017. constructor();
  6018. readonly isDirty: boolean;
  6019. zOffset: number;
  6020. cullFace: Nullable<number>;
  6021. cull: Nullable<boolean>;
  6022. depthFunc: Nullable<number>;
  6023. depthMask: boolean;
  6024. depthTest: boolean;
  6025. frontFace: Nullable<number>;
  6026. reset(): void;
  6027. apply(gl: WebGLRenderingContext): void;
  6028. }
  6029. }
  6030. declare module BABYLON {
  6031. /**
  6032. * @hidden
  6033. **/
  6034. export class _StencilState {
  6035. /** 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 */
  6036. static readonly ALWAYS: number;
  6037. /** Passed to stencilOperation to specify that stencil value must be kept */
  6038. static readonly KEEP: number;
  6039. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6040. static readonly REPLACE: number;
  6041. private _isStencilTestDirty;
  6042. private _isStencilMaskDirty;
  6043. private _isStencilFuncDirty;
  6044. private _isStencilOpDirty;
  6045. private _stencilTest;
  6046. private _stencilMask;
  6047. private _stencilFunc;
  6048. private _stencilFuncRef;
  6049. private _stencilFuncMask;
  6050. private _stencilOpStencilFail;
  6051. private _stencilOpDepthFail;
  6052. private _stencilOpStencilDepthPass;
  6053. readonly isDirty: boolean;
  6054. stencilFunc: number;
  6055. stencilFuncRef: number;
  6056. stencilFuncMask: number;
  6057. stencilOpStencilFail: number;
  6058. stencilOpDepthFail: number;
  6059. stencilOpStencilDepthPass: number;
  6060. stencilMask: number;
  6061. stencilTest: boolean;
  6062. constructor();
  6063. reset(): void;
  6064. apply(gl: WebGLRenderingContext): void;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * @hidden
  6070. **/
  6071. export class _TimeToken {
  6072. _startTimeQuery: Nullable<WebGLQuery>;
  6073. _endTimeQuery: Nullable<WebGLQuery>;
  6074. _timeElapsedQuery: Nullable<WebGLQuery>;
  6075. _timeElapsedQueryEnded: boolean;
  6076. }
  6077. }
  6078. declare module BABYLON {
  6079. /**
  6080. * Internal interface used to track InternalTexture already bound to the GL context
  6081. */
  6082. export interface IInternalTextureTracker {
  6083. /**
  6084. * Gets or set the previous tracker in the list
  6085. */
  6086. previous: Nullable<IInternalTextureTracker>;
  6087. /**
  6088. * Gets or set the next tracker in the list
  6089. */
  6090. next: Nullable<IInternalTextureTracker>;
  6091. }
  6092. /**
  6093. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6094. */
  6095. export class DummyInternalTextureTracker {
  6096. /**
  6097. * Gets or set the previous tracker in the list
  6098. */
  6099. previous: Nullable<IInternalTextureTracker>;
  6100. /**
  6101. * Gets or set the next tracker in the list
  6102. */
  6103. next: Nullable<IInternalTextureTracker>;
  6104. }
  6105. }
  6106. declare module BABYLON {
  6107. /**
  6108. * Class used to store data associated with WebGL texture data for the engine
  6109. * This class should not be used directly
  6110. */
  6111. export class InternalTexture implements IInternalTextureTracker {
  6112. /** hidden */
  6113. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6114. /**
  6115. * The source of the texture data is unknown
  6116. */
  6117. static DATASOURCE_UNKNOWN: number;
  6118. /**
  6119. * Texture data comes from an URL
  6120. */
  6121. static DATASOURCE_URL: number;
  6122. /**
  6123. * Texture data is only used for temporary storage
  6124. */
  6125. static DATASOURCE_TEMP: number;
  6126. /**
  6127. * Texture data comes from raw data (ArrayBuffer)
  6128. */
  6129. static DATASOURCE_RAW: number;
  6130. /**
  6131. * Texture content is dynamic (video or dynamic texture)
  6132. */
  6133. static DATASOURCE_DYNAMIC: number;
  6134. /**
  6135. * Texture content is generated by rendering to it
  6136. */
  6137. static DATASOURCE_RENDERTARGET: number;
  6138. /**
  6139. * Texture content is part of a multi render target process
  6140. */
  6141. static DATASOURCE_MULTIRENDERTARGET: number;
  6142. /**
  6143. * Texture data comes from a cube data file
  6144. */
  6145. static DATASOURCE_CUBE: number;
  6146. /**
  6147. * Texture data comes from a raw cube data
  6148. */
  6149. static DATASOURCE_CUBERAW: number;
  6150. /**
  6151. * Texture data come from a prefiltered cube data file
  6152. */
  6153. static DATASOURCE_CUBEPREFILTERED: number;
  6154. /**
  6155. * Texture content is raw 3D data
  6156. */
  6157. static DATASOURCE_RAW3D: number;
  6158. /**
  6159. * Texture content is a depth texture
  6160. */
  6161. static DATASOURCE_DEPTHTEXTURE: number;
  6162. /**
  6163. * Texture data comes from a raw cube data encoded with RGBD
  6164. */
  6165. static DATASOURCE_CUBERAW_RGBD: number;
  6166. /**
  6167. * Defines if the texture is ready
  6168. */
  6169. isReady: boolean;
  6170. /**
  6171. * Defines if the texture is a cube texture
  6172. */
  6173. isCube: boolean;
  6174. /**
  6175. * Defines if the texture contains 3D data
  6176. */
  6177. is3D: boolean;
  6178. /**
  6179. * Gets the URL used to load this texture
  6180. */
  6181. url: string;
  6182. /**
  6183. * Gets the sampling mode of the texture
  6184. */
  6185. samplingMode: number;
  6186. /**
  6187. * Gets a boolean indicating if the texture needs mipmaps generation
  6188. */
  6189. generateMipMaps: boolean;
  6190. /**
  6191. * Gets the number of samples used by the texture (WebGL2+ only)
  6192. */
  6193. samples: number;
  6194. /**
  6195. * Gets the type of the texture (int, float...)
  6196. */
  6197. type: number;
  6198. /**
  6199. * Gets the format of the texture (RGB, RGBA...)
  6200. */
  6201. format: number;
  6202. /**
  6203. * Observable called when the texture is loaded
  6204. */
  6205. onLoadedObservable: Observable<InternalTexture>;
  6206. /**
  6207. * Gets the width of the texture
  6208. */
  6209. width: number;
  6210. /**
  6211. * Gets the height of the texture
  6212. */
  6213. height: number;
  6214. /**
  6215. * Gets the depth of the texture
  6216. */
  6217. depth: number;
  6218. /**
  6219. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6220. */
  6221. baseWidth: number;
  6222. /**
  6223. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6224. */
  6225. baseHeight: number;
  6226. /**
  6227. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6228. */
  6229. baseDepth: number;
  6230. /**
  6231. * Gets a boolean indicating if the texture is inverted on Y axis
  6232. */
  6233. invertY: boolean;
  6234. /**
  6235. * Gets or set the previous tracker in the list
  6236. */
  6237. previous: Nullable<IInternalTextureTracker>;
  6238. /**
  6239. * Gets or set the next tracker in the list
  6240. */
  6241. next: Nullable<IInternalTextureTracker>;
  6242. /** @hidden */
  6243. _invertVScale: boolean;
  6244. /** @hidden */
  6245. _initialSlot: number;
  6246. /** @hidden */
  6247. _designatedSlot: number;
  6248. /** @hidden */
  6249. _dataSource: number;
  6250. /** @hidden */
  6251. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6252. /** @hidden */
  6253. _bufferView: Nullable<ArrayBufferView>;
  6254. /** @hidden */
  6255. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6256. /** @hidden */
  6257. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6258. /** @hidden */
  6259. _size: number;
  6260. /** @hidden */
  6261. _extension: string;
  6262. /** @hidden */
  6263. _files: Nullable<string[]>;
  6264. /** @hidden */
  6265. _workingCanvas: HTMLCanvasElement;
  6266. /** @hidden */
  6267. _workingContext: CanvasRenderingContext2D;
  6268. /** @hidden */
  6269. _framebuffer: Nullable<WebGLFramebuffer>;
  6270. /** @hidden */
  6271. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6272. /** @hidden */
  6273. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6274. /** @hidden */
  6275. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6276. /** @hidden */
  6277. _attachments: Nullable<number[]>;
  6278. /** @hidden */
  6279. _cachedCoordinatesMode: Nullable<number>;
  6280. /** @hidden */
  6281. _cachedWrapU: Nullable<number>;
  6282. /** @hidden */
  6283. _cachedWrapV: Nullable<number>;
  6284. /** @hidden */
  6285. _cachedWrapR: Nullable<number>;
  6286. /** @hidden */
  6287. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6288. /** @hidden */
  6289. _isDisabled: boolean;
  6290. /** @hidden */
  6291. _compression: Nullable<string>;
  6292. /** @hidden */
  6293. _generateStencilBuffer: boolean;
  6294. /** @hidden */
  6295. _generateDepthBuffer: boolean;
  6296. /** @hidden */
  6297. _comparisonFunction: number;
  6298. /** @hidden */
  6299. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6300. /** @hidden */
  6301. _lodGenerationScale: number;
  6302. /** @hidden */
  6303. _lodGenerationOffset: number;
  6304. /** @hidden */
  6305. _lodTextureHigh: BaseTexture;
  6306. /** @hidden */
  6307. _lodTextureMid: BaseTexture;
  6308. /** @hidden */
  6309. _lodTextureLow: BaseTexture;
  6310. /** @hidden */
  6311. _isRGBD: boolean;
  6312. /** @hidden */
  6313. _webGLTexture: Nullable<WebGLTexture>;
  6314. /** @hidden */
  6315. _references: number;
  6316. private _engine;
  6317. /**
  6318. * Gets the Engine the texture belongs to.
  6319. * @returns The babylon engine
  6320. */
  6321. getEngine(): Engine;
  6322. /**
  6323. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6324. */
  6325. readonly dataSource: number;
  6326. /**
  6327. * Creates a new InternalTexture
  6328. * @param engine defines the engine to use
  6329. * @param dataSource defines the type of data that will be used
  6330. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6331. */
  6332. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6333. /**
  6334. * Increments the number of references (ie. the number of Texture that point to it)
  6335. */
  6336. incrementReferences(): void;
  6337. /**
  6338. * Change the size of the texture (not the size of the content)
  6339. * @param width defines the new width
  6340. * @param height defines the new height
  6341. * @param depth defines the new depth (1 by default)
  6342. */
  6343. updateSize(width: int, height: int, depth?: int): void;
  6344. /** @hidden */
  6345. _rebuild(): void;
  6346. /** @hidden */
  6347. _swapAndDie(target: InternalTexture): void;
  6348. /**
  6349. * Dispose the current allocated resources
  6350. */
  6351. dispose(): void;
  6352. }
  6353. }
  6354. declare module BABYLON {
  6355. /**
  6356. * This represents the main contract an easing function should follow.
  6357. * Easing functions are used throughout the animation system.
  6358. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6359. */
  6360. export interface IEasingFunction {
  6361. /**
  6362. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6363. * of the easing function.
  6364. * The link below provides some of the most common examples of easing functions.
  6365. * @see https://easings.net/
  6366. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6367. * @returns the corresponding value on the curve defined by the easing function
  6368. */
  6369. ease(gradient: number): number;
  6370. }
  6371. /**
  6372. * Base class used for every default easing function.
  6373. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6374. */
  6375. export class EasingFunction implements IEasingFunction {
  6376. /**
  6377. * Interpolation follows the mathematical formula associated with the easing function.
  6378. */
  6379. static readonly EASINGMODE_EASEIN: number;
  6380. /**
  6381. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6382. */
  6383. static readonly EASINGMODE_EASEOUT: number;
  6384. /**
  6385. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6386. */
  6387. static readonly EASINGMODE_EASEINOUT: number;
  6388. private _easingMode;
  6389. /**
  6390. * Sets the easing mode of the current function.
  6391. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6392. */
  6393. setEasingMode(easingMode: number): void;
  6394. /**
  6395. * Gets the current easing mode.
  6396. * @returns the easing mode
  6397. */
  6398. getEasingMode(): number;
  6399. /**
  6400. * @hidden
  6401. */
  6402. easeInCore(gradient: number): number;
  6403. /**
  6404. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6405. * of the easing function.
  6406. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6407. * @returns the corresponding value on the curve defined by the easing function
  6408. */
  6409. ease(gradient: number): number;
  6410. }
  6411. /**
  6412. * Easing function with a circle shape (see link below).
  6413. * @see https://easings.net/#easeInCirc
  6414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6415. */
  6416. export class CircleEase extends EasingFunction implements IEasingFunction {
  6417. /** @hidden */
  6418. easeInCore(gradient: number): number;
  6419. }
  6420. /**
  6421. * Easing function with a ease back shape (see link below).
  6422. * @see https://easings.net/#easeInBack
  6423. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6424. */
  6425. export class BackEase extends EasingFunction implements IEasingFunction {
  6426. /** Defines the amplitude of the function */
  6427. amplitude: number;
  6428. /**
  6429. * Instantiates a back ease easing
  6430. * @see https://easings.net/#easeInBack
  6431. * @param amplitude Defines the amplitude of the function
  6432. */
  6433. constructor(
  6434. /** Defines the amplitude of the function */
  6435. amplitude?: number);
  6436. /** @hidden */
  6437. easeInCore(gradient: number): number;
  6438. }
  6439. /**
  6440. * Easing function with a bouncing shape (see link below).
  6441. * @see https://easings.net/#easeInBounce
  6442. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6443. */
  6444. export class BounceEase extends EasingFunction implements IEasingFunction {
  6445. /** Defines the number of bounces */
  6446. bounces: number;
  6447. /** Defines the amplitude of the bounce */
  6448. bounciness: number;
  6449. /**
  6450. * Instantiates a bounce easing
  6451. * @see https://easings.net/#easeInBounce
  6452. * @param bounces Defines the number of bounces
  6453. * @param bounciness Defines the amplitude of the bounce
  6454. */
  6455. constructor(
  6456. /** Defines the number of bounces */
  6457. bounces?: number,
  6458. /** Defines the amplitude of the bounce */
  6459. bounciness?: number);
  6460. /** @hidden */
  6461. easeInCore(gradient: number): number;
  6462. }
  6463. /**
  6464. * Easing function with a power of 3 shape (see link below).
  6465. * @see https://easings.net/#easeInCubic
  6466. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6467. */
  6468. export class CubicEase extends EasingFunction implements IEasingFunction {
  6469. /** @hidden */
  6470. easeInCore(gradient: number): number;
  6471. }
  6472. /**
  6473. * Easing function with an elastic shape (see link below).
  6474. * @see https://easings.net/#easeInElastic
  6475. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6476. */
  6477. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6478. /** Defines the number of oscillations*/
  6479. oscillations: number;
  6480. /** Defines the amplitude of the oscillations*/
  6481. springiness: number;
  6482. /**
  6483. * Instantiates an elastic easing function
  6484. * @see https://easings.net/#easeInElastic
  6485. * @param oscillations Defines the number of oscillations
  6486. * @param springiness Defines the amplitude of the oscillations
  6487. */
  6488. constructor(
  6489. /** Defines the number of oscillations*/
  6490. oscillations?: number,
  6491. /** Defines the amplitude of the oscillations*/
  6492. springiness?: number);
  6493. /** @hidden */
  6494. easeInCore(gradient: number): number;
  6495. }
  6496. /**
  6497. * Easing function with an exponential shape (see link below).
  6498. * @see https://easings.net/#easeInExpo
  6499. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6500. */
  6501. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6502. /** Defines the exponent of the function */
  6503. exponent: number;
  6504. /**
  6505. * Instantiates an exponential easing function
  6506. * @see https://easings.net/#easeInExpo
  6507. * @param exponent Defines the exponent of the function
  6508. */
  6509. constructor(
  6510. /** Defines the exponent of the function */
  6511. exponent?: number);
  6512. /** @hidden */
  6513. easeInCore(gradient: number): number;
  6514. }
  6515. /**
  6516. * Easing function with a power shape (see link below).
  6517. * @see https://easings.net/#easeInQuad
  6518. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6519. */
  6520. export class PowerEase extends EasingFunction implements IEasingFunction {
  6521. /** Defines the power of the function */
  6522. power: number;
  6523. /**
  6524. * Instantiates an power base easing function
  6525. * @see https://easings.net/#easeInQuad
  6526. * @param power Defines the power of the function
  6527. */
  6528. constructor(
  6529. /** Defines the power of the function */
  6530. power?: number);
  6531. /** @hidden */
  6532. easeInCore(gradient: number): number;
  6533. }
  6534. /**
  6535. * Easing function with a power of 2 shape (see link below).
  6536. * @see https://easings.net/#easeInQuad
  6537. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6538. */
  6539. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6540. /** @hidden */
  6541. easeInCore(gradient: number): number;
  6542. }
  6543. /**
  6544. * Easing function with a power of 4 shape (see link below).
  6545. * @see https://easings.net/#easeInQuart
  6546. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6547. */
  6548. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with a power of 5 shape (see link below).
  6554. * @see https://easings.net/#easeInQuint
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6558. /** @hidden */
  6559. easeInCore(gradient: number): number;
  6560. }
  6561. /**
  6562. * Easing function with a sin shape (see link below).
  6563. * @see https://easings.net/#easeInSine
  6564. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6565. */
  6566. export class SineEase extends EasingFunction implements IEasingFunction {
  6567. /** @hidden */
  6568. easeInCore(gradient: number): number;
  6569. }
  6570. /**
  6571. * Easing function with a bezier shape (see link below).
  6572. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6573. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6574. */
  6575. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6576. /** Defines the x component of the start tangent in the bezier curve */
  6577. x1: number;
  6578. /** Defines the y component of the start tangent in the bezier curve */
  6579. y1: number;
  6580. /** Defines the x component of the end tangent in the bezier curve */
  6581. x2: number;
  6582. /** Defines the y component of the end tangent in the bezier curve */
  6583. y2: number;
  6584. /**
  6585. * Instantiates a bezier function
  6586. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6587. * @param x1 Defines the x component of the start tangent in the bezier curve
  6588. * @param y1 Defines the y component of the start tangent in the bezier curve
  6589. * @param x2 Defines the x component of the end tangent in the bezier curve
  6590. * @param y2 Defines the y component of the end tangent in the bezier curve
  6591. */
  6592. constructor(
  6593. /** Defines the x component of the start tangent in the bezier curve */
  6594. x1?: number,
  6595. /** Defines the y component of the start tangent in the bezier curve */
  6596. y1?: number,
  6597. /** Defines the x component of the end tangent in the bezier curve */
  6598. x2?: number,
  6599. /** Defines the y component of the end tangent in the bezier curve */
  6600. y2?: number);
  6601. /** @hidden */
  6602. easeInCore(gradient: number): number;
  6603. }
  6604. }
  6605. declare module BABYLON {
  6606. /**
  6607. * Defines an interface which represents an animation key frame
  6608. */
  6609. export interface IAnimationKey {
  6610. /**
  6611. * Frame of the key frame
  6612. */
  6613. frame: number;
  6614. /**
  6615. * Value at the specifies key frame
  6616. */
  6617. value: any;
  6618. /**
  6619. * The input tangent for the cubic hermite spline
  6620. */
  6621. inTangent?: any;
  6622. /**
  6623. * The output tangent for the cubic hermite spline
  6624. */
  6625. outTangent?: any;
  6626. /**
  6627. * The animation interpolation type
  6628. */
  6629. interpolation?: AnimationKeyInterpolation;
  6630. }
  6631. /**
  6632. * Enum for the animation key frame interpolation type
  6633. */
  6634. export enum AnimationKeyInterpolation {
  6635. /**
  6636. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6637. */
  6638. STEP = 1
  6639. }
  6640. }
  6641. declare module BABYLON {
  6642. /**
  6643. * Represents the range of an animation
  6644. */
  6645. export class AnimationRange {
  6646. /**The name of the animation range**/
  6647. name: string;
  6648. /**The starting frame of the animation */
  6649. from: number;
  6650. /**The ending frame of the animation*/
  6651. to: number;
  6652. /**
  6653. * Initializes the range of an animation
  6654. * @param name The name of the animation range
  6655. * @param from The starting frame of the animation
  6656. * @param to The ending frame of the animation
  6657. */
  6658. constructor(
  6659. /**The name of the animation range**/
  6660. name: string,
  6661. /**The starting frame of the animation */
  6662. from: number,
  6663. /**The ending frame of the animation*/
  6664. to: number);
  6665. /**
  6666. * Makes a copy of the animation range
  6667. * @returns A copy of the animation range
  6668. */
  6669. clone(): AnimationRange;
  6670. }
  6671. }
  6672. declare module BABYLON {
  6673. /**
  6674. * Composed of a frame, and an action function
  6675. */
  6676. export class AnimationEvent {
  6677. /** The frame for which the event is triggered **/
  6678. frame: number;
  6679. /** The event to perform when triggered **/
  6680. action: (currentFrame: number) => void;
  6681. /** Specifies if the event should be triggered only once**/
  6682. onlyOnce?: boolean | undefined;
  6683. /**
  6684. * Specifies if the animation event is done
  6685. */
  6686. isDone: boolean;
  6687. /**
  6688. * Initializes the animation event
  6689. * @param frame The frame for which the event is triggered
  6690. * @param action The event to perform when triggered
  6691. * @param onlyOnce Specifies if the event should be triggered only once
  6692. */
  6693. constructor(
  6694. /** The frame for which the event is triggered **/
  6695. frame: number,
  6696. /** The event to perform when triggered **/
  6697. action: (currentFrame: number) => void,
  6698. /** Specifies if the event should be triggered only once**/
  6699. onlyOnce?: boolean | undefined);
  6700. /** @hidden */
  6701. _clone(): AnimationEvent;
  6702. }
  6703. }
  6704. declare module BABYLON {
  6705. /**
  6706. * Interface used to define a behavior
  6707. */
  6708. export interface Behavior<T> {
  6709. /** gets or sets behavior's name */
  6710. name: string;
  6711. /**
  6712. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6713. */
  6714. init(): void;
  6715. /**
  6716. * Called when the behavior is attached to a target
  6717. * @param target defines the target where the behavior is attached to
  6718. */
  6719. attach(target: T): void;
  6720. /**
  6721. * Called when the behavior is detached from its target
  6722. */
  6723. detach(): void;
  6724. }
  6725. /**
  6726. * Interface implemented by classes supporting behaviors
  6727. */
  6728. export interface IBehaviorAware<T> {
  6729. /**
  6730. * Attach a behavior
  6731. * @param behavior defines the behavior to attach
  6732. * @returns the current host
  6733. */
  6734. addBehavior(behavior: Behavior<T>): T;
  6735. /**
  6736. * Remove a behavior from the current object
  6737. * @param behavior defines the behavior to detach
  6738. * @returns the current host
  6739. */
  6740. removeBehavior(behavior: Behavior<T>): T;
  6741. /**
  6742. * Gets a behavior using its name to search
  6743. * @param name defines the name to search
  6744. * @returns the behavior or null if not found
  6745. */
  6746. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * Defines a runtime animation
  6752. */
  6753. export class RuntimeAnimation {
  6754. private _events;
  6755. /**
  6756. * The current frame of the runtime animation
  6757. */
  6758. private _currentFrame;
  6759. /**
  6760. * The animation used by the runtime animation
  6761. */
  6762. private _animation;
  6763. /**
  6764. * The target of the runtime animation
  6765. */
  6766. private _target;
  6767. /**
  6768. * The initiating animatable
  6769. */
  6770. private _host;
  6771. /**
  6772. * The original value of the runtime animation
  6773. */
  6774. private _originalValue;
  6775. /**
  6776. * The original blend value of the runtime animation
  6777. */
  6778. private _originalBlendValue;
  6779. /**
  6780. * The offsets cache of the runtime animation
  6781. */
  6782. private _offsetsCache;
  6783. /**
  6784. * The high limits cache of the runtime animation
  6785. */
  6786. private _highLimitsCache;
  6787. /**
  6788. * Specifies if the runtime animation has been stopped
  6789. */
  6790. private _stopped;
  6791. /**
  6792. * The blending factor of the runtime animation
  6793. */
  6794. private _blendingFactor;
  6795. /**
  6796. * The BabylonJS scene
  6797. */
  6798. private _scene;
  6799. /**
  6800. * The current value of the runtime animation
  6801. */
  6802. private _currentValue;
  6803. /** @hidden */
  6804. _workValue: any;
  6805. /**
  6806. * The active target of the runtime animation
  6807. */
  6808. private _activeTarget;
  6809. /**
  6810. * The target path of the runtime animation
  6811. */
  6812. private _targetPath;
  6813. /**
  6814. * The weight of the runtime animation
  6815. */
  6816. private _weight;
  6817. /**
  6818. * The ratio offset of the runtime animation
  6819. */
  6820. private _ratioOffset;
  6821. /**
  6822. * The previous delay of the runtime animation
  6823. */
  6824. private _previousDelay;
  6825. /**
  6826. * The previous ratio of the runtime animation
  6827. */
  6828. private _previousRatio;
  6829. /**
  6830. * Gets the current frame of the runtime animation
  6831. */
  6832. readonly currentFrame: number;
  6833. /**
  6834. * Gets the weight of the runtime animation
  6835. */
  6836. readonly weight: number;
  6837. /**
  6838. * Gets the current value of the runtime animation
  6839. */
  6840. readonly currentValue: any;
  6841. /**
  6842. * Gets the target path of the runtime animation
  6843. */
  6844. readonly targetPath: string;
  6845. /**
  6846. * Gets the actual target of the runtime animation
  6847. */
  6848. readonly target: any;
  6849. /**
  6850. * Create a new RuntimeAnimation object
  6851. * @param target defines the target of the animation
  6852. * @param animation defines the source animation object
  6853. * @param scene defines the hosting scene
  6854. * @param host defines the initiating Animatable
  6855. */
  6856. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6857. /**
  6858. * Gets the animation from the runtime animation
  6859. */
  6860. readonly animation: Animation;
  6861. /**
  6862. * Resets the runtime animation to the beginning
  6863. * @param restoreOriginal defines whether to restore the target property to the original value
  6864. */
  6865. reset(restoreOriginal?: boolean): void;
  6866. /**
  6867. * Specifies if the runtime animation is stopped
  6868. * @returns Boolean specifying if the runtime animation is stopped
  6869. */
  6870. isStopped(): boolean;
  6871. /**
  6872. * Disposes of the runtime animation
  6873. */
  6874. dispose(): void;
  6875. /**
  6876. * Interpolates the animation from the current frame
  6877. * @param currentFrame The frame to interpolate the animation to
  6878. * @param repeatCount The number of times that the animation should loop
  6879. * @param loopMode The type of looping mode to use
  6880. * @param offsetValue Animation offset value
  6881. * @param highLimitValue The high limit value
  6882. * @returns The interpolated value
  6883. */
  6884. private _interpolate;
  6885. /**
  6886. * Apply the interpolated value to the target
  6887. * @param currentValue defines the value computed by the animation
  6888. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6889. */
  6890. setValue(currentValue: any, weight?: number): void;
  6891. private _setValue;
  6892. /**
  6893. * Gets the loop pmode of the runtime animation
  6894. * @returns Loop Mode
  6895. */
  6896. private _getCorrectLoopMode;
  6897. /**
  6898. * Move the current animation to a given frame
  6899. * @param frame defines the frame to move to
  6900. */
  6901. goToFrame(frame: number): void;
  6902. /**
  6903. * @hidden Internal use only
  6904. */
  6905. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6906. /**
  6907. * Execute the current animation
  6908. * @param delay defines the delay to add to the current frame
  6909. * @param from defines the lower bound of the animation range
  6910. * @param to defines the upper bound of the animation range
  6911. * @param loop defines if the current animation must loop
  6912. * @param speedRatio defines the current speed ratio
  6913. * @param weight defines the weight of the animation (default is -1 so no weight)
  6914. * @param onLoop optional callback called when animation loops
  6915. * @returns a boolean indicating if the animation is running
  6916. */
  6917. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6918. }
  6919. }
  6920. declare module BABYLON {
  6921. /**
  6922. * @hidden
  6923. */
  6924. export class IntersectionInfo {
  6925. bu: Nullable<number>;
  6926. bv: Nullable<number>;
  6927. distance: number;
  6928. faceId: number;
  6929. subMeshId: number;
  6930. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6931. }
  6932. }
  6933. declare module BABYLON {
  6934. /**
  6935. * Class used to store bounding sphere information
  6936. */
  6937. export class BoundingSphere {
  6938. /**
  6939. * Gets the center of the bounding sphere in local space
  6940. */
  6941. readonly center: Vector3;
  6942. /**
  6943. * Radius of the bounding sphere in local space
  6944. */
  6945. radius: number;
  6946. /**
  6947. * Gets the center of the bounding sphere in world space
  6948. */
  6949. readonly centerWorld: Vector3;
  6950. /**
  6951. * Radius of the bounding sphere in world space
  6952. */
  6953. radiusWorld: number;
  6954. /**
  6955. * Gets the minimum vector in local space
  6956. */
  6957. readonly minimum: Vector3;
  6958. /**
  6959. * Gets the maximum vector in local space
  6960. */
  6961. readonly maximum: Vector3;
  6962. private _worldMatrix;
  6963. private static readonly TmpVector3;
  6964. /**
  6965. * Creates a new bounding sphere
  6966. * @param min defines the minimum vector (in local space)
  6967. * @param max defines the maximum vector (in local space)
  6968. * @param worldMatrix defines the new world matrix
  6969. */
  6970. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6971. /**
  6972. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6973. * @param min defines the new minimum vector (in local space)
  6974. * @param max defines the new maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6978. /**
  6979. * Scale the current bounding sphere by applying a scale factor
  6980. * @param factor defines the scale factor to apply
  6981. * @returns the current bounding box
  6982. */
  6983. scale(factor: number): BoundingSphere;
  6984. /**
  6985. * Gets the world matrix of the bounding box
  6986. * @returns a matrix
  6987. */
  6988. getWorldMatrix(): DeepImmutable<Matrix>;
  6989. /** @hidden */
  6990. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6991. /**
  6992. * Tests if the bounding sphere is intersecting the frustum planes
  6993. * @param frustumPlanes defines the frustum planes to test
  6994. * @returns true if there is an intersection
  6995. */
  6996. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6997. /**
  6998. * Tests if the bounding sphere center is in between the frustum planes.
  6999. * Used for optimistic fast inclusion.
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if the sphere center is in between the frustum planes
  7002. */
  7003. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if a point is inside the bounding sphere
  7006. * @param point defines the point to test
  7007. * @returns true if the point is inside the bounding sphere
  7008. */
  7009. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7010. /**
  7011. * Checks if two sphere intersct
  7012. * @param sphere0 sphere 0
  7013. * @param sphere1 sphere 1
  7014. * @returns true if the speres intersect
  7015. */
  7016. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7017. }
  7018. }
  7019. declare module BABYLON {
  7020. /**
  7021. * Class used to store bounding box information
  7022. */
  7023. export class BoundingBox implements ICullable {
  7024. /**
  7025. * Gets the 8 vectors representing the bounding box in local space
  7026. */
  7027. readonly vectors: Vector3[];
  7028. /**
  7029. * Gets the center of the bounding box in local space
  7030. */
  7031. readonly center: Vector3;
  7032. /**
  7033. * Gets the center of the bounding box in world space
  7034. */
  7035. readonly centerWorld: Vector3;
  7036. /**
  7037. * Gets the extend size in local space
  7038. */
  7039. readonly extendSize: Vector3;
  7040. /**
  7041. * Gets the extend size in world space
  7042. */
  7043. readonly extendSizeWorld: Vector3;
  7044. /**
  7045. * Gets the OBB (object bounding box) directions
  7046. */
  7047. readonly directions: Vector3[];
  7048. /**
  7049. * Gets the 8 vectors representing the bounding box in world space
  7050. */
  7051. readonly vectorsWorld: Vector3[];
  7052. /**
  7053. * Gets the minimum vector in world space
  7054. */
  7055. readonly minimumWorld: Vector3;
  7056. /**
  7057. * Gets the maximum vector in world space
  7058. */
  7059. readonly maximumWorld: Vector3;
  7060. /**
  7061. * Gets the minimum vector in local space
  7062. */
  7063. readonly minimum: Vector3;
  7064. /**
  7065. * Gets the maximum vector in local space
  7066. */
  7067. readonly maximum: Vector3;
  7068. private _worldMatrix;
  7069. private static readonly TmpVector3;
  7070. /**
  7071. * @hidden
  7072. */
  7073. _tag: number;
  7074. /**
  7075. * Creates a new bounding box
  7076. * @param min defines the minimum vector (in local space)
  7077. * @param max defines the maximum vector (in local space)
  7078. * @param worldMatrix defines the new world matrix
  7079. */
  7080. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7081. /**
  7082. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7083. * @param min defines the new minimum vector (in local space)
  7084. * @param max defines the new maximum vector (in local space)
  7085. * @param worldMatrix defines the new world matrix
  7086. */
  7087. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7088. /**
  7089. * Scale the current bounding box by applying a scale factor
  7090. * @param factor defines the scale factor to apply
  7091. * @returns the current bounding box
  7092. */
  7093. scale(factor: number): BoundingBox;
  7094. /**
  7095. * Gets the world matrix of the bounding box
  7096. * @returns a matrix
  7097. */
  7098. getWorldMatrix(): DeepImmutable<Matrix>;
  7099. /** @hidden */
  7100. _update(world: DeepImmutable<Matrix>): void;
  7101. /**
  7102. * Tests if the bounding box is intersecting the frustum planes
  7103. * @param frustumPlanes defines the frustum planes to test
  7104. * @returns true if there is an intersection
  7105. */
  7106. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7107. /**
  7108. * Tests if the bounding box is entirely inside the frustum planes
  7109. * @param frustumPlanes defines the frustum planes to test
  7110. * @returns true if there is an inclusion
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /**
  7114. * Tests if a point is inside the bounding box
  7115. * @param point defines the point to test
  7116. * @returns true if the point is inside the bounding box
  7117. */
  7118. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7119. /**
  7120. * Tests if the bounding box intersects with a bounding sphere
  7121. * @param sphere defines the sphere to test
  7122. * @returns true if there is an intersection
  7123. */
  7124. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7125. /**
  7126. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7127. * @param min defines the min vector to use
  7128. * @param max defines the max vector to use
  7129. * @returns true if there is an intersection
  7130. */
  7131. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7132. /**
  7133. * Tests if two bounding boxes are intersections
  7134. * @param box0 defines the first box to test
  7135. * @param box1 defines the second box to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7139. /**
  7140. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7141. * @param minPoint defines the minimum vector of the bounding box
  7142. * @param maxPoint defines the maximum vector of the bounding box
  7143. * @param sphereCenter defines the sphere center
  7144. * @param sphereRadius defines the sphere radius
  7145. * @returns true if there is an intersection
  7146. */
  7147. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7148. /**
  7149. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7150. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7151. * @param frustumPlanes defines the frustum planes to test
  7152. * @return true if there is an inclusion
  7153. */
  7154. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7155. /**
  7156. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7157. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7158. * @param frustumPlanes defines the frustum planes to test
  7159. * @return true if there is an intersection
  7160. */
  7161. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7162. }
  7163. }
  7164. declare module BABYLON {
  7165. /** @hidden */
  7166. export class Collider {
  7167. /** Define if a collision was found */
  7168. collisionFound: boolean;
  7169. /**
  7170. * Define last intersection point in local space
  7171. */
  7172. intersectionPoint: Vector3;
  7173. /**
  7174. * Define last collided mesh
  7175. */
  7176. collidedMesh: Nullable<AbstractMesh>;
  7177. private _collisionPoint;
  7178. private _planeIntersectionPoint;
  7179. private _tempVector;
  7180. private _tempVector2;
  7181. private _tempVector3;
  7182. private _tempVector4;
  7183. private _edge;
  7184. private _baseToVertex;
  7185. private _destinationPoint;
  7186. private _slidePlaneNormal;
  7187. private _displacementVector;
  7188. /** @hidden */
  7189. _radius: Vector3;
  7190. /** @hidden */
  7191. _retry: number;
  7192. private _velocity;
  7193. private _basePoint;
  7194. private _epsilon;
  7195. /** @hidden */
  7196. _velocityWorldLength: number;
  7197. /** @hidden */
  7198. _basePointWorld: Vector3;
  7199. private _velocityWorld;
  7200. private _normalizedVelocity;
  7201. /** @hidden */
  7202. _initialVelocity: Vector3;
  7203. /** @hidden */
  7204. _initialPosition: Vector3;
  7205. private _nearestDistance;
  7206. private _collisionMask;
  7207. collisionMask: number;
  7208. /**
  7209. * Gets the plane normal used to compute the sliding response (in local space)
  7210. */
  7211. readonly slidePlaneNormal: Vector3;
  7212. /** @hidden */
  7213. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7214. /** @hidden */
  7215. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7216. /** @hidden */
  7217. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7218. /** @hidden */
  7219. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7220. /** @hidden */
  7221. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7222. /** @hidden */
  7223. _getResponse(pos: Vector3, vel: Vector3): void;
  7224. }
  7225. }
  7226. declare module BABYLON {
  7227. /**
  7228. * Interface for cullable objects
  7229. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7230. */
  7231. export interface ICullable {
  7232. /**
  7233. * Checks if the object or part of the object is in the frustum
  7234. * @param frustumPlanes Camera near/planes
  7235. * @returns true if the object is in frustum otherwise false
  7236. */
  7237. isInFrustum(frustumPlanes: Plane[]): boolean;
  7238. /**
  7239. * Checks if a cullable object (mesh...) is in the camera frustum
  7240. * Unlike isInFrustum this cheks the full bounding box
  7241. * @param frustumPlanes Camera near/planes
  7242. * @returns true if the object is in frustum otherwise false
  7243. */
  7244. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7245. }
  7246. /**
  7247. * Info for a bounding data of a mesh
  7248. */
  7249. export class BoundingInfo implements ICullable {
  7250. /**
  7251. * Bounding box for the mesh
  7252. */
  7253. readonly boundingBox: BoundingBox;
  7254. /**
  7255. * Bounding sphere for the mesh
  7256. */
  7257. readonly boundingSphere: BoundingSphere;
  7258. private _isLocked;
  7259. private static readonly TmpVector3;
  7260. /**
  7261. * Constructs bounding info
  7262. * @param minimum min vector of the bounding box/sphere
  7263. * @param maximum max vector of the bounding box/sphere
  7264. * @param worldMatrix defines the new world matrix
  7265. */
  7266. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7267. /**
  7268. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7269. * @param min defines the new minimum vector (in local space)
  7270. * @param max defines the new maximum vector (in local space)
  7271. * @param worldMatrix defines the new world matrix
  7272. */
  7273. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7274. /**
  7275. * min vector of the bounding box/sphere
  7276. */
  7277. readonly minimum: Vector3;
  7278. /**
  7279. * max vector of the bounding box/sphere
  7280. */
  7281. readonly maximum: Vector3;
  7282. /**
  7283. * If the info is locked and won't be updated to avoid perf overhead
  7284. */
  7285. isLocked: boolean;
  7286. /**
  7287. * Updates the bounding sphere and box
  7288. * @param world world matrix to be used to update
  7289. */
  7290. update(world: DeepImmutable<Matrix>): void;
  7291. /**
  7292. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7293. * @param center New center of the bounding info
  7294. * @param extend New extend of the bounding info
  7295. * @returns the current bounding info
  7296. */
  7297. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7298. /**
  7299. * Scale the current bounding info by applying a scale factor
  7300. * @param factor defines the scale factor to apply
  7301. * @returns the current bounding info
  7302. */
  7303. scale(factor: number): BoundingInfo;
  7304. /**
  7305. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7306. * @param frustumPlanes defines the frustum to test
  7307. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7308. * @returns true if the bounding info is in the frustum planes
  7309. */
  7310. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7311. /**
  7312. * Gets the world distance between the min and max points of the bounding box
  7313. */
  7314. readonly diagonalLength: number;
  7315. /**
  7316. * Checks if a cullable object (mesh...) is in the camera frustum
  7317. * Unlike isInFrustum this cheks the full bounding box
  7318. * @param frustumPlanes Camera near/planes
  7319. * @returns true if the object is in frustum otherwise false
  7320. */
  7321. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7322. /** @hidden */
  7323. _checkCollision(collider: Collider): boolean;
  7324. /**
  7325. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7326. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7327. * @param point the point to check intersection with
  7328. * @returns if the point intersects
  7329. */
  7330. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7331. /**
  7332. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7333. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7334. * @param boundingInfo the bounding info to check intersection with
  7335. * @param precise if the intersection should be done using OBB
  7336. * @returns if the bounding info intersects
  7337. */
  7338. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7339. }
  7340. }
  7341. declare module BABYLON {
  7342. /**
  7343. * Defines an array and its length.
  7344. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7345. */
  7346. export interface ISmartArrayLike<T> {
  7347. /**
  7348. * The data of the array.
  7349. */
  7350. data: Array<T>;
  7351. /**
  7352. * The active length of the array.
  7353. */
  7354. length: number;
  7355. }
  7356. /**
  7357. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7358. */
  7359. export class SmartArray<T> implements ISmartArrayLike<T> {
  7360. /**
  7361. * The full set of data from the array.
  7362. */
  7363. data: Array<T>;
  7364. /**
  7365. * The active length of the array.
  7366. */
  7367. length: number;
  7368. protected _id: number;
  7369. /**
  7370. * Instantiates a Smart Array.
  7371. * @param capacity defines the default capacity of the array.
  7372. */
  7373. constructor(capacity: number);
  7374. /**
  7375. * Pushes a value at the end of the active data.
  7376. * @param value defines the object to push in the array.
  7377. */
  7378. push(value: T): void;
  7379. /**
  7380. * Iterates over the active data and apply the lambda to them.
  7381. * @param func defines the action to apply on each value.
  7382. */
  7383. forEach(func: (content: T) => void): void;
  7384. /**
  7385. * Sorts the full sets of data.
  7386. * @param compareFn defines the comparison function to apply.
  7387. */
  7388. sort(compareFn: (a: T, b: T) => number): void;
  7389. /**
  7390. * Resets the active data to an empty array.
  7391. */
  7392. reset(): void;
  7393. /**
  7394. * Releases all the data from the array as well as the array.
  7395. */
  7396. dispose(): void;
  7397. /**
  7398. * Concats the active data with a given array.
  7399. * @param array defines the data to concatenate with.
  7400. */
  7401. concat(array: any): void;
  7402. /**
  7403. * Returns the position of a value in the active data.
  7404. * @param value defines the value to find the index for
  7405. * @returns the index if found in the active data otherwise -1
  7406. */
  7407. indexOf(value: T): number;
  7408. /**
  7409. * Returns whether an element is part of the active data.
  7410. * @param value defines the value to look for
  7411. * @returns true if found in the active data otherwise false
  7412. */
  7413. contains(value: T): boolean;
  7414. private static _GlobalId;
  7415. }
  7416. /**
  7417. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7418. * The data in this array can only be present once
  7419. */
  7420. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7421. private _duplicateId;
  7422. /**
  7423. * Pushes a value at the end of the active data.
  7424. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7425. * @param value defines the object to push in the array.
  7426. */
  7427. push(value: T): void;
  7428. /**
  7429. * Pushes a value at the end of the active data.
  7430. * If the data is already present, it won t be added again
  7431. * @param value defines the object to push in the array.
  7432. * @returns true if added false if it was already present
  7433. */
  7434. pushNoDuplicate(value: T): boolean;
  7435. /**
  7436. * Resets the active data to an empty array.
  7437. */
  7438. reset(): void;
  7439. /**
  7440. * Concats the active data with a given array.
  7441. * This ensures no dupplicate will be present in the result.
  7442. * @param array defines the data to concatenate with.
  7443. */
  7444. concatWithNoDuplicate(array: any): void;
  7445. }
  7446. }
  7447. declare module BABYLON {
  7448. /**
  7449. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7450. * separate meshes. This can be use to improve performances.
  7451. * @see http://doc.babylonjs.com/how_to/multi_materials
  7452. */
  7453. export class MultiMaterial extends Material {
  7454. private _subMaterials;
  7455. /**
  7456. * Gets or Sets the list of Materials used within the multi material.
  7457. * They need to be ordered according to the submeshes order in the associated mesh
  7458. */
  7459. subMaterials: Nullable<Material>[];
  7460. /**
  7461. * Function used to align with Node.getChildren()
  7462. * @returns the list of Materials used within the multi material
  7463. */
  7464. getChildren(): Nullable<Material>[];
  7465. /**
  7466. * Instantiates a new Multi Material
  7467. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7468. * separate meshes. This can be use to improve performances.
  7469. * @see http://doc.babylonjs.com/how_to/multi_materials
  7470. * @param name Define the name in the scene
  7471. * @param scene Define the scene the material belongs to
  7472. */
  7473. constructor(name: string, scene: Scene);
  7474. private _hookArray;
  7475. /**
  7476. * Get one of the submaterial by its index in the submaterials array
  7477. * @param index The index to look the sub material at
  7478. * @returns The Material if the index has been defined
  7479. */
  7480. getSubMaterial(index: number): Nullable<Material>;
  7481. /**
  7482. * Get the list of active textures for the whole sub materials list.
  7483. * @returns All the textures that will be used during the rendering
  7484. */
  7485. getActiveTextures(): BaseTexture[];
  7486. /**
  7487. * Gets the current class name of the material e.g. "MultiMaterial"
  7488. * Mainly use in serialization.
  7489. * @returns the class name
  7490. */
  7491. getClassName(): string;
  7492. /**
  7493. * Checks if the material is ready to render the requested sub mesh
  7494. * @param mesh Define the mesh the submesh belongs to
  7495. * @param subMesh Define the sub mesh to look readyness for
  7496. * @param useInstances Define whether or not the material is used with instances
  7497. * @returns true if ready, otherwise false
  7498. */
  7499. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7500. /**
  7501. * Clones the current material and its related sub materials
  7502. * @param name Define the name of the newly cloned material
  7503. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7504. * @returns the cloned material
  7505. */
  7506. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7507. /**
  7508. * Serializes the materials into a JSON representation.
  7509. * @returns the JSON representation
  7510. */
  7511. serialize(): any;
  7512. /**
  7513. * Dispose the material and release its associated resources
  7514. * @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)
  7515. * @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)
  7516. * @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)
  7517. */
  7518. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7519. /**
  7520. * Creates a MultiMaterial from parsed MultiMaterial data.
  7521. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7522. * @param scene defines the hosting scene
  7523. * @returns a new MultiMaterial
  7524. */
  7525. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7526. }
  7527. }
  7528. declare module BABYLON {
  7529. /**
  7530. * Class used to represent data loading progression
  7531. */
  7532. export class SceneLoaderFlags {
  7533. private static _ForceFullSceneLoadingForIncremental;
  7534. private static _ShowLoadingScreen;
  7535. private static _CleanBoneMatrixWeights;
  7536. private static _loggingLevel;
  7537. /**
  7538. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7539. */
  7540. static ForceFullSceneLoadingForIncremental: boolean;
  7541. /**
  7542. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7543. */
  7544. static ShowLoadingScreen: boolean;
  7545. /**
  7546. * Defines the current logging level (while loading the scene)
  7547. * @ignorenaming
  7548. */
  7549. static loggingLevel: number;
  7550. /**
  7551. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7552. */
  7553. static CleanBoneMatrixWeights: boolean;
  7554. }
  7555. }
  7556. declare module BABYLON {
  7557. /**
  7558. * Class used to override all child animations of a given target
  7559. */
  7560. export class AnimationPropertiesOverride {
  7561. /**
  7562. * Gets or sets a value indicating if animation blending must be used
  7563. */
  7564. enableBlending: boolean;
  7565. /**
  7566. * Gets or sets the blending speed to use when enableBlending is true
  7567. */
  7568. blendingSpeed: number;
  7569. /**
  7570. * Gets or sets the default loop mode to use
  7571. */
  7572. loopMode: number;
  7573. }
  7574. }
  7575. declare module BABYLON {
  7576. /**
  7577. * Defines a target to use with MorphTargetManager
  7578. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7579. */
  7580. export class MorphTarget implements IAnimatable {
  7581. /** defines the name of the target */
  7582. name: string;
  7583. /**
  7584. * Gets or sets the list of animations
  7585. */
  7586. animations: Animation[];
  7587. private _scene;
  7588. private _positions;
  7589. private _normals;
  7590. private _tangents;
  7591. private _influence;
  7592. /**
  7593. * Observable raised when the influence changes
  7594. */
  7595. onInfluenceChanged: Observable<boolean>;
  7596. /** @hidden */
  7597. _onDataLayoutChanged: Observable<void>;
  7598. /**
  7599. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  7600. */
  7601. influence: number;
  7602. /**
  7603. * Gets or sets the id of the morph Target
  7604. */
  7605. id: string;
  7606. private _animationPropertiesOverride;
  7607. /**
  7608. * Gets or sets the animation properties override
  7609. */
  7610. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7611. /**
  7612. * Creates a new MorphTarget
  7613. * @param name defines the name of the target
  7614. * @param influence defines the influence to use
  7615. * @param scene defines the scene the morphtarget belongs to
  7616. */
  7617. constructor(
  7618. /** defines the name of the target */
  7619. name: string, influence?: number, scene?: Nullable<Scene>);
  7620. /**
  7621. * Gets a boolean defining if the target contains position data
  7622. */
  7623. readonly hasPositions: boolean;
  7624. /**
  7625. * Gets a boolean defining if the target contains normal data
  7626. */
  7627. readonly hasNormals: boolean;
  7628. /**
  7629. * Gets a boolean defining if the target contains tangent data
  7630. */
  7631. readonly hasTangents: boolean;
  7632. /**
  7633. * Affects position data to this target
  7634. * @param data defines the position data to use
  7635. */
  7636. setPositions(data: Nullable<FloatArray>): void;
  7637. /**
  7638. * Gets the position data stored in this target
  7639. * @returns a FloatArray containing the position data (or null if not present)
  7640. */
  7641. getPositions(): Nullable<FloatArray>;
  7642. /**
  7643. * Affects normal data to this target
  7644. * @param data defines the normal data to use
  7645. */
  7646. setNormals(data: Nullable<FloatArray>): void;
  7647. /**
  7648. * Gets the normal data stored in this target
  7649. * @returns a FloatArray containing the normal data (or null if not present)
  7650. */
  7651. getNormals(): Nullable<FloatArray>;
  7652. /**
  7653. * Affects tangent data to this target
  7654. * @param data defines the tangent data to use
  7655. */
  7656. setTangents(data: Nullable<FloatArray>): void;
  7657. /**
  7658. * Gets the tangent data stored in this target
  7659. * @returns a FloatArray containing the tangent data (or null if not present)
  7660. */
  7661. getTangents(): Nullable<FloatArray>;
  7662. /**
  7663. * Serializes the current target into a Serialization object
  7664. * @returns the serialized object
  7665. */
  7666. serialize(): any;
  7667. /**
  7668. * Returns the string "MorphTarget"
  7669. * @returns "MorphTarget"
  7670. */
  7671. getClassName(): string;
  7672. /**
  7673. * Creates a new target from serialized data
  7674. * @param serializationObject defines the serialized data to use
  7675. * @returns a new MorphTarget
  7676. */
  7677. static Parse(serializationObject: any): MorphTarget;
  7678. /**
  7679. * Creates a MorphTarget from mesh data
  7680. * @param mesh defines the source mesh
  7681. * @param name defines the name to use for the new target
  7682. * @param influence defines the influence to attach to the target
  7683. * @returns a new MorphTarget
  7684. */
  7685. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  7686. }
  7687. }
  7688. declare module BABYLON {
  7689. /**
  7690. * This class is used to deform meshes using morphing between different targets
  7691. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  7692. */
  7693. export class MorphTargetManager {
  7694. private _targets;
  7695. private _targetInfluenceChangedObservers;
  7696. private _targetDataLayoutChangedObservers;
  7697. private _activeTargets;
  7698. private _scene;
  7699. private _influences;
  7700. private _supportsNormals;
  7701. private _supportsTangents;
  7702. private _vertexCount;
  7703. private _uniqueId;
  7704. private _tempInfluences;
  7705. /**
  7706. * Creates a new MorphTargetManager
  7707. * @param scene defines the current scene
  7708. */
  7709. constructor(scene?: Nullable<Scene>);
  7710. /**
  7711. * Gets the unique ID of this manager
  7712. */
  7713. readonly uniqueId: number;
  7714. /**
  7715. * Gets the number of vertices handled by this manager
  7716. */
  7717. readonly vertexCount: number;
  7718. /**
  7719. * Gets a boolean indicating if this manager supports morphing of normals
  7720. */
  7721. readonly supportsNormals: boolean;
  7722. /**
  7723. * Gets a boolean indicating if this manager supports morphing of tangents
  7724. */
  7725. readonly supportsTangents: boolean;
  7726. /**
  7727. * Gets the number of targets stored in this manager
  7728. */
  7729. readonly numTargets: number;
  7730. /**
  7731. * Gets the number of influencers (ie. the number of targets with influences > 0)
  7732. */
  7733. readonly numInfluencers: number;
  7734. /**
  7735. * Gets the list of influences (one per target)
  7736. */
  7737. readonly influences: Float32Array;
  7738. /**
  7739. * Gets the active target at specified index. An active target is a target with an influence > 0
  7740. * @param index defines the index to check
  7741. * @returns the requested target
  7742. */
  7743. getActiveTarget(index: number): MorphTarget;
  7744. /**
  7745. * Gets the target at specified index
  7746. * @param index defines the index to check
  7747. * @returns the requested target
  7748. */
  7749. getTarget(index: number): MorphTarget;
  7750. /**
  7751. * Add a new target to this manager
  7752. * @param target defines the target to add
  7753. */
  7754. addTarget(target: MorphTarget): void;
  7755. /**
  7756. * Removes a target from the manager
  7757. * @param target defines the target to remove
  7758. */
  7759. removeTarget(target: MorphTarget): void;
  7760. /**
  7761. * Serializes the current manager into a Serialization object
  7762. * @returns the serialized object
  7763. */
  7764. serialize(): any;
  7765. private _syncActiveTargets;
  7766. /**
  7767. * Syncrhonize the targets with all the meshes using this morph target manager
  7768. */
  7769. synchronize(): void;
  7770. /**
  7771. * Creates a new MorphTargetManager from serialized data
  7772. * @param serializationObject defines the serialized data
  7773. * @param scene defines the hosting scene
  7774. * @returns the new MorphTargetManager
  7775. */
  7776. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  7777. }
  7778. }
  7779. declare module BABYLON {
  7780. /**
  7781. * Creates an instance based on a source mesh.
  7782. */
  7783. export class InstancedMesh extends AbstractMesh {
  7784. private _sourceMesh;
  7785. private _currentLOD;
  7786. /** @hidden */
  7787. _indexInSourceMeshInstanceArray: number;
  7788. constructor(name: string, source: Mesh);
  7789. /**
  7790. * Returns the string "InstancedMesh".
  7791. */
  7792. getClassName(): string;
  7793. /**
  7794. * If the source mesh receives shadows
  7795. */
  7796. readonly receiveShadows: boolean;
  7797. /**
  7798. * The material of the source mesh
  7799. */
  7800. readonly material: Nullable<Material>;
  7801. /**
  7802. * Visibility of the source mesh
  7803. */
  7804. readonly visibility: number;
  7805. /**
  7806. * Skeleton of the source mesh
  7807. */
  7808. readonly skeleton: Nullable<Skeleton>;
  7809. /**
  7810. * Rendering ground id of the source mesh
  7811. */
  7812. renderingGroupId: number;
  7813. /**
  7814. * Returns the total number of vertices (integer).
  7815. */
  7816. getTotalVertices(): number;
  7817. /**
  7818. * Returns a positive integer : the total number of indices in this mesh geometry.
  7819. * @returns the numner of indices or zero if the mesh has no geometry.
  7820. */
  7821. getTotalIndices(): number;
  7822. /**
  7823. * The source mesh of the instance
  7824. */
  7825. readonly sourceMesh: Mesh;
  7826. /**
  7827. * Is this node ready to be used/rendered
  7828. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  7829. * @return {boolean} is it ready
  7830. */
  7831. isReady(completeCheck?: boolean): boolean;
  7832. /**
  7833. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  7834. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  7835. * @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.
  7836. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  7837. */
  7838. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  7839. /**
  7840. * Sets the vertex data of the mesh geometry for the requested `kind`.
  7841. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  7842. * The `data` are either a numeric array either a Float32Array.
  7843. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  7844. * 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).
  7845. * Note that a new underlying VertexBuffer object is created each call.
  7846. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  7847. *
  7848. * Possible `kind` values :
  7849. * - VertexBuffer.PositionKind
  7850. * - VertexBuffer.UVKind
  7851. * - VertexBuffer.UV2Kind
  7852. * - VertexBuffer.UV3Kind
  7853. * - VertexBuffer.UV4Kind
  7854. * - VertexBuffer.UV5Kind
  7855. * - VertexBuffer.UV6Kind
  7856. * - VertexBuffer.ColorKind
  7857. * - VertexBuffer.MatricesIndicesKind
  7858. * - VertexBuffer.MatricesIndicesExtraKind
  7859. * - VertexBuffer.MatricesWeightsKind
  7860. * - VertexBuffer.MatricesWeightsExtraKind
  7861. *
  7862. * Returns the Mesh.
  7863. */
  7864. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  7865. /**
  7866. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  7867. * If the mesh has no geometry, it is simply returned as it is.
  7868. * The `data` are either a numeric array either a Float32Array.
  7869. * No new underlying VertexBuffer object is created.
  7870. * 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.
  7871. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  7872. *
  7873. * Possible `kind` values :
  7874. * - VertexBuffer.PositionKind
  7875. * - VertexBuffer.UVKind
  7876. * - VertexBuffer.UV2Kind
  7877. * - VertexBuffer.UV3Kind
  7878. * - VertexBuffer.UV4Kind
  7879. * - VertexBuffer.UV5Kind
  7880. * - VertexBuffer.UV6Kind
  7881. * - VertexBuffer.ColorKind
  7882. * - VertexBuffer.MatricesIndicesKind
  7883. * - VertexBuffer.MatricesIndicesExtraKind
  7884. * - VertexBuffer.MatricesWeightsKind
  7885. * - VertexBuffer.MatricesWeightsExtraKind
  7886. *
  7887. * Returns the Mesh.
  7888. */
  7889. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  7890. /**
  7891. * Sets the mesh indices.
  7892. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  7893. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  7894. * This method creates a new index buffer each call.
  7895. * Returns the Mesh.
  7896. */
  7897. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  7898. /**
  7899. * Boolean : True if the mesh owns the requested kind of data.
  7900. */
  7901. isVerticesDataPresent(kind: string): boolean;
  7902. /**
  7903. * Returns an array of indices (IndicesArray).
  7904. */
  7905. getIndices(): Nullable<IndicesArray>;
  7906. readonly _positions: Nullable<Vector3[]>;
  7907. /**
  7908. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  7909. * This means the mesh underlying bounding box and sphere are recomputed.
  7910. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  7911. * @returns the current mesh
  7912. */
  7913. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  7914. /** @hidden */
  7915. _preActivate(): InstancedMesh;
  7916. /** @hidden */
  7917. _activate(renderId: number): InstancedMesh;
  7918. /**
  7919. * Returns the current associated LOD AbstractMesh.
  7920. */
  7921. getLOD(camera: Camera): AbstractMesh;
  7922. /** @hidden */
  7923. _syncSubMeshes(): InstancedMesh;
  7924. /** @hidden */
  7925. _generatePointsArray(): boolean;
  7926. /**
  7927. * Creates a new InstancedMesh from the current mesh.
  7928. * - name (string) : the cloned mesh name
  7929. * - newParent (optional Node) : the optional Node to parent the clone to.
  7930. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  7931. *
  7932. * Returns the clone.
  7933. */
  7934. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  7935. /**
  7936. * Disposes the InstancedMesh.
  7937. * Returns nothing.
  7938. */
  7939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7940. }
  7941. }
  7942. declare module BABYLON {
  7943. /**
  7944. * Class for creating a cube texture
  7945. */
  7946. export class CubeTexture extends BaseTexture {
  7947. private _delayedOnLoad;
  7948. /**
  7949. * The url of the texture
  7950. */
  7951. url: string;
  7952. /**
  7953. * Gets or sets the center of the bounding box associated with the cube texture.
  7954. * It must define where the camera used to render the texture was set
  7955. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7956. */
  7957. boundingBoxPosition: Vector3;
  7958. private _boundingBoxSize;
  7959. /**
  7960. * Gets or sets the size of the bounding box associated with the cube texture
  7961. * When defined, the cubemap will switch to local mode
  7962. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7963. * @example https://www.babylonjs-playground.com/#RNASML
  7964. */
  7965. /**
  7966. * Returns the bounding box size
  7967. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7968. */
  7969. boundingBoxSize: Vector3;
  7970. protected _rotationY: number;
  7971. /**
  7972. * Sets texture matrix rotation angle around Y axis in radians.
  7973. */
  7974. /**
  7975. * Gets texture matrix rotation angle around Y axis radians.
  7976. */
  7977. rotationY: number;
  7978. /**
  7979. * Are mip maps generated for this texture or not.
  7980. */
  7981. readonly noMipmap: boolean;
  7982. private _noMipmap;
  7983. private _files;
  7984. private _extensions;
  7985. private _textureMatrix;
  7986. private _format;
  7987. private _createPolynomials;
  7988. /** @hidden */
  7989. _prefiltered: boolean;
  7990. /**
  7991. * Creates a cube texture from an array of image urls
  7992. * @param files defines an array of image urls
  7993. * @param scene defines the hosting scene
  7994. * @param noMipmap specifies if mip maps are not used
  7995. * @returns a cube texture
  7996. */
  7997. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7998. /**
  7999. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8000. * @param url defines the url of the prefiltered texture
  8001. * @param scene defines the scene the texture is attached to
  8002. * @param forcedExtension defines the extension of the file if different from the url
  8003. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8004. * @return the prefiltered texture
  8005. */
  8006. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8007. /**
  8008. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8009. * as prefiltered data.
  8010. * @param rootUrl defines the url of the texture or the root name of the six images
  8011. * @param scene defines the scene the texture is attached to
  8012. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8013. * @param noMipmap defines if mipmaps should be created or not
  8014. * @param files defines the six files to load for the different faces
  8015. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8016. * @param onError defines a callback triggered in case of error during load
  8017. * @param format defines the internal format to use for the texture once loaded
  8018. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8019. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8020. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8021. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8022. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8023. * @return the cube texture
  8024. */
  8025. 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);
  8026. /**
  8027. * Get the current class name of the texture useful for serialization or dynamic coding.
  8028. * @returns "CubeTexture"
  8029. */
  8030. getClassName(): string;
  8031. /**
  8032. * Update the url (and optional buffer) of this texture if url was null during construction.
  8033. * @param url the url of the texture
  8034. * @param forcedExtension defines the extension to use
  8035. * @param onLoad callback called when the texture is loaded (defaults to null)
  8036. */
  8037. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8038. /**
  8039. * Delays loading of the cube texture
  8040. * @param forcedExtension defines the extension to use
  8041. */
  8042. delayLoad(forcedExtension?: string): void;
  8043. /**
  8044. * Returns the reflection texture matrix
  8045. * @returns the reflection texture matrix
  8046. */
  8047. getReflectionTextureMatrix(): Matrix;
  8048. /**
  8049. * Sets the reflection texture matrix
  8050. * @param value Reflection texture matrix
  8051. */
  8052. setReflectionTextureMatrix(value: Matrix): void;
  8053. /**
  8054. * Parses text to create a cube texture
  8055. * @param parsedTexture define the serialized text to read from
  8056. * @param scene defines the hosting scene
  8057. * @param rootUrl defines the root url of the cube texture
  8058. * @returns a cube texture
  8059. */
  8060. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8061. /**
  8062. * Makes a clone, or deep copy, of the cube texture
  8063. * @returns a new cube texture
  8064. */
  8065. clone(): CubeTexture;
  8066. }
  8067. }
  8068. declare module BABYLON {
  8069. /** @hidden */
  8070. export var postprocessVertexShader: {
  8071. name: string;
  8072. shader: string;
  8073. };
  8074. }
  8075. declare module BABYLON {
  8076. /**
  8077. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8078. * This is the base of the follow, arc rotate cameras and Free camera
  8079. * @see http://doc.babylonjs.com/features/cameras
  8080. */
  8081. export class TargetCamera extends Camera {
  8082. private static _RigCamTransformMatrix;
  8083. private static _TargetTransformMatrix;
  8084. private static _TargetFocalPoint;
  8085. /**
  8086. * Define the current direction the camera is moving to
  8087. */
  8088. cameraDirection: Vector3;
  8089. /**
  8090. * Define the current rotation the camera is rotating to
  8091. */
  8092. cameraRotation: Vector2;
  8093. /**
  8094. * When set, the up vector of the camera will be updated by the rotation of the camera
  8095. */
  8096. updateUpVectorFromRotation: boolean;
  8097. private _tmpQuaternion;
  8098. /**
  8099. * Define the current rotation of the camera
  8100. */
  8101. rotation: Vector3;
  8102. /**
  8103. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8104. */
  8105. rotationQuaternion: Quaternion;
  8106. /**
  8107. * Define the current speed of the camera
  8108. */
  8109. speed: number;
  8110. /**
  8111. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8112. * around all axis.
  8113. */
  8114. noRotationConstraint: boolean;
  8115. /**
  8116. * Define the current target of the camera as an object or a position.
  8117. */
  8118. lockedTarget: any;
  8119. /** @hidden */
  8120. _currentTarget: Vector3;
  8121. /** @hidden */
  8122. _initialFocalDistance: number;
  8123. /** @hidden */
  8124. _viewMatrix: Matrix;
  8125. /** @hidden */
  8126. _camMatrix: Matrix;
  8127. /** @hidden */
  8128. _cameraTransformMatrix: Matrix;
  8129. /** @hidden */
  8130. _cameraRotationMatrix: Matrix;
  8131. /** @hidden */
  8132. _referencePoint: Vector3;
  8133. /** @hidden */
  8134. _transformedReferencePoint: Vector3;
  8135. protected _globalCurrentTarget: Vector3;
  8136. protected _globalCurrentUpVector: Vector3;
  8137. /** @hidden */
  8138. _reset: () => void;
  8139. private _defaultUp;
  8140. /**
  8141. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8142. * This is the base of the follow, arc rotate cameras and Free camera
  8143. * @see http://doc.babylonjs.com/features/cameras
  8144. * @param name Defines the name of the camera in the scene
  8145. * @param position Defines the start position of the camera in the scene
  8146. * @param scene Defines the scene the camera belongs to
  8147. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8148. */
  8149. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8150. /**
  8151. * Gets the position in front of the camera at a given distance.
  8152. * @param distance The distance from the camera we want the position to be
  8153. * @returns the position
  8154. */
  8155. getFrontPosition(distance: number): Vector3;
  8156. /** @hidden */
  8157. _getLockedTargetPosition(): Nullable<Vector3>;
  8158. private _storedPosition;
  8159. private _storedRotation;
  8160. private _storedRotationQuaternion;
  8161. /**
  8162. * Store current camera state of the camera (fov, position, rotation, etc..)
  8163. * @returns the camera
  8164. */
  8165. storeState(): Camera;
  8166. /**
  8167. * Restored camera state. You must call storeState() first
  8168. * @returns whether it was successful or not
  8169. * @hidden
  8170. */
  8171. _restoreStateValues(): boolean;
  8172. /** @hidden */
  8173. _initCache(): void;
  8174. /** @hidden */
  8175. _updateCache(ignoreParentClass?: boolean): void;
  8176. /** @hidden */
  8177. _isSynchronizedViewMatrix(): boolean;
  8178. /** @hidden */
  8179. _computeLocalCameraSpeed(): number;
  8180. /** @hidden */
  8181. setTarget(target: Vector3): void;
  8182. /**
  8183. * Return the current target position of the camera. This value is expressed in local space.
  8184. * @returns the target position
  8185. */
  8186. getTarget(): Vector3;
  8187. /** @hidden */
  8188. _decideIfNeedsToMove(): boolean;
  8189. /** @hidden */
  8190. _updatePosition(): void;
  8191. /** @hidden */
  8192. _checkInputs(): void;
  8193. protected _updateCameraRotationMatrix(): void;
  8194. /**
  8195. * 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)
  8196. * @returns the current camera
  8197. */
  8198. private _rotateUpVectorWithCameraRotationMatrix;
  8199. private _cachedRotationZ;
  8200. private _cachedQuaternionRotationZ;
  8201. /** @hidden */
  8202. _getViewMatrix(): Matrix;
  8203. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8204. /**
  8205. * @hidden
  8206. */
  8207. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8208. /**
  8209. * @hidden
  8210. */
  8211. _updateRigCameras(): void;
  8212. private _getRigCamPositionAndTarget;
  8213. /**
  8214. * Gets the current object class name.
  8215. * @return the class name
  8216. */
  8217. getClassName(): string;
  8218. }
  8219. }
  8220. declare module BABYLON {
  8221. /**
  8222. * @ignore
  8223. * This is a list of all the different input types that are available in the application.
  8224. * Fo instance: ArcRotateCameraGamepadInput...
  8225. */
  8226. export var CameraInputTypes: {};
  8227. /**
  8228. * This is the contract to implement in order to create a new input class.
  8229. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8230. */
  8231. export interface ICameraInput<TCamera extends Camera> {
  8232. /**
  8233. * Defines the camera the input is attached to.
  8234. */
  8235. camera: Nullable<TCamera>;
  8236. /**
  8237. * Gets the class name of the current intput.
  8238. * @returns the class name
  8239. */
  8240. getClassName(): string;
  8241. /**
  8242. * Get the friendly name associated with the input class.
  8243. * @returns the input friendly name
  8244. */
  8245. getSimpleName(): string;
  8246. /**
  8247. * Attach the input controls to a specific dom element to get the input from.
  8248. * @param element Defines the element the controls should be listened from
  8249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8250. */
  8251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8252. /**
  8253. * Detach the current controls from the specified dom element.
  8254. * @param element Defines the element to stop listening the inputs from
  8255. */
  8256. detachControl(element: Nullable<HTMLElement>): void;
  8257. /**
  8258. * Update the current camera state depending on the inputs that have been used this frame.
  8259. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8260. */
  8261. checkInputs?: () => void;
  8262. }
  8263. /**
  8264. * Represents a map of input types to input instance or input index to input instance.
  8265. */
  8266. export interface CameraInputsMap<TCamera extends Camera> {
  8267. /**
  8268. * Accessor to the input by input type.
  8269. */
  8270. [name: string]: ICameraInput<TCamera>;
  8271. /**
  8272. * Accessor to the input by input index.
  8273. */
  8274. [idx: number]: ICameraInput<TCamera>;
  8275. }
  8276. /**
  8277. * This represents the input manager used within a camera.
  8278. * It helps dealing with all the different kind of input attached to a camera.
  8279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8280. */
  8281. export class CameraInputsManager<TCamera extends Camera> {
  8282. /**
  8283. * Defines the list of inputs attahed to the camera.
  8284. */
  8285. attached: CameraInputsMap<TCamera>;
  8286. /**
  8287. * Defines the dom element the camera is collecting inputs from.
  8288. * This is null if the controls have not been attached.
  8289. */
  8290. attachedElement: Nullable<HTMLElement>;
  8291. /**
  8292. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8293. */
  8294. noPreventDefault: boolean;
  8295. /**
  8296. * Defined the camera the input manager belongs to.
  8297. */
  8298. camera: TCamera;
  8299. /**
  8300. * Update the current camera state depending on the inputs that have been used this frame.
  8301. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8302. */
  8303. checkInputs: () => void;
  8304. /**
  8305. * Instantiate a new Camera Input Manager.
  8306. * @param camera Defines the camera the input manager blongs to
  8307. */
  8308. constructor(camera: TCamera);
  8309. /**
  8310. * Add an input method to a camera
  8311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8312. * @param input camera input method
  8313. */
  8314. add(input: ICameraInput<TCamera>): void;
  8315. /**
  8316. * Remove a specific input method from a camera
  8317. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8318. * @param inputToRemove camera input method
  8319. */
  8320. remove(inputToRemove: ICameraInput<TCamera>): void;
  8321. /**
  8322. * Remove a specific input type from a camera
  8323. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8324. * @param inputType the type of the input to remove
  8325. */
  8326. removeByType(inputType: string): void;
  8327. private _addCheckInputs;
  8328. /**
  8329. * Attach the input controls to the currently attached dom element to listen the events from.
  8330. * @param input Defines the input to attach
  8331. */
  8332. attachInput(input: ICameraInput<TCamera>): void;
  8333. /**
  8334. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8335. * @param element Defines the dom element to collect the events from
  8336. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8337. */
  8338. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8339. /**
  8340. * Detach the current manager inputs controls from a specific dom element.
  8341. * @param element Defines the dom element to collect the events from
  8342. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8343. */
  8344. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8345. /**
  8346. * Rebuild the dynamic inputCheck function from the current list of
  8347. * defined inputs in the manager.
  8348. */
  8349. rebuildInputCheck(): void;
  8350. /**
  8351. * Remove all attached input methods from a camera
  8352. */
  8353. clear(): void;
  8354. /**
  8355. * Serialize the current input manager attached to a camera.
  8356. * This ensures than once parsed,
  8357. * the input associated to the camera will be identical to the current ones
  8358. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8359. */
  8360. serialize(serializedCamera: any): void;
  8361. /**
  8362. * Parses an input manager serialized JSON to restore the previous list of inputs
  8363. * and states associated to a camera.
  8364. * @param parsedCamera Defines the JSON to parse
  8365. */
  8366. parse(parsedCamera: any): void;
  8367. }
  8368. }
  8369. declare module BABYLON {
  8370. /**
  8371. * Gather the list of keyboard event types as constants.
  8372. */
  8373. export class KeyboardEventTypes {
  8374. /**
  8375. * The keydown event is fired when a key becomes active (pressed).
  8376. */
  8377. static readonly KEYDOWN: number;
  8378. /**
  8379. * The keyup event is fired when a key has been released.
  8380. */
  8381. static readonly KEYUP: number;
  8382. }
  8383. /**
  8384. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8385. */
  8386. export class KeyboardInfo {
  8387. /**
  8388. * Defines the type of event (KeyboardEventTypes)
  8389. */
  8390. type: number;
  8391. /**
  8392. * Defines the related dom event
  8393. */
  8394. event: KeyboardEvent;
  8395. /**
  8396. * Instantiates a new keyboard info.
  8397. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8398. * @param type Defines the type of event (KeyboardEventTypes)
  8399. * @param event Defines the related dom event
  8400. */
  8401. constructor(
  8402. /**
  8403. * Defines the type of event (KeyboardEventTypes)
  8404. */
  8405. type: number,
  8406. /**
  8407. * Defines the related dom event
  8408. */
  8409. event: KeyboardEvent);
  8410. }
  8411. /**
  8412. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8413. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8414. */
  8415. export class KeyboardInfoPre extends KeyboardInfo {
  8416. /**
  8417. * Defines the type of event (KeyboardEventTypes)
  8418. */
  8419. type: number;
  8420. /**
  8421. * Defines the related dom event
  8422. */
  8423. event: KeyboardEvent;
  8424. /**
  8425. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8426. */
  8427. skipOnPointerObservable: boolean;
  8428. /**
  8429. * Instantiates a new keyboard pre info.
  8430. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8431. * @param type Defines the type of event (KeyboardEventTypes)
  8432. * @param event Defines the related dom event
  8433. */
  8434. constructor(
  8435. /**
  8436. * Defines the type of event (KeyboardEventTypes)
  8437. */
  8438. type: number,
  8439. /**
  8440. * Defines the related dom event
  8441. */
  8442. event: KeyboardEvent);
  8443. }
  8444. }
  8445. declare module BABYLON {
  8446. /**
  8447. * Manage the keyboard inputs to control the movement of a free camera.
  8448. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8449. */
  8450. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8451. /**
  8452. * Defines the camera the input is attached to.
  8453. */
  8454. camera: FreeCamera;
  8455. /**
  8456. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8457. */
  8458. keysUp: number[];
  8459. /**
  8460. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8461. */
  8462. keysDown: number[];
  8463. /**
  8464. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8465. */
  8466. keysLeft: number[];
  8467. /**
  8468. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8469. */
  8470. keysRight: number[];
  8471. private _keys;
  8472. private _onCanvasBlurObserver;
  8473. private _onKeyboardObserver;
  8474. private _engine;
  8475. private _scene;
  8476. /**
  8477. * Attach the input controls to a specific dom element to get the input from.
  8478. * @param element Defines the element the controls should be listened from
  8479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8480. */
  8481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8482. /**
  8483. * Detach the current controls from the specified dom element.
  8484. * @param element Defines the element to stop listening the inputs from
  8485. */
  8486. detachControl(element: Nullable<HTMLElement>): void;
  8487. /**
  8488. * Update the current camera state depending on the inputs that have been used this frame.
  8489. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8490. */
  8491. checkInputs(): void;
  8492. /**
  8493. * Gets the class name of the current intput.
  8494. * @returns the class name
  8495. */
  8496. getClassName(): string;
  8497. /** @hidden */
  8498. _onLostFocus(): void;
  8499. /**
  8500. * Get the friendly name associated with the input class.
  8501. * @returns the input friendly name
  8502. */
  8503. getSimpleName(): string;
  8504. }
  8505. }
  8506. declare module BABYLON {
  8507. /**
  8508. * Interface used to define ActionEvent
  8509. */
  8510. export interface IActionEvent {
  8511. /** The mesh or sprite that triggered the action */
  8512. source: any;
  8513. /** The X mouse cursor position at the time of the event */
  8514. pointerX: number;
  8515. /** The Y mouse cursor position at the time of the event */
  8516. pointerY: number;
  8517. /** The mesh that is currently pointed at (can be null) */
  8518. meshUnderPointer: Nullable<AbstractMesh>;
  8519. /** the original (browser) event that triggered the ActionEvent */
  8520. sourceEvent?: any;
  8521. /** additional data for the event */
  8522. additionalData?: any;
  8523. }
  8524. /**
  8525. * ActionEvent is the event being sent when an action is triggered.
  8526. */
  8527. export class ActionEvent implements IActionEvent {
  8528. /** The mesh or sprite that triggered the action */
  8529. source: any;
  8530. /** The X mouse cursor position at the time of the event */
  8531. pointerX: number;
  8532. /** The Y mouse cursor position at the time of the event */
  8533. pointerY: number;
  8534. /** The mesh that is currently pointed at (can be null) */
  8535. meshUnderPointer: Nullable<AbstractMesh>;
  8536. /** the original (browser) event that triggered the ActionEvent */
  8537. sourceEvent?: any;
  8538. /** additional data for the event */
  8539. additionalData?: any;
  8540. /**
  8541. * Creates a new ActionEvent
  8542. * @param source The mesh or sprite that triggered the action
  8543. * @param pointerX The X mouse cursor position at the time of the event
  8544. * @param pointerY The Y mouse cursor position at the time of the event
  8545. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  8546. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  8547. * @param additionalData additional data for the event
  8548. */
  8549. constructor(
  8550. /** The mesh or sprite that triggered the action */
  8551. source: any,
  8552. /** The X mouse cursor position at the time of the event */
  8553. pointerX: number,
  8554. /** The Y mouse cursor position at the time of the event */
  8555. pointerY: number,
  8556. /** The mesh that is currently pointed at (can be null) */
  8557. meshUnderPointer: Nullable<AbstractMesh>,
  8558. /** the original (browser) event that triggered the ActionEvent */
  8559. sourceEvent?: any,
  8560. /** additional data for the event */
  8561. additionalData?: any);
  8562. /**
  8563. * Helper function to auto-create an ActionEvent from a source mesh.
  8564. * @param source The source mesh that triggered the event
  8565. * @param evt The original (browser) event
  8566. * @param additionalData additional data for the event
  8567. * @returns the new ActionEvent
  8568. */
  8569. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  8570. /**
  8571. * Helper function to auto-create an ActionEvent from a source sprite
  8572. * @param source The source sprite that triggered the event
  8573. * @param scene Scene associated with the sprite
  8574. * @param evt The original (browser) event
  8575. * @param additionalData additional data for the event
  8576. * @returns the new ActionEvent
  8577. */
  8578. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  8579. /**
  8580. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  8581. * @param scene the scene where the event occurred
  8582. * @param evt The original (browser) event
  8583. * @returns the new ActionEvent
  8584. */
  8585. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  8586. /**
  8587. * Helper function to auto-create an ActionEvent from a primitive
  8588. * @param prim defines the target primitive
  8589. * @param pointerPos defines the pointer position
  8590. * @param evt The original (browser) event
  8591. * @param additionalData additional data for the event
  8592. * @returns the new ActionEvent
  8593. */
  8594. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  8595. }
  8596. }
  8597. declare module BABYLON {
  8598. /**
  8599. * Interface describing all the common properties and methods a shadow light needs to implement.
  8600. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8601. * as well as binding the different shadow properties to the effects.
  8602. */
  8603. export interface IShadowLight extends Light {
  8604. /**
  8605. * The light id in the scene (used in scene.findLighById for instance)
  8606. */
  8607. id: string;
  8608. /**
  8609. * The position the shdow will be casted from.
  8610. */
  8611. position: Vector3;
  8612. /**
  8613. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8614. */
  8615. direction: Vector3;
  8616. /**
  8617. * The transformed position. Position of the light in world space taking parenting in account.
  8618. */
  8619. transformedPosition: Vector3;
  8620. /**
  8621. * The transformed direction. Direction of the light in world space taking parenting in account.
  8622. */
  8623. transformedDirection: Vector3;
  8624. /**
  8625. * The friendly name of the light in the scene.
  8626. */
  8627. name: string;
  8628. /**
  8629. * Defines the shadow projection clipping minimum z value.
  8630. */
  8631. shadowMinZ: number;
  8632. /**
  8633. * Defines the shadow projection clipping maximum z value.
  8634. */
  8635. shadowMaxZ: number;
  8636. /**
  8637. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8638. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8639. */
  8640. computeTransformedInformation(): boolean;
  8641. /**
  8642. * Gets the scene the light belongs to.
  8643. * @returns The scene
  8644. */
  8645. getScene(): Scene;
  8646. /**
  8647. * Callback defining a custom Projection Matrix Builder.
  8648. * This can be used to override the default projection matrix computation.
  8649. */
  8650. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8651. /**
  8652. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8653. * @param matrix The materix to updated with the projection information
  8654. * @param viewMatrix The transform matrix of the light
  8655. * @param renderList The list of mesh to render in the map
  8656. * @returns The current light
  8657. */
  8658. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8659. /**
  8660. * Gets the current depth scale used in ESM.
  8661. * @returns The scale
  8662. */
  8663. getDepthScale(): number;
  8664. /**
  8665. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8666. * @returns true if a cube texture needs to be use
  8667. */
  8668. needCube(): boolean;
  8669. /**
  8670. * Detects if the projection matrix requires to be recomputed this frame.
  8671. * @returns true if it requires to be recomputed otherwise, false.
  8672. */
  8673. needProjectionMatrixCompute(): boolean;
  8674. /**
  8675. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8676. */
  8677. forceProjectionMatrixCompute(): void;
  8678. /**
  8679. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8680. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8681. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8682. */
  8683. getShadowDirection(faceIndex?: number): Vector3;
  8684. /**
  8685. * Gets the minZ used for shadow according to both the scene and the light.
  8686. * @param activeCamera The camera we are returning the min for
  8687. * @returns the depth min z
  8688. */
  8689. getDepthMinZ(activeCamera: Camera): number;
  8690. /**
  8691. * Gets the maxZ used for shadow according to both the scene and the light.
  8692. * @param activeCamera The camera we are returning the max for
  8693. * @returns the depth max z
  8694. */
  8695. getDepthMaxZ(activeCamera: Camera): number;
  8696. }
  8697. /**
  8698. * Base implementation IShadowLight
  8699. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8700. */
  8701. export abstract class ShadowLight extends Light implements IShadowLight {
  8702. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8703. protected _position: Vector3;
  8704. protected _setPosition(value: Vector3): void;
  8705. /**
  8706. * Sets the position the shadow will be casted from. Also use as the light position for both
  8707. * point and spot lights.
  8708. */
  8709. /**
  8710. * Sets the position the shadow will be casted from. Also use as the light position for both
  8711. * point and spot lights.
  8712. */
  8713. position: Vector3;
  8714. protected _direction: Vector3;
  8715. protected _setDirection(value: Vector3): void;
  8716. /**
  8717. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8718. * Also use as the light direction on spot and directional lights.
  8719. */
  8720. /**
  8721. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8722. * Also use as the light direction on spot and directional lights.
  8723. */
  8724. direction: Vector3;
  8725. private _shadowMinZ;
  8726. /**
  8727. * Gets the shadow projection clipping minimum z value.
  8728. */
  8729. /**
  8730. * Sets the shadow projection clipping minimum z value.
  8731. */
  8732. shadowMinZ: number;
  8733. private _shadowMaxZ;
  8734. /**
  8735. * Sets the shadow projection clipping maximum z value.
  8736. */
  8737. /**
  8738. * Gets the shadow projection clipping maximum z value.
  8739. */
  8740. shadowMaxZ: number;
  8741. /**
  8742. * Callback defining a custom Projection Matrix Builder.
  8743. * This can be used to override the default projection matrix computation.
  8744. */
  8745. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8746. /**
  8747. * The transformed position. Position of the light in world space taking parenting in account.
  8748. */
  8749. transformedPosition: Vector3;
  8750. /**
  8751. * The transformed direction. Direction of the light in world space taking parenting in account.
  8752. */
  8753. transformedDirection: Vector3;
  8754. private _needProjectionMatrixCompute;
  8755. /**
  8756. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8757. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8758. */
  8759. computeTransformedInformation(): boolean;
  8760. /**
  8761. * Return the depth scale used for the shadow map.
  8762. * @returns the depth scale.
  8763. */
  8764. getDepthScale(): number;
  8765. /**
  8766. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8767. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8768. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8769. */
  8770. getShadowDirection(faceIndex?: number): Vector3;
  8771. /**
  8772. * Returns the ShadowLight absolute position in the World.
  8773. * @returns the position vector in world space
  8774. */
  8775. getAbsolutePosition(): Vector3;
  8776. /**
  8777. * Sets the ShadowLight direction toward the passed target.
  8778. * @param target The point to target in local space
  8779. * @returns the updated ShadowLight direction
  8780. */
  8781. setDirectionToTarget(target: Vector3): Vector3;
  8782. /**
  8783. * Returns the light rotation in euler definition.
  8784. * @returns the x y z rotation in local space.
  8785. */
  8786. getRotation(): Vector3;
  8787. /**
  8788. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8789. * @returns true if a cube texture needs to be use
  8790. */
  8791. needCube(): boolean;
  8792. /**
  8793. * Detects if the projection matrix requires to be recomputed this frame.
  8794. * @returns true if it requires to be recomputed otherwise, false.
  8795. */
  8796. needProjectionMatrixCompute(): boolean;
  8797. /**
  8798. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8799. */
  8800. forceProjectionMatrixCompute(): void;
  8801. /** @hidden */
  8802. _initCache(): void;
  8803. /** @hidden */
  8804. _isSynchronized(): boolean;
  8805. /**
  8806. * Computes the world matrix of the node
  8807. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8808. * @returns the world matrix
  8809. */
  8810. computeWorldMatrix(force?: boolean): Matrix;
  8811. /**
  8812. * Gets the minZ used for shadow according to both the scene and the light.
  8813. * @param activeCamera The camera we are returning the min for
  8814. * @returns the depth min z
  8815. */
  8816. getDepthMinZ(activeCamera: Camera): number;
  8817. /**
  8818. * Gets the maxZ used for shadow according to both the scene and the light.
  8819. * @param activeCamera The camera we are returning the max for
  8820. * @returns the depth max z
  8821. */
  8822. getDepthMaxZ(activeCamera: Camera): number;
  8823. /**
  8824. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8825. * @param matrix The materix to updated with the projection information
  8826. * @param viewMatrix The transform matrix of the light
  8827. * @param renderList The list of mesh to render in the map
  8828. * @returns The current light
  8829. */
  8830. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8831. }
  8832. }
  8833. declare module BABYLON {
  8834. /**
  8835. * "Static Class" containing the most commonly used helper while dealing with material for
  8836. * rendering purpose.
  8837. *
  8838. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8839. *
  8840. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8841. */
  8842. export class MaterialHelper {
  8843. /**
  8844. * Bind the current view position to an effect.
  8845. * @param effect The effect to be bound
  8846. * @param scene The scene the eyes position is used from
  8847. */
  8848. static BindEyePosition(effect: Effect, scene: Scene): void;
  8849. /**
  8850. * Helps preparing the defines values about the UVs in used in the effect.
  8851. * UVs are shared as much as we can accross channels in the shaders.
  8852. * @param texture The texture we are preparing the UVs for
  8853. * @param defines The defines to update
  8854. * @param key The channel key "diffuse", "specular"... used in the shader
  8855. */
  8856. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8857. /**
  8858. * Binds a texture matrix value to its corrsponding uniform
  8859. * @param texture The texture to bind the matrix for
  8860. * @param uniformBuffer The uniform buffer receivin the data
  8861. * @param key The channel key "diffuse", "specular"... used in the shader
  8862. */
  8863. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8864. /**
  8865. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8866. * @param mesh defines the current mesh
  8867. * @param scene defines the current scene
  8868. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8869. * @param pointsCloud defines if point cloud rendering has to be turned on
  8870. * @param fogEnabled defines if fog has to be turned on
  8871. * @param alphaTest defines if alpha testing has to be turned on
  8872. * @param defines defines the current list of defines
  8873. */
  8874. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8875. /**
  8876. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8877. * @param scene defines the current scene
  8878. * @param engine defines the current engine
  8879. * @param defines specifies the list of active defines
  8880. * @param useInstances defines if instances have to be turned on
  8881. * @param useClipPlane defines if clip plane have to be turned on
  8882. */
  8883. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8884. /**
  8885. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8886. * @param mesh The mesh containing the geometry data we will draw
  8887. * @param defines The defines to update
  8888. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8889. * @param useBones Precise whether bones should be used or not (override mesh info)
  8890. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8891. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8892. * @returns false if defines are considered not dirty and have not been checked
  8893. */
  8894. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8895. /**
  8896. * Prepares the defines related to the light information passed in parameter
  8897. * @param scene The scene we are intending to draw
  8898. * @param mesh The mesh the effect is compiling for
  8899. * @param defines The defines to update
  8900. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8901. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8902. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8903. * @returns true if normals will be required for the rest of the effect
  8904. */
  8905. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8906. /**
  8907. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  8908. * that won t be acctive due to defines being turned off.
  8909. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8910. * @param samplersList The samplers list
  8911. * @param defines The defines helping in the list generation
  8912. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8913. */
  8914. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8915. /**
  8916. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8917. * @param defines The defines to update while falling back
  8918. * @param fallbacks The authorized effect fallbacks
  8919. * @param maxSimultaneousLights The maximum number of lights allowed
  8920. * @param rank the current rank of the Effect
  8921. * @returns The newly affected rank
  8922. */
  8923. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8924. /**
  8925. * Prepares the list of attributes required for morph targets according to the effect defines.
  8926. * @param attribs The current list of supported attribs
  8927. * @param mesh The mesh to prepare the morph targets attributes for
  8928. * @param defines The current Defines of the effect
  8929. */
  8930. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8931. /**
  8932. * Prepares the list of attributes required for bones according to the effect defines.
  8933. * @param attribs The current list of supported attribs
  8934. * @param mesh The mesh to prepare the bones attributes for
  8935. * @param defines The current Defines of the effect
  8936. * @param fallbacks The current efffect fallback strategy
  8937. */
  8938. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8939. /**
  8940. * Prepares the list of attributes required for instances according to the effect defines.
  8941. * @param attribs The current list of supported attribs
  8942. * @param defines The current Defines of the effect
  8943. */
  8944. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  8945. /**
  8946. * Binds the light shadow information to the effect for the given mesh.
  8947. * @param light The light containing the generator
  8948. * @param scene The scene the lights belongs to
  8949. * @param mesh The mesh we are binding the information to render
  8950. * @param lightIndex The light index in the effect used to render the mesh
  8951. * @param effect The effect we are binding the data to
  8952. */
  8953. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8954. /**
  8955. * Binds the light information to the effect.
  8956. * @param light The light containing the generator
  8957. * @param effect The effect we are binding the data to
  8958. * @param lightIndex The light index in the effect used to render
  8959. */
  8960. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8961. /**
  8962. * Binds the lights information from the scene to the effect for the given mesh.
  8963. * @param scene The scene the lights belongs to
  8964. * @param mesh The mesh we are binding the information to render
  8965. * @param effect The effect we are binding the data to
  8966. * @param defines The generated defines for the effect
  8967. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8968. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8969. */
  8970. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8971. private static _tempFogColor;
  8972. /**
  8973. * Binds the fog information from the scene to the effect for the given mesh.
  8974. * @param scene The scene the lights belongs to
  8975. * @param mesh The mesh we are binding the information to render
  8976. * @param effect The effect we are binding the data to
  8977. * @param linearSpace Defines if the fog effect is applied in linear space
  8978. */
  8979. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8980. /**
  8981. * Binds the bones information from the mesh to the effect.
  8982. * @param mesh The mesh we are binding the information to render
  8983. * @param effect The effect we are binding the data to
  8984. */
  8985. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8986. /**
  8987. * Binds the morph targets information from the mesh to the effect.
  8988. * @param abstractMesh The mesh we are binding the information to render
  8989. * @param effect The effect we are binding the data to
  8990. */
  8991. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8992. /**
  8993. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8994. * @param defines The generated defines used in the effect
  8995. * @param effect The effect we are binding the data to
  8996. * @param scene The scene we are willing to render with logarithmic scale for
  8997. */
  8998. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8999. /**
  9000. * Binds the clip plane information from the scene to the effect.
  9001. * @param scene The scene the clip plane information are extracted from
  9002. * @param effect The effect we are binding the data to
  9003. */
  9004. static BindClipPlane(effect: Effect, scene: Scene): void;
  9005. }
  9006. }
  9007. declare module BABYLON {
  9008. /** @hidden */
  9009. export var kernelBlurVaryingDeclaration: {
  9010. name: string;
  9011. shader: string;
  9012. };
  9013. }
  9014. declare module BABYLON {
  9015. /** @hidden */
  9016. export var kernelBlurFragment: {
  9017. name: string;
  9018. shader: string;
  9019. };
  9020. }
  9021. declare module BABYLON {
  9022. /** @hidden */
  9023. export var kernelBlurFragment2: {
  9024. name: string;
  9025. shader: string;
  9026. };
  9027. }
  9028. declare module BABYLON {
  9029. /** @hidden */
  9030. export var kernelBlurPixelShader: {
  9031. name: string;
  9032. shader: string;
  9033. };
  9034. }
  9035. declare module BABYLON {
  9036. /** @hidden */
  9037. export var kernelBlurVertex: {
  9038. name: string;
  9039. shader: string;
  9040. };
  9041. }
  9042. declare module BABYLON {
  9043. /** @hidden */
  9044. export var kernelBlurVertexShader: {
  9045. name: string;
  9046. shader: string;
  9047. };
  9048. }
  9049. declare module BABYLON {
  9050. /**
  9051. * The Blur Post Process which blurs an image based on a kernel and direction.
  9052. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9053. */
  9054. export class BlurPostProcess extends PostProcess {
  9055. /** The direction in which to blur the image. */
  9056. direction: Vector2;
  9057. private blockCompilation;
  9058. protected _kernel: number;
  9059. protected _idealKernel: number;
  9060. protected _packedFloat: boolean;
  9061. private _staticDefines;
  9062. /**
  9063. * Sets the length in pixels of the blur sample region
  9064. */
  9065. /**
  9066. * Gets the length in pixels of the blur sample region
  9067. */
  9068. kernel: number;
  9069. /**
  9070. * Sets wether or not the blur needs to unpack/repack floats
  9071. */
  9072. /**
  9073. * Gets wether or not the blur is unpacking/repacking floats
  9074. */
  9075. packedFloat: boolean;
  9076. /**
  9077. * Creates a new instance BlurPostProcess
  9078. * @param name The name of the effect.
  9079. * @param direction The direction in which to blur the image.
  9080. * @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.
  9081. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9082. * @param camera The camera to apply the render pass to.
  9083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9084. * @param engine The engine which the post process will be applied. (default: current engine)
  9085. * @param reusable If the post process can be reused on the same frame. (default: false)
  9086. * @param textureType Type of textures used when performing the post process. (default: 0)
  9087. * @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)
  9088. */
  9089. constructor(name: string,
  9090. /** The direction in which to blur the image. */
  9091. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9092. /**
  9093. * Updates the effect with the current post process compile time values and recompiles the shader.
  9094. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9095. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9096. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9097. * @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
  9098. * @param onCompiled Called when the shader has been compiled.
  9099. * @param onError Called if there is an error when compiling a shader.
  9100. */
  9101. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9102. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9103. /**
  9104. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9105. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9106. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9107. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9108. * The gaps between physical kernels are compensated for in the weighting of the samples
  9109. * @param idealKernel Ideal blur kernel.
  9110. * @return Nearest best kernel.
  9111. */
  9112. protected _nearestBestKernel(idealKernel: number): number;
  9113. /**
  9114. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9115. * @param x The point on the Gaussian distribution to sample.
  9116. * @return the value of the Gaussian function at x.
  9117. */
  9118. protected _gaussianWeight(x: number): number;
  9119. /**
  9120. * Generates a string that can be used as a floating point number in GLSL.
  9121. * @param x Value to print.
  9122. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9123. * @return GLSL float string.
  9124. */
  9125. protected _glslFloat(x: number, decimalFigures?: number): string;
  9126. }
  9127. }
  9128. declare module BABYLON {
  9129. /** @hidden */
  9130. export var shadowMapPixelShader: {
  9131. name: string;
  9132. shader: string;
  9133. };
  9134. }
  9135. declare module BABYLON {
  9136. /** @hidden */
  9137. export var bonesDeclaration: {
  9138. name: string;
  9139. shader: string;
  9140. };
  9141. }
  9142. declare module BABYLON {
  9143. /** @hidden */
  9144. export var morphTargetsVertexGlobalDeclaration: {
  9145. name: string;
  9146. shader: string;
  9147. };
  9148. }
  9149. declare module BABYLON {
  9150. /** @hidden */
  9151. export var morphTargetsVertexDeclaration: {
  9152. name: string;
  9153. shader: string;
  9154. };
  9155. }
  9156. declare module BABYLON {
  9157. /** @hidden */
  9158. export var instancesDeclaration: {
  9159. name: string;
  9160. shader: string;
  9161. };
  9162. }
  9163. declare module BABYLON {
  9164. /** @hidden */
  9165. export var helperFunctions: {
  9166. name: string;
  9167. shader: string;
  9168. };
  9169. }
  9170. declare module BABYLON {
  9171. /** @hidden */
  9172. export var morphTargetsVertex: {
  9173. name: string;
  9174. shader: string;
  9175. };
  9176. }
  9177. declare module BABYLON {
  9178. /** @hidden */
  9179. export var instancesVertex: {
  9180. name: string;
  9181. shader: string;
  9182. };
  9183. }
  9184. declare module BABYLON {
  9185. /** @hidden */
  9186. export var bonesVertex: {
  9187. name: string;
  9188. shader: string;
  9189. };
  9190. }
  9191. declare module BABYLON {
  9192. /** @hidden */
  9193. export var shadowMapVertexShader: {
  9194. name: string;
  9195. shader: string;
  9196. };
  9197. }
  9198. declare module BABYLON {
  9199. /** @hidden */
  9200. export var depthBoxBlurPixelShader: {
  9201. name: string;
  9202. shader: string;
  9203. };
  9204. }
  9205. declare module BABYLON {
  9206. /**
  9207. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9208. */
  9209. export interface ICustomShaderOptions {
  9210. /**
  9211. * Gets or sets the custom shader name to use
  9212. */
  9213. shaderName: string;
  9214. /**
  9215. * The list of attribute names used in the shader
  9216. */
  9217. attributes?: string[];
  9218. /**
  9219. * The list of unifrom names used in the shader
  9220. */
  9221. uniforms?: string[];
  9222. /**
  9223. * The list of sampler names used in the shader
  9224. */
  9225. samplers?: string[];
  9226. /**
  9227. * The list of defines used in the shader
  9228. */
  9229. defines?: string[];
  9230. }
  9231. /**
  9232. * Interface to implement to create a shadow generator compatible with BJS.
  9233. */
  9234. export interface IShadowGenerator {
  9235. /**
  9236. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9237. * @returns The render target texture if present otherwise, null
  9238. */
  9239. getShadowMap(): Nullable<RenderTargetTexture>;
  9240. /**
  9241. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9242. * @returns The render target texture if the shadow map is present otherwise, null
  9243. */
  9244. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9245. /**
  9246. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9247. * @param subMesh The submesh we want to render in the shadow map
  9248. * @param useInstances Defines wether will draw in the map using instances
  9249. * @returns true if ready otherwise, false
  9250. */
  9251. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9252. /**
  9253. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9254. * @param defines Defines of the material we want to update
  9255. * @param lightIndex Index of the light in the enabled light list of the material
  9256. */
  9257. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9258. /**
  9259. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9260. * defined in the generator but impacting the effect).
  9261. * It implies the unifroms available on the materials are the standard BJS ones.
  9262. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9263. * @param effect The effect we are binfing the information for
  9264. */
  9265. bindShadowLight(lightIndex: string, effect: Effect): void;
  9266. /**
  9267. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9268. * (eq to shadow prjection matrix * light transform matrix)
  9269. * @returns The transform matrix used to create the shadow map
  9270. */
  9271. getTransformMatrix(): Matrix;
  9272. /**
  9273. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9274. * Cube and 2D textures for instance.
  9275. */
  9276. recreateShadowMap(): void;
  9277. /**
  9278. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9279. * @param onCompiled Callback triggered at the and of the effects compilation
  9280. * @param options Sets of optional options forcing the compilation with different modes
  9281. */
  9282. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9283. useInstances: boolean;
  9284. }>): void;
  9285. /**
  9286. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9287. * @param options Sets of optional options forcing the compilation with different modes
  9288. * @returns A promise that resolves when the compilation completes
  9289. */
  9290. forceCompilationAsync(options?: Partial<{
  9291. useInstances: boolean;
  9292. }>): Promise<void>;
  9293. /**
  9294. * Serializes the shadow generator setup to a json object.
  9295. * @returns The serialized JSON object
  9296. */
  9297. serialize(): any;
  9298. /**
  9299. * Disposes the Shadow map and related Textures and effects.
  9300. */
  9301. dispose(): void;
  9302. }
  9303. /**
  9304. * Default implementation IShadowGenerator.
  9305. * This is the main object responsible of generating shadows in the framework.
  9306. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9307. */
  9308. export class ShadowGenerator implements IShadowGenerator {
  9309. /**
  9310. * Shadow generator mode None: no filtering applied.
  9311. */
  9312. static readonly FILTER_NONE: number;
  9313. /**
  9314. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9315. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9316. */
  9317. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9318. /**
  9319. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9320. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9321. */
  9322. static readonly FILTER_POISSONSAMPLING: number;
  9323. /**
  9324. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9325. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9326. */
  9327. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9328. /**
  9329. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9330. * edge artifacts on steep falloff.
  9331. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9332. */
  9333. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9334. /**
  9335. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9336. * edge artifacts on steep falloff.
  9337. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9338. */
  9339. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9340. /**
  9341. * Shadow generator mode PCF: Percentage Closer Filtering
  9342. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9343. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9344. */
  9345. static readonly FILTER_PCF: number;
  9346. /**
  9347. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9348. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9349. * Contact Hardening
  9350. */
  9351. static readonly FILTER_PCSS: number;
  9352. /**
  9353. * Reserved for PCF and PCSS
  9354. * Highest Quality.
  9355. *
  9356. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9357. *
  9358. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9359. */
  9360. static readonly QUALITY_HIGH: number;
  9361. /**
  9362. * Reserved for PCF and PCSS
  9363. * Good tradeoff for quality/perf cross devices
  9364. *
  9365. * Execute PCF on a 3*3 kernel.
  9366. *
  9367. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9368. */
  9369. static readonly QUALITY_MEDIUM: number;
  9370. /**
  9371. * Reserved for PCF and PCSS
  9372. * The lowest quality but the fastest.
  9373. *
  9374. * Execute PCF on a 1*1 kernel.
  9375. *
  9376. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9377. */
  9378. static readonly QUALITY_LOW: number;
  9379. /** Gets or sets the custom shader name to use */
  9380. customShaderOptions: ICustomShaderOptions;
  9381. /**
  9382. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9383. */
  9384. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9385. private _bias;
  9386. /**
  9387. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9388. */
  9389. /**
  9390. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9391. */
  9392. bias: number;
  9393. private _normalBias;
  9394. /**
  9395. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9396. */
  9397. /**
  9398. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9399. */
  9400. normalBias: number;
  9401. private _blurBoxOffset;
  9402. /**
  9403. * Gets the blur box offset: offset applied during the blur pass.
  9404. * Only useful if useKernelBlur = false
  9405. */
  9406. /**
  9407. * Sets the blur box offset: offset applied during the blur pass.
  9408. * Only useful if useKernelBlur = false
  9409. */
  9410. blurBoxOffset: number;
  9411. private _blurScale;
  9412. /**
  9413. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9414. * 2 means half of the size.
  9415. */
  9416. /**
  9417. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9418. * 2 means half of the size.
  9419. */
  9420. blurScale: number;
  9421. private _blurKernel;
  9422. /**
  9423. * Gets the blur kernel: kernel size of the blur pass.
  9424. * Only useful if useKernelBlur = true
  9425. */
  9426. /**
  9427. * Sets the blur kernel: kernel size of the blur pass.
  9428. * Only useful if useKernelBlur = true
  9429. */
  9430. blurKernel: number;
  9431. private _useKernelBlur;
  9432. /**
  9433. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9434. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9435. */
  9436. /**
  9437. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9438. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9439. */
  9440. useKernelBlur: boolean;
  9441. private _depthScale;
  9442. /**
  9443. * Gets the depth scale used in ESM mode.
  9444. */
  9445. /**
  9446. * Sets the depth scale used in ESM mode.
  9447. * This can override the scale stored on the light.
  9448. */
  9449. depthScale: number;
  9450. private _filter;
  9451. /**
  9452. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9453. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9454. */
  9455. /**
  9456. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9457. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9458. */
  9459. filter: number;
  9460. /**
  9461. * Gets if the current filter is set to Poisson Sampling.
  9462. */
  9463. /**
  9464. * Sets the current filter to Poisson Sampling.
  9465. */
  9466. usePoissonSampling: boolean;
  9467. /**
  9468. * Gets if the current filter is set to ESM.
  9469. */
  9470. /**
  9471. * Sets the current filter is to ESM.
  9472. */
  9473. useExponentialShadowMap: boolean;
  9474. /**
  9475. * Gets if the current filter is set to filtered ESM.
  9476. */
  9477. /**
  9478. * Gets if the current filter is set to filtered ESM.
  9479. */
  9480. useBlurExponentialShadowMap: boolean;
  9481. /**
  9482. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9483. * exponential to prevent steep falloff artifacts).
  9484. */
  9485. /**
  9486. * Sets the current filter to "close ESM" (using the inverse of the
  9487. * exponential to prevent steep falloff artifacts).
  9488. */
  9489. useCloseExponentialShadowMap: boolean;
  9490. /**
  9491. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9492. * exponential to prevent steep falloff artifacts).
  9493. */
  9494. /**
  9495. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9496. * exponential to prevent steep falloff artifacts).
  9497. */
  9498. useBlurCloseExponentialShadowMap: boolean;
  9499. /**
  9500. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9501. */
  9502. /**
  9503. * Sets the current filter to "PCF" (percentage closer filtering).
  9504. */
  9505. usePercentageCloserFiltering: boolean;
  9506. private _filteringQuality;
  9507. /**
  9508. * Gets the PCF or PCSS Quality.
  9509. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9510. */
  9511. /**
  9512. * Sets the PCF or PCSS Quality.
  9513. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9514. */
  9515. filteringQuality: number;
  9516. /**
  9517. * Gets if the current filter is set to "PCSS" (contact hardening).
  9518. */
  9519. /**
  9520. * Sets the current filter to "PCSS" (contact hardening).
  9521. */
  9522. useContactHardeningShadow: boolean;
  9523. private _contactHardeningLightSizeUVRatio;
  9524. /**
  9525. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9526. * Using a ratio helps keeping shape stability independently of the map size.
  9527. *
  9528. * It does not account for the light projection as it was having too much
  9529. * instability during the light setup or during light position changes.
  9530. *
  9531. * Only valid if useContactHardeningShadow is true.
  9532. */
  9533. /**
  9534. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9535. * Using a ratio helps keeping shape stability independently of the map size.
  9536. *
  9537. * It does not account for the light projection as it was having too much
  9538. * instability during the light setup or during light position changes.
  9539. *
  9540. * Only valid if useContactHardeningShadow is true.
  9541. */
  9542. contactHardeningLightSizeUVRatio: number;
  9543. private _darkness;
  9544. /**
  9545. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9546. * 0 means strongest and 1 would means no shadow.
  9547. * @returns the darkness.
  9548. */
  9549. getDarkness(): number;
  9550. /**
  9551. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9552. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9553. * @returns the shadow generator allowing fluent coding.
  9554. */
  9555. setDarkness(darkness: number): ShadowGenerator;
  9556. private _transparencyShadow;
  9557. /**
  9558. * Sets the ability to have transparent shadow (boolean).
  9559. * @param transparent True if transparent else False
  9560. * @returns the shadow generator allowing fluent coding
  9561. */
  9562. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9563. private _shadowMap;
  9564. private _shadowMap2;
  9565. /**
  9566. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9567. * @returns The render target texture if present otherwise, null
  9568. */
  9569. getShadowMap(): Nullable<RenderTargetTexture>;
  9570. /**
  9571. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9572. * @returns The render target texture if the shadow map is present otherwise, null
  9573. */
  9574. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9575. /**
  9576. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9577. * @param mesh Mesh to add
  9578. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9579. * @returns the Shadow Generator itself
  9580. */
  9581. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9582. /**
  9583. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9584. * @param mesh Mesh to remove
  9585. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9586. * @returns the Shadow Generator itself
  9587. */
  9588. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9589. /**
  9590. * Controls the extent to which the shadows fade out at the edge of the frustum
  9591. * Used only by directionals and spots
  9592. */
  9593. frustumEdgeFalloff: number;
  9594. private _light;
  9595. /**
  9596. * Returns the associated light object.
  9597. * @returns the light generating the shadow
  9598. */
  9599. getLight(): IShadowLight;
  9600. /**
  9601. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9602. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9603. * It might on the other hand introduce peter panning.
  9604. */
  9605. forceBackFacesOnly: boolean;
  9606. private _scene;
  9607. private _lightDirection;
  9608. private _effect;
  9609. private _viewMatrix;
  9610. private _projectionMatrix;
  9611. private _transformMatrix;
  9612. private _cachedPosition;
  9613. private _cachedDirection;
  9614. private _cachedDefines;
  9615. private _currentRenderID;
  9616. private _boxBlurPostprocess;
  9617. private _kernelBlurXPostprocess;
  9618. private _kernelBlurYPostprocess;
  9619. private _blurPostProcesses;
  9620. private _mapSize;
  9621. private _currentFaceIndex;
  9622. private _currentFaceIndexCache;
  9623. private _textureType;
  9624. private _defaultTextureMatrix;
  9625. /** @hidden */
  9626. static _SceneComponentInitialization: (scene: Scene) => void;
  9627. /**
  9628. * Creates a ShadowGenerator object.
  9629. * A ShadowGenerator is the required tool to use the shadows.
  9630. * Each light casting shadows needs to use its own ShadowGenerator.
  9631. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9632. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9633. * @param light The light object generating the shadows.
  9634. * @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.
  9635. */
  9636. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9637. private _initializeGenerator;
  9638. private _initializeShadowMap;
  9639. private _initializeBlurRTTAndPostProcesses;
  9640. private _renderForShadowMap;
  9641. private _renderSubMeshForShadowMap;
  9642. private _applyFilterValues;
  9643. /**
  9644. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9645. * @param onCompiled Callback triggered at the and of the effects compilation
  9646. * @param options Sets of optional options forcing the compilation with different modes
  9647. */
  9648. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9649. useInstances: boolean;
  9650. }>): void;
  9651. /**
  9652. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9653. * @param options Sets of optional options forcing the compilation with different modes
  9654. * @returns A promise that resolves when the compilation completes
  9655. */
  9656. forceCompilationAsync(options?: Partial<{
  9657. useInstances: boolean;
  9658. }>): Promise<void>;
  9659. /**
  9660. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9661. * @param subMesh The submesh we want to render in the shadow map
  9662. * @param useInstances Defines wether will draw in the map using instances
  9663. * @returns true if ready otherwise, false
  9664. */
  9665. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9666. /**
  9667. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9668. * @param defines Defines of the material we want to update
  9669. * @param lightIndex Index of the light in the enabled light list of the material
  9670. */
  9671. prepareDefines(defines: any, lightIndex: number): void;
  9672. /**
  9673. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9674. * defined in the generator but impacting the effect).
  9675. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9676. * @param effect The effect we are binfing the information for
  9677. */
  9678. bindShadowLight(lightIndex: string, effect: Effect): void;
  9679. /**
  9680. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9681. * (eq to shadow prjection matrix * light transform matrix)
  9682. * @returns The transform matrix used to create the shadow map
  9683. */
  9684. getTransformMatrix(): Matrix;
  9685. /**
  9686. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9687. * Cube and 2D textures for instance.
  9688. */
  9689. recreateShadowMap(): void;
  9690. private _disposeBlurPostProcesses;
  9691. private _disposeRTTandPostProcesses;
  9692. /**
  9693. * Disposes the ShadowGenerator.
  9694. * Returns nothing.
  9695. */
  9696. dispose(): void;
  9697. /**
  9698. * Serializes the shadow generator setup to a json object.
  9699. * @returns The serialized JSON object
  9700. */
  9701. serialize(): any;
  9702. /**
  9703. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9704. * @param parsedShadowGenerator The JSON object to parse
  9705. * @param scene The scene to create the shadow map for
  9706. * @returns The parsed shadow generator
  9707. */
  9708. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9709. }
  9710. }
  9711. declare module BABYLON {
  9712. /**
  9713. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9714. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9715. * 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.
  9716. */
  9717. export abstract class Light extends Node {
  9718. /**
  9719. * Falloff Default: light is falling off following the material specification:
  9720. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9721. */
  9722. static readonly FALLOFF_DEFAULT: number;
  9723. /**
  9724. * Falloff Physical: light is falling off following the inverse squared distance law.
  9725. */
  9726. static readonly FALLOFF_PHYSICAL: number;
  9727. /**
  9728. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9729. * to enhance interoperability with other engines.
  9730. */
  9731. static readonly FALLOFF_GLTF: number;
  9732. /**
  9733. * Falloff Standard: light is falling off like in the standard material
  9734. * to enhance interoperability with other materials.
  9735. */
  9736. static readonly FALLOFF_STANDARD: number;
  9737. /**
  9738. * If every light affecting the material is in this lightmapMode,
  9739. * material.lightmapTexture adds or multiplies
  9740. * (depends on material.useLightmapAsShadowmap)
  9741. * after every other light calculations.
  9742. */
  9743. static readonly LIGHTMAP_DEFAULT: number;
  9744. /**
  9745. * material.lightmapTexture as only diffuse lighting from this light
  9746. * adds only specular lighting from this light
  9747. * adds dynamic shadows
  9748. */
  9749. static readonly LIGHTMAP_SPECULAR: number;
  9750. /**
  9751. * material.lightmapTexture as only lighting
  9752. * no light calculation from this light
  9753. * only adds dynamic shadows from this light
  9754. */
  9755. static readonly LIGHTMAP_SHADOWSONLY: number;
  9756. /**
  9757. * Each light type uses the default quantity according to its type:
  9758. * point/spot lights use luminous intensity
  9759. * directional lights use illuminance
  9760. */
  9761. static readonly INTENSITYMODE_AUTOMATIC: number;
  9762. /**
  9763. * lumen (lm)
  9764. */
  9765. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9766. /**
  9767. * candela (lm/sr)
  9768. */
  9769. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9770. /**
  9771. * lux (lm/m^2)
  9772. */
  9773. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9774. /**
  9775. * nit (cd/m^2)
  9776. */
  9777. static readonly INTENSITYMODE_LUMINANCE: number;
  9778. /**
  9779. * Light type const id of the point light.
  9780. */
  9781. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9782. /**
  9783. * Light type const id of the directional light.
  9784. */
  9785. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9786. /**
  9787. * Light type const id of the spot light.
  9788. */
  9789. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9790. /**
  9791. * Light type const id of the hemispheric light.
  9792. */
  9793. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9794. /**
  9795. * Diffuse gives the basic color to an object.
  9796. */
  9797. diffuse: Color3;
  9798. /**
  9799. * Specular produces a highlight color on an object.
  9800. * Note: This is note affecting PBR materials.
  9801. */
  9802. specular: Color3;
  9803. /**
  9804. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9805. * falling off base on range or angle.
  9806. * This can be set to any values in Light.FALLOFF_x.
  9807. *
  9808. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9809. * other types of materials.
  9810. */
  9811. falloffType: number;
  9812. /**
  9813. * Strength of the light.
  9814. * Note: By default it is define in the framework own unit.
  9815. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9816. */
  9817. intensity: number;
  9818. private _range;
  9819. protected _inverseSquaredRange: number;
  9820. /**
  9821. * Defines how far from the source the light is impacting in scene units.
  9822. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9823. */
  9824. /**
  9825. * Defines how far from the source the light is impacting in scene units.
  9826. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9827. */
  9828. range: number;
  9829. /**
  9830. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9831. * of light.
  9832. */
  9833. private _photometricScale;
  9834. private _intensityMode;
  9835. /**
  9836. * Gets the photometric scale used to interpret the intensity.
  9837. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9838. */
  9839. /**
  9840. * Sets the photometric scale used to interpret the intensity.
  9841. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9842. */
  9843. intensityMode: number;
  9844. private _radius;
  9845. /**
  9846. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9847. */
  9848. /**
  9849. * sets the light radius used by PBR Materials to simulate soft area lights.
  9850. */
  9851. radius: number;
  9852. private _renderPriority;
  9853. /**
  9854. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9855. * exceeding the number allowed of the materials.
  9856. */
  9857. renderPriority: number;
  9858. private _shadowEnabled;
  9859. /**
  9860. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9861. * the current shadow generator.
  9862. */
  9863. /**
  9864. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9865. * the current shadow generator.
  9866. */
  9867. shadowEnabled: boolean;
  9868. private _includedOnlyMeshes;
  9869. /**
  9870. * Gets the only meshes impacted by this light.
  9871. */
  9872. /**
  9873. * Sets the only meshes impacted by this light.
  9874. */
  9875. includedOnlyMeshes: AbstractMesh[];
  9876. private _excludedMeshes;
  9877. /**
  9878. * Gets the meshes not impacted by this light.
  9879. */
  9880. /**
  9881. * Sets the meshes not impacted by this light.
  9882. */
  9883. excludedMeshes: AbstractMesh[];
  9884. private _excludeWithLayerMask;
  9885. /**
  9886. * Gets the layer id use to find what meshes are not impacted by the light.
  9887. * Inactive if 0
  9888. */
  9889. /**
  9890. * Sets the layer id use to find what meshes are not impacted by the light.
  9891. * Inactive if 0
  9892. */
  9893. excludeWithLayerMask: number;
  9894. private _includeOnlyWithLayerMask;
  9895. /**
  9896. * Gets the layer id use to find what meshes are impacted by the light.
  9897. * Inactive if 0
  9898. */
  9899. /**
  9900. * Sets the layer id use to find what meshes are impacted by the light.
  9901. * Inactive if 0
  9902. */
  9903. includeOnlyWithLayerMask: number;
  9904. private _lightmapMode;
  9905. /**
  9906. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9907. */
  9908. /**
  9909. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9910. */
  9911. lightmapMode: number;
  9912. /**
  9913. * Shadow generator associted to the light.
  9914. * @hidden Internal use only.
  9915. */
  9916. _shadowGenerator: Nullable<IShadowGenerator>;
  9917. /**
  9918. * @hidden Internal use only.
  9919. */
  9920. _excludedMeshesIds: string[];
  9921. /**
  9922. * @hidden Internal use only.
  9923. */
  9924. _includedOnlyMeshesIds: string[];
  9925. /**
  9926. * The current light unifom buffer.
  9927. * @hidden Internal use only.
  9928. */
  9929. _uniformBuffer: UniformBuffer;
  9930. /**
  9931. * Creates a Light object in the scene.
  9932. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9933. * @param name The firendly name of the light
  9934. * @param scene The scene the light belongs too
  9935. */
  9936. constructor(name: string, scene: Scene);
  9937. protected abstract _buildUniformLayout(): void;
  9938. /**
  9939. * Sets the passed Effect "effect" with the Light information.
  9940. * @param effect The effect to update
  9941. * @param lightIndex The index of the light in the effect to update
  9942. * @returns The light
  9943. */
  9944. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9945. /**
  9946. * Returns the string "Light".
  9947. * @returns the class name
  9948. */
  9949. getClassName(): string;
  9950. /** @hidden */
  9951. readonly _isLight: boolean;
  9952. /**
  9953. * Converts the light information to a readable string for debug purpose.
  9954. * @param fullDetails Supports for multiple levels of logging within scene loading
  9955. * @returns the human readable light info
  9956. */
  9957. toString(fullDetails?: boolean): string;
  9958. /** @hidden */
  9959. protected _syncParentEnabledState(): void;
  9960. /**
  9961. * Set the enabled state of this node.
  9962. * @param value - the new enabled state
  9963. */
  9964. setEnabled(value: boolean): void;
  9965. /**
  9966. * Returns the Light associated shadow generator if any.
  9967. * @return the associated shadow generator.
  9968. */
  9969. getShadowGenerator(): Nullable<IShadowGenerator>;
  9970. /**
  9971. * Returns a Vector3, the absolute light position in the World.
  9972. * @returns the world space position of the light
  9973. */
  9974. getAbsolutePosition(): Vector3;
  9975. /**
  9976. * Specifies if the light will affect the passed mesh.
  9977. * @param mesh The mesh to test against the light
  9978. * @return true the mesh is affected otherwise, false.
  9979. */
  9980. canAffectMesh(mesh: AbstractMesh): boolean;
  9981. /**
  9982. * Sort function to order lights for rendering.
  9983. * @param a First Light object to compare to second.
  9984. * @param b Second Light object to compare first.
  9985. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9986. */
  9987. static CompareLightsPriority(a: Light, b: Light): number;
  9988. /**
  9989. * Releases resources associated with this node.
  9990. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9991. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9992. */
  9993. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9994. /**
  9995. * Returns the light type ID (integer).
  9996. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9997. */
  9998. getTypeID(): number;
  9999. /**
  10000. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10001. * @returns the scaled intensity in intensity mode unit
  10002. */
  10003. getScaledIntensity(): number;
  10004. /**
  10005. * Returns a new Light object, named "name", from the current one.
  10006. * @param name The name of the cloned light
  10007. * @returns the new created light
  10008. */
  10009. clone(name: string): Nullable<Light>;
  10010. /**
  10011. * Serializes the current light into a Serialization object.
  10012. * @returns the serialized object.
  10013. */
  10014. serialize(): any;
  10015. /**
  10016. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10017. * This new light is named "name" and added to the passed scene.
  10018. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10019. * @param name The friendly name of the light
  10020. * @param scene The scene the new light will belong to
  10021. * @returns the constructor function
  10022. */
  10023. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10024. /**
  10025. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10026. * @param parsedLight The JSON representation of the light
  10027. * @param scene The scene to create the parsed light in
  10028. * @returns the created light after parsing
  10029. */
  10030. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10031. private _hookArrayForExcluded;
  10032. private _hookArrayForIncludedOnly;
  10033. private _resyncMeshes;
  10034. /**
  10035. * Forces the meshes to update their light related information in their rendering used effects
  10036. * @hidden Internal Use Only
  10037. */
  10038. _markMeshesAsLightDirty(): void;
  10039. /**
  10040. * Recomputes the cached photometric scale if needed.
  10041. */
  10042. private _computePhotometricScale;
  10043. /**
  10044. * Returns the Photometric Scale according to the light type and intensity mode.
  10045. */
  10046. private _getPhotometricScale;
  10047. /**
  10048. * Reorder the light in the scene according to their defined priority.
  10049. * @hidden Internal Use Only
  10050. */
  10051. _reorderLightsInScene(): void;
  10052. /**
  10053. * Prepares the list of defines specific to the light type.
  10054. * @param defines the list of defines
  10055. * @param lightIndex defines the index of the light for the effect
  10056. */
  10057. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10058. }
  10059. }
  10060. declare module BABYLON {
  10061. /**
  10062. * Interface used to define Action
  10063. */
  10064. export interface IAction {
  10065. /**
  10066. * Trigger for the action
  10067. */
  10068. trigger: number;
  10069. /** the trigger, with or without parameters, for the action */
  10070. triggerOptions: any;
  10071. /**
  10072. * Gets the trigger parameters
  10073. * @returns the trigger parameters
  10074. */
  10075. getTriggerParameter(): any;
  10076. /**
  10077. * Internal only - executes current action event
  10078. * @hidden
  10079. */
  10080. _executeCurrent(evt?: ActionEvent): void;
  10081. /**
  10082. * Serialize placeholder for child classes
  10083. * @param parent of child
  10084. * @returns the serialized object
  10085. */
  10086. serialize(parent: any): any;
  10087. }
  10088. /**
  10089. * The action to be carried out following a trigger
  10090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10091. */
  10092. export class Action implements IAction {
  10093. /** the trigger, with or without parameters, for the action */
  10094. triggerOptions: any;
  10095. /**
  10096. * Trigger for the action
  10097. */
  10098. trigger: number;
  10099. /**
  10100. * Internal only - manager for action
  10101. * @hidden
  10102. */
  10103. _actionManager: ActionManager;
  10104. private _nextActiveAction;
  10105. private _child;
  10106. private _condition?;
  10107. private _triggerParameter;
  10108. /**
  10109. * An event triggered prior to action being executed.
  10110. */
  10111. onBeforeExecuteObservable: Observable<Action>;
  10112. /**
  10113. * Creates a new Action
  10114. * @param triggerOptions the trigger, with or without parameters, for the action
  10115. * @param condition an optional determinant of action
  10116. */
  10117. constructor(
  10118. /** the trigger, with or without parameters, for the action */
  10119. triggerOptions: any, condition?: Condition);
  10120. /**
  10121. * Internal only
  10122. * @hidden
  10123. */
  10124. _prepare(): void;
  10125. /**
  10126. * Gets the trigger parameters
  10127. * @returns the trigger parameters
  10128. */
  10129. getTriggerParameter(): any;
  10130. /**
  10131. * Internal only - executes current action event
  10132. * @hidden
  10133. */
  10134. _executeCurrent(evt?: ActionEvent): void;
  10135. /**
  10136. * Execute placeholder for child classes
  10137. * @param evt optional action event
  10138. */
  10139. execute(evt?: ActionEvent): void;
  10140. /**
  10141. * Skips to next active action
  10142. */
  10143. skipToNextActiveAction(): void;
  10144. /**
  10145. * Adds action to chain of actions, may be a DoNothingAction
  10146. * @param action defines the next action to execute
  10147. * @returns The action passed in
  10148. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10149. */
  10150. then(action: Action): Action;
  10151. /**
  10152. * Internal only
  10153. * @hidden
  10154. */
  10155. _getProperty(propertyPath: string): string;
  10156. /**
  10157. * Internal only
  10158. * @hidden
  10159. */
  10160. _getEffectiveTarget(target: any, propertyPath: string): any;
  10161. /**
  10162. * Serialize placeholder for child classes
  10163. * @param parent of child
  10164. * @returns the serialized object
  10165. */
  10166. serialize(parent: any): any;
  10167. /**
  10168. * Internal only called by serialize
  10169. * @hidden
  10170. */
  10171. protected _serialize(serializedAction: any, parent?: any): any;
  10172. /**
  10173. * Internal only
  10174. * @hidden
  10175. */
  10176. static _SerializeValueAsString: (value: any) => string;
  10177. /**
  10178. * Internal only
  10179. * @hidden
  10180. */
  10181. static _GetTargetProperty: (target: Scene | Node) => {
  10182. name: string;
  10183. targetType: string;
  10184. value: string;
  10185. };
  10186. }
  10187. }
  10188. declare module BABYLON {
  10189. /**
  10190. * A Condition applied to an Action
  10191. */
  10192. export class Condition {
  10193. /**
  10194. * Internal only - manager for action
  10195. * @hidden
  10196. */
  10197. _actionManager: ActionManager;
  10198. /**
  10199. * Internal only
  10200. * @hidden
  10201. */
  10202. _evaluationId: number;
  10203. /**
  10204. * Internal only
  10205. * @hidden
  10206. */
  10207. _currentResult: boolean;
  10208. /**
  10209. * Creates a new Condition
  10210. * @param actionManager the manager of the action the condition is applied to
  10211. */
  10212. constructor(actionManager: ActionManager);
  10213. /**
  10214. * Check if the current condition is valid
  10215. * @returns a boolean
  10216. */
  10217. isValid(): boolean;
  10218. /**
  10219. * Internal only
  10220. * @hidden
  10221. */
  10222. _getProperty(propertyPath: string): string;
  10223. /**
  10224. * Internal only
  10225. * @hidden
  10226. */
  10227. _getEffectiveTarget(target: any, propertyPath: string): any;
  10228. /**
  10229. * Serialize placeholder for child classes
  10230. * @returns the serialized object
  10231. */
  10232. serialize(): any;
  10233. /**
  10234. * Internal only
  10235. * @hidden
  10236. */
  10237. protected _serialize(serializedCondition: any): any;
  10238. }
  10239. /**
  10240. * Defines specific conditional operators as extensions of Condition
  10241. */
  10242. export class ValueCondition extends Condition {
  10243. /** path to specify the property of the target the conditional operator uses */
  10244. propertyPath: string;
  10245. /** the value compared by the conditional operator against the current value of the property */
  10246. value: any;
  10247. /** the conditional operator, default ValueCondition.IsEqual */
  10248. operator: number;
  10249. /**
  10250. * Internal only
  10251. * @hidden
  10252. */
  10253. private static _IsEqual;
  10254. /**
  10255. * Internal only
  10256. * @hidden
  10257. */
  10258. private static _IsDifferent;
  10259. /**
  10260. * Internal only
  10261. * @hidden
  10262. */
  10263. private static _IsGreater;
  10264. /**
  10265. * Internal only
  10266. * @hidden
  10267. */
  10268. private static _IsLesser;
  10269. /**
  10270. * returns the number for IsEqual
  10271. */
  10272. static readonly IsEqual: number;
  10273. /**
  10274. * Returns the number for IsDifferent
  10275. */
  10276. static readonly IsDifferent: number;
  10277. /**
  10278. * Returns the number for IsGreater
  10279. */
  10280. static readonly IsGreater: number;
  10281. /**
  10282. * Returns the number for IsLesser
  10283. */
  10284. static readonly IsLesser: number;
  10285. /**
  10286. * Internal only The action manager for the condition
  10287. * @hidden
  10288. */
  10289. _actionManager: ActionManager;
  10290. /**
  10291. * Internal only
  10292. * @hidden
  10293. */
  10294. private _target;
  10295. /**
  10296. * Internal only
  10297. * @hidden
  10298. */
  10299. private _effectiveTarget;
  10300. /**
  10301. * Internal only
  10302. * @hidden
  10303. */
  10304. private _property;
  10305. /**
  10306. * Creates a new ValueCondition
  10307. * @param actionManager manager for the action the condition applies to
  10308. * @param target for the action
  10309. * @param propertyPath path to specify the property of the target the conditional operator uses
  10310. * @param value the value compared by the conditional operator against the current value of the property
  10311. * @param operator the conditional operator, default ValueCondition.IsEqual
  10312. */
  10313. constructor(actionManager: ActionManager, target: any,
  10314. /** path to specify the property of the target the conditional operator uses */
  10315. propertyPath: string,
  10316. /** the value compared by the conditional operator against the current value of the property */
  10317. value: any,
  10318. /** the conditional operator, default ValueCondition.IsEqual */
  10319. operator?: number);
  10320. /**
  10321. * Compares the given value with the property value for the specified conditional operator
  10322. * @returns the result of the comparison
  10323. */
  10324. isValid(): boolean;
  10325. /**
  10326. * Serialize the ValueCondition into a JSON compatible object
  10327. * @returns serialization object
  10328. */
  10329. serialize(): any;
  10330. /**
  10331. * Gets the name of the conditional operator for the ValueCondition
  10332. * @param operator the conditional operator
  10333. * @returns the name
  10334. */
  10335. static GetOperatorName(operator: number): string;
  10336. }
  10337. /**
  10338. * Defines a predicate condition as an extension of Condition
  10339. */
  10340. export class PredicateCondition extends Condition {
  10341. /** defines the predicate function used to validate the condition */
  10342. predicate: () => boolean;
  10343. /**
  10344. * Internal only - manager for action
  10345. * @hidden
  10346. */
  10347. _actionManager: ActionManager;
  10348. /**
  10349. * Creates a new PredicateCondition
  10350. * @param actionManager manager for the action the condition applies to
  10351. * @param predicate defines the predicate function used to validate the condition
  10352. */
  10353. constructor(actionManager: ActionManager,
  10354. /** defines the predicate function used to validate the condition */
  10355. predicate: () => boolean);
  10356. /**
  10357. * @returns the validity of the predicate condition
  10358. */
  10359. isValid(): boolean;
  10360. }
  10361. /**
  10362. * Defines a state condition as an extension of Condition
  10363. */
  10364. export class StateCondition extends Condition {
  10365. /** Value to compare with target state */
  10366. value: string;
  10367. /**
  10368. * Internal only - manager for action
  10369. * @hidden
  10370. */
  10371. _actionManager: ActionManager;
  10372. /**
  10373. * Internal only
  10374. * @hidden
  10375. */
  10376. private _target;
  10377. /**
  10378. * Creates a new StateCondition
  10379. * @param actionManager manager for the action the condition applies to
  10380. * @param target of the condition
  10381. * @param value to compare with target state
  10382. */
  10383. constructor(actionManager: ActionManager, target: any,
  10384. /** Value to compare with target state */
  10385. value: string);
  10386. /**
  10387. * Gets a boolean indicating if the current condition is met
  10388. * @returns the validity of the state
  10389. */
  10390. isValid(): boolean;
  10391. /**
  10392. * Serialize the StateCondition into a JSON compatible object
  10393. * @returns serialization object
  10394. */
  10395. serialize(): any;
  10396. }
  10397. }
  10398. declare module BABYLON {
  10399. /**
  10400. * This defines an action responsible to toggle a boolean once triggered.
  10401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10402. */
  10403. export class SwitchBooleanAction extends Action {
  10404. /**
  10405. * The path to the boolean property in the target object
  10406. */
  10407. propertyPath: string;
  10408. private _target;
  10409. private _effectiveTarget;
  10410. private _property;
  10411. /**
  10412. * Instantiate the action
  10413. * @param triggerOptions defines the trigger options
  10414. * @param target defines the object containing the boolean
  10415. * @param propertyPath defines the path to the boolean property in the target object
  10416. * @param condition defines the trigger related conditions
  10417. */
  10418. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10419. /** @hidden */
  10420. _prepare(): void;
  10421. /**
  10422. * Execute the action toggle the boolean value.
  10423. */
  10424. execute(): void;
  10425. /**
  10426. * Serializes the actions and its related information.
  10427. * @param parent defines the object to serialize in
  10428. * @returns the serialized object
  10429. */
  10430. serialize(parent: any): any;
  10431. }
  10432. /**
  10433. * This defines an action responsible to set a the state field of the target
  10434. * to a desired value once triggered.
  10435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10436. */
  10437. export class SetStateAction extends Action {
  10438. /**
  10439. * The value to store in the state field.
  10440. */
  10441. value: string;
  10442. private _target;
  10443. /**
  10444. * Instantiate the action
  10445. * @param triggerOptions defines the trigger options
  10446. * @param target defines the object containing the state property
  10447. * @param value defines the value to store in the state field
  10448. * @param condition defines the trigger related conditions
  10449. */
  10450. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10451. /**
  10452. * Execute the action and store the value on the target state property.
  10453. */
  10454. execute(): void;
  10455. /**
  10456. * Serializes the actions and its related information.
  10457. * @param parent defines the object to serialize in
  10458. * @returns the serialized object
  10459. */
  10460. serialize(parent: any): any;
  10461. }
  10462. /**
  10463. * This defines an action responsible to set a property of the target
  10464. * to a desired value once triggered.
  10465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10466. */
  10467. export class SetValueAction extends Action {
  10468. /**
  10469. * The path of the property to set in the target.
  10470. */
  10471. propertyPath: string;
  10472. /**
  10473. * The value to set in the property
  10474. */
  10475. value: any;
  10476. private _target;
  10477. private _effectiveTarget;
  10478. private _property;
  10479. /**
  10480. * Instantiate the action
  10481. * @param triggerOptions defines the trigger options
  10482. * @param target defines the object containing the property
  10483. * @param propertyPath defines the path of the property to set in the target
  10484. * @param value defines the value to set in the property
  10485. * @param condition defines the trigger related conditions
  10486. */
  10487. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10488. /** @hidden */
  10489. _prepare(): void;
  10490. /**
  10491. * Execute the action and set the targetted property to the desired value.
  10492. */
  10493. execute(): void;
  10494. /**
  10495. * Serializes the actions and its related information.
  10496. * @param parent defines the object to serialize in
  10497. * @returns the serialized object
  10498. */
  10499. serialize(parent: any): any;
  10500. }
  10501. /**
  10502. * This defines an action responsible to increment the target value
  10503. * to a desired value once triggered.
  10504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10505. */
  10506. export class IncrementValueAction extends Action {
  10507. /**
  10508. * The path of the property to increment in the target.
  10509. */
  10510. propertyPath: string;
  10511. /**
  10512. * The value we should increment the property by.
  10513. */
  10514. value: any;
  10515. private _target;
  10516. private _effectiveTarget;
  10517. private _property;
  10518. /**
  10519. * Instantiate the action
  10520. * @param triggerOptions defines the trigger options
  10521. * @param target defines the object containing the property
  10522. * @param propertyPath defines the path of the property to increment in the target
  10523. * @param value defines the value value we should increment the property by
  10524. * @param condition defines the trigger related conditions
  10525. */
  10526. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10527. /** @hidden */
  10528. _prepare(): void;
  10529. /**
  10530. * Execute the action and increment the target of the value amount.
  10531. */
  10532. execute(): void;
  10533. /**
  10534. * Serializes the actions and its related information.
  10535. * @param parent defines the object to serialize in
  10536. * @returns the serialized object
  10537. */
  10538. serialize(parent: any): any;
  10539. }
  10540. /**
  10541. * This defines an action responsible to start an animation once triggered.
  10542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10543. */
  10544. export class PlayAnimationAction extends Action {
  10545. /**
  10546. * Where the animation should start (animation frame)
  10547. */
  10548. from: number;
  10549. /**
  10550. * Where the animation should stop (animation frame)
  10551. */
  10552. to: number;
  10553. /**
  10554. * Define if the animation should loop or stop after the first play.
  10555. */
  10556. loop?: boolean;
  10557. private _target;
  10558. /**
  10559. * Instantiate the action
  10560. * @param triggerOptions defines the trigger options
  10561. * @param target defines the target animation or animation name
  10562. * @param from defines from where the animation should start (animation frame)
  10563. * @param end defines where the animation should stop (animation frame)
  10564. * @param loop defines if the animation should loop or stop after the first play
  10565. * @param condition defines the trigger related conditions
  10566. */
  10567. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10568. /** @hidden */
  10569. _prepare(): void;
  10570. /**
  10571. * Execute the action and play the animation.
  10572. */
  10573. execute(): void;
  10574. /**
  10575. * Serializes the actions and its related information.
  10576. * @param parent defines the object to serialize in
  10577. * @returns the serialized object
  10578. */
  10579. serialize(parent: any): any;
  10580. }
  10581. /**
  10582. * This defines an action responsible to stop an animation once triggered.
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10584. */
  10585. export class StopAnimationAction extends Action {
  10586. private _target;
  10587. /**
  10588. * Instantiate the action
  10589. * @param triggerOptions defines the trigger options
  10590. * @param target defines the target animation or animation name
  10591. * @param condition defines the trigger related conditions
  10592. */
  10593. constructor(triggerOptions: any, target: any, condition?: Condition);
  10594. /** @hidden */
  10595. _prepare(): void;
  10596. /**
  10597. * Execute the action and stop the animation.
  10598. */
  10599. execute(): void;
  10600. /**
  10601. * Serializes the actions and its related information.
  10602. * @param parent defines the object to serialize in
  10603. * @returns the serialized object
  10604. */
  10605. serialize(parent: any): any;
  10606. }
  10607. /**
  10608. * This defines an action responsible that does nothing once triggered.
  10609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10610. */
  10611. export class DoNothingAction extends Action {
  10612. /**
  10613. * Instantiate the action
  10614. * @param triggerOptions defines the trigger options
  10615. * @param condition defines the trigger related conditions
  10616. */
  10617. constructor(triggerOptions?: any, condition?: Condition);
  10618. /**
  10619. * Execute the action and do nothing.
  10620. */
  10621. execute(): void;
  10622. /**
  10623. * Serializes the actions and its related information.
  10624. * @param parent defines the object to serialize in
  10625. * @returns the serialized object
  10626. */
  10627. serialize(parent: any): any;
  10628. }
  10629. /**
  10630. * This defines an action responsible to trigger several actions once triggered.
  10631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10632. */
  10633. export class CombineAction extends Action {
  10634. /**
  10635. * The list of aggregated animations to run.
  10636. */
  10637. children: Action[];
  10638. /**
  10639. * Instantiate the action
  10640. * @param triggerOptions defines the trigger options
  10641. * @param children defines the list of aggregated animations to run
  10642. * @param condition defines the trigger related conditions
  10643. */
  10644. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10645. /** @hidden */
  10646. _prepare(): void;
  10647. /**
  10648. * Execute the action and executes all the aggregated actions.
  10649. */
  10650. execute(evt: ActionEvent): void;
  10651. /**
  10652. * Serializes the actions and its related information.
  10653. * @param parent defines the object to serialize in
  10654. * @returns the serialized object
  10655. */
  10656. serialize(parent: any): any;
  10657. }
  10658. /**
  10659. * This defines an action responsible to run code (external event) once triggered.
  10660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10661. */
  10662. export class ExecuteCodeAction extends Action {
  10663. /**
  10664. * The callback function to run.
  10665. */
  10666. func: (evt: ActionEvent) => void;
  10667. /**
  10668. * Instantiate the action
  10669. * @param triggerOptions defines the trigger options
  10670. * @param func defines the callback function to run
  10671. * @param condition defines the trigger related conditions
  10672. */
  10673. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10674. /**
  10675. * Execute the action and run the attached code.
  10676. */
  10677. execute(evt: ActionEvent): void;
  10678. }
  10679. /**
  10680. * This defines an action responsible to set the parent property of the target once triggered.
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class SetParentAction extends Action {
  10684. private _parent;
  10685. private _target;
  10686. /**
  10687. * Instantiate the action
  10688. * @param triggerOptions defines the trigger options
  10689. * @param target defines the target containing the parent property
  10690. * @param parent defines from where the animation should start (animation frame)
  10691. * @param condition defines the trigger related conditions
  10692. */
  10693. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10694. /** @hidden */
  10695. _prepare(): void;
  10696. /**
  10697. * Execute the action and set the parent property.
  10698. */
  10699. execute(): void;
  10700. /**
  10701. * Serializes the actions and its related information.
  10702. * @param parent defines the object to serialize in
  10703. * @returns the serialized object
  10704. */
  10705. serialize(parent: any): any;
  10706. }
  10707. }
  10708. declare module BABYLON {
  10709. /**
  10710. * Abstract class used to decouple action Manager from scene and meshes.
  10711. * Do not instantiate.
  10712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10713. */
  10714. export abstract class AbstractActionManager implements IDisposable {
  10715. /** Gets the list of active triggers */
  10716. static Triggers: {
  10717. [key: string]: number;
  10718. };
  10719. /** Gets the cursor to use when hovering items */
  10720. hoverCursor: string;
  10721. /** Gets the list of actions */
  10722. actions: IAction[];
  10723. /**
  10724. * Releases all associated resources
  10725. */
  10726. abstract dispose(): void;
  10727. /**
  10728. * Does this action manager has pointer triggers
  10729. */
  10730. abstract readonly hasPointerTriggers: boolean;
  10731. /**
  10732. * Does this action manager has pick triggers
  10733. */
  10734. abstract readonly hasPickTriggers: boolean;
  10735. /**
  10736. * Process a specific trigger
  10737. * @param trigger defines the trigger to process
  10738. * @param evt defines the event details to be processed
  10739. */
  10740. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  10741. /**
  10742. * Does this action manager handles actions of any of the given triggers
  10743. * @param triggers defines the triggers to be tested
  10744. * @return a boolean indicating whether one (or more) of the triggers is handled
  10745. */
  10746. abstract hasSpecificTriggers(triggers: number[]): boolean;
  10747. /**
  10748. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10749. * speed.
  10750. * @param triggerA defines the trigger to be tested
  10751. * @param triggerB defines the trigger to be tested
  10752. * @return a boolean indicating whether one (or more) of the triggers is handled
  10753. */
  10754. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10755. /**
  10756. * Does this action manager handles actions of a given trigger
  10757. * @param trigger defines the trigger to be tested
  10758. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10759. * @return whether the trigger is handled
  10760. */
  10761. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10762. /**
  10763. * Serialize this manager to a JSON object
  10764. * @param name defines the property name to store this manager
  10765. * @returns a JSON representation of this manager
  10766. */
  10767. abstract serialize(name: string): any;
  10768. /**
  10769. * Does exist one action manager with at least one trigger
  10770. **/
  10771. static readonly HasTriggers: boolean;
  10772. /**
  10773. * Does exist one action manager with at least one pick trigger
  10774. **/
  10775. static readonly HasPickTriggers: boolean;
  10776. /**
  10777. * Does exist one action manager that handles actions of a given trigger
  10778. * @param trigger defines the trigger to be tested
  10779. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  10780. **/
  10781. static HasSpecificTrigger(trigger: number): boolean;
  10782. }
  10783. }
  10784. declare module BABYLON {
  10785. /**
  10786. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10787. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10789. */
  10790. export class ActionManager extends AbstractActionManager {
  10791. /**
  10792. * Nothing
  10793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10794. */
  10795. static readonly NothingTrigger: number;
  10796. /**
  10797. * On pick
  10798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10799. */
  10800. static readonly OnPickTrigger: number;
  10801. /**
  10802. * On left pick
  10803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10804. */
  10805. static readonly OnLeftPickTrigger: number;
  10806. /**
  10807. * On right pick
  10808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10809. */
  10810. static readonly OnRightPickTrigger: number;
  10811. /**
  10812. * On center pick
  10813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10814. */
  10815. static readonly OnCenterPickTrigger: number;
  10816. /**
  10817. * On pick down
  10818. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10819. */
  10820. static readonly OnPickDownTrigger: number;
  10821. /**
  10822. * On double pick
  10823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10824. */
  10825. static readonly OnDoublePickTrigger: number;
  10826. /**
  10827. * On pick up
  10828. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10829. */
  10830. static readonly OnPickUpTrigger: number;
  10831. /**
  10832. * On pick out.
  10833. * This trigger will only be raised if you also declared a OnPickDown
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10835. */
  10836. static readonly OnPickOutTrigger: number;
  10837. /**
  10838. * On long press
  10839. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10840. */
  10841. static readonly OnLongPressTrigger: number;
  10842. /**
  10843. * On pointer over
  10844. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10845. */
  10846. static readonly OnPointerOverTrigger: number;
  10847. /**
  10848. * On pointer out
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10850. */
  10851. static readonly OnPointerOutTrigger: number;
  10852. /**
  10853. * On every frame
  10854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10855. */
  10856. static readonly OnEveryFrameTrigger: number;
  10857. /**
  10858. * On intersection enter
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10860. */
  10861. static readonly OnIntersectionEnterTrigger: number;
  10862. /**
  10863. * On intersection exit
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10865. */
  10866. static readonly OnIntersectionExitTrigger: number;
  10867. /**
  10868. * On key down
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10870. */
  10871. static readonly OnKeyDownTrigger: number;
  10872. /**
  10873. * On key up
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnKeyUpTrigger: number;
  10877. private _scene;
  10878. /**
  10879. * Creates a new action manager
  10880. * @param scene defines the hosting scene
  10881. */
  10882. constructor(scene: Scene);
  10883. /**
  10884. * Releases all associated resources
  10885. */
  10886. dispose(): void;
  10887. /**
  10888. * Gets hosting scene
  10889. * @returns the hosting scene
  10890. */
  10891. getScene(): Scene;
  10892. /**
  10893. * Does this action manager handles actions of any of the given triggers
  10894. * @param triggers defines the triggers to be tested
  10895. * @return a boolean indicating whether one (or more) of the triggers is handled
  10896. */
  10897. hasSpecificTriggers(triggers: number[]): boolean;
  10898. /**
  10899. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10900. * speed.
  10901. * @param triggerA defines the trigger to be tested
  10902. * @param triggerB defines the trigger to be tested
  10903. * @return a boolean indicating whether one (or more) of the triggers is handled
  10904. */
  10905. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10906. /**
  10907. * Does this action manager handles actions of a given trigger
  10908. * @param trigger defines the trigger to be tested
  10909. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10910. * @return whether the trigger is handled
  10911. */
  10912. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10913. /**
  10914. * Does this action manager has pointer triggers
  10915. */
  10916. readonly hasPointerTriggers: boolean;
  10917. /**
  10918. * Does this action manager has pick triggers
  10919. */
  10920. readonly hasPickTriggers: boolean;
  10921. /**
  10922. * Registers an action to this action manager
  10923. * @param action defines the action to be registered
  10924. * @return the action amended (prepared) after registration
  10925. */
  10926. registerAction(action: Action): Nullable<Action>;
  10927. /**
  10928. * Unregisters an action to this action manager
  10929. * @param action defines the action to be unregistered
  10930. * @return a boolean indicating whether the action has been unregistered
  10931. */
  10932. unregisterAction(action: Action): Boolean;
  10933. /**
  10934. * Process a specific trigger
  10935. * @param trigger defines the trigger to process
  10936. * @param evt defines the event details to be processed
  10937. */
  10938. processTrigger(trigger: number, evt?: IActionEvent): void;
  10939. /** @hidden */
  10940. _getEffectiveTarget(target: any, propertyPath: string): any;
  10941. /** @hidden */
  10942. _getProperty(propertyPath: string): string;
  10943. /**
  10944. * Serialize this manager to a JSON object
  10945. * @param name defines the property name to store this manager
  10946. * @returns a JSON representation of this manager
  10947. */
  10948. serialize(name: string): any;
  10949. /**
  10950. * Creates a new ActionManager from a JSON data
  10951. * @param parsedActions defines the JSON data to read from
  10952. * @param object defines the hosting mesh
  10953. * @param scene defines the hosting scene
  10954. */
  10955. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10956. /**
  10957. * Get a trigger name by index
  10958. * @param trigger defines the trigger index
  10959. * @returns a trigger name
  10960. */
  10961. static GetTriggerName(trigger: number): string;
  10962. }
  10963. }
  10964. declare module BABYLON {
  10965. /**
  10966. * Class representing a ray with position and direction
  10967. */
  10968. export class Ray {
  10969. /** origin point */
  10970. origin: Vector3;
  10971. /** direction */
  10972. direction: Vector3;
  10973. /** length of the ray */
  10974. length: number;
  10975. private static readonly TmpVector3;
  10976. private _tmpRay;
  10977. /**
  10978. * Creates a new ray
  10979. * @param origin origin point
  10980. * @param direction direction
  10981. * @param length length of the ray
  10982. */
  10983. constructor(
  10984. /** origin point */
  10985. origin: Vector3,
  10986. /** direction */
  10987. direction: Vector3,
  10988. /** length of the ray */
  10989. length?: number);
  10990. /**
  10991. * Checks if the ray intersects a box
  10992. * @param minimum bound of the box
  10993. * @param maximum bound of the box
  10994. * @param intersectionTreshold extra extend to be added to the box in all direction
  10995. * @returns if the box was hit
  10996. */
  10997. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10998. /**
  10999. * Checks if the ray intersects a box
  11000. * @param box the bounding box to check
  11001. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11002. * @returns if the box was hit
  11003. */
  11004. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11005. /**
  11006. * If the ray hits a sphere
  11007. * @param sphere the bounding sphere to check
  11008. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11009. * @returns true if it hits the sphere
  11010. */
  11011. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11012. /**
  11013. * If the ray hits a triange
  11014. * @param vertex0 triangle vertex
  11015. * @param vertex1 triangle vertex
  11016. * @param vertex2 triangle vertex
  11017. * @returns intersection information if hit
  11018. */
  11019. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11020. /**
  11021. * Checks if ray intersects a plane
  11022. * @param plane the plane to check
  11023. * @returns the distance away it was hit
  11024. */
  11025. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11026. /**
  11027. * Checks if ray intersects a mesh
  11028. * @param mesh the mesh to check
  11029. * @param fastCheck if only the bounding box should checked
  11030. * @returns picking info of the intersecton
  11031. */
  11032. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11033. /**
  11034. * Checks if ray intersects a mesh
  11035. * @param meshes the meshes to check
  11036. * @param fastCheck if only the bounding box should checked
  11037. * @param results array to store result in
  11038. * @returns Array of picking infos
  11039. */
  11040. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11041. private _comparePickingInfo;
  11042. private static smallnum;
  11043. private static rayl;
  11044. /**
  11045. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11046. * @param sega the first point of the segment to test the intersection against
  11047. * @param segb the second point of the segment to test the intersection against
  11048. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11049. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11050. */
  11051. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11052. /**
  11053. * Update the ray from viewport position
  11054. * @param x position
  11055. * @param y y position
  11056. * @param viewportWidth viewport width
  11057. * @param viewportHeight viewport height
  11058. * @param world world matrix
  11059. * @param view view matrix
  11060. * @param projection projection matrix
  11061. * @returns this ray updated
  11062. */
  11063. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11064. /**
  11065. * Creates a ray with origin and direction of 0,0,0
  11066. * @returns the new ray
  11067. */
  11068. static Zero(): Ray;
  11069. /**
  11070. * Creates a new ray from screen space and viewport
  11071. * @param x position
  11072. * @param y y position
  11073. * @param viewportWidth viewport width
  11074. * @param viewportHeight viewport height
  11075. * @param world world matrix
  11076. * @param view view matrix
  11077. * @param projection projection matrix
  11078. * @returns new ray
  11079. */
  11080. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11081. /**
  11082. * 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
  11083. * transformed to the given world matrix.
  11084. * @param origin The origin point
  11085. * @param end The end point
  11086. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11087. * @returns the new ray
  11088. */
  11089. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11090. /**
  11091. * Transforms a ray by a matrix
  11092. * @param ray ray to transform
  11093. * @param matrix matrix to apply
  11094. * @returns the resulting new ray
  11095. */
  11096. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11097. /**
  11098. * Transforms a ray by a matrix
  11099. * @param ray ray to transform
  11100. * @param matrix matrix to apply
  11101. * @param result ray to store result in
  11102. */
  11103. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11104. /**
  11105. * Unproject a ray from screen space to object space
  11106. * @param sourceX defines the screen space x coordinate to use
  11107. * @param sourceY defines the screen space y coordinate to use
  11108. * @param viewportWidth defines the current width of the viewport
  11109. * @param viewportHeight defines the current height of the viewport
  11110. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11111. * @param view defines the view matrix to use
  11112. * @param projection defines the projection matrix to use
  11113. */
  11114. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11115. }
  11116. interface Scene {
  11117. /** @hidden */
  11118. _tempPickingRay: Nullable<Ray>;
  11119. /** @hidden */
  11120. _cachedRayForTransform: Ray;
  11121. /** @hidden */
  11122. _pickWithRayInverseMatrix: Matrix;
  11123. /** @hidden */
  11124. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11125. /** @hidden */
  11126. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  11127. }
  11128. }
  11129. declare module BABYLON {
  11130. /**
  11131. * Groups all the scene component constants in one place to ease maintenance.
  11132. * @hidden
  11133. */
  11134. export class SceneComponentConstants {
  11135. static readonly NAME_EFFECTLAYER: string;
  11136. static readonly NAME_LAYER: string;
  11137. static readonly NAME_LENSFLARESYSTEM: string;
  11138. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11139. static readonly NAME_PARTICLESYSTEM: string;
  11140. static readonly NAME_GAMEPAD: string;
  11141. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11142. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11143. static readonly NAME_DEPTHRENDERER: string;
  11144. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11145. static readonly NAME_SPRITE: string;
  11146. static readonly NAME_OUTLINERENDERER: string;
  11147. static readonly NAME_PROCEDURALTEXTURE: string;
  11148. static readonly NAME_SHADOWGENERATOR: string;
  11149. static readonly NAME_OCTREE: string;
  11150. static readonly NAME_PHYSICSENGINE: string;
  11151. static readonly NAME_AUDIO: string;
  11152. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11153. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11154. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11155. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11156. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11157. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11158. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11159. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11160. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11161. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11162. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11163. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11164. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11165. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11166. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11167. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11168. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11169. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11170. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11171. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11172. static readonly STEP_AFTERRENDER_AUDIO: number;
  11173. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11174. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11175. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11176. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11177. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11178. static readonly STEP_POINTERMOVE_SPRITE: number;
  11179. static readonly STEP_POINTERDOWN_SPRITE: number;
  11180. static readonly STEP_POINTERUP_SPRITE: number;
  11181. }
  11182. /**
  11183. * This represents a scene component.
  11184. *
  11185. * This is used to decouple the dependency the scene is having on the different workloads like
  11186. * layers, post processes...
  11187. */
  11188. export interface ISceneComponent {
  11189. /**
  11190. * The name of the component. Each component must have a unique name.
  11191. */
  11192. name: string;
  11193. /**
  11194. * The scene the component belongs to.
  11195. */
  11196. scene: Scene;
  11197. /**
  11198. * Register the component to one instance of a scene.
  11199. */
  11200. register(): void;
  11201. /**
  11202. * Rebuilds the elements related to this component in case of
  11203. * context lost for instance.
  11204. */
  11205. rebuild(): void;
  11206. /**
  11207. * Disposes the component and the associated ressources.
  11208. */
  11209. dispose(): void;
  11210. }
  11211. /**
  11212. * This represents a SERIALIZABLE scene component.
  11213. *
  11214. * This extends Scene Component to add Serialization methods on top.
  11215. */
  11216. export interface ISceneSerializableComponent extends ISceneComponent {
  11217. /**
  11218. * Adds all the element from the container to the scene
  11219. * @param container the container holding the elements
  11220. */
  11221. addFromContainer(container: AbstractScene): void;
  11222. /**
  11223. * Removes all the elements in the container from the scene
  11224. * @param container contains the elements to remove
  11225. */
  11226. removeFromContainer(container: AbstractScene): void;
  11227. /**
  11228. * Serializes the component data to the specified json object
  11229. * @param serializationObject The object to serialize to
  11230. */
  11231. serialize(serializationObject: any): void;
  11232. }
  11233. /**
  11234. * Strong typing of a Mesh related stage step action
  11235. */
  11236. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11237. /**
  11238. * Strong typing of a Evaluate Sub Mesh related stage step action
  11239. */
  11240. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11241. /**
  11242. * Strong typing of a Active Mesh related stage step action
  11243. */
  11244. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11245. /**
  11246. * Strong typing of a Camera related stage step action
  11247. */
  11248. export type CameraStageAction = (camera: Camera) => void;
  11249. /**
  11250. * Strong typing of a Render Target related stage step action
  11251. */
  11252. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11253. /**
  11254. * Strong typing of a RenderingGroup related stage step action
  11255. */
  11256. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11257. /**
  11258. * Strong typing of a Mesh Render related stage step action
  11259. */
  11260. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11261. /**
  11262. * Strong typing of a simple stage step action
  11263. */
  11264. export type SimpleStageAction = () => void;
  11265. /**
  11266. * Strong typing of a render target action.
  11267. */
  11268. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11269. /**
  11270. * Strong typing of a pointer move action.
  11271. */
  11272. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11273. /**
  11274. * Strong typing of a pointer up/down action.
  11275. */
  11276. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11277. /**
  11278. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11279. * @hidden
  11280. */
  11281. export class Stage<T extends Function> extends Array<{
  11282. index: number;
  11283. component: ISceneComponent;
  11284. action: T;
  11285. }> {
  11286. /**
  11287. * Hide ctor from the rest of the world.
  11288. * @param items The items to add.
  11289. */
  11290. private constructor();
  11291. /**
  11292. * Creates a new Stage.
  11293. * @returns A new instance of a Stage
  11294. */
  11295. static Create<T extends Function>(): Stage<T>;
  11296. /**
  11297. * Registers a step in an ordered way in the targeted stage.
  11298. * @param index Defines the position to register the step in
  11299. * @param component Defines the component attached to the step
  11300. * @param action Defines the action to launch during the step
  11301. */
  11302. registerStep(index: number, component: ISceneComponent, action: T): void;
  11303. /**
  11304. * Clears all the steps from the stage.
  11305. */
  11306. clear(): void;
  11307. }
  11308. }
  11309. declare module BABYLON {
  11310. interface Scene {
  11311. /** @hidden */
  11312. _pointerOverSprite: Nullable<Sprite>;
  11313. /** @hidden */
  11314. _pickedDownSprite: Nullable<Sprite>;
  11315. /** @hidden */
  11316. _tempSpritePickingRay: Nullable<Ray>;
  11317. /**
  11318. * All of the sprite managers added to this scene
  11319. * @see http://doc.babylonjs.com/babylon101/sprites
  11320. */
  11321. spriteManagers: Array<ISpriteManager>;
  11322. /**
  11323. * An event triggered when sprites rendering is about to start
  11324. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11325. */
  11326. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11327. /**
  11328. * An event triggered when sprites rendering is done
  11329. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11330. */
  11331. onAfterSpritesRenderingObservable: Observable<Scene>;
  11332. /** @hidden */
  11333. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11334. /** Launch a ray to try to pick a sprite in the scene
  11335. * @param x position on screen
  11336. * @param y position on screen
  11337. * @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
  11338. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11339. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11340. * @returns a PickingInfo
  11341. */
  11342. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11343. /** Use the given ray to pick a sprite in the scene
  11344. * @param ray The ray (in world space) to use to pick meshes
  11345. * @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
  11346. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11347. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11348. * @returns a PickingInfo
  11349. */
  11350. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11351. /**
  11352. * Force the sprite under the pointer
  11353. * @param sprite defines the sprite to use
  11354. */
  11355. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11356. /**
  11357. * Gets the sprite under the pointer
  11358. * @returns a Sprite or null if no sprite is under the pointer
  11359. */
  11360. getPointerOverSprite(): Nullable<Sprite>;
  11361. }
  11362. /**
  11363. * Defines the sprite scene component responsible to manage sprites
  11364. * in a given scene.
  11365. */
  11366. export class SpriteSceneComponent implements ISceneComponent {
  11367. /**
  11368. * The component name helpfull to identify the component in the list of scene components.
  11369. */
  11370. readonly name: string;
  11371. /**
  11372. * The scene the component belongs to.
  11373. */
  11374. scene: Scene;
  11375. /** @hidden */
  11376. private _spritePredicate;
  11377. /**
  11378. * Creates a new instance of the component for the given scene
  11379. * @param scene Defines the scene to register the component in
  11380. */
  11381. constructor(scene: Scene);
  11382. /**
  11383. * Registers the component in a given scene
  11384. */
  11385. register(): void;
  11386. /**
  11387. * Rebuilds the elements related to this component in case of
  11388. * context lost for instance.
  11389. */
  11390. rebuild(): void;
  11391. /**
  11392. * Disposes the component and the associated ressources.
  11393. */
  11394. dispose(): void;
  11395. private _pickSpriteButKeepRay;
  11396. private _pointerMove;
  11397. private _pointerDown;
  11398. private _pointerUp;
  11399. }
  11400. }
  11401. declare module BABYLON {
  11402. /** @hidden */
  11403. export var fogFragmentDeclaration: {
  11404. name: string;
  11405. shader: string;
  11406. };
  11407. }
  11408. declare module BABYLON {
  11409. /** @hidden */
  11410. export var fogFragment: {
  11411. name: string;
  11412. shader: string;
  11413. };
  11414. }
  11415. declare module BABYLON {
  11416. /** @hidden */
  11417. export var spritesPixelShader: {
  11418. name: string;
  11419. shader: string;
  11420. };
  11421. }
  11422. declare module BABYLON {
  11423. /** @hidden */
  11424. export var fogVertexDeclaration: {
  11425. name: string;
  11426. shader: string;
  11427. };
  11428. }
  11429. declare module BABYLON {
  11430. /** @hidden */
  11431. export var spritesVertexShader: {
  11432. name: string;
  11433. shader: string;
  11434. };
  11435. }
  11436. declare module BABYLON {
  11437. /**
  11438. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11439. */
  11440. export interface ISpriteManager extends IDisposable {
  11441. /**
  11442. * Restricts the camera to viewing objects with the same layerMask.
  11443. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11444. */
  11445. layerMask: number;
  11446. /**
  11447. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11448. */
  11449. isPickable: boolean;
  11450. /**
  11451. * Specifies the rendering group id for this mesh (0 by default)
  11452. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11453. */
  11454. renderingGroupId: number;
  11455. /**
  11456. * Defines the list of sprites managed by the manager.
  11457. */
  11458. sprites: Array<Sprite>;
  11459. /**
  11460. * Tests the intersection of a sprite with a specific ray.
  11461. * @param ray The ray we are sending to test the collision
  11462. * @param camera The camera space we are sending rays in
  11463. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11464. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11465. * @returns picking info or null.
  11466. */
  11467. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11468. /**
  11469. * Renders the list of sprites on screen.
  11470. */
  11471. render(): void;
  11472. }
  11473. /**
  11474. * Class used to manage multiple sprites on the same spritesheet
  11475. * @see http://doc.babylonjs.com/babylon101/sprites
  11476. */
  11477. export class SpriteManager implements ISpriteManager {
  11478. /** defines the manager's name */
  11479. name: string;
  11480. /** Gets the list of sprites */
  11481. sprites: Sprite[];
  11482. /** Gets or sets the rendering group id (0 by default) */
  11483. renderingGroupId: number;
  11484. /** Gets or sets camera layer mask */
  11485. layerMask: number;
  11486. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11487. fogEnabled: boolean;
  11488. /** Gets or sets a boolean indicating if the sprites are pickable */
  11489. isPickable: boolean;
  11490. /** Defines the default width of a cell in the spritesheet */
  11491. cellWidth: number;
  11492. /** Defines the default height of a cell in the spritesheet */
  11493. cellHeight: number;
  11494. /**
  11495. * An event triggered when the manager is disposed.
  11496. */
  11497. onDisposeObservable: Observable<SpriteManager>;
  11498. private _onDisposeObserver;
  11499. /**
  11500. * Callback called when the manager is disposed
  11501. */
  11502. onDispose: () => void;
  11503. private _capacity;
  11504. private _spriteTexture;
  11505. private _epsilon;
  11506. private _scene;
  11507. private _vertexData;
  11508. private _buffer;
  11509. private _vertexBuffers;
  11510. private _indexBuffer;
  11511. private _effectBase;
  11512. private _effectFog;
  11513. /**
  11514. * Gets or sets the spritesheet texture
  11515. */
  11516. texture: Texture;
  11517. /**
  11518. * Creates a new sprite manager
  11519. * @param name defines the manager's name
  11520. * @param imgUrl defines the sprite sheet url
  11521. * @param capacity defines the maximum allowed number of sprites
  11522. * @param cellSize defines the size of a sprite cell
  11523. * @param scene defines the hosting scene
  11524. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11525. * @param samplingMode defines the smapling mode to use with spritesheet
  11526. */
  11527. constructor(
  11528. /** defines the manager's name */
  11529. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11530. private _appendSpriteVertex;
  11531. /**
  11532. * Intersects the sprites with a ray
  11533. * @param ray defines the ray to intersect with
  11534. * @param camera defines the current active camera
  11535. * @param predicate defines a predicate used to select candidate sprites
  11536. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11537. * @returns null if no hit or a PickingInfo
  11538. */
  11539. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11540. /**
  11541. * Render all child sprites
  11542. */
  11543. render(): void;
  11544. /**
  11545. * Release associated resources
  11546. */
  11547. dispose(): void;
  11548. }
  11549. }
  11550. declare module BABYLON {
  11551. /**
  11552. * Class used to represent a sprite
  11553. * @see http://doc.babylonjs.com/babylon101/sprites
  11554. */
  11555. export class Sprite {
  11556. /** defines the name */
  11557. name: string;
  11558. /** Gets or sets the current world position */
  11559. position: Vector3;
  11560. /** Gets or sets the main color */
  11561. color: Color4;
  11562. /** Gets or sets the width */
  11563. width: number;
  11564. /** Gets or sets the height */
  11565. height: number;
  11566. /** Gets or sets rotation angle */
  11567. angle: number;
  11568. /** Gets or sets the cell index in the sprite sheet */
  11569. cellIndex: number;
  11570. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11571. invertU: number;
  11572. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11573. invertV: number;
  11574. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11575. disposeWhenFinishedAnimating: boolean;
  11576. /** Gets the list of attached animations */
  11577. animations: Animation[];
  11578. /** Gets or sets a boolean indicating if the sprite can be picked */
  11579. isPickable: boolean;
  11580. /**
  11581. * Gets or sets the associated action manager
  11582. */
  11583. actionManager: Nullable<ActionManager>;
  11584. private _animationStarted;
  11585. private _loopAnimation;
  11586. private _fromIndex;
  11587. private _toIndex;
  11588. private _delay;
  11589. private _direction;
  11590. private _manager;
  11591. private _time;
  11592. private _onAnimationEnd;
  11593. /**
  11594. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11595. */
  11596. isVisible: boolean;
  11597. /**
  11598. * Gets or sets the sprite size
  11599. */
  11600. size: number;
  11601. /**
  11602. * Creates a new Sprite
  11603. * @param name defines the name
  11604. * @param manager defines the manager
  11605. */
  11606. constructor(
  11607. /** defines the name */
  11608. name: string, manager: ISpriteManager);
  11609. /**
  11610. * Starts an animation
  11611. * @param from defines the initial key
  11612. * @param to defines the end key
  11613. * @param loop defines if the animation must loop
  11614. * @param delay defines the start delay (in ms)
  11615. * @param onAnimationEnd defines a callback to call when animation ends
  11616. */
  11617. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11618. /** Stops current animation (if any) */
  11619. stopAnimation(): void;
  11620. /** @hidden */
  11621. _animate(deltaTime: number): void;
  11622. /** Release associated resources */
  11623. dispose(): void;
  11624. }
  11625. }
  11626. declare module BABYLON {
  11627. /**
  11628. * Information about the result of picking within a scene
  11629. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11630. */
  11631. export class PickingInfo {
  11632. /** @hidden */
  11633. _pickingUnavailable: boolean;
  11634. /**
  11635. * If the pick collided with an object
  11636. */
  11637. hit: boolean;
  11638. /**
  11639. * Distance away where the pick collided
  11640. */
  11641. distance: number;
  11642. /**
  11643. * The location of pick collision
  11644. */
  11645. pickedPoint: Nullable<Vector3>;
  11646. /**
  11647. * The mesh corresponding the the pick collision
  11648. */
  11649. pickedMesh: Nullable<AbstractMesh>;
  11650. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11651. bu: number;
  11652. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11653. bv: number;
  11654. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11655. faceId: number;
  11656. /** Id of the the submesh that was picked */
  11657. subMeshId: number;
  11658. /** If a sprite was picked, this will be the sprite the pick collided with */
  11659. pickedSprite: Nullable<Sprite>;
  11660. /**
  11661. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11662. */
  11663. originMesh: Nullable<AbstractMesh>;
  11664. /**
  11665. * The ray that was used to perform the picking.
  11666. */
  11667. ray: Nullable<Ray>;
  11668. /**
  11669. * Gets the normal correspodning to the face the pick collided with
  11670. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11671. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11672. * @returns The normal correspodning to the face the pick collided with
  11673. */
  11674. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11675. /**
  11676. * Gets the texture coordinates of where the pick occured
  11677. * @returns the vector containing the coordnates of the texture
  11678. */
  11679. getTextureCoordinates(): Nullable<Vector2>;
  11680. }
  11681. }
  11682. declare module BABYLON {
  11683. /**
  11684. * Gather the list of pointer event types as constants.
  11685. */
  11686. export class PointerEventTypes {
  11687. /**
  11688. * 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.
  11689. */
  11690. static readonly POINTERDOWN: number;
  11691. /**
  11692. * The pointerup event is fired when a pointer is no longer active.
  11693. */
  11694. static readonly POINTERUP: number;
  11695. /**
  11696. * The pointermove event is fired when a pointer changes coordinates.
  11697. */
  11698. static readonly POINTERMOVE: number;
  11699. /**
  11700. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11701. */
  11702. static readonly POINTERWHEEL: number;
  11703. /**
  11704. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11705. */
  11706. static readonly POINTERPICK: number;
  11707. /**
  11708. * The pointertap event is fired when a the object has been touched and released without drag.
  11709. */
  11710. static readonly POINTERTAP: number;
  11711. /**
  11712. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11713. */
  11714. static readonly POINTERDOUBLETAP: number;
  11715. }
  11716. /**
  11717. * Base class of pointer info types.
  11718. */
  11719. export class PointerInfoBase {
  11720. /**
  11721. * Defines the type of event (PointerEventTypes)
  11722. */
  11723. type: number;
  11724. /**
  11725. * Defines the related dom event
  11726. */
  11727. event: PointerEvent | MouseWheelEvent;
  11728. /**
  11729. * Instantiates the base class of pointers info.
  11730. * @param type Defines the type of event (PointerEventTypes)
  11731. * @param event Defines the related dom event
  11732. */
  11733. constructor(
  11734. /**
  11735. * Defines the type of event (PointerEventTypes)
  11736. */
  11737. type: number,
  11738. /**
  11739. * Defines the related dom event
  11740. */
  11741. event: PointerEvent | MouseWheelEvent);
  11742. }
  11743. /**
  11744. * This class is used to store pointer related info for the onPrePointerObservable event.
  11745. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11746. */
  11747. export class PointerInfoPre extends PointerInfoBase {
  11748. /**
  11749. * Ray from a pointer if availible (eg. 6dof controller)
  11750. */
  11751. ray: Nullable<Ray>;
  11752. /**
  11753. * Defines the local position of the pointer on the canvas.
  11754. */
  11755. localPosition: Vector2;
  11756. /**
  11757. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11758. */
  11759. skipOnPointerObservable: boolean;
  11760. /**
  11761. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11762. * @param type Defines the type of event (PointerEventTypes)
  11763. * @param event Defines the related dom event
  11764. * @param localX Defines the local x coordinates of the pointer when the event occured
  11765. * @param localY Defines the local y coordinates of the pointer when the event occured
  11766. */
  11767. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11768. }
  11769. /**
  11770. * This type contains all the data related to a pointer event in Babylon.js.
  11771. * 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.
  11772. */
  11773. export class PointerInfo extends PointerInfoBase {
  11774. /**
  11775. * Defines the picking info associated to the info (if any)\
  11776. */
  11777. pickInfo: Nullable<PickingInfo>;
  11778. /**
  11779. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11780. * @param type Defines the type of event (PointerEventTypes)
  11781. * @param event Defines the related dom event
  11782. * @param pickInfo Defines the picking info associated to the info (if any)\
  11783. */
  11784. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11785. /**
  11786. * Defines the picking info associated to the info (if any)\
  11787. */
  11788. pickInfo: Nullable<PickingInfo>);
  11789. }
  11790. }
  11791. declare module BABYLON {
  11792. /**
  11793. * Manage the mouse inputs to control the movement of a free camera.
  11794. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11795. */
  11796. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11797. /**
  11798. * Define if touch is enabled in the mouse input
  11799. */
  11800. touchEnabled: boolean;
  11801. /**
  11802. * Defines the camera the input is attached to.
  11803. */
  11804. camera: FreeCamera;
  11805. /**
  11806. * Defines the buttons associated with the input to handle camera move.
  11807. */
  11808. buttons: number[];
  11809. /**
  11810. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11811. */
  11812. angularSensibility: number;
  11813. private _pointerInput;
  11814. private _onMouseMove;
  11815. private _observer;
  11816. private previousPosition;
  11817. /**
  11818. * Manage the mouse inputs to control the movement of a free camera.
  11819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11820. * @param touchEnabled Defines if touch is enabled or not
  11821. */
  11822. constructor(
  11823. /**
  11824. * Define if touch is enabled in the mouse input
  11825. */
  11826. touchEnabled?: boolean);
  11827. /**
  11828. * Attach the input controls to a specific dom element to get the input from.
  11829. * @param element Defines the element the controls should be listened from
  11830. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11831. */
  11832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11833. /**
  11834. * Detach the current controls from the specified dom element.
  11835. * @param element Defines the element to stop listening the inputs from
  11836. */
  11837. detachControl(element: Nullable<HTMLElement>): void;
  11838. /**
  11839. * Gets the class name of the current intput.
  11840. * @returns the class name
  11841. */
  11842. getClassName(): string;
  11843. /**
  11844. * Get the friendly name associated with the input class.
  11845. * @returns the input friendly name
  11846. */
  11847. getSimpleName(): string;
  11848. }
  11849. }
  11850. declare module BABYLON {
  11851. /**
  11852. * Manage the touch inputs to control the movement of a free camera.
  11853. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11854. */
  11855. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11856. /**
  11857. * Defines the camera the input is attached to.
  11858. */
  11859. camera: FreeCamera;
  11860. /**
  11861. * Defines the touch sensibility for rotation.
  11862. * The higher the faster.
  11863. */
  11864. touchAngularSensibility: number;
  11865. /**
  11866. * Defines the touch sensibility for move.
  11867. * The higher the faster.
  11868. */
  11869. touchMoveSensibility: number;
  11870. private _offsetX;
  11871. private _offsetY;
  11872. private _pointerPressed;
  11873. private _pointerInput;
  11874. private _observer;
  11875. private _onLostFocus;
  11876. /**
  11877. * Attach the input controls to a specific dom element to get the input from.
  11878. * @param element Defines the element the controls should be listened from
  11879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11880. */
  11881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11882. /**
  11883. * Detach the current controls from the specified dom element.
  11884. * @param element Defines the element to stop listening the inputs from
  11885. */
  11886. detachControl(element: Nullable<HTMLElement>): void;
  11887. /**
  11888. * Update the current camera state depending on the inputs that have been used this frame.
  11889. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11890. */
  11891. checkInputs(): void;
  11892. /**
  11893. * Gets the class name of the current intput.
  11894. * @returns the class name
  11895. */
  11896. getClassName(): string;
  11897. /**
  11898. * Get the friendly name associated with the input class.
  11899. * @returns the input friendly name
  11900. */
  11901. getSimpleName(): string;
  11902. }
  11903. }
  11904. declare module BABYLON {
  11905. /**
  11906. * Default Inputs manager for the FreeCamera.
  11907. * It groups all the default supported inputs for ease of use.
  11908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11909. */
  11910. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11911. /**
  11912. * Instantiates a new FreeCameraInputsManager.
  11913. * @param camera Defines the camera the inputs belong to
  11914. */
  11915. constructor(camera: FreeCamera);
  11916. /**
  11917. * Add keyboard input support to the input manager.
  11918. * @returns the current input manager
  11919. */
  11920. addKeyboard(): FreeCameraInputsManager;
  11921. /**
  11922. * Add mouse input support to the input manager.
  11923. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11924. * @returns the current input manager
  11925. */
  11926. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11927. /**
  11928. * Add touch input support to the input manager.
  11929. * @returns the current input manager
  11930. */
  11931. addTouch(): FreeCameraInputsManager;
  11932. }
  11933. }
  11934. declare module BABYLON {
  11935. /**
  11936. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11937. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11938. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11939. */
  11940. export class FreeCamera extends TargetCamera {
  11941. /**
  11942. * Define the collision ellipsoid of the camera.
  11943. * This is helpful to simulate a camera body like the player body around the camera
  11944. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11945. */
  11946. ellipsoid: Vector3;
  11947. /**
  11948. * Define an offset for the position of the ellipsoid around the camera.
  11949. * This can be helpful to determine the center of the body near the gravity center of the body
  11950. * instead of its head.
  11951. */
  11952. ellipsoidOffset: Vector3;
  11953. /**
  11954. * Enable or disable collisions of the camera with the rest of the scene objects.
  11955. */
  11956. checkCollisions: boolean;
  11957. /**
  11958. * Enable or disable gravity on the camera.
  11959. */
  11960. applyGravity: boolean;
  11961. /**
  11962. * Define the input manager associated to the camera.
  11963. */
  11964. inputs: FreeCameraInputsManager;
  11965. /**
  11966. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11967. * Higher values reduce sensitivity.
  11968. */
  11969. /**
  11970. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11971. * Higher values reduce sensitivity.
  11972. */
  11973. angularSensibility: number;
  11974. /**
  11975. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11976. */
  11977. keysUp: number[];
  11978. /**
  11979. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11980. */
  11981. keysDown: number[];
  11982. /**
  11983. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11984. */
  11985. keysLeft: number[];
  11986. /**
  11987. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11988. */
  11989. keysRight: number[];
  11990. /**
  11991. * Event raised when the camera collide with a mesh in the scene.
  11992. */
  11993. onCollide: (collidedMesh: AbstractMesh) => void;
  11994. private _collider;
  11995. private _needMoveForGravity;
  11996. private _oldPosition;
  11997. private _diffPosition;
  11998. private _newPosition;
  11999. /** @hidden */
  12000. _localDirection: Vector3;
  12001. /** @hidden */
  12002. _transformedDirection: Vector3;
  12003. /**
  12004. * Instantiates a Free Camera.
  12005. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12006. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12007. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12008. * @param name Define the name of the camera in the scene
  12009. * @param position Define the start position of the camera in the scene
  12010. * @param scene Define the scene the camera belongs to
  12011. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12012. */
  12013. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12014. /**
  12015. * Attached controls to the current camera.
  12016. * @param element Defines the element the controls should be listened from
  12017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12018. */
  12019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12020. /**
  12021. * Detach the current controls from the camera.
  12022. * The camera will stop reacting to inputs.
  12023. * @param element Defines the element to stop listening the inputs from
  12024. */
  12025. detachControl(element: HTMLElement): void;
  12026. private _collisionMask;
  12027. /**
  12028. * Define a collision mask to limit the list of object the camera can collide with
  12029. */
  12030. collisionMask: number;
  12031. /** @hidden */
  12032. _collideWithWorld(displacement: Vector3): void;
  12033. private _onCollisionPositionChange;
  12034. /** @hidden */
  12035. _checkInputs(): void;
  12036. /** @hidden */
  12037. _decideIfNeedsToMove(): boolean;
  12038. /** @hidden */
  12039. _updatePosition(): void;
  12040. /**
  12041. * Destroy the camera and release the current resources hold by it.
  12042. */
  12043. dispose(): void;
  12044. /**
  12045. * Gets the current object class name.
  12046. * @return the class name
  12047. */
  12048. getClassName(): string;
  12049. }
  12050. }
  12051. declare module BABYLON {
  12052. /**
  12053. * Represents a gamepad control stick position
  12054. */
  12055. export class StickValues {
  12056. /**
  12057. * The x component of the control stick
  12058. */
  12059. x: number;
  12060. /**
  12061. * The y component of the control stick
  12062. */
  12063. y: number;
  12064. /**
  12065. * Initializes the gamepad x and y control stick values
  12066. * @param x The x component of the gamepad control stick value
  12067. * @param y The y component of the gamepad control stick value
  12068. */
  12069. constructor(
  12070. /**
  12071. * The x component of the control stick
  12072. */
  12073. x: number,
  12074. /**
  12075. * The y component of the control stick
  12076. */
  12077. y: number);
  12078. }
  12079. /**
  12080. * An interface which manages callbacks for gamepad button changes
  12081. */
  12082. export interface GamepadButtonChanges {
  12083. /**
  12084. * Called when a gamepad has been changed
  12085. */
  12086. changed: boolean;
  12087. /**
  12088. * Called when a gamepad press event has been triggered
  12089. */
  12090. pressChanged: boolean;
  12091. /**
  12092. * Called when a touch event has been triggered
  12093. */
  12094. touchChanged: boolean;
  12095. /**
  12096. * Called when a value has changed
  12097. */
  12098. valueChanged: boolean;
  12099. }
  12100. /**
  12101. * Represents a gamepad
  12102. */
  12103. export class Gamepad {
  12104. /**
  12105. * The id of the gamepad
  12106. */
  12107. id: string;
  12108. /**
  12109. * The index of the gamepad
  12110. */
  12111. index: number;
  12112. /**
  12113. * The browser gamepad
  12114. */
  12115. browserGamepad: any;
  12116. /**
  12117. * Specifies what type of gamepad this represents
  12118. */
  12119. type: number;
  12120. private _leftStick;
  12121. private _rightStick;
  12122. /** @hidden */
  12123. _isConnected: boolean;
  12124. private _leftStickAxisX;
  12125. private _leftStickAxisY;
  12126. private _rightStickAxisX;
  12127. private _rightStickAxisY;
  12128. /**
  12129. * Triggered when the left control stick has been changed
  12130. */
  12131. private _onleftstickchanged;
  12132. /**
  12133. * Triggered when the right control stick has been changed
  12134. */
  12135. private _onrightstickchanged;
  12136. /**
  12137. * Represents a gamepad controller
  12138. */
  12139. static GAMEPAD: number;
  12140. /**
  12141. * Represents a generic controller
  12142. */
  12143. static GENERIC: number;
  12144. /**
  12145. * Represents an XBox controller
  12146. */
  12147. static XBOX: number;
  12148. /**
  12149. * Represents a pose-enabled controller
  12150. */
  12151. static POSE_ENABLED: number;
  12152. /**
  12153. * Specifies whether the left control stick should be Y-inverted
  12154. */
  12155. protected _invertLeftStickY: boolean;
  12156. /**
  12157. * Specifies if the gamepad has been connected
  12158. */
  12159. readonly isConnected: boolean;
  12160. /**
  12161. * Initializes the gamepad
  12162. * @param id The id of the gamepad
  12163. * @param index The index of the gamepad
  12164. * @param browserGamepad The browser gamepad
  12165. * @param leftStickX The x component of the left joystick
  12166. * @param leftStickY The y component of the left joystick
  12167. * @param rightStickX The x component of the right joystick
  12168. * @param rightStickY The y component of the right joystick
  12169. */
  12170. constructor(
  12171. /**
  12172. * The id of the gamepad
  12173. */
  12174. id: string,
  12175. /**
  12176. * The index of the gamepad
  12177. */
  12178. index: number,
  12179. /**
  12180. * The browser gamepad
  12181. */
  12182. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12183. /**
  12184. * Callback triggered when the left joystick has changed
  12185. * @param callback
  12186. */
  12187. onleftstickchanged(callback: (values: StickValues) => void): void;
  12188. /**
  12189. * Callback triggered when the right joystick has changed
  12190. * @param callback
  12191. */
  12192. onrightstickchanged(callback: (values: StickValues) => void): void;
  12193. /**
  12194. * Gets the left joystick
  12195. */
  12196. /**
  12197. * Sets the left joystick values
  12198. */
  12199. leftStick: StickValues;
  12200. /**
  12201. * Gets the right joystick
  12202. */
  12203. /**
  12204. * Sets the right joystick value
  12205. */
  12206. rightStick: StickValues;
  12207. /**
  12208. * Updates the gamepad joystick positions
  12209. */
  12210. update(): void;
  12211. /**
  12212. * Disposes the gamepad
  12213. */
  12214. dispose(): void;
  12215. }
  12216. /**
  12217. * Represents a generic gamepad
  12218. */
  12219. export class GenericPad extends Gamepad {
  12220. private _buttons;
  12221. private _onbuttondown;
  12222. private _onbuttonup;
  12223. /**
  12224. * Observable triggered when a button has been pressed
  12225. */
  12226. onButtonDownObservable: Observable<number>;
  12227. /**
  12228. * Observable triggered when a button has been released
  12229. */
  12230. onButtonUpObservable: Observable<number>;
  12231. /**
  12232. * Callback triggered when a button has been pressed
  12233. * @param callback Called when a button has been pressed
  12234. */
  12235. onbuttondown(callback: (buttonPressed: number) => void): void;
  12236. /**
  12237. * Callback triggered when a button has been released
  12238. * @param callback Called when a button has been released
  12239. */
  12240. onbuttonup(callback: (buttonReleased: number) => void): void;
  12241. /**
  12242. * Initializes the generic gamepad
  12243. * @param id The id of the generic gamepad
  12244. * @param index The index of the generic gamepad
  12245. * @param browserGamepad The browser gamepad
  12246. */
  12247. constructor(id: string, index: number, browserGamepad: any);
  12248. private _setButtonValue;
  12249. /**
  12250. * Updates the generic gamepad
  12251. */
  12252. update(): void;
  12253. /**
  12254. * Disposes the generic gamepad
  12255. */
  12256. dispose(): void;
  12257. }
  12258. }
  12259. declare module BABYLON {
  12260. /**
  12261. * 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.
  12262. * @see https://doc.babylonjs.com/how_to/transformnode
  12263. */
  12264. export class TransformNode extends Node {
  12265. /**
  12266. * Object will not rotate to face the camera
  12267. */
  12268. static BILLBOARDMODE_NONE: number;
  12269. /**
  12270. * Object will rotate to face the camera but only on the x axis
  12271. */
  12272. static BILLBOARDMODE_X: number;
  12273. /**
  12274. * Object will rotate to face the camera but only on the y axis
  12275. */
  12276. static BILLBOARDMODE_Y: number;
  12277. /**
  12278. * Object will rotate to face the camera but only on the z axis
  12279. */
  12280. static BILLBOARDMODE_Z: number;
  12281. /**
  12282. * Object will rotate to face the camera
  12283. */
  12284. static BILLBOARDMODE_ALL: number;
  12285. private _forward;
  12286. private _forwardInverted;
  12287. private _up;
  12288. private _right;
  12289. private _rightInverted;
  12290. private _position;
  12291. private _rotation;
  12292. private _rotationQuaternion;
  12293. protected _scaling: Vector3;
  12294. protected _isDirty: boolean;
  12295. private _transformToBoneReferal;
  12296. /**
  12297. * Set the billboard mode. Default is 0.
  12298. *
  12299. * | Value | Type | Description |
  12300. * | --- | --- | --- |
  12301. * | 0 | BILLBOARDMODE_NONE | |
  12302. * | 1 | BILLBOARDMODE_X | |
  12303. * | 2 | BILLBOARDMODE_Y | |
  12304. * | 4 | BILLBOARDMODE_Z | |
  12305. * | 7 | BILLBOARDMODE_ALL | |
  12306. *
  12307. */
  12308. billboardMode: number;
  12309. /**
  12310. * 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
  12311. */
  12312. scalingDeterminant: number;
  12313. /**
  12314. * Sets the distance of the object to max, often used by skybox
  12315. */
  12316. infiniteDistance: boolean;
  12317. /**
  12318. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  12319. * By default the system will update normals to compensate
  12320. */
  12321. ignoreNonUniformScaling: boolean;
  12322. /** @hidden */
  12323. _poseMatrix: Matrix;
  12324. /** @hidden */
  12325. _localMatrix: Matrix;
  12326. private _absolutePosition;
  12327. private _pivotMatrix;
  12328. private _pivotMatrixInverse;
  12329. protected _postMultiplyPivotMatrix: boolean;
  12330. protected _isWorldMatrixFrozen: boolean;
  12331. /** @hidden */
  12332. _indexInSceneTransformNodesArray: number;
  12333. /**
  12334. * An event triggered after the world matrix is updated
  12335. */
  12336. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  12337. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  12338. /**
  12339. * Gets a string identifying the name of the class
  12340. * @returns "TransformNode" string
  12341. */
  12342. getClassName(): string;
  12343. /**
  12344. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  12345. */
  12346. position: Vector3;
  12347. /**
  12348. * 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)).
  12349. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  12350. */
  12351. rotation: Vector3;
  12352. /**
  12353. * 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)).
  12354. */
  12355. scaling: Vector3;
  12356. /**
  12357. * 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).
  12358. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  12359. */
  12360. rotationQuaternion: Nullable<Quaternion>;
  12361. /**
  12362. * The forward direction of that transform in world space.
  12363. */
  12364. readonly forward: Vector3;
  12365. /**
  12366. * The up direction of that transform in world space.
  12367. */
  12368. readonly up: Vector3;
  12369. /**
  12370. * The right direction of that transform in world space.
  12371. */
  12372. readonly right: Vector3;
  12373. /**
  12374. * Copies the parameter passed Matrix into the mesh Pose matrix.
  12375. * @param matrix the matrix to copy the pose from
  12376. * @returns this TransformNode.
  12377. */
  12378. updatePoseMatrix(matrix: Matrix): TransformNode;
  12379. /**
  12380. * Returns the mesh Pose matrix.
  12381. * @returns the pose matrix
  12382. */
  12383. getPoseMatrix(): Matrix;
  12384. /** @hidden */
  12385. _isSynchronized(): boolean;
  12386. /** @hidden */
  12387. _initCache(): void;
  12388. /**
  12389. * Flag the transform node as dirty (Forcing it to update everything)
  12390. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  12391. * @returns this transform node
  12392. */
  12393. markAsDirty(property: string): TransformNode;
  12394. /**
  12395. * Returns the current mesh absolute position.
  12396. * Returns a Vector3.
  12397. */
  12398. readonly absolutePosition: Vector3;
  12399. /**
  12400. * Sets a new matrix to apply before all other transformation
  12401. * @param matrix defines the transform matrix
  12402. * @returns the current TransformNode
  12403. */
  12404. setPreTransformMatrix(matrix: Matrix): TransformNode;
  12405. /**
  12406. * Sets a new pivot matrix to the current node
  12407. * @param matrix defines the new pivot matrix to use
  12408. * @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
  12409. * @returns the current TransformNode
  12410. */
  12411. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  12412. /**
  12413. * Returns the mesh pivot matrix.
  12414. * Default : Identity.
  12415. * @returns the matrix
  12416. */
  12417. getPivotMatrix(): Matrix;
  12418. /**
  12419. * Prevents the World matrix to be computed any longer.
  12420. * @returns the TransformNode.
  12421. */
  12422. freezeWorldMatrix(): TransformNode;
  12423. /**
  12424. * Allows back the World matrix computation.
  12425. * @returns the TransformNode.
  12426. */
  12427. unfreezeWorldMatrix(): this;
  12428. /**
  12429. * True if the World matrix has been frozen.
  12430. */
  12431. readonly isWorldMatrixFrozen: boolean;
  12432. /**
  12433. * Retuns the mesh absolute position in the World.
  12434. * @returns a Vector3.
  12435. */
  12436. getAbsolutePosition(): Vector3;
  12437. /**
  12438. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  12439. * @param absolutePosition the absolute position to set
  12440. * @returns the TransformNode.
  12441. */
  12442. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  12443. /**
  12444. * Sets the mesh position in its local space.
  12445. * @param vector3 the position to set in localspace
  12446. * @returns the TransformNode.
  12447. */
  12448. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  12449. /**
  12450. * Returns the mesh position in the local space from the current World matrix values.
  12451. * @returns a new Vector3.
  12452. */
  12453. getPositionExpressedInLocalSpace(): Vector3;
  12454. /**
  12455. * Translates the mesh along the passed Vector3 in its local space.
  12456. * @param vector3 the distance to translate in localspace
  12457. * @returns the TransformNode.
  12458. */
  12459. locallyTranslate(vector3: Vector3): TransformNode;
  12460. private static _lookAtVectorCache;
  12461. /**
  12462. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  12463. * @param targetPoint the position (must be in same space as current mesh) to look at
  12464. * @param yawCor optional yaw (y-axis) correction in radians
  12465. * @param pitchCor optional pitch (x-axis) correction in radians
  12466. * @param rollCor optional roll (z-axis) correction in radians
  12467. * @param space the choosen space of the target
  12468. * @returns the TransformNode.
  12469. */
  12470. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  12471. /**
  12472. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12473. * This Vector3 is expressed in the World space.
  12474. * @param localAxis axis to rotate
  12475. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  12476. */
  12477. getDirection(localAxis: Vector3): Vector3;
  12478. /**
  12479. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  12480. * localAxis is expressed in the mesh local space.
  12481. * result is computed in the Wordl space from the mesh World matrix.
  12482. * @param localAxis axis to rotate
  12483. * @param result the resulting transformnode
  12484. * @returns this TransformNode.
  12485. */
  12486. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  12487. /**
  12488. * Sets this transform node rotation to the given local axis.
  12489. * @param localAxis the axis in local space
  12490. * @param yawCor optional yaw (y-axis) correction in radians
  12491. * @param pitchCor optional pitch (x-axis) correction in radians
  12492. * @param rollCor optional roll (z-axis) correction in radians
  12493. * @returns this TransformNode
  12494. */
  12495. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  12496. /**
  12497. * Sets a new pivot point to the current node
  12498. * @param point defines the new pivot point to use
  12499. * @param space defines if the point is in world or local space (local by default)
  12500. * @returns the current TransformNode
  12501. */
  12502. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  12503. /**
  12504. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  12505. * @returns the pivot point
  12506. */
  12507. getPivotPoint(): Vector3;
  12508. /**
  12509. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  12510. * @param result the vector3 to store the result
  12511. * @returns this TransformNode.
  12512. */
  12513. getPivotPointToRef(result: Vector3): TransformNode;
  12514. /**
  12515. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  12516. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  12517. */
  12518. getAbsolutePivotPoint(): Vector3;
  12519. /**
  12520. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  12521. * @param result vector3 to store the result
  12522. * @returns this TransformNode.
  12523. */
  12524. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  12525. /**
  12526. * Defines the passed node as the parent of the current node.
  12527. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  12528. * @param node the node ot set as the parent
  12529. * @returns this TransformNode.
  12530. */
  12531. setParent(node: Nullable<Node>): TransformNode;
  12532. private _nonUniformScaling;
  12533. /**
  12534. * True if the scaling property of this object is non uniform eg. (1,2,1)
  12535. */
  12536. readonly nonUniformScaling: boolean;
  12537. /** @hidden */
  12538. _updateNonUniformScalingState(value: boolean): boolean;
  12539. /**
  12540. * Attach the current TransformNode to another TransformNode associated with a bone
  12541. * @param bone Bone affecting the TransformNode
  12542. * @param affectedTransformNode TransformNode associated with the bone
  12543. * @returns this object
  12544. */
  12545. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  12546. /**
  12547. * Detach the transform node if its associated with a bone
  12548. * @returns this object
  12549. */
  12550. detachFromBone(): TransformNode;
  12551. private static _rotationAxisCache;
  12552. /**
  12553. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  12554. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12555. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12556. * The passed axis is also normalized.
  12557. * @param axis the axis to rotate around
  12558. * @param amount the amount to rotate in radians
  12559. * @param space Space to rotate in (Default: local)
  12560. * @returns the TransformNode.
  12561. */
  12562. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  12563. /**
  12564. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  12565. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  12566. * The passed axis is also normalized. .
  12567. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  12568. * @param point the point to rotate around
  12569. * @param axis the axis to rotate around
  12570. * @param amount the amount to rotate in radians
  12571. * @returns the TransformNode
  12572. */
  12573. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  12574. /**
  12575. * Translates the mesh along the axis vector for the passed distance in the given space.
  12576. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  12577. * @param axis the axis to translate in
  12578. * @param distance the distance to translate
  12579. * @param space Space to rotate in (Default: local)
  12580. * @returns the TransformNode.
  12581. */
  12582. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  12583. /**
  12584. * Adds a rotation step to the mesh current rotation.
  12585. * x, y, z are Euler angles expressed in radians.
  12586. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  12587. * This means this rotation is made in the mesh local space only.
  12588. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  12589. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  12590. * ```javascript
  12591. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  12592. * ```
  12593. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  12594. * 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.
  12595. * @param x Rotation to add
  12596. * @param y Rotation to add
  12597. * @param z Rotation to add
  12598. * @returns the TransformNode.
  12599. */
  12600. addRotation(x: number, y: number, z: number): TransformNode;
  12601. /**
  12602. * Computes the world matrix of the node
  12603. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12604. * @returns the world matrix
  12605. */
  12606. computeWorldMatrix(force?: boolean): Matrix;
  12607. protected _afterComputeWorldMatrix(): void;
  12608. /**
  12609. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  12610. * @param func callback function to add
  12611. *
  12612. * @returns the TransformNode.
  12613. */
  12614. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12615. /**
  12616. * Removes a registered callback function.
  12617. * @param func callback function to remove
  12618. * @returns the TransformNode.
  12619. */
  12620. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  12621. /**
  12622. * Gets the position of the current mesh in camera space
  12623. * @param camera defines the camera to use
  12624. * @returns a position
  12625. */
  12626. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  12627. /**
  12628. * Returns the distance from the mesh to the active camera
  12629. * @param camera defines the camera to use
  12630. * @returns the distance
  12631. */
  12632. getDistanceToCamera(camera?: Nullable<Camera>): number;
  12633. /**
  12634. * Clone the current transform node
  12635. * @param name Name of the new clone
  12636. * @param newParent New parent for the clone
  12637. * @param doNotCloneChildren Do not clone children hierarchy
  12638. * @returns the new transform node
  12639. */
  12640. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  12641. /**
  12642. * Serializes the objects information.
  12643. * @param currentSerializationObject defines the object to serialize in
  12644. * @returns the serialized object
  12645. */
  12646. serialize(currentSerializationObject?: any): any;
  12647. /**
  12648. * Returns a new TransformNode object parsed from the source provided.
  12649. * @param parsedTransformNode is the source.
  12650. * @param scene the scne the object belongs to
  12651. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  12652. * @returns a new TransformNode object parsed from the source provided.
  12653. */
  12654. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  12655. /**
  12656. * Get all child-transformNodes of this node
  12657. * @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
  12658. * @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
  12659. * @returns an array of TransformNode
  12660. */
  12661. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  12662. /**
  12663. * Releases resources associated with this transform node.
  12664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12666. */
  12667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12668. }
  12669. }
  12670. declare module BABYLON {
  12671. /**
  12672. * Defines the types of pose enabled controllers that are supported
  12673. */
  12674. export enum PoseEnabledControllerType {
  12675. /**
  12676. * HTC Vive
  12677. */
  12678. VIVE = 0,
  12679. /**
  12680. * Oculus Rift
  12681. */
  12682. OCULUS = 1,
  12683. /**
  12684. * Windows mixed reality
  12685. */
  12686. WINDOWS = 2,
  12687. /**
  12688. * Samsung gear VR
  12689. */
  12690. GEAR_VR = 3,
  12691. /**
  12692. * Google Daydream
  12693. */
  12694. DAYDREAM = 4,
  12695. /**
  12696. * Generic
  12697. */
  12698. GENERIC = 5
  12699. }
  12700. /**
  12701. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12702. */
  12703. export interface MutableGamepadButton {
  12704. /**
  12705. * Value of the button/trigger
  12706. */
  12707. value: number;
  12708. /**
  12709. * If the button/trigger is currently touched
  12710. */
  12711. touched: boolean;
  12712. /**
  12713. * If the button/trigger is currently pressed
  12714. */
  12715. pressed: boolean;
  12716. }
  12717. /**
  12718. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12719. * @hidden
  12720. */
  12721. export interface ExtendedGamepadButton extends GamepadButton {
  12722. /**
  12723. * If the button/trigger is currently pressed
  12724. */
  12725. readonly pressed: boolean;
  12726. /**
  12727. * If the button/trigger is currently touched
  12728. */
  12729. readonly touched: boolean;
  12730. /**
  12731. * Value of the button/trigger
  12732. */
  12733. readonly value: number;
  12734. }
  12735. /** @hidden */
  12736. export interface _GamePadFactory {
  12737. /**
  12738. * Returns wether or not the current gamepad can be created for this type of controller.
  12739. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12740. * @returns true if it can be created, otherwise false
  12741. */
  12742. canCreate(gamepadInfo: any): boolean;
  12743. /**
  12744. * Creates a new instance of the Gamepad.
  12745. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12746. * @returns the new gamepad instance
  12747. */
  12748. create(gamepadInfo: any): Gamepad;
  12749. }
  12750. /**
  12751. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12752. */
  12753. export class PoseEnabledControllerHelper {
  12754. /** @hidden */
  12755. static _ControllerFactories: _GamePadFactory[];
  12756. /** @hidden */
  12757. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12758. /**
  12759. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12760. * @param vrGamepad the gamepad to initialized
  12761. * @returns a vr controller of the type the gamepad identified as
  12762. */
  12763. static InitiateController(vrGamepad: any): Gamepad;
  12764. }
  12765. /**
  12766. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12767. */
  12768. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12769. private _deviceRoomPosition;
  12770. private _deviceRoomRotationQuaternion;
  12771. /**
  12772. * The device position in babylon space
  12773. */
  12774. devicePosition: Vector3;
  12775. /**
  12776. * The device rotation in babylon space
  12777. */
  12778. deviceRotationQuaternion: Quaternion;
  12779. /**
  12780. * The scale factor of the device in babylon space
  12781. */
  12782. deviceScaleFactor: number;
  12783. /**
  12784. * (Likely devicePosition should be used instead) The device position in its room space
  12785. */
  12786. position: Vector3;
  12787. /**
  12788. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12789. */
  12790. rotationQuaternion: Quaternion;
  12791. /**
  12792. * The type of controller (Eg. Windows mixed reality)
  12793. */
  12794. controllerType: PoseEnabledControllerType;
  12795. protected _calculatedPosition: Vector3;
  12796. private _calculatedRotation;
  12797. /**
  12798. * The raw pose from the device
  12799. */
  12800. rawPose: DevicePose;
  12801. private _trackPosition;
  12802. private _maxRotationDistFromHeadset;
  12803. private _draggedRoomRotation;
  12804. /**
  12805. * @hidden
  12806. */
  12807. _disableTrackPosition(fixedPosition: Vector3): void;
  12808. /**
  12809. * Internal, the mesh attached to the controller
  12810. * @hidden
  12811. */
  12812. _mesh: Nullable<AbstractMesh>;
  12813. private _poseControlledCamera;
  12814. private _leftHandSystemQuaternion;
  12815. /**
  12816. * Internal, matrix used to convert room space to babylon space
  12817. * @hidden
  12818. */
  12819. _deviceToWorld: Matrix;
  12820. /**
  12821. * Node to be used when casting a ray from the controller
  12822. * @hidden
  12823. */
  12824. _pointingPoseNode: Nullable<TransformNode>;
  12825. /**
  12826. * Name of the child mesh that can be used to cast a ray from the controller
  12827. */
  12828. static readonly POINTING_POSE: string;
  12829. /**
  12830. * Creates a new PoseEnabledController from a gamepad
  12831. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12832. */
  12833. constructor(browserGamepad: any);
  12834. private _workingMatrix;
  12835. /**
  12836. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12837. */
  12838. update(): void;
  12839. /**
  12840. * Updates only the pose device and mesh without doing any button event checking
  12841. */
  12842. protected _updatePoseAndMesh(): void;
  12843. /**
  12844. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12845. * @param poseData raw pose fromthe device
  12846. */
  12847. updateFromDevice(poseData: DevicePose): void;
  12848. /**
  12849. * @hidden
  12850. */
  12851. _meshAttachedObservable: Observable<AbstractMesh>;
  12852. /**
  12853. * Attaches a mesh to the controller
  12854. * @param mesh the mesh to be attached
  12855. */
  12856. attachToMesh(mesh: AbstractMesh): void;
  12857. /**
  12858. * Attaches the controllers mesh to a camera
  12859. * @param camera the camera the mesh should be attached to
  12860. */
  12861. attachToPoseControlledCamera(camera: TargetCamera): void;
  12862. /**
  12863. * Disposes of the controller
  12864. */
  12865. dispose(): void;
  12866. /**
  12867. * The mesh that is attached to the controller
  12868. */
  12869. readonly mesh: Nullable<AbstractMesh>;
  12870. /**
  12871. * Gets the ray of the controller in the direction the controller is pointing
  12872. * @param length the length the resulting ray should be
  12873. * @returns a ray in the direction the controller is pointing
  12874. */
  12875. getForwardRay(length?: number): Ray;
  12876. }
  12877. }
  12878. declare module BABYLON {
  12879. /**
  12880. * Defines the WebVRController object that represents controllers tracked in 3D space
  12881. */
  12882. export abstract class WebVRController extends PoseEnabledController {
  12883. /**
  12884. * Internal, the default controller model for the controller
  12885. */
  12886. protected _defaultModel: AbstractMesh;
  12887. /**
  12888. * Fired when the trigger state has changed
  12889. */
  12890. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12891. /**
  12892. * Fired when the main button state has changed
  12893. */
  12894. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12895. /**
  12896. * Fired when the secondary button state has changed
  12897. */
  12898. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12899. /**
  12900. * Fired when the pad state has changed
  12901. */
  12902. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12903. /**
  12904. * Fired when controllers stick values have changed
  12905. */
  12906. onPadValuesChangedObservable: Observable<StickValues>;
  12907. /**
  12908. * Array of button availible on the controller
  12909. */
  12910. protected _buttons: Array<MutableGamepadButton>;
  12911. private _onButtonStateChange;
  12912. /**
  12913. * Fired when a controller button's state has changed
  12914. * @param callback the callback containing the button that was modified
  12915. */
  12916. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12917. /**
  12918. * X and Y axis corrisponding to the controllers joystick
  12919. */
  12920. pad: StickValues;
  12921. /**
  12922. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12923. */
  12924. hand: string;
  12925. /**
  12926. * The default controller model for the controller
  12927. */
  12928. readonly defaultModel: AbstractMesh;
  12929. /**
  12930. * Creates a new WebVRController from a gamepad
  12931. * @param vrGamepad the gamepad that the WebVRController should be created from
  12932. */
  12933. constructor(vrGamepad: any);
  12934. /**
  12935. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12936. */
  12937. update(): void;
  12938. /**
  12939. * Function to be called when a button is modified
  12940. */
  12941. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12942. /**
  12943. * Loads a mesh and attaches it to the controller
  12944. * @param scene the scene the mesh should be added to
  12945. * @param meshLoaded callback for when the mesh has been loaded
  12946. */
  12947. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12948. private _setButtonValue;
  12949. private _changes;
  12950. private _checkChanges;
  12951. /**
  12952. * Disposes of th webVRCOntroller
  12953. */
  12954. dispose(): void;
  12955. }
  12956. }
  12957. declare module BABYLON {
  12958. /**
  12959. * The HemisphericLight simulates the ambient environment light,
  12960. * so the passed direction is the light reflection direction, not the incoming direction.
  12961. */
  12962. export class HemisphericLight extends Light {
  12963. /**
  12964. * The groundColor is the light in the opposite direction to the one specified during creation.
  12965. * 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.
  12966. */
  12967. groundColor: Color3;
  12968. /**
  12969. * The light reflection direction, not the incoming direction.
  12970. */
  12971. direction: Vector3;
  12972. /**
  12973. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12974. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12975. * The HemisphericLight can't cast shadows.
  12976. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12977. * @param name The friendly name of the light
  12978. * @param direction The direction of the light reflection
  12979. * @param scene The scene the light belongs to
  12980. */
  12981. constructor(name: string, direction: Vector3, scene: Scene);
  12982. protected _buildUniformLayout(): void;
  12983. /**
  12984. * Returns the string "HemisphericLight".
  12985. * @return The class name
  12986. */
  12987. getClassName(): string;
  12988. /**
  12989. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12990. * Returns the updated direction.
  12991. * @param target The target the direction should point to
  12992. * @return The computed direction
  12993. */
  12994. setDirectionToTarget(target: Vector3): Vector3;
  12995. /**
  12996. * Returns the shadow generator associated to the light.
  12997. * @returns Always null for hemispheric lights because it does not support shadows.
  12998. */
  12999. getShadowGenerator(): Nullable<IShadowGenerator>;
  13000. /**
  13001. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13002. * @param effect The effect to update
  13003. * @param lightIndex The index of the light in the effect to update
  13004. * @returns The hemispheric light
  13005. */
  13006. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13007. /**
  13008. * Computes the world matrix of the node
  13009. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13010. * @param useWasUpdatedFlag defines a reserved property
  13011. * @returns the world matrix
  13012. */
  13013. computeWorldMatrix(): Matrix;
  13014. /**
  13015. * Returns the integer 3.
  13016. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13017. */
  13018. getTypeID(): number;
  13019. /**
  13020. * Prepares the list of defines specific to the light type.
  13021. * @param defines the list of defines
  13022. * @param lightIndex defines the index of the light for the effect
  13023. */
  13024. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13025. }
  13026. }
  13027. declare module BABYLON {
  13028. /**
  13029. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13030. * IMPORTANT!! The data is right-hand data.
  13031. * @export
  13032. * @interface DevicePose
  13033. */
  13034. export interface DevicePose {
  13035. /**
  13036. * The position of the device, values in array are [x,y,z].
  13037. */
  13038. readonly position: Nullable<Float32Array>;
  13039. /**
  13040. * The linearVelocity of the device, values in array are [x,y,z].
  13041. */
  13042. readonly linearVelocity: Nullable<Float32Array>;
  13043. /**
  13044. * The linearAcceleration of the device, values in array are [x,y,z].
  13045. */
  13046. readonly linearAcceleration: Nullable<Float32Array>;
  13047. /**
  13048. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13049. */
  13050. readonly orientation: Nullable<Float32Array>;
  13051. /**
  13052. * The angularVelocity of the device, values in array are [x,y,z].
  13053. */
  13054. readonly angularVelocity: Nullable<Float32Array>;
  13055. /**
  13056. * The angularAcceleration of the device, values in array are [x,y,z].
  13057. */
  13058. readonly angularAcceleration: Nullable<Float32Array>;
  13059. }
  13060. /**
  13061. * Interface representing a pose controlled object in Babylon.
  13062. * A pose controlled object has both regular pose values as well as pose values
  13063. * from an external device such as a VR head mounted display
  13064. */
  13065. export interface PoseControlled {
  13066. /**
  13067. * The position of the object in babylon space.
  13068. */
  13069. position: Vector3;
  13070. /**
  13071. * The rotation quaternion of the object in babylon space.
  13072. */
  13073. rotationQuaternion: Quaternion;
  13074. /**
  13075. * The position of the device in babylon space.
  13076. */
  13077. devicePosition?: Vector3;
  13078. /**
  13079. * The rotation quaternion of the device in babylon space.
  13080. */
  13081. deviceRotationQuaternion: Quaternion;
  13082. /**
  13083. * The raw pose coming from the device.
  13084. */
  13085. rawPose: Nullable<DevicePose>;
  13086. /**
  13087. * The scale of the device to be used when translating from device space to babylon space.
  13088. */
  13089. deviceScaleFactor: number;
  13090. /**
  13091. * Updates the poseControlled values based on the input device pose.
  13092. * @param poseData the pose data to update the object with
  13093. */
  13094. updateFromDevice(poseData: DevicePose): void;
  13095. }
  13096. /**
  13097. * Set of options to customize the webVRCamera
  13098. */
  13099. export interface WebVROptions {
  13100. /**
  13101. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13102. */
  13103. trackPosition?: boolean;
  13104. /**
  13105. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13106. */
  13107. positionScale?: number;
  13108. /**
  13109. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13110. */
  13111. displayName?: string;
  13112. /**
  13113. * Should the native controller meshes be initialized. (default: true)
  13114. */
  13115. controllerMeshes?: boolean;
  13116. /**
  13117. * Creating a default HemiLight only on controllers. (default: true)
  13118. */
  13119. defaultLightingOnControllers?: boolean;
  13120. /**
  13121. * If you don't want to use the default VR button of the helper. (default: false)
  13122. */
  13123. useCustomVRButton?: boolean;
  13124. /**
  13125. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13126. */
  13127. customVRButton?: HTMLButtonElement;
  13128. /**
  13129. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13130. */
  13131. rayLength?: number;
  13132. /**
  13133. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13134. */
  13135. defaultHeight?: number;
  13136. }
  13137. /**
  13138. * This represents a WebVR camera.
  13139. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13140. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13141. */
  13142. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13143. private webVROptions;
  13144. /**
  13145. * @hidden
  13146. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13147. */
  13148. _vrDevice: any;
  13149. /**
  13150. * The rawPose of the vrDevice.
  13151. */
  13152. rawPose: Nullable<DevicePose>;
  13153. private _onVREnabled;
  13154. private _specsVersion;
  13155. private _attached;
  13156. private _frameData;
  13157. protected _descendants: Array<Node>;
  13158. private _deviceRoomPosition;
  13159. /** @hidden */
  13160. _deviceRoomRotationQuaternion: Quaternion;
  13161. private _standingMatrix;
  13162. /**
  13163. * Represents device position in babylon space.
  13164. */
  13165. devicePosition: Vector3;
  13166. /**
  13167. * Represents device rotation in babylon space.
  13168. */
  13169. deviceRotationQuaternion: Quaternion;
  13170. /**
  13171. * The scale of the device to be used when translating from device space to babylon space.
  13172. */
  13173. deviceScaleFactor: number;
  13174. private _deviceToWorld;
  13175. private _worldToDevice;
  13176. /**
  13177. * References to the webVR controllers for the vrDevice.
  13178. */
  13179. controllers: Array<WebVRController>;
  13180. /**
  13181. * Emits an event when a controller is attached.
  13182. */
  13183. onControllersAttachedObservable: Observable<WebVRController[]>;
  13184. /**
  13185. * Emits an event when a controller's mesh has been loaded;
  13186. */
  13187. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13188. /**
  13189. * Emits an event when the HMD's pose has been updated.
  13190. */
  13191. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13192. private _poseSet;
  13193. /**
  13194. * If the rig cameras be used as parent instead of this camera.
  13195. */
  13196. rigParenting: boolean;
  13197. private _lightOnControllers;
  13198. private _defaultHeight?;
  13199. /**
  13200. * Instantiates a WebVRFreeCamera.
  13201. * @param name The name of the WebVRFreeCamera
  13202. * @param position The starting anchor position for the camera
  13203. * @param scene The scene the camera belongs to
  13204. * @param webVROptions a set of customizable options for the webVRCamera
  13205. */
  13206. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13207. /**
  13208. * Gets the device distance from the ground in meters.
  13209. * @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.
  13210. */
  13211. deviceDistanceToRoomGround(): number;
  13212. /**
  13213. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13214. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13215. */
  13216. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13217. /**
  13218. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13219. * @returns A promise with a boolean set to if the standing matrix is supported.
  13220. */
  13221. useStandingMatrixAsync(): Promise<boolean>;
  13222. /**
  13223. * Disposes the camera
  13224. */
  13225. dispose(): void;
  13226. /**
  13227. * Gets a vrController by name.
  13228. * @param name The name of the controller to retreive
  13229. * @returns the controller matching the name specified or null if not found
  13230. */
  13231. getControllerByName(name: string): Nullable<WebVRController>;
  13232. private _leftController;
  13233. /**
  13234. * The controller corrisponding to the users left hand.
  13235. */
  13236. readonly leftController: Nullable<WebVRController>;
  13237. private _rightController;
  13238. /**
  13239. * The controller corrisponding to the users right hand.
  13240. */
  13241. readonly rightController: Nullable<WebVRController>;
  13242. /**
  13243. * Casts a ray forward from the vrCamera's gaze.
  13244. * @param length Length of the ray (default: 100)
  13245. * @returns the ray corrisponding to the gaze
  13246. */
  13247. getForwardRay(length?: number): Ray;
  13248. /**
  13249. * @hidden
  13250. * Updates the camera based on device's frame data
  13251. */
  13252. _checkInputs(): void;
  13253. /**
  13254. * Updates the poseControlled values based on the input device pose.
  13255. * @param poseData Pose coming from the device
  13256. */
  13257. updateFromDevice(poseData: DevicePose): void;
  13258. private _htmlElementAttached;
  13259. private _detachIfAttached;
  13260. /**
  13261. * WebVR's attach control will start broadcasting frames to the device.
  13262. * Note that in certain browsers (chrome for example) this function must be called
  13263. * within a user-interaction callback. Example:
  13264. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13265. *
  13266. * @param element html element to attach the vrDevice to
  13267. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13268. */
  13269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13270. /**
  13271. * Detaches the camera from the html element and disables VR
  13272. *
  13273. * @param element html element to detach from
  13274. */
  13275. detachControl(element: HTMLElement): void;
  13276. /**
  13277. * @returns the name of this class
  13278. */
  13279. getClassName(): string;
  13280. /**
  13281. * Calls resetPose on the vrDisplay
  13282. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13283. */
  13284. resetToCurrentRotation(): void;
  13285. /**
  13286. * @hidden
  13287. * Updates the rig cameras (left and right eye)
  13288. */
  13289. _updateRigCameras(): void;
  13290. private _workingVector;
  13291. private _oneVector;
  13292. private _workingMatrix;
  13293. private updateCacheCalled;
  13294. private _correctPositionIfNotTrackPosition;
  13295. /**
  13296. * @hidden
  13297. * Updates the cached values of the camera
  13298. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13299. */
  13300. _updateCache(ignoreParentClass?: boolean): void;
  13301. /**
  13302. * @hidden
  13303. * Get current device position in babylon world
  13304. */
  13305. _computeDevicePosition(): void;
  13306. /**
  13307. * Updates the current device position and rotation in the babylon world
  13308. */
  13309. update(): void;
  13310. /**
  13311. * @hidden
  13312. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13313. * @returns an identity matrix
  13314. */
  13315. _getViewMatrix(): Matrix;
  13316. private _tmpMatrix;
  13317. /**
  13318. * This function is called by the two RIG cameras.
  13319. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13320. * @hidden
  13321. */
  13322. _getWebVRViewMatrix(): Matrix;
  13323. /** @hidden */
  13324. _getWebVRProjectionMatrix(): Matrix;
  13325. private _onGamepadConnectedObserver;
  13326. private _onGamepadDisconnectedObserver;
  13327. private _updateCacheWhenTrackingDisabledObserver;
  13328. /**
  13329. * Initializes the controllers and their meshes
  13330. */
  13331. initControllers(): void;
  13332. }
  13333. }
  13334. declare module BABYLON {
  13335. /**
  13336. * Size options for a post process
  13337. */
  13338. export type PostProcessOptions = {
  13339. width: number;
  13340. height: number;
  13341. };
  13342. /**
  13343. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13344. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13345. */
  13346. export class PostProcess {
  13347. /** Name of the PostProcess. */
  13348. name: string;
  13349. /**
  13350. * Gets or sets the unique id of the post process
  13351. */
  13352. uniqueId: number;
  13353. /**
  13354. * Width of the texture to apply the post process on
  13355. */
  13356. width: number;
  13357. /**
  13358. * Height of the texture to apply the post process on
  13359. */
  13360. height: number;
  13361. /**
  13362. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13363. * @hidden
  13364. */
  13365. _outputTexture: Nullable<InternalTexture>;
  13366. /**
  13367. * Sampling mode used by the shader
  13368. * See https://doc.babylonjs.com/classes/3.1/texture
  13369. */
  13370. renderTargetSamplingMode: number;
  13371. /**
  13372. * Clear color to use when screen clearing
  13373. */
  13374. clearColor: Color4;
  13375. /**
  13376. * If the buffer needs to be cleared before applying the post process. (default: true)
  13377. * Should be set to false if shader will overwrite all previous pixels.
  13378. */
  13379. autoClear: boolean;
  13380. /**
  13381. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13382. */
  13383. alphaMode: number;
  13384. /**
  13385. * Sets the setAlphaBlendConstants of the babylon engine
  13386. */
  13387. alphaConstants: Color4;
  13388. /**
  13389. * Animations to be used for the post processing
  13390. */
  13391. animations: Animation[];
  13392. /**
  13393. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13394. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13395. */
  13396. enablePixelPerfectMode: boolean;
  13397. /**
  13398. * Force the postprocess to be applied without taking in account viewport
  13399. */
  13400. forceFullscreenViewport: boolean;
  13401. /**
  13402. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13403. *
  13404. * | Value | Type | Description |
  13405. * | ----- | ----------------------------------- | ----------- |
  13406. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13407. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13408. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13409. *
  13410. */
  13411. scaleMode: number;
  13412. /**
  13413. * Force textures to be a power of two (default: false)
  13414. */
  13415. alwaysForcePOT: boolean;
  13416. private _samples;
  13417. /**
  13418. * Number of sample textures (default: 1)
  13419. */
  13420. samples: number;
  13421. /**
  13422. * Modify the scale of the post process to be the same as the viewport (default: false)
  13423. */
  13424. adaptScaleToCurrentViewport: boolean;
  13425. private _camera;
  13426. private _scene;
  13427. private _engine;
  13428. private _options;
  13429. private _reusable;
  13430. private _textureType;
  13431. /**
  13432. * Smart array of input and output textures for the post process.
  13433. * @hidden
  13434. */
  13435. _textures: SmartArray<InternalTexture>;
  13436. /**
  13437. * The index in _textures that corresponds to the output texture.
  13438. * @hidden
  13439. */
  13440. _currentRenderTextureInd: number;
  13441. private _effect;
  13442. private _samplers;
  13443. private _fragmentUrl;
  13444. private _vertexUrl;
  13445. private _parameters;
  13446. private _scaleRatio;
  13447. protected _indexParameters: any;
  13448. private _shareOutputWithPostProcess;
  13449. private _texelSize;
  13450. private _forcedOutputTexture;
  13451. /**
  13452. * Returns the fragment url or shader name used in the post process.
  13453. * @returns the fragment url or name in the shader store.
  13454. */
  13455. getEffectName(): string;
  13456. /**
  13457. * An event triggered when the postprocess is activated.
  13458. */
  13459. onActivateObservable: Observable<Camera>;
  13460. private _onActivateObserver;
  13461. /**
  13462. * A function that is added to the onActivateObservable
  13463. */
  13464. onActivate: Nullable<(camera: Camera) => void>;
  13465. /**
  13466. * An event triggered when the postprocess changes its size.
  13467. */
  13468. onSizeChangedObservable: Observable<PostProcess>;
  13469. private _onSizeChangedObserver;
  13470. /**
  13471. * A function that is added to the onSizeChangedObservable
  13472. */
  13473. onSizeChanged: (postProcess: PostProcess) => void;
  13474. /**
  13475. * An event triggered when the postprocess applies its effect.
  13476. */
  13477. onApplyObservable: Observable<Effect>;
  13478. private _onApplyObserver;
  13479. /**
  13480. * A function that is added to the onApplyObservable
  13481. */
  13482. onApply: (effect: Effect) => void;
  13483. /**
  13484. * An event triggered before rendering the postprocess
  13485. */
  13486. onBeforeRenderObservable: Observable<Effect>;
  13487. private _onBeforeRenderObserver;
  13488. /**
  13489. * A function that is added to the onBeforeRenderObservable
  13490. */
  13491. onBeforeRender: (effect: Effect) => void;
  13492. /**
  13493. * An event triggered after rendering the postprocess
  13494. */
  13495. onAfterRenderObservable: Observable<Effect>;
  13496. private _onAfterRenderObserver;
  13497. /**
  13498. * A function that is added to the onAfterRenderObservable
  13499. */
  13500. onAfterRender: (efect: Effect) => void;
  13501. /**
  13502. * 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
  13503. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13504. */
  13505. inputTexture: InternalTexture;
  13506. /**
  13507. * Gets the camera which post process is applied to.
  13508. * @returns The camera the post process is applied to.
  13509. */
  13510. getCamera(): Camera;
  13511. /**
  13512. * Gets the texel size of the postprocess.
  13513. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13514. */
  13515. readonly texelSize: Vector2;
  13516. /**
  13517. * Creates a new instance PostProcess
  13518. * @param name The name of the PostProcess.
  13519. * @param fragmentUrl The url of the fragment shader to be used.
  13520. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13521. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13522. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13523. * @param camera The camera to apply the render pass to.
  13524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13525. * @param engine The engine which the post process will be applied. (default: current engine)
  13526. * @param reusable If the post process can be reused on the same frame. (default: false)
  13527. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13528. * @param textureType Type of textures used when performing the post process. (default: 0)
  13529. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13530. * @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
  13531. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13532. */
  13533. constructor(
  13534. /** Name of the PostProcess. */
  13535. 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);
  13536. /**
  13537. * Gets a string idenfifying the name of the class
  13538. * @returns "PostProcess" string
  13539. */
  13540. getClassName(): string;
  13541. /**
  13542. * Gets the engine which this post process belongs to.
  13543. * @returns The engine the post process was enabled with.
  13544. */
  13545. getEngine(): Engine;
  13546. /**
  13547. * The effect that is created when initializing the post process.
  13548. * @returns The created effect corrisponding the the postprocess.
  13549. */
  13550. getEffect(): Effect;
  13551. /**
  13552. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13553. * @param postProcess The post process to share the output with.
  13554. * @returns This post process.
  13555. */
  13556. shareOutputWith(postProcess: PostProcess): PostProcess;
  13557. /**
  13558. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13559. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13560. */
  13561. useOwnOutput(): void;
  13562. /**
  13563. * Updates the effect with the current post process compile time values and recompiles the shader.
  13564. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13565. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13566. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13567. * @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
  13568. * @param onCompiled Called when the shader has been compiled.
  13569. * @param onError Called if there is an error when compiling a shader.
  13570. */
  13571. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13572. /**
  13573. * The post process is reusable if it can be used multiple times within one frame.
  13574. * @returns If the post process is reusable
  13575. */
  13576. isReusable(): boolean;
  13577. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13578. markTextureDirty(): void;
  13579. /**
  13580. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13581. * 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.
  13582. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13583. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13584. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13585. * @returns The target texture that was bound to be written to.
  13586. */
  13587. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13588. /**
  13589. * If the post process is supported.
  13590. */
  13591. readonly isSupported: boolean;
  13592. /**
  13593. * The aspect ratio of the output texture.
  13594. */
  13595. readonly aspectRatio: number;
  13596. /**
  13597. * Get a value indicating if the post-process is ready to be used
  13598. * @returns true if the post-process is ready (shader is compiled)
  13599. */
  13600. isReady(): boolean;
  13601. /**
  13602. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13603. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13604. */
  13605. apply(): Nullable<Effect>;
  13606. private _disposeTextures;
  13607. /**
  13608. * Disposes the post process.
  13609. * @param camera The camera to dispose the post process on.
  13610. */
  13611. dispose(camera?: Camera): void;
  13612. }
  13613. }
  13614. declare module BABYLON {
  13615. /**
  13616. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13617. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13618. */
  13619. export class PostProcessManager {
  13620. private _scene;
  13621. private _indexBuffer;
  13622. private _vertexBuffers;
  13623. /**
  13624. * Creates a new instance PostProcess
  13625. * @param scene The scene that the post process is associated with.
  13626. */
  13627. constructor(scene: Scene);
  13628. private _prepareBuffers;
  13629. private _buildIndexBuffer;
  13630. /**
  13631. * Rebuilds the vertex buffers of the manager.
  13632. * @hidden
  13633. */
  13634. _rebuild(): void;
  13635. /**
  13636. * Prepares a frame to be run through a post process.
  13637. * @param sourceTexture The input texture to the post procesess. (default: null)
  13638. * @param postProcesses An array of post processes to be run. (default: null)
  13639. * @returns True if the post processes were able to be run.
  13640. * @hidden
  13641. */
  13642. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13643. /**
  13644. * Manually render a set of post processes to a texture.
  13645. * @param postProcesses An array of post processes to be run.
  13646. * @param targetTexture The target texture to render to.
  13647. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13648. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13649. * @param lodLevel defines which lod of the texture to render to
  13650. */
  13651. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13652. /**
  13653. * Finalize the result of the output of the postprocesses.
  13654. * @param doNotPresent If true the result will not be displayed to the screen.
  13655. * @param targetTexture The target texture to render to.
  13656. * @param faceIndex The index of the face to bind the target texture to.
  13657. * @param postProcesses The array of post processes to render.
  13658. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13659. * @hidden
  13660. */
  13661. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13662. /**
  13663. * Disposes of the post process manager.
  13664. */
  13665. dispose(): void;
  13666. }
  13667. }
  13668. declare module BABYLON {
  13669. /**
  13670. * Raw texture can help creating a texture directly from an array of data.
  13671. * This can be super useful if you either get the data from an uncompressed source or
  13672. * if you wish to create your texture pixel by pixel.
  13673. */
  13674. export class RawTexture extends Texture {
  13675. /**
  13676. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13677. */
  13678. format: number;
  13679. private _engine;
  13680. /**
  13681. * Instantiates a new RawTexture.
  13682. * Raw texture can help creating a texture directly from an array of data.
  13683. * This can be super useful if you either get the data from an uncompressed source or
  13684. * if you wish to create your texture pixel by pixel.
  13685. * @param data define the array of data to use to create the texture
  13686. * @param width define the width of the texture
  13687. * @param height define the height of the texture
  13688. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13689. * @param scene define the scene the texture belongs to
  13690. * @param generateMipMaps define whether mip maps should be generated or not
  13691. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13692. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13693. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13694. */
  13695. constructor(data: ArrayBufferView, width: number, height: number,
  13696. /**
  13697. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13698. */
  13699. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13700. /**
  13701. * Updates the texture underlying data.
  13702. * @param data Define the new data of the texture
  13703. */
  13704. update(data: ArrayBufferView): void;
  13705. /**
  13706. * Creates a luminance texture from some data.
  13707. * @param data Define the texture data
  13708. * @param width Define the width of the texture
  13709. * @param height Define the height of the texture
  13710. * @param scene Define the scene the texture belongs to
  13711. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13712. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13713. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13714. * @returns the luminance texture
  13715. */
  13716. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13717. /**
  13718. * Creates a luminance alpha texture from some data.
  13719. * @param data Define the texture data
  13720. * @param width Define the width of the texture
  13721. * @param height Define the height of the texture
  13722. * @param scene Define the scene the texture belongs to
  13723. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13724. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13725. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13726. * @returns the luminance alpha texture
  13727. */
  13728. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13729. /**
  13730. * Creates an alpha texture from some data.
  13731. * @param data Define the texture data
  13732. * @param width Define the width of the texture
  13733. * @param height Define the height of the texture
  13734. * @param scene Define the scene the texture belongs to
  13735. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13736. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13737. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13738. * @returns the alpha texture
  13739. */
  13740. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13741. /**
  13742. * Creates a RGB texture from some data.
  13743. * @param data Define the texture data
  13744. * @param width Define the width of the texture
  13745. * @param height Define the height of the texture
  13746. * @param scene Define the scene the texture belongs to
  13747. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13748. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13749. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13750. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13751. * @returns the RGB alpha texture
  13752. */
  13753. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13754. /**
  13755. * Creates a RGBA texture from some data.
  13756. * @param data Define the texture data
  13757. * @param width Define the width of the texture
  13758. * @param height Define the height of the texture
  13759. * @param scene Define the scene the texture belongs to
  13760. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13761. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13762. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13763. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13764. * @returns the RGBA texture
  13765. */
  13766. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13767. /**
  13768. * Creates a R texture from some data.
  13769. * @param data Define the texture data
  13770. * @param width Define the width of the texture
  13771. * @param height Define the height of the texture
  13772. * @param scene Define the scene the texture belongs to
  13773. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13774. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13775. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13776. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13777. * @returns the R texture
  13778. */
  13779. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13780. }
  13781. }
  13782. declare module BABYLON {
  13783. interface AbstractScene {
  13784. /**
  13785. * The list of layers (background and foreground) of the scene
  13786. */
  13787. layers: Array<Layer>;
  13788. }
  13789. /**
  13790. * Defines the layer scene component responsible to manage any layers
  13791. * in a given scene.
  13792. */
  13793. export class LayerSceneComponent implements ISceneComponent {
  13794. /**
  13795. * The component name helpfull to identify the component in the list of scene components.
  13796. */
  13797. readonly name: string;
  13798. /**
  13799. * The scene the component belongs to.
  13800. */
  13801. scene: Scene;
  13802. private _engine;
  13803. /**
  13804. * Creates a new instance of the component for the given scene
  13805. * @param scene Defines the scene to register the component in
  13806. */
  13807. constructor(scene: Scene);
  13808. /**
  13809. * Registers the component in a given scene
  13810. */
  13811. register(): void;
  13812. /**
  13813. * Rebuilds the elements related to this component in case of
  13814. * context lost for instance.
  13815. */
  13816. rebuild(): void;
  13817. /**
  13818. * Disposes the component and the associated ressources.
  13819. */
  13820. dispose(): void;
  13821. private _draw;
  13822. private _drawCameraPredicate;
  13823. private _drawCameraBackground;
  13824. private _drawCameraForeground;
  13825. private _drawRenderTargetPredicate;
  13826. private _drawRenderTargetBackground;
  13827. private _drawRenderTargetForeground;
  13828. }
  13829. }
  13830. declare module BABYLON {
  13831. /** @hidden */
  13832. export var layerPixelShader: {
  13833. name: string;
  13834. shader: string;
  13835. };
  13836. }
  13837. declare module BABYLON {
  13838. /** @hidden */
  13839. export var layerVertexShader: {
  13840. name: string;
  13841. shader: string;
  13842. };
  13843. }
  13844. declare module BABYLON {
  13845. /**
  13846. * This represents a full screen 2d layer.
  13847. * This can be useful to display a picture in the background of your scene for instance.
  13848. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13849. */
  13850. export class Layer {
  13851. /**
  13852. * Define the name of the layer.
  13853. */
  13854. name: string;
  13855. /**
  13856. * Define the texture the layer should display.
  13857. */
  13858. texture: Nullable<Texture>;
  13859. /**
  13860. * Is the layer in background or foreground.
  13861. */
  13862. isBackground: boolean;
  13863. /**
  13864. * Define the color of the layer (instead of texture).
  13865. */
  13866. color: Color4;
  13867. /**
  13868. * Define the scale of the layer in order to zoom in out of the texture.
  13869. */
  13870. scale: Vector2;
  13871. /**
  13872. * Define an offset for the layer in order to shift the texture.
  13873. */
  13874. offset: Vector2;
  13875. /**
  13876. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13877. */
  13878. alphaBlendingMode: number;
  13879. /**
  13880. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13881. * Alpha test will not mix with the background color in case of transparency.
  13882. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13883. */
  13884. alphaTest: boolean;
  13885. /**
  13886. * Define a mask to restrict the layer to only some of the scene cameras.
  13887. */
  13888. layerMask: number;
  13889. /**
  13890. * Define the list of render target the layer is visible into.
  13891. */
  13892. renderTargetTextures: RenderTargetTexture[];
  13893. /**
  13894. * Define if the layer is only used in renderTarget or if it also
  13895. * renders in the main frame buffer of the canvas.
  13896. */
  13897. renderOnlyInRenderTargetTextures: boolean;
  13898. private _scene;
  13899. private _vertexBuffers;
  13900. private _indexBuffer;
  13901. private _effect;
  13902. private _alphaTestEffect;
  13903. /**
  13904. * An event triggered when the layer is disposed.
  13905. */
  13906. onDisposeObservable: Observable<Layer>;
  13907. private _onDisposeObserver;
  13908. /**
  13909. * Back compatibility with callback before the onDisposeObservable existed.
  13910. * The set callback will be triggered when the layer has been disposed.
  13911. */
  13912. onDispose: () => void;
  13913. /**
  13914. * An event triggered before rendering the scene
  13915. */
  13916. onBeforeRenderObservable: Observable<Layer>;
  13917. private _onBeforeRenderObserver;
  13918. /**
  13919. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13920. * The set callback will be triggered just before rendering the layer.
  13921. */
  13922. onBeforeRender: () => void;
  13923. /**
  13924. * An event triggered after rendering the scene
  13925. */
  13926. onAfterRenderObservable: Observable<Layer>;
  13927. private _onAfterRenderObserver;
  13928. /**
  13929. * Back compatibility with callback before the onAfterRenderObservable existed.
  13930. * The set callback will be triggered just after rendering the layer.
  13931. */
  13932. onAfterRender: () => void;
  13933. /**
  13934. * Instantiates a new layer.
  13935. * This represents a full screen 2d layer.
  13936. * This can be useful to display a picture in the background of your scene for instance.
  13937. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13938. * @param name Define the name of the layer in the scene
  13939. * @param imgUrl Define the url of the texture to display in the layer
  13940. * @param scene Define the scene the layer belongs to
  13941. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13942. * @param color Defines a color for the layer
  13943. */
  13944. constructor(
  13945. /**
  13946. * Define the name of the layer.
  13947. */
  13948. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13949. private _createIndexBuffer;
  13950. /** @hidden */
  13951. _rebuild(): void;
  13952. /**
  13953. * Renders the layer in the scene.
  13954. */
  13955. render(): void;
  13956. /**
  13957. * Disposes and releases the associated ressources.
  13958. */
  13959. dispose(): void;
  13960. }
  13961. }
  13962. declare module BABYLON {
  13963. interface AbstractScene {
  13964. /**
  13965. * The list of procedural textures added to the scene
  13966. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13967. */
  13968. proceduralTextures: Array<ProceduralTexture>;
  13969. }
  13970. /**
  13971. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13972. * in a given scene.
  13973. */
  13974. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13975. /**
  13976. * The component name helpfull to identify the component in the list of scene components.
  13977. */
  13978. readonly name: string;
  13979. /**
  13980. * The scene the component belongs to.
  13981. */
  13982. scene: Scene;
  13983. /**
  13984. * Creates a new instance of the component for the given scene
  13985. * @param scene Defines the scene to register the component in
  13986. */
  13987. constructor(scene: Scene);
  13988. /**
  13989. * Registers the component in a given scene
  13990. */
  13991. register(): void;
  13992. /**
  13993. * Rebuilds the elements related to this component in case of
  13994. * context lost for instance.
  13995. */
  13996. rebuild(): void;
  13997. /**
  13998. * Disposes the component and the associated ressources.
  13999. */
  14000. dispose(): void;
  14001. private _beforeClear;
  14002. }
  14003. }
  14004. declare module BABYLON {
  14005. /** @hidden */
  14006. export var proceduralVertexShader: {
  14007. name: string;
  14008. shader: string;
  14009. };
  14010. }
  14011. declare module BABYLON {
  14012. /**
  14013. * 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.
  14014. * This is the base class of any Procedural texture and contains most of the shareable code.
  14015. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14016. */
  14017. export class ProceduralTexture extends Texture {
  14018. isCube: boolean;
  14019. /**
  14020. * Define if the texture is enabled or not (disabled texture will not render)
  14021. */
  14022. isEnabled: boolean;
  14023. /**
  14024. * Define if the texture must be cleared before rendering (default is true)
  14025. */
  14026. autoClear: boolean;
  14027. /**
  14028. * Callback called when the texture is generated
  14029. */
  14030. onGenerated: () => void;
  14031. /**
  14032. * Event raised when the texture is generated
  14033. */
  14034. onGeneratedObservable: Observable<ProceduralTexture>;
  14035. /** @hidden */
  14036. _generateMipMaps: boolean;
  14037. /** @hidden **/
  14038. _effect: Effect;
  14039. /** @hidden */
  14040. _textures: {
  14041. [key: string]: Texture;
  14042. };
  14043. private _size;
  14044. private _currentRefreshId;
  14045. private _refreshRate;
  14046. private _vertexBuffers;
  14047. private _indexBuffer;
  14048. private _uniforms;
  14049. private _samplers;
  14050. private _fragment;
  14051. private _floats;
  14052. private _ints;
  14053. private _floatsArrays;
  14054. private _colors3;
  14055. private _colors4;
  14056. private _vectors2;
  14057. private _vectors3;
  14058. private _matrices;
  14059. private _fallbackTexture;
  14060. private _fallbackTextureUsed;
  14061. private _engine;
  14062. private _cachedDefines;
  14063. private _contentUpdateId;
  14064. private _contentData;
  14065. /**
  14066. * Instantiates a new procedural texture.
  14067. * 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.
  14068. * This is the base class of any Procedural texture and contains most of the shareable code.
  14069. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14070. * @param name Define the name of the texture
  14071. * @param size Define the size of the texture to create
  14072. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14073. * @param scene Define the scene the texture belongs to
  14074. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14075. * @param generateMipMaps Define if the texture should creates mip maps or not
  14076. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14077. */
  14078. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14079. /**
  14080. * The effect that is created when initializing the post process.
  14081. * @returns The created effect corrisponding the the postprocess.
  14082. */
  14083. getEffect(): Effect;
  14084. /**
  14085. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14086. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14087. */
  14088. getContent(): Nullable<ArrayBufferView>;
  14089. private _createIndexBuffer;
  14090. /** @hidden */
  14091. _rebuild(): void;
  14092. /**
  14093. * Resets the texture in order to recreate its associated resources.
  14094. * This can be called in case of context loss
  14095. */
  14096. reset(): void;
  14097. protected _getDefines(): string;
  14098. /**
  14099. * Is the texture ready to be used ? (rendered at least once)
  14100. * @returns true if ready, otherwise, false.
  14101. */
  14102. isReady(): boolean;
  14103. /**
  14104. * Resets the refresh counter of the texture and start bak from scratch.
  14105. * Could be useful to regenerate the texture if it is setup to render only once.
  14106. */
  14107. resetRefreshCounter(): void;
  14108. /**
  14109. * Set the fragment shader to use in order to render the texture.
  14110. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14111. */
  14112. setFragment(fragment: any): void;
  14113. /**
  14114. * Define the refresh rate of the texture or the rendering frequency.
  14115. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14116. */
  14117. refreshRate: number;
  14118. /** @hidden */
  14119. _shouldRender(): boolean;
  14120. /**
  14121. * Get the size the texture is rendering at.
  14122. * @returns the size (texture is always squared)
  14123. */
  14124. getRenderSize(): number;
  14125. /**
  14126. * Resize the texture to new value.
  14127. * @param size Define the new size the texture should have
  14128. * @param generateMipMaps Define whether the new texture should create mip maps
  14129. */
  14130. resize(size: number, generateMipMaps: boolean): void;
  14131. private _checkUniform;
  14132. /**
  14133. * Set a texture in the shader program used to render.
  14134. * @param name Define the name of the uniform samplers as defined in the shader
  14135. * @param texture Define the texture to bind to this sampler
  14136. * @return the texture itself allowing "fluent" like uniform updates
  14137. */
  14138. setTexture(name: string, texture: Texture): ProceduralTexture;
  14139. /**
  14140. * Set a float in the shader.
  14141. * @param name Define the name of the uniform as defined in the shader
  14142. * @param value Define the value to give to the uniform
  14143. * @return the texture itself allowing "fluent" like uniform updates
  14144. */
  14145. setFloat(name: string, value: number): ProceduralTexture;
  14146. /**
  14147. * Set a int in the shader.
  14148. * @param name Define the name of the uniform as defined in the shader
  14149. * @param value Define the value to give to the uniform
  14150. * @return the texture itself allowing "fluent" like uniform updates
  14151. */
  14152. setInt(name: string, value: number): ProceduralTexture;
  14153. /**
  14154. * Set an array of floats in the shader.
  14155. * @param name Define the name of the uniform as defined in the shader
  14156. * @param value Define the value to give to the uniform
  14157. * @return the texture itself allowing "fluent" like uniform updates
  14158. */
  14159. setFloats(name: string, value: number[]): ProceduralTexture;
  14160. /**
  14161. * Set a vec3 in the shader from a Color3.
  14162. * @param name Define the name of the uniform as defined in the shader
  14163. * @param value Define the value to give to the uniform
  14164. * @return the texture itself allowing "fluent" like uniform updates
  14165. */
  14166. setColor3(name: string, value: Color3): ProceduralTexture;
  14167. /**
  14168. * Set a vec4 in the shader from a Color4.
  14169. * @param name Define the name of the uniform as defined in the shader
  14170. * @param value Define the value to give to the uniform
  14171. * @return the texture itself allowing "fluent" like uniform updates
  14172. */
  14173. setColor4(name: string, value: Color4): ProceduralTexture;
  14174. /**
  14175. * Set a vec2 in the shader from a Vector2.
  14176. * @param name Define the name of the uniform as defined in the shader
  14177. * @param value Define the value to give to the uniform
  14178. * @return the texture itself allowing "fluent" like uniform updates
  14179. */
  14180. setVector2(name: string, value: Vector2): ProceduralTexture;
  14181. /**
  14182. * Set a vec3 in the shader from a Vector3.
  14183. * @param name Define the name of the uniform as defined in the shader
  14184. * @param value Define the value to give to the uniform
  14185. * @return the texture itself allowing "fluent" like uniform updates
  14186. */
  14187. setVector3(name: string, value: Vector3): ProceduralTexture;
  14188. /**
  14189. * Set a mat4 in the shader from a MAtrix.
  14190. * @param name Define the name of the uniform as defined in the shader
  14191. * @param value Define the value to give to the uniform
  14192. * @return the texture itself allowing "fluent" like uniform updates
  14193. */
  14194. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14195. /**
  14196. * Render the texture to its associated render target.
  14197. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14198. */
  14199. render(useCameraPostProcess?: boolean): void;
  14200. /**
  14201. * Clone the texture.
  14202. * @returns the cloned texture
  14203. */
  14204. clone(): ProceduralTexture;
  14205. /**
  14206. * Dispose the texture and release its asoociated resources.
  14207. */
  14208. dispose(): void;
  14209. }
  14210. }
  14211. declare module BABYLON {
  14212. /**
  14213. * This represents the base class for particle system in Babylon.
  14214. * 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.
  14215. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14216. * @example https://doc.babylonjs.com/babylon101/particles
  14217. */
  14218. export class BaseParticleSystem {
  14219. /**
  14220. * Source color is added to the destination color without alpha affecting the result
  14221. */
  14222. static BLENDMODE_ONEONE: number;
  14223. /**
  14224. * Blend current color and particle color using particle’s alpha
  14225. */
  14226. static BLENDMODE_STANDARD: number;
  14227. /**
  14228. * Add current color and particle color multiplied by particle’s alpha
  14229. */
  14230. static BLENDMODE_ADD: number;
  14231. /**
  14232. * Multiply current color with particle color
  14233. */
  14234. static BLENDMODE_MULTIPLY: number;
  14235. /**
  14236. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14237. */
  14238. static BLENDMODE_MULTIPLYADD: number;
  14239. /**
  14240. * List of animations used by the particle system.
  14241. */
  14242. animations: Animation[];
  14243. /**
  14244. * The id of the Particle system.
  14245. */
  14246. id: string;
  14247. /**
  14248. * The friendly name of the Particle system.
  14249. */
  14250. name: string;
  14251. /**
  14252. * The rendering group used by the Particle system to chose when to render.
  14253. */
  14254. renderingGroupId: number;
  14255. /**
  14256. * The emitter represents the Mesh or position we are attaching the particle system to.
  14257. */
  14258. emitter: Nullable<AbstractMesh | Vector3>;
  14259. /**
  14260. * The maximum number of particles to emit per frame
  14261. */
  14262. emitRate: number;
  14263. /**
  14264. * If you want to launch only a few particles at once, that can be done, as well.
  14265. */
  14266. manualEmitCount: number;
  14267. /**
  14268. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14269. */
  14270. updateSpeed: number;
  14271. /**
  14272. * The amount of time the particle system is running (depends of the overall update speed).
  14273. */
  14274. targetStopDuration: number;
  14275. /**
  14276. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14277. */
  14278. disposeOnStop: boolean;
  14279. /**
  14280. * Minimum power of emitting particles.
  14281. */
  14282. minEmitPower: number;
  14283. /**
  14284. * Maximum power of emitting particles.
  14285. */
  14286. maxEmitPower: number;
  14287. /**
  14288. * Minimum life time of emitting particles.
  14289. */
  14290. minLifeTime: number;
  14291. /**
  14292. * Maximum life time of emitting particles.
  14293. */
  14294. maxLifeTime: number;
  14295. /**
  14296. * Minimum Size of emitting particles.
  14297. */
  14298. minSize: number;
  14299. /**
  14300. * Maximum Size of emitting particles.
  14301. */
  14302. maxSize: number;
  14303. /**
  14304. * Minimum scale of emitting particles on X axis.
  14305. */
  14306. minScaleX: number;
  14307. /**
  14308. * Maximum scale of emitting particles on X axis.
  14309. */
  14310. maxScaleX: number;
  14311. /**
  14312. * Minimum scale of emitting particles on Y axis.
  14313. */
  14314. minScaleY: number;
  14315. /**
  14316. * Maximum scale of emitting particles on Y axis.
  14317. */
  14318. maxScaleY: number;
  14319. /**
  14320. * Gets or sets the minimal initial rotation in radians.
  14321. */
  14322. minInitialRotation: number;
  14323. /**
  14324. * Gets or sets the maximal initial rotation in radians.
  14325. */
  14326. maxInitialRotation: number;
  14327. /**
  14328. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14329. */
  14330. minAngularSpeed: number;
  14331. /**
  14332. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14333. */
  14334. maxAngularSpeed: number;
  14335. /**
  14336. * The texture used to render each particle. (this can be a spritesheet)
  14337. */
  14338. particleTexture: Nullable<Texture>;
  14339. /**
  14340. * The layer mask we are rendering the particles through.
  14341. */
  14342. layerMask: number;
  14343. /**
  14344. * This can help using your own shader to render the particle system.
  14345. * The according effect will be created
  14346. */
  14347. customShader: any;
  14348. /**
  14349. * By default particle system starts as soon as they are created. This prevents the
  14350. * automatic start to happen and let you decide when to start emitting particles.
  14351. */
  14352. preventAutoStart: boolean;
  14353. private _noiseTexture;
  14354. /**
  14355. * Gets or sets a texture used to add random noise to particle positions
  14356. */
  14357. noiseTexture: Nullable<ProceduralTexture>;
  14358. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14359. noiseStrength: Vector3;
  14360. /**
  14361. * Callback triggered when the particle animation is ending.
  14362. */
  14363. onAnimationEnd: Nullable<() => void>;
  14364. /**
  14365. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14366. */
  14367. blendMode: number;
  14368. /**
  14369. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14370. * to override the particles.
  14371. */
  14372. forceDepthWrite: boolean;
  14373. /** 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 */
  14374. preWarmCycles: number;
  14375. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14376. preWarmStepOffset: number;
  14377. /**
  14378. * 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)
  14379. */
  14380. spriteCellChangeSpeed: number;
  14381. /**
  14382. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14383. */
  14384. startSpriteCellID: number;
  14385. /**
  14386. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14387. */
  14388. endSpriteCellID: number;
  14389. /**
  14390. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14391. */
  14392. spriteCellWidth: number;
  14393. /**
  14394. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14395. */
  14396. spriteCellHeight: number;
  14397. /**
  14398. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14399. */
  14400. spriteRandomStartCell: boolean;
  14401. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14402. translationPivot: Vector2;
  14403. /** @hidden */
  14404. protected _isAnimationSheetEnabled: boolean;
  14405. /**
  14406. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14407. */
  14408. beginAnimationOnStart: boolean;
  14409. /**
  14410. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14411. */
  14412. beginAnimationFrom: number;
  14413. /**
  14414. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14415. */
  14416. beginAnimationTo: number;
  14417. /**
  14418. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14419. */
  14420. beginAnimationLoop: boolean;
  14421. /**
  14422. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14423. */
  14424. isAnimationSheetEnabled: boolean;
  14425. /**
  14426. * Get hosting scene
  14427. * @returns the scene
  14428. */
  14429. getScene(): Scene;
  14430. /**
  14431. * You can use gravity if you want to give an orientation to your particles.
  14432. */
  14433. gravity: Vector3;
  14434. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14435. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14436. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14437. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14438. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14439. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14440. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14441. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14442. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14443. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14444. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14445. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14446. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14447. /**
  14448. * Defines the delay in milliseconds before starting the system (0 by default)
  14449. */
  14450. startDelay: number;
  14451. /**
  14452. * Gets the current list of drag gradients.
  14453. * You must use addDragGradient and removeDragGradient to udpate this list
  14454. * @returns the list of drag gradients
  14455. */
  14456. getDragGradients(): Nullable<Array<FactorGradient>>;
  14457. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14458. limitVelocityDamping: number;
  14459. /**
  14460. * Gets the current list of limit velocity gradients.
  14461. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14462. * @returns the list of limit velocity gradients
  14463. */
  14464. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14465. /**
  14466. * Gets the current list of color gradients.
  14467. * You must use addColorGradient and removeColorGradient to udpate this list
  14468. * @returns the list of color gradients
  14469. */
  14470. getColorGradients(): Nullable<Array<ColorGradient>>;
  14471. /**
  14472. * Gets the current list of size gradients.
  14473. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14474. * @returns the list of size gradients
  14475. */
  14476. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14477. /**
  14478. * Gets the current list of color remap gradients.
  14479. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14480. * @returns the list of color remap gradients
  14481. */
  14482. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14483. /**
  14484. * Gets the current list of alpha remap gradients.
  14485. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14486. * @returns the list of alpha remap gradients
  14487. */
  14488. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14489. /**
  14490. * Gets the current list of life time gradients.
  14491. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14492. * @returns the list of life time gradients
  14493. */
  14494. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14495. /**
  14496. * Gets the current list of angular speed gradients.
  14497. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14498. * @returns the list of angular speed gradients
  14499. */
  14500. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14501. /**
  14502. * Gets the current list of velocity gradients.
  14503. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14504. * @returns the list of velocity gradients
  14505. */
  14506. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14507. /**
  14508. * Gets the current list of start size gradients.
  14509. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14510. * @returns the list of start size gradients
  14511. */
  14512. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14513. /**
  14514. * Gets the current list of emit rate gradients.
  14515. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14516. * @returns the list of emit rate gradients
  14517. */
  14518. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14519. /**
  14520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14521. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14522. */
  14523. direction1: Vector3;
  14524. /**
  14525. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14526. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14527. */
  14528. direction2: Vector3;
  14529. /**
  14530. * 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.
  14531. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14532. */
  14533. minEmitBox: Vector3;
  14534. /**
  14535. * 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.
  14536. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14537. */
  14538. maxEmitBox: Vector3;
  14539. /**
  14540. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14541. */
  14542. color1: Color4;
  14543. /**
  14544. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14545. */
  14546. color2: Color4;
  14547. /**
  14548. * Color the particle will have at the end of its lifetime
  14549. */
  14550. colorDead: Color4;
  14551. /**
  14552. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14553. */
  14554. textureMask: Color4;
  14555. /**
  14556. * The particle emitter type defines the emitter used by the particle system.
  14557. * It can be for example box, sphere, or cone...
  14558. */
  14559. particleEmitterType: IParticleEmitterType;
  14560. /** @hidden */
  14561. _isSubEmitter: boolean;
  14562. /**
  14563. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14564. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14565. */
  14566. billboardMode: number;
  14567. protected _isBillboardBased: boolean;
  14568. /**
  14569. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14570. */
  14571. isBillboardBased: boolean;
  14572. /**
  14573. * The scene the particle system belongs to.
  14574. */
  14575. protected _scene: Scene;
  14576. /**
  14577. * Local cache of defines for image processing.
  14578. */
  14579. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14580. /**
  14581. * Default configuration related to image processing available in the standard Material.
  14582. */
  14583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14584. /**
  14585. * Gets the image processing configuration used either in this material.
  14586. */
  14587. /**
  14588. * Sets the Default image processing configuration used either in the this material.
  14589. *
  14590. * If sets to null, the scene one is in use.
  14591. */
  14592. imageProcessingConfiguration: ImageProcessingConfiguration;
  14593. /**
  14594. * Attaches a new image processing configuration to the Standard Material.
  14595. * @param configuration
  14596. */
  14597. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14598. /** @hidden */
  14599. protected _reset(): void;
  14600. /** @hidden */
  14601. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14602. /**
  14603. * Instantiates a particle system.
  14604. * 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.
  14605. * @param name The name of the particle system
  14606. */
  14607. constructor(name: string);
  14608. /**
  14609. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14610. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14611. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14612. * @returns the emitter
  14613. */
  14614. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14615. /**
  14616. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14617. * @param radius The radius of the hemisphere to emit from
  14618. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14619. * @returns the emitter
  14620. */
  14621. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14622. /**
  14623. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14624. * @param radius The radius of the sphere to emit from
  14625. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14626. * @returns the emitter
  14627. */
  14628. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14629. /**
  14630. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14631. * @param radius The radius of the sphere to emit from
  14632. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14633. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14634. * @returns the emitter
  14635. */
  14636. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14637. /**
  14638. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14639. * @param radius The radius of the emission cylinder
  14640. * @param height The height of the emission cylinder
  14641. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14642. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14643. * @returns the emitter
  14644. */
  14645. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14646. /**
  14647. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14648. * @param radius The radius of the cylinder to emit from
  14649. * @param height The height of the emission cylinder
  14650. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14653. * @returns the emitter
  14654. */
  14655. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14656. /**
  14657. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14658. * @param radius The radius of the cone to emit from
  14659. * @param angle The base angle of the cone
  14660. * @returns the emitter
  14661. */
  14662. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14663. /**
  14664. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14665. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14666. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14667. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14668. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14669. * @returns the emitter
  14670. */
  14671. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14672. }
  14673. }
  14674. declare module BABYLON {
  14675. /**
  14676. * Type of sub emitter
  14677. */
  14678. export enum SubEmitterType {
  14679. /**
  14680. * Attached to the particle over it's lifetime
  14681. */
  14682. ATTACHED = 0,
  14683. /**
  14684. * Created when the particle dies
  14685. */
  14686. END = 1
  14687. }
  14688. /**
  14689. * Sub emitter class used to emit particles from an existing particle
  14690. */
  14691. export class SubEmitter {
  14692. /**
  14693. * the particle system to be used by the sub emitter
  14694. */
  14695. particleSystem: ParticleSystem;
  14696. /**
  14697. * Type of the submitter (Default: END)
  14698. */
  14699. type: SubEmitterType;
  14700. /**
  14701. * 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)
  14702. * Note: This only is supported when using an emitter of type Mesh
  14703. */
  14704. inheritDirection: boolean;
  14705. /**
  14706. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14707. */
  14708. inheritedVelocityAmount: number;
  14709. /**
  14710. * Creates a sub emitter
  14711. * @param particleSystem the particle system to be used by the sub emitter
  14712. */
  14713. constructor(
  14714. /**
  14715. * the particle system to be used by the sub emitter
  14716. */
  14717. particleSystem: ParticleSystem);
  14718. /**
  14719. * Clones the sub emitter
  14720. * @returns the cloned sub emitter
  14721. */
  14722. clone(): SubEmitter;
  14723. /**
  14724. * Serialize current object to a JSON object
  14725. * @returns the serialized object
  14726. */
  14727. serialize(): any;
  14728. /** @hidden */
  14729. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14730. /**
  14731. * Creates a new SubEmitter from a serialized JSON version
  14732. * @param serializationObject defines the JSON object to read from
  14733. * @param scene defines the hosting scene
  14734. * @param rootUrl defines the rootUrl for data loading
  14735. * @returns a new SubEmitter
  14736. */
  14737. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14738. /** Release associated resources */
  14739. dispose(): void;
  14740. }
  14741. }
  14742. declare module BABYLON {
  14743. /** @hidden */
  14744. export var clipPlaneFragmentDeclaration: {
  14745. name: string;
  14746. shader: string;
  14747. };
  14748. }
  14749. declare module BABYLON {
  14750. /** @hidden */
  14751. export var imageProcessingDeclaration: {
  14752. name: string;
  14753. shader: string;
  14754. };
  14755. }
  14756. declare module BABYLON {
  14757. /** @hidden */
  14758. export var imageProcessingFunctions: {
  14759. name: string;
  14760. shader: string;
  14761. };
  14762. }
  14763. declare module BABYLON {
  14764. /** @hidden */
  14765. export var clipPlaneFragment: {
  14766. name: string;
  14767. shader: string;
  14768. };
  14769. }
  14770. declare module BABYLON {
  14771. /** @hidden */
  14772. export var particlesPixelShader: {
  14773. name: string;
  14774. shader: string;
  14775. };
  14776. }
  14777. declare module BABYLON {
  14778. /** @hidden */
  14779. export var clipPlaneVertexDeclaration: {
  14780. name: string;
  14781. shader: string;
  14782. };
  14783. }
  14784. declare module BABYLON {
  14785. /** @hidden */
  14786. export var clipPlaneVertex: {
  14787. name: string;
  14788. shader: string;
  14789. };
  14790. }
  14791. declare module BABYLON {
  14792. /** @hidden */
  14793. export var particlesVertexShader: {
  14794. name: string;
  14795. shader: string;
  14796. };
  14797. }
  14798. declare module BABYLON {
  14799. /**
  14800. * This represents a particle system in Babylon.
  14801. * 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.
  14802. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14803. * @example https://doc.babylonjs.com/babylon101/particles
  14804. */
  14805. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14806. /**
  14807. * Billboard mode will only apply to Y axis
  14808. */
  14809. static readonly BILLBOARDMODE_Y: number;
  14810. /**
  14811. * Billboard mode will apply to all axes
  14812. */
  14813. static readonly BILLBOARDMODE_ALL: number;
  14814. /**
  14815. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14816. */
  14817. static readonly BILLBOARDMODE_STRETCHED: number;
  14818. /**
  14819. * This function can be defined to provide custom update for active particles.
  14820. * This function will be called instead of regular update (age, position, color, etc.).
  14821. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14822. */
  14823. updateFunction: (particles: Particle[]) => void;
  14824. private _emitterWorldMatrix;
  14825. /**
  14826. * This function can be defined to specify initial direction for every new particle.
  14827. * It by default use the emitterType defined function
  14828. */
  14829. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14830. /**
  14831. * This function can be defined to specify initial position for every new particle.
  14832. * It by default use the emitterType defined function
  14833. */
  14834. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14835. /**
  14836. * @hidden
  14837. */
  14838. _inheritedVelocityOffset: Vector3;
  14839. /**
  14840. * An event triggered when the system is disposed
  14841. */
  14842. onDisposeObservable: Observable<ParticleSystem>;
  14843. private _onDisposeObserver;
  14844. /**
  14845. * Sets a callback that will be triggered when the system is disposed
  14846. */
  14847. onDispose: () => void;
  14848. private _particles;
  14849. private _epsilon;
  14850. private _capacity;
  14851. private _stockParticles;
  14852. private _newPartsExcess;
  14853. private _vertexData;
  14854. private _vertexBuffer;
  14855. private _vertexBuffers;
  14856. private _spriteBuffer;
  14857. private _indexBuffer;
  14858. private _effect;
  14859. private _customEffect;
  14860. private _cachedDefines;
  14861. private _scaledColorStep;
  14862. private _colorDiff;
  14863. private _scaledDirection;
  14864. private _scaledGravity;
  14865. private _currentRenderId;
  14866. private _alive;
  14867. private _useInstancing;
  14868. private _started;
  14869. private _stopped;
  14870. private _actualFrame;
  14871. private _scaledUpdateSpeed;
  14872. private _vertexBufferSize;
  14873. /** @hidden */
  14874. _currentEmitRateGradient: Nullable<FactorGradient>;
  14875. /** @hidden */
  14876. _currentEmitRate1: number;
  14877. /** @hidden */
  14878. _currentEmitRate2: number;
  14879. /** @hidden */
  14880. _currentStartSizeGradient: Nullable<FactorGradient>;
  14881. /** @hidden */
  14882. _currentStartSize1: number;
  14883. /** @hidden */
  14884. _currentStartSize2: number;
  14885. private readonly _rawTextureWidth;
  14886. private _rampGradientsTexture;
  14887. private _useRampGradients;
  14888. /** Gets or sets a boolean indicating that ramp gradients must be used
  14889. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14890. */
  14891. useRampGradients: boolean;
  14892. /**
  14893. * 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.
  14894. * 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: [])
  14895. */
  14896. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14897. private _subEmitters;
  14898. /**
  14899. * @hidden
  14900. * If the particle systems emitter should be disposed when the particle system is disposed
  14901. */
  14902. _disposeEmitterOnDispose: boolean;
  14903. /**
  14904. * The current active Sub-systems, this property is used by the root particle system only.
  14905. */
  14906. activeSubSystems: Array<ParticleSystem>;
  14907. private _rootParticleSystem;
  14908. /**
  14909. * Gets the current list of active particles
  14910. */
  14911. readonly particles: Particle[];
  14912. /**
  14913. * Returns the string "ParticleSystem"
  14914. * @returns a string containing the class name
  14915. */
  14916. getClassName(): string;
  14917. /**
  14918. * Instantiates a particle system.
  14919. * 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.
  14920. * @param name The name of the particle system
  14921. * @param capacity The max number of particles alive at the same time
  14922. * @param scene The scene the particle system belongs to
  14923. * @param customEffect a custom effect used to change the way particles are rendered by default
  14924. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14925. * @param epsilon Offset used to render the particles
  14926. */
  14927. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14928. private _addFactorGradient;
  14929. private _removeFactorGradient;
  14930. /**
  14931. * Adds a new life time gradient
  14932. * @param gradient defines the gradient to use (between 0 and 1)
  14933. * @param factor defines the life time factor to affect to the specified gradient
  14934. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14935. * @returns the current particle system
  14936. */
  14937. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14938. /**
  14939. * Remove a specific life time gradient
  14940. * @param gradient defines the gradient to remove
  14941. * @returns the current particle system
  14942. */
  14943. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14944. /**
  14945. * Adds a new size gradient
  14946. * @param gradient defines the gradient to use (between 0 and 1)
  14947. * @param factor defines the size factor to affect to the specified gradient
  14948. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14949. * @returns the current particle system
  14950. */
  14951. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14952. /**
  14953. * Remove a specific size gradient
  14954. * @param gradient defines the gradient to remove
  14955. * @returns the current particle system
  14956. */
  14957. removeSizeGradient(gradient: number): IParticleSystem;
  14958. /**
  14959. * Adds a new color remap gradient
  14960. * @param gradient defines the gradient to use (between 0 and 1)
  14961. * @param min defines the color remap minimal range
  14962. * @param max defines the color remap maximal range
  14963. * @returns the current particle system
  14964. */
  14965. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14966. /**
  14967. * Remove a specific color remap gradient
  14968. * @param gradient defines the gradient to remove
  14969. * @returns the current particle system
  14970. */
  14971. removeColorRemapGradient(gradient: number): IParticleSystem;
  14972. /**
  14973. * Adds a new alpha remap gradient
  14974. * @param gradient defines the gradient to use (between 0 and 1)
  14975. * @param min defines the alpha remap minimal range
  14976. * @param max defines the alpha remap maximal range
  14977. * @returns the current particle system
  14978. */
  14979. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14980. /**
  14981. * Remove a specific alpha remap gradient
  14982. * @param gradient defines the gradient to remove
  14983. * @returns the current particle system
  14984. */
  14985. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14986. /**
  14987. * Adds a new angular speed gradient
  14988. * @param gradient defines the gradient to use (between 0 and 1)
  14989. * @param factor defines the angular speed to affect to the specified gradient
  14990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14991. * @returns the current particle system
  14992. */
  14993. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14994. /**
  14995. * Remove a specific angular speed gradient
  14996. * @param gradient defines the gradient to remove
  14997. * @returns the current particle system
  14998. */
  14999. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15000. /**
  15001. * Adds a new velocity gradient
  15002. * @param gradient defines the gradient to use (between 0 and 1)
  15003. * @param factor defines the velocity to affect to the specified gradient
  15004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15005. * @returns the current particle system
  15006. */
  15007. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15008. /**
  15009. * Remove a specific velocity gradient
  15010. * @param gradient defines the gradient to remove
  15011. * @returns the current particle system
  15012. */
  15013. removeVelocityGradient(gradient: number): IParticleSystem;
  15014. /**
  15015. * Adds a new limit velocity gradient
  15016. * @param gradient defines the gradient to use (between 0 and 1)
  15017. * @param factor defines the limit velocity value to affect to the specified gradient
  15018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15019. * @returns the current particle system
  15020. */
  15021. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15022. /**
  15023. * Remove a specific limit velocity gradient
  15024. * @param gradient defines the gradient to remove
  15025. * @returns the current particle system
  15026. */
  15027. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15028. /**
  15029. * Adds a new drag gradient
  15030. * @param gradient defines the gradient to use (between 0 and 1)
  15031. * @param factor defines the drag value to affect to the specified gradient
  15032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15033. * @returns the current particle system
  15034. */
  15035. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15036. /**
  15037. * Remove a specific drag gradient
  15038. * @param gradient defines the gradient to remove
  15039. * @returns the current particle system
  15040. */
  15041. removeDragGradient(gradient: number): IParticleSystem;
  15042. /**
  15043. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15044. * @param gradient defines the gradient to use (between 0 and 1)
  15045. * @param factor defines the emit rate value to affect to the specified gradient
  15046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15047. * @returns the current particle system
  15048. */
  15049. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15050. /**
  15051. * Remove a specific emit rate gradient
  15052. * @param gradient defines the gradient to remove
  15053. * @returns the current particle system
  15054. */
  15055. removeEmitRateGradient(gradient: number): IParticleSystem;
  15056. /**
  15057. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15058. * @param gradient defines the gradient to use (between 0 and 1)
  15059. * @param factor defines the start size value to affect to the specified gradient
  15060. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15061. * @returns the current particle system
  15062. */
  15063. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15064. /**
  15065. * Remove a specific start size gradient
  15066. * @param gradient defines the gradient to remove
  15067. * @returns the current particle system
  15068. */
  15069. removeStartSizeGradient(gradient: number): IParticleSystem;
  15070. private _createRampGradientTexture;
  15071. /**
  15072. * Gets the current list of ramp gradients.
  15073. * You must use addRampGradient and removeRampGradient to udpate this list
  15074. * @returns the list of ramp gradients
  15075. */
  15076. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15077. /**
  15078. * Adds a new ramp gradient used to remap particle colors
  15079. * @param gradient defines the gradient to use (between 0 and 1)
  15080. * @param color defines the color to affect to the specified gradient
  15081. * @returns the current particle system
  15082. */
  15083. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15084. /**
  15085. * Remove a specific ramp gradient
  15086. * @param gradient defines the gradient to remove
  15087. * @returns the current particle system
  15088. */
  15089. removeRampGradient(gradient: number): ParticleSystem;
  15090. /**
  15091. * Adds a new color gradient
  15092. * @param gradient defines the gradient to use (between 0 and 1)
  15093. * @param color1 defines the color to affect to the specified gradient
  15094. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15095. * @returns this particle system
  15096. */
  15097. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15098. /**
  15099. * Remove a specific color gradient
  15100. * @param gradient defines the gradient to remove
  15101. * @returns this particle system
  15102. */
  15103. removeColorGradient(gradient: number): IParticleSystem;
  15104. private _fetchR;
  15105. protected _reset(): void;
  15106. private _resetEffect;
  15107. private _createVertexBuffers;
  15108. private _createIndexBuffer;
  15109. /**
  15110. * Gets the maximum number of particles active at the same time.
  15111. * @returns The max number of active particles.
  15112. */
  15113. getCapacity(): number;
  15114. /**
  15115. * Gets whether there are still active particles in the system.
  15116. * @returns True if it is alive, otherwise false.
  15117. */
  15118. isAlive(): boolean;
  15119. /**
  15120. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15121. * @returns True if it has been started, otherwise false.
  15122. */
  15123. isStarted(): boolean;
  15124. private _prepareSubEmitterInternalArray;
  15125. /**
  15126. * Starts the particle system and begins to emit
  15127. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15128. */
  15129. start(delay?: number): void;
  15130. /**
  15131. * Stops the particle system.
  15132. * @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.
  15133. */
  15134. stop(stopSubEmitters?: boolean): void;
  15135. /**
  15136. * Remove all active particles
  15137. */
  15138. reset(): void;
  15139. /**
  15140. * @hidden (for internal use only)
  15141. */
  15142. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15143. /**
  15144. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15145. * Its lifetime will start back at 0.
  15146. */
  15147. recycleParticle: (particle: Particle) => void;
  15148. private _stopSubEmitters;
  15149. private _createParticle;
  15150. private _removeFromRoot;
  15151. private _emitFromParticle;
  15152. private _update;
  15153. /** @hidden */
  15154. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15155. /** @hidden */
  15156. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15157. /** @hidden */
  15158. private _getEffect;
  15159. /**
  15160. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15161. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15162. */
  15163. animate(preWarmOnly?: boolean): void;
  15164. private _appendParticleVertices;
  15165. /**
  15166. * Rebuilds the particle system.
  15167. */
  15168. rebuild(): void;
  15169. /**
  15170. * Is this system ready to be used/rendered
  15171. * @return true if the system is ready
  15172. */
  15173. isReady(): boolean;
  15174. private _render;
  15175. /**
  15176. * Renders the particle system in its current state.
  15177. * @returns the current number of particles
  15178. */
  15179. render(): number;
  15180. /**
  15181. * Disposes the particle system and free the associated resources
  15182. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15183. */
  15184. dispose(disposeTexture?: boolean): void;
  15185. /**
  15186. * Clones the particle system.
  15187. * @param name The name of the cloned object
  15188. * @param newEmitter The new emitter to use
  15189. * @returns the cloned particle system
  15190. */
  15191. clone(name: string, newEmitter: any): ParticleSystem;
  15192. /**
  15193. * Serializes the particle system to a JSON object.
  15194. * @returns the JSON object
  15195. */
  15196. serialize(): any;
  15197. /** @hidden */
  15198. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15199. /** @hidden */
  15200. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15201. /**
  15202. * Parses a JSON object to create a particle system.
  15203. * @param parsedParticleSystem The JSON object to parse
  15204. * @param scene The scene to create the particle system in
  15205. * @param rootUrl The root url to use to load external dependencies like texture
  15206. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15207. * @returns the Parsed particle system
  15208. */
  15209. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15210. }
  15211. }
  15212. declare module BABYLON {
  15213. /**
  15214. * A particle represents one of the element emitted by a particle system.
  15215. * This is mainly define by its coordinates, direction, velocity and age.
  15216. */
  15217. export class Particle {
  15218. /**
  15219. * The particle system the particle belongs to.
  15220. */
  15221. particleSystem: ParticleSystem;
  15222. private static _Count;
  15223. /**
  15224. * Unique ID of the particle
  15225. */
  15226. id: number;
  15227. /**
  15228. * The world position of the particle in the scene.
  15229. */
  15230. position: Vector3;
  15231. /**
  15232. * The world direction of the particle in the scene.
  15233. */
  15234. direction: Vector3;
  15235. /**
  15236. * The color of the particle.
  15237. */
  15238. color: Color4;
  15239. /**
  15240. * The color change of the particle per step.
  15241. */
  15242. colorStep: Color4;
  15243. /**
  15244. * Defines how long will the life of the particle be.
  15245. */
  15246. lifeTime: number;
  15247. /**
  15248. * The current age of the particle.
  15249. */
  15250. age: number;
  15251. /**
  15252. * The current size of the particle.
  15253. */
  15254. size: number;
  15255. /**
  15256. * The current scale of the particle.
  15257. */
  15258. scale: Vector2;
  15259. /**
  15260. * The current angle of the particle.
  15261. */
  15262. angle: number;
  15263. /**
  15264. * Defines how fast is the angle changing.
  15265. */
  15266. angularSpeed: number;
  15267. /**
  15268. * Defines the cell index used by the particle to be rendered from a sprite.
  15269. */
  15270. cellIndex: number;
  15271. /**
  15272. * The information required to support color remapping
  15273. */
  15274. remapData: Vector4;
  15275. /** @hidden */
  15276. _randomCellOffset?: number;
  15277. /** @hidden */
  15278. _initialDirection: Nullable<Vector3>;
  15279. /** @hidden */
  15280. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15281. /** @hidden */
  15282. _initialStartSpriteCellID: number;
  15283. /** @hidden */
  15284. _initialEndSpriteCellID: number;
  15285. /** @hidden */
  15286. _currentColorGradient: Nullable<ColorGradient>;
  15287. /** @hidden */
  15288. _currentColor1: Color4;
  15289. /** @hidden */
  15290. _currentColor2: Color4;
  15291. /** @hidden */
  15292. _currentSizeGradient: Nullable<FactorGradient>;
  15293. /** @hidden */
  15294. _currentSize1: number;
  15295. /** @hidden */
  15296. _currentSize2: number;
  15297. /** @hidden */
  15298. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15299. /** @hidden */
  15300. _currentAngularSpeed1: number;
  15301. /** @hidden */
  15302. _currentAngularSpeed2: number;
  15303. /** @hidden */
  15304. _currentVelocityGradient: Nullable<FactorGradient>;
  15305. /** @hidden */
  15306. _currentVelocity1: number;
  15307. /** @hidden */
  15308. _currentVelocity2: number;
  15309. /** @hidden */
  15310. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15311. /** @hidden */
  15312. _currentLimitVelocity1: number;
  15313. /** @hidden */
  15314. _currentLimitVelocity2: number;
  15315. /** @hidden */
  15316. _currentDragGradient: Nullable<FactorGradient>;
  15317. /** @hidden */
  15318. _currentDrag1: number;
  15319. /** @hidden */
  15320. _currentDrag2: number;
  15321. /** @hidden */
  15322. _randomNoiseCoordinates1: Vector3;
  15323. /** @hidden */
  15324. _randomNoiseCoordinates2: Vector3;
  15325. /**
  15326. * Creates a new instance Particle
  15327. * @param particleSystem the particle system the particle belongs to
  15328. */
  15329. constructor(
  15330. /**
  15331. * The particle system the particle belongs to.
  15332. */
  15333. particleSystem: ParticleSystem);
  15334. private updateCellInfoFromSystem;
  15335. /**
  15336. * Defines how the sprite cell index is updated for the particle
  15337. */
  15338. updateCellIndex(): void;
  15339. /** @hidden */
  15340. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15341. /** @hidden */
  15342. _inheritParticleInfoToSubEmitters(): void;
  15343. /** @hidden */
  15344. _reset(): void;
  15345. /**
  15346. * Copy the properties of particle to another one.
  15347. * @param other the particle to copy the information to.
  15348. */
  15349. copyTo(other: Particle): void;
  15350. }
  15351. }
  15352. declare module BABYLON {
  15353. /**
  15354. * Particle emitter represents a volume emitting particles.
  15355. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15356. */
  15357. export interface IParticleEmitterType {
  15358. /**
  15359. * Called by the particle System when the direction is computed for the created particle.
  15360. * @param worldMatrix is the world matrix of the particle system
  15361. * @param directionToUpdate is the direction vector to update with the result
  15362. * @param particle is the particle we are computed the direction for
  15363. */
  15364. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15365. /**
  15366. * Called by the particle System when the position is computed for the created particle.
  15367. * @param worldMatrix is the world matrix of the particle system
  15368. * @param positionToUpdate is the position vector to update with the result
  15369. * @param particle is the particle we are computed the position for
  15370. */
  15371. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15372. /**
  15373. * Clones the current emitter and returns a copy of it
  15374. * @returns the new emitter
  15375. */
  15376. clone(): IParticleEmitterType;
  15377. /**
  15378. * Called by the GPUParticleSystem to setup the update shader
  15379. * @param effect defines the update shader
  15380. */
  15381. applyToShader(effect: Effect): void;
  15382. /**
  15383. * Returns a string to use to update the GPU particles update shader
  15384. * @returns the effect defines string
  15385. */
  15386. getEffectDefines(): string;
  15387. /**
  15388. * Returns a string representing the class name
  15389. * @returns a string containing the class name
  15390. */
  15391. getClassName(): string;
  15392. /**
  15393. * Serializes the particle system to a JSON object.
  15394. * @returns the JSON object
  15395. */
  15396. serialize(): any;
  15397. /**
  15398. * Parse properties from a JSON object
  15399. * @param serializationObject defines the JSON object
  15400. */
  15401. parse(serializationObject: any): void;
  15402. }
  15403. }
  15404. declare module BABYLON {
  15405. /**
  15406. * Particle emitter emitting particles from the inside of a box.
  15407. * It emits the particles randomly between 2 given directions.
  15408. */
  15409. export class BoxParticleEmitter implements IParticleEmitterType {
  15410. /**
  15411. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15412. */
  15413. direction1: Vector3;
  15414. /**
  15415. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15416. */
  15417. direction2: Vector3;
  15418. /**
  15419. * 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.
  15420. */
  15421. minEmitBox: Vector3;
  15422. /**
  15423. * 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.
  15424. */
  15425. maxEmitBox: Vector3;
  15426. /**
  15427. * Creates a new instance BoxParticleEmitter
  15428. */
  15429. constructor();
  15430. /**
  15431. * Called by the particle System when the direction is computed for the created particle.
  15432. * @param worldMatrix is the world matrix of the particle system
  15433. * @param directionToUpdate is the direction vector to update with the result
  15434. * @param particle is the particle we are computed the direction for
  15435. */
  15436. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15437. /**
  15438. * Called by the particle System when the position is computed for the created particle.
  15439. * @param worldMatrix is the world matrix of the particle system
  15440. * @param positionToUpdate is the position vector to update with the result
  15441. * @param particle is the particle we are computed the position for
  15442. */
  15443. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15444. /**
  15445. * Clones the current emitter and returns a copy of it
  15446. * @returns the new emitter
  15447. */
  15448. clone(): BoxParticleEmitter;
  15449. /**
  15450. * Called by the GPUParticleSystem to setup the update shader
  15451. * @param effect defines the update shader
  15452. */
  15453. applyToShader(effect: Effect): void;
  15454. /**
  15455. * Returns a string to use to update the GPU particles update shader
  15456. * @returns a string containng the defines string
  15457. */
  15458. getEffectDefines(): string;
  15459. /**
  15460. * Returns the string "BoxParticleEmitter"
  15461. * @returns a string containing the class name
  15462. */
  15463. getClassName(): string;
  15464. /**
  15465. * Serializes the particle system to a JSON object.
  15466. * @returns the JSON object
  15467. */
  15468. serialize(): any;
  15469. /**
  15470. * Parse properties from a JSON object
  15471. * @param serializationObject defines the JSON object
  15472. */
  15473. parse(serializationObject: any): void;
  15474. }
  15475. }
  15476. declare module BABYLON {
  15477. /**
  15478. * Particle emitter emitting particles from the inside of a cone.
  15479. * It emits the particles alongside the cone volume from the base to the particle.
  15480. * The emission direction might be randomized.
  15481. */
  15482. export class ConeParticleEmitter implements IParticleEmitterType {
  15483. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15484. directionRandomizer: number;
  15485. private _radius;
  15486. private _angle;
  15487. private _height;
  15488. /**
  15489. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15490. */
  15491. radiusRange: number;
  15492. /**
  15493. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15494. */
  15495. heightRange: number;
  15496. /**
  15497. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15498. */
  15499. emitFromSpawnPointOnly: boolean;
  15500. /**
  15501. * Gets or sets the radius of the emission cone
  15502. */
  15503. radius: number;
  15504. /**
  15505. * Gets or sets the angle of the emission cone
  15506. */
  15507. angle: number;
  15508. private _buildHeight;
  15509. /**
  15510. * Creates a new instance ConeParticleEmitter
  15511. * @param radius the radius of the emission cone (1 by default)
  15512. * @param angle the cone base angle (PI by default)
  15513. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15514. */
  15515. constructor(radius?: number, angle?: number,
  15516. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15517. directionRandomizer?: number);
  15518. /**
  15519. * Called by the particle System when the direction is computed for the created particle.
  15520. * @param worldMatrix is the world matrix of the particle system
  15521. * @param directionToUpdate is the direction vector to update with the result
  15522. * @param particle is the particle we are computed the direction for
  15523. */
  15524. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15525. /**
  15526. * Called by the particle System when the position is computed for the created particle.
  15527. * @param worldMatrix is the world matrix of the particle system
  15528. * @param positionToUpdate is the position vector to update with the result
  15529. * @param particle is the particle we are computed the position for
  15530. */
  15531. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15532. /**
  15533. * Clones the current emitter and returns a copy of it
  15534. * @returns the new emitter
  15535. */
  15536. clone(): ConeParticleEmitter;
  15537. /**
  15538. * Called by the GPUParticleSystem to setup the update shader
  15539. * @param effect defines the update shader
  15540. */
  15541. applyToShader(effect: Effect): void;
  15542. /**
  15543. * Returns a string to use to update the GPU particles update shader
  15544. * @returns a string containng the defines string
  15545. */
  15546. getEffectDefines(): string;
  15547. /**
  15548. * Returns the string "ConeParticleEmitter"
  15549. * @returns a string containing the class name
  15550. */
  15551. getClassName(): string;
  15552. /**
  15553. * Serializes the particle system to a JSON object.
  15554. * @returns the JSON object
  15555. */
  15556. serialize(): any;
  15557. /**
  15558. * Parse properties from a JSON object
  15559. * @param serializationObject defines the JSON object
  15560. */
  15561. parse(serializationObject: any): void;
  15562. }
  15563. }
  15564. declare module BABYLON {
  15565. /**
  15566. * Particle emitter emitting particles from the inside of a cylinder.
  15567. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15568. */
  15569. export class CylinderParticleEmitter implements IParticleEmitterType {
  15570. /**
  15571. * The radius of the emission cylinder.
  15572. */
  15573. radius: number;
  15574. /**
  15575. * The height of the emission cylinder.
  15576. */
  15577. height: number;
  15578. /**
  15579. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15580. */
  15581. radiusRange: number;
  15582. /**
  15583. * How much to randomize the particle direction [0-1].
  15584. */
  15585. directionRandomizer: number;
  15586. /**
  15587. * Creates a new instance CylinderParticleEmitter
  15588. * @param radius the radius of the emission cylinder (1 by default)
  15589. * @param height the height of the emission cylinder (1 by default)
  15590. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15591. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15592. */
  15593. constructor(
  15594. /**
  15595. * The radius of the emission cylinder.
  15596. */
  15597. radius?: number,
  15598. /**
  15599. * The height of the emission cylinder.
  15600. */
  15601. height?: number,
  15602. /**
  15603. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15604. */
  15605. radiusRange?: number,
  15606. /**
  15607. * How much to randomize the particle direction [0-1].
  15608. */
  15609. directionRandomizer?: number);
  15610. /**
  15611. * Called by the particle System when the direction is computed for the created particle.
  15612. * @param worldMatrix is the world matrix of the particle system
  15613. * @param directionToUpdate is the direction vector to update with the result
  15614. * @param particle is the particle we are computed the direction for
  15615. */
  15616. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15617. /**
  15618. * Called by the particle System when the position is computed for the created particle.
  15619. * @param worldMatrix is the world matrix of the particle system
  15620. * @param positionToUpdate is the position vector to update with the result
  15621. * @param particle is the particle we are computed the position for
  15622. */
  15623. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15624. /**
  15625. * Clones the current emitter and returns a copy of it
  15626. * @returns the new emitter
  15627. */
  15628. clone(): CylinderParticleEmitter;
  15629. /**
  15630. * Called by the GPUParticleSystem to setup the update shader
  15631. * @param effect defines the update shader
  15632. */
  15633. applyToShader(effect: Effect): void;
  15634. /**
  15635. * Returns a string to use to update the GPU particles update shader
  15636. * @returns a string containng the defines string
  15637. */
  15638. getEffectDefines(): string;
  15639. /**
  15640. * Returns the string "CylinderParticleEmitter"
  15641. * @returns a string containing the class name
  15642. */
  15643. getClassName(): string;
  15644. /**
  15645. * Serializes the particle system to a JSON object.
  15646. * @returns the JSON object
  15647. */
  15648. serialize(): any;
  15649. /**
  15650. * Parse properties from a JSON object
  15651. * @param serializationObject defines the JSON object
  15652. */
  15653. parse(serializationObject: any): void;
  15654. }
  15655. /**
  15656. * Particle emitter emitting particles from the inside of a cylinder.
  15657. * It emits the particles randomly between two vectors.
  15658. */
  15659. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15660. /**
  15661. * The min limit of the emission direction.
  15662. */
  15663. direction1: Vector3;
  15664. /**
  15665. * The max limit of the emission direction.
  15666. */
  15667. direction2: Vector3;
  15668. /**
  15669. * Creates a new instance CylinderDirectedParticleEmitter
  15670. * @param radius the radius of the emission cylinder (1 by default)
  15671. * @param height the height of the emission cylinder (1 by default)
  15672. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15673. * @param direction1 the min limit of the emission direction (up vector by default)
  15674. * @param direction2 the max limit of the emission direction (up vector by default)
  15675. */
  15676. constructor(radius?: number, height?: number, radiusRange?: number,
  15677. /**
  15678. * The min limit of the emission direction.
  15679. */
  15680. direction1?: Vector3,
  15681. /**
  15682. * The max limit of the emission direction.
  15683. */
  15684. direction2?: Vector3);
  15685. /**
  15686. * Called by the particle System when the direction is computed for the created particle.
  15687. * @param worldMatrix is the world matrix of the particle system
  15688. * @param directionToUpdate is the direction vector to update with the result
  15689. * @param particle is the particle we are computed the direction for
  15690. */
  15691. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15692. /**
  15693. * Clones the current emitter and returns a copy of it
  15694. * @returns the new emitter
  15695. */
  15696. clone(): CylinderDirectedParticleEmitter;
  15697. /**
  15698. * Called by the GPUParticleSystem to setup the update shader
  15699. * @param effect defines the update shader
  15700. */
  15701. applyToShader(effect: Effect): void;
  15702. /**
  15703. * Returns a string to use to update the GPU particles update shader
  15704. * @returns a string containng the defines string
  15705. */
  15706. getEffectDefines(): string;
  15707. /**
  15708. * Returns the string "CylinderDirectedParticleEmitter"
  15709. * @returns a string containing the class name
  15710. */
  15711. getClassName(): string;
  15712. /**
  15713. * Serializes the particle system to a JSON object.
  15714. * @returns the JSON object
  15715. */
  15716. serialize(): any;
  15717. /**
  15718. * Parse properties from a JSON object
  15719. * @param serializationObject defines the JSON object
  15720. */
  15721. parse(serializationObject: any): void;
  15722. }
  15723. }
  15724. declare module BABYLON {
  15725. /**
  15726. * Particle emitter emitting particles from the inside of a hemisphere.
  15727. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15728. */
  15729. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15730. /**
  15731. * The radius of the emission hemisphere.
  15732. */
  15733. radius: number;
  15734. /**
  15735. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15736. */
  15737. radiusRange: number;
  15738. /**
  15739. * How much to randomize the particle direction [0-1].
  15740. */
  15741. directionRandomizer: number;
  15742. /**
  15743. * Creates a new instance HemisphericParticleEmitter
  15744. * @param radius the radius of the emission hemisphere (1 by default)
  15745. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15746. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15747. */
  15748. constructor(
  15749. /**
  15750. * The radius of the emission hemisphere.
  15751. */
  15752. radius?: number,
  15753. /**
  15754. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15755. */
  15756. radiusRange?: number,
  15757. /**
  15758. * How much to randomize the particle direction [0-1].
  15759. */
  15760. directionRandomizer?: number);
  15761. /**
  15762. * Called by the particle System when the direction is computed for the created particle.
  15763. * @param worldMatrix is the world matrix of the particle system
  15764. * @param directionToUpdate is the direction vector to update with the result
  15765. * @param particle is the particle we are computed the direction for
  15766. */
  15767. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15768. /**
  15769. * Called by the particle System when the position is computed for the created particle.
  15770. * @param worldMatrix is the world matrix of the particle system
  15771. * @param positionToUpdate is the position vector to update with the result
  15772. * @param particle is the particle we are computed the position for
  15773. */
  15774. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15775. /**
  15776. * Clones the current emitter and returns a copy of it
  15777. * @returns the new emitter
  15778. */
  15779. clone(): HemisphericParticleEmitter;
  15780. /**
  15781. * Called by the GPUParticleSystem to setup the update shader
  15782. * @param effect defines the update shader
  15783. */
  15784. applyToShader(effect: Effect): void;
  15785. /**
  15786. * Returns a string to use to update the GPU particles update shader
  15787. * @returns a string containng the defines string
  15788. */
  15789. getEffectDefines(): string;
  15790. /**
  15791. * Returns the string "HemisphericParticleEmitter"
  15792. * @returns a string containing the class name
  15793. */
  15794. getClassName(): string;
  15795. /**
  15796. * Serializes the particle system to a JSON object.
  15797. * @returns the JSON object
  15798. */
  15799. serialize(): any;
  15800. /**
  15801. * Parse properties from a JSON object
  15802. * @param serializationObject defines the JSON object
  15803. */
  15804. parse(serializationObject: any): void;
  15805. }
  15806. }
  15807. declare module BABYLON {
  15808. /**
  15809. * Particle emitter emitting particles from a point.
  15810. * It emits the particles randomly between 2 given directions.
  15811. */
  15812. export class PointParticleEmitter implements IParticleEmitterType {
  15813. /**
  15814. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15815. */
  15816. direction1: Vector3;
  15817. /**
  15818. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15819. */
  15820. direction2: Vector3;
  15821. /**
  15822. * Creates a new instance PointParticleEmitter
  15823. */
  15824. constructor();
  15825. /**
  15826. * Called by the particle System when the direction is computed for the created particle.
  15827. * @param worldMatrix is the world matrix of the particle system
  15828. * @param directionToUpdate is the direction vector to update with the result
  15829. * @param particle is the particle we are computed the direction for
  15830. */
  15831. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15832. /**
  15833. * Called by the particle System when the position is computed for the created particle.
  15834. * @param worldMatrix is the world matrix of the particle system
  15835. * @param positionToUpdate is the position vector to update with the result
  15836. * @param particle is the particle we are computed the position for
  15837. */
  15838. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15839. /**
  15840. * Clones the current emitter and returns a copy of it
  15841. * @returns the new emitter
  15842. */
  15843. clone(): PointParticleEmitter;
  15844. /**
  15845. * Called by the GPUParticleSystem to setup the update shader
  15846. * @param effect defines the update shader
  15847. */
  15848. applyToShader(effect: Effect): void;
  15849. /**
  15850. * Returns a string to use to update the GPU particles update shader
  15851. * @returns a string containng the defines string
  15852. */
  15853. getEffectDefines(): string;
  15854. /**
  15855. * Returns the string "PointParticleEmitter"
  15856. * @returns a string containing the class name
  15857. */
  15858. getClassName(): string;
  15859. /**
  15860. * Serializes the particle system to a JSON object.
  15861. * @returns the JSON object
  15862. */
  15863. serialize(): any;
  15864. /**
  15865. * Parse properties from a JSON object
  15866. * @param serializationObject defines the JSON object
  15867. */
  15868. parse(serializationObject: any): void;
  15869. }
  15870. }
  15871. declare module BABYLON {
  15872. /**
  15873. * Particle emitter emitting particles from the inside of a sphere.
  15874. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15875. */
  15876. export class SphereParticleEmitter implements IParticleEmitterType {
  15877. /**
  15878. * The radius of the emission sphere.
  15879. */
  15880. radius: number;
  15881. /**
  15882. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15883. */
  15884. radiusRange: number;
  15885. /**
  15886. * How much to randomize the particle direction [0-1].
  15887. */
  15888. directionRandomizer: number;
  15889. /**
  15890. * Creates a new instance SphereParticleEmitter
  15891. * @param radius the radius of the emission sphere (1 by default)
  15892. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15893. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15894. */
  15895. constructor(
  15896. /**
  15897. * The radius of the emission sphere.
  15898. */
  15899. radius?: number,
  15900. /**
  15901. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15902. */
  15903. radiusRange?: number,
  15904. /**
  15905. * How much to randomize the particle direction [0-1].
  15906. */
  15907. directionRandomizer?: number);
  15908. /**
  15909. * Called by the particle System when the direction is computed for the created particle.
  15910. * @param worldMatrix is the world matrix of the particle system
  15911. * @param directionToUpdate is the direction vector to update with the result
  15912. * @param particle is the particle we are computed the direction for
  15913. */
  15914. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15915. /**
  15916. * Called by the particle System when the position is computed for the created particle.
  15917. * @param worldMatrix is the world matrix of the particle system
  15918. * @param positionToUpdate is the position vector to update with the result
  15919. * @param particle is the particle we are computed the position for
  15920. */
  15921. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15922. /**
  15923. * Clones the current emitter and returns a copy of it
  15924. * @returns the new emitter
  15925. */
  15926. clone(): SphereParticleEmitter;
  15927. /**
  15928. * Called by the GPUParticleSystem to setup the update shader
  15929. * @param effect defines the update shader
  15930. */
  15931. applyToShader(effect: Effect): void;
  15932. /**
  15933. * Returns a string to use to update the GPU particles update shader
  15934. * @returns a string containng the defines string
  15935. */
  15936. getEffectDefines(): string;
  15937. /**
  15938. * Returns the string "SphereParticleEmitter"
  15939. * @returns a string containing the class name
  15940. */
  15941. getClassName(): string;
  15942. /**
  15943. * Serializes the particle system to a JSON object.
  15944. * @returns the JSON object
  15945. */
  15946. serialize(): any;
  15947. /**
  15948. * Parse properties from a JSON object
  15949. * @param serializationObject defines the JSON object
  15950. */
  15951. parse(serializationObject: any): void;
  15952. }
  15953. /**
  15954. * Particle emitter emitting particles from the inside of a sphere.
  15955. * It emits the particles randomly between two vectors.
  15956. */
  15957. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15958. /**
  15959. * The min limit of the emission direction.
  15960. */
  15961. direction1: Vector3;
  15962. /**
  15963. * The max limit of the emission direction.
  15964. */
  15965. direction2: Vector3;
  15966. /**
  15967. * Creates a new instance SphereDirectedParticleEmitter
  15968. * @param radius the radius of the emission sphere (1 by default)
  15969. * @param direction1 the min limit of the emission direction (up vector by default)
  15970. * @param direction2 the max limit of the emission direction (up vector by default)
  15971. */
  15972. constructor(radius?: number,
  15973. /**
  15974. * The min limit of the emission direction.
  15975. */
  15976. direction1?: Vector3,
  15977. /**
  15978. * The max limit of the emission direction.
  15979. */
  15980. direction2?: Vector3);
  15981. /**
  15982. * Called by the particle System when the direction is computed for the created particle.
  15983. * @param worldMatrix is the world matrix of the particle system
  15984. * @param directionToUpdate is the direction vector to update with the result
  15985. * @param particle is the particle we are computed the direction for
  15986. */
  15987. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15988. /**
  15989. * Clones the current emitter and returns a copy of it
  15990. * @returns the new emitter
  15991. */
  15992. clone(): SphereDirectedParticleEmitter;
  15993. /**
  15994. * Called by the GPUParticleSystem to setup the update shader
  15995. * @param effect defines the update shader
  15996. */
  15997. applyToShader(effect: Effect): void;
  15998. /**
  15999. * Returns a string to use to update the GPU particles update shader
  16000. * @returns a string containng the defines string
  16001. */
  16002. getEffectDefines(): string;
  16003. /**
  16004. * Returns the string "SphereDirectedParticleEmitter"
  16005. * @returns a string containing the class name
  16006. */
  16007. getClassName(): string;
  16008. /**
  16009. * Serializes the particle system to a JSON object.
  16010. * @returns the JSON object
  16011. */
  16012. serialize(): any;
  16013. /**
  16014. * Parse properties from a JSON object
  16015. * @param serializationObject defines the JSON object
  16016. */
  16017. parse(serializationObject: any): void;
  16018. }
  16019. }
  16020. declare module BABYLON {
  16021. /**
  16022. * Interface representing a particle system in Babylon.js.
  16023. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16024. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16025. */
  16026. export interface IParticleSystem {
  16027. /**
  16028. * List of animations used by the particle system.
  16029. */
  16030. animations: Animation[];
  16031. /**
  16032. * The id of the Particle system.
  16033. */
  16034. id: string;
  16035. /**
  16036. * The name of the Particle system.
  16037. */
  16038. name: string;
  16039. /**
  16040. * The emitter represents the Mesh or position we are attaching the particle system to.
  16041. */
  16042. emitter: Nullable<AbstractMesh | Vector3>;
  16043. /**
  16044. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16045. */
  16046. isBillboardBased: boolean;
  16047. /**
  16048. * The rendering group used by the Particle system to chose when to render.
  16049. */
  16050. renderingGroupId: number;
  16051. /**
  16052. * The layer mask we are rendering the particles through.
  16053. */
  16054. layerMask: number;
  16055. /**
  16056. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16057. */
  16058. updateSpeed: number;
  16059. /**
  16060. * The amount of time the particle system is running (depends of the overall update speed).
  16061. */
  16062. targetStopDuration: number;
  16063. /**
  16064. * The texture used to render each particle. (this can be a spritesheet)
  16065. */
  16066. particleTexture: Nullable<Texture>;
  16067. /**
  16068. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16069. */
  16070. blendMode: number;
  16071. /**
  16072. * Minimum life time of emitting particles.
  16073. */
  16074. minLifeTime: number;
  16075. /**
  16076. * Maximum life time of emitting particles.
  16077. */
  16078. maxLifeTime: number;
  16079. /**
  16080. * Minimum Size of emitting particles.
  16081. */
  16082. minSize: number;
  16083. /**
  16084. * Maximum Size of emitting particles.
  16085. */
  16086. maxSize: number;
  16087. /**
  16088. * Minimum scale of emitting particles on X axis.
  16089. */
  16090. minScaleX: number;
  16091. /**
  16092. * Maximum scale of emitting particles on X axis.
  16093. */
  16094. maxScaleX: number;
  16095. /**
  16096. * Minimum scale of emitting particles on Y axis.
  16097. */
  16098. minScaleY: number;
  16099. /**
  16100. * Maximum scale of emitting particles on Y axis.
  16101. */
  16102. maxScaleY: number;
  16103. /**
  16104. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16105. */
  16106. color1: Color4;
  16107. /**
  16108. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16109. */
  16110. color2: Color4;
  16111. /**
  16112. * Color the particle will have at the end of its lifetime.
  16113. */
  16114. colorDead: Color4;
  16115. /**
  16116. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16117. */
  16118. emitRate: number;
  16119. /**
  16120. * You can use gravity if you want to give an orientation to your particles.
  16121. */
  16122. gravity: Vector3;
  16123. /**
  16124. * Minimum power of emitting particles.
  16125. */
  16126. minEmitPower: number;
  16127. /**
  16128. * Maximum power of emitting particles.
  16129. */
  16130. maxEmitPower: number;
  16131. /**
  16132. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16133. */
  16134. minAngularSpeed: number;
  16135. /**
  16136. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16137. */
  16138. maxAngularSpeed: number;
  16139. /**
  16140. * Gets or sets the minimal initial rotation in radians.
  16141. */
  16142. minInitialRotation: number;
  16143. /**
  16144. * Gets or sets the maximal initial rotation in radians.
  16145. */
  16146. maxInitialRotation: number;
  16147. /**
  16148. * The particle emitter type defines the emitter used by the particle system.
  16149. * It can be for example box, sphere, or cone...
  16150. */
  16151. particleEmitterType: Nullable<IParticleEmitterType>;
  16152. /**
  16153. * Defines the delay in milliseconds before starting the system (0 by default)
  16154. */
  16155. startDelay: number;
  16156. /**
  16157. * 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
  16158. */
  16159. preWarmCycles: number;
  16160. /**
  16161. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16162. */
  16163. preWarmStepOffset: number;
  16164. /**
  16165. * 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)
  16166. */
  16167. spriteCellChangeSpeed: number;
  16168. /**
  16169. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16170. */
  16171. startSpriteCellID: number;
  16172. /**
  16173. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16174. */
  16175. endSpriteCellID: number;
  16176. /**
  16177. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16178. */
  16179. spriteCellWidth: number;
  16180. /**
  16181. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16182. */
  16183. spriteCellHeight: number;
  16184. /**
  16185. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16186. */
  16187. spriteRandomStartCell: boolean;
  16188. /**
  16189. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16190. */
  16191. isAnimationSheetEnabled: boolean;
  16192. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16193. translationPivot: Vector2;
  16194. /**
  16195. * Gets or sets a texture used to add random noise to particle positions
  16196. */
  16197. noiseTexture: Nullable<BaseTexture>;
  16198. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16199. noiseStrength: Vector3;
  16200. /**
  16201. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16202. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16203. */
  16204. billboardMode: number;
  16205. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16206. limitVelocityDamping: number;
  16207. /**
  16208. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16209. */
  16210. beginAnimationOnStart: boolean;
  16211. /**
  16212. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16213. */
  16214. beginAnimationFrom: number;
  16215. /**
  16216. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16217. */
  16218. beginAnimationTo: number;
  16219. /**
  16220. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16221. */
  16222. beginAnimationLoop: boolean;
  16223. /**
  16224. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16225. */
  16226. disposeOnStop: boolean;
  16227. /**
  16228. * Gets the maximum number of particles active at the same time.
  16229. * @returns The max number of active particles.
  16230. */
  16231. getCapacity(): number;
  16232. /**
  16233. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16234. * @returns True if it has been started, otherwise false.
  16235. */
  16236. isStarted(): boolean;
  16237. /**
  16238. * Animates the particle system for this frame.
  16239. */
  16240. animate(): void;
  16241. /**
  16242. * Renders the particle system in its current state.
  16243. * @returns the current number of particles
  16244. */
  16245. render(): number;
  16246. /**
  16247. * Dispose the particle system and frees its associated resources.
  16248. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16249. */
  16250. dispose(disposeTexture?: boolean): void;
  16251. /**
  16252. * Clones the particle system.
  16253. * @param name The name of the cloned object
  16254. * @param newEmitter The new emitter to use
  16255. * @returns the cloned particle system
  16256. */
  16257. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16258. /**
  16259. * Serializes the particle system to a JSON object.
  16260. * @returns the JSON object
  16261. */
  16262. serialize(): any;
  16263. /**
  16264. * Rebuild the particle system
  16265. */
  16266. rebuild(): void;
  16267. /**
  16268. * Starts the particle system and begins to emit
  16269. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16270. */
  16271. start(delay?: number): void;
  16272. /**
  16273. * Stops the particle system.
  16274. */
  16275. stop(): void;
  16276. /**
  16277. * Remove all active particles
  16278. */
  16279. reset(): void;
  16280. /**
  16281. * Is this system ready to be used/rendered
  16282. * @return true if the system is ready
  16283. */
  16284. isReady(): boolean;
  16285. /**
  16286. * Adds a new color gradient
  16287. * @param gradient defines the gradient to use (between 0 and 1)
  16288. * @param color1 defines the color to affect to the specified gradient
  16289. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16290. * @returns the current particle system
  16291. */
  16292. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16293. /**
  16294. * Remove a specific color gradient
  16295. * @param gradient defines the gradient to remove
  16296. * @returns the current particle system
  16297. */
  16298. removeColorGradient(gradient: number): IParticleSystem;
  16299. /**
  16300. * Adds a new size gradient
  16301. * @param gradient defines the gradient to use (between 0 and 1)
  16302. * @param factor defines the size factor to affect to the specified gradient
  16303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16304. * @returns the current particle system
  16305. */
  16306. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16307. /**
  16308. * Remove a specific size gradient
  16309. * @param gradient defines the gradient to remove
  16310. * @returns the current particle system
  16311. */
  16312. removeSizeGradient(gradient: number): IParticleSystem;
  16313. /**
  16314. * Gets the current list of color gradients.
  16315. * You must use addColorGradient and removeColorGradient to udpate this list
  16316. * @returns the list of color gradients
  16317. */
  16318. getColorGradients(): Nullable<Array<ColorGradient>>;
  16319. /**
  16320. * Gets the current list of size gradients.
  16321. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16322. * @returns the list of size gradients
  16323. */
  16324. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16325. /**
  16326. * Gets the current list of angular speed gradients.
  16327. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16328. * @returns the list of angular speed gradients
  16329. */
  16330. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16331. /**
  16332. * Adds a new angular speed gradient
  16333. * @param gradient defines the gradient to use (between 0 and 1)
  16334. * @param factor defines the angular speed to affect to the specified gradient
  16335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16336. * @returns the current particle system
  16337. */
  16338. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16339. /**
  16340. * Remove a specific angular speed gradient
  16341. * @param gradient defines the gradient to remove
  16342. * @returns the current particle system
  16343. */
  16344. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16345. /**
  16346. * Gets the current list of velocity gradients.
  16347. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16348. * @returns the list of velocity gradients
  16349. */
  16350. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16351. /**
  16352. * Adds a new velocity gradient
  16353. * @param gradient defines the gradient to use (between 0 and 1)
  16354. * @param factor defines the velocity to affect to the specified gradient
  16355. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16356. * @returns the current particle system
  16357. */
  16358. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16359. /**
  16360. * Remove a specific velocity gradient
  16361. * @param gradient defines the gradient to remove
  16362. * @returns the current particle system
  16363. */
  16364. removeVelocityGradient(gradient: number): IParticleSystem;
  16365. /**
  16366. * Gets the current list of limit velocity gradients.
  16367. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16368. * @returns the list of limit velocity gradients
  16369. */
  16370. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16371. /**
  16372. * Adds a new limit velocity gradient
  16373. * @param gradient defines the gradient to use (between 0 and 1)
  16374. * @param factor defines the limit velocity to affect to the specified gradient
  16375. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16376. * @returns the current particle system
  16377. */
  16378. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16379. /**
  16380. * Remove a specific limit velocity gradient
  16381. * @param gradient defines the gradient to remove
  16382. * @returns the current particle system
  16383. */
  16384. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16385. /**
  16386. * Adds a new drag gradient
  16387. * @param gradient defines the gradient to use (between 0 and 1)
  16388. * @param factor defines the drag to affect to the specified gradient
  16389. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16390. * @returns the current particle system
  16391. */
  16392. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16393. /**
  16394. * Remove a specific drag gradient
  16395. * @param gradient defines the gradient to remove
  16396. * @returns the current particle system
  16397. */
  16398. removeDragGradient(gradient: number): IParticleSystem;
  16399. /**
  16400. * Gets the current list of drag gradients.
  16401. * You must use addDragGradient and removeDragGradient to udpate this list
  16402. * @returns the list of drag gradients
  16403. */
  16404. getDragGradients(): Nullable<Array<FactorGradient>>;
  16405. /**
  16406. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16407. * @param gradient defines the gradient to use (between 0 and 1)
  16408. * @param factor defines the emit rate to affect to the specified gradient
  16409. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16410. * @returns the current particle system
  16411. */
  16412. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16413. /**
  16414. * Remove a specific emit rate gradient
  16415. * @param gradient defines the gradient to remove
  16416. * @returns the current particle system
  16417. */
  16418. removeEmitRateGradient(gradient: number): IParticleSystem;
  16419. /**
  16420. * Gets the current list of emit rate gradients.
  16421. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16422. * @returns the list of emit rate gradients
  16423. */
  16424. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16425. /**
  16426. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16427. * @param gradient defines the gradient to use (between 0 and 1)
  16428. * @param factor defines the start size to affect to the specified gradient
  16429. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16430. * @returns the current particle system
  16431. */
  16432. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16433. /**
  16434. * Remove a specific start size gradient
  16435. * @param gradient defines the gradient to remove
  16436. * @returns the current particle system
  16437. */
  16438. removeStartSizeGradient(gradient: number): IParticleSystem;
  16439. /**
  16440. * Gets the current list of start size gradients.
  16441. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16442. * @returns the list of start size gradients
  16443. */
  16444. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16445. /**
  16446. * Adds a new life time gradient
  16447. * @param gradient defines the gradient to use (between 0 and 1)
  16448. * @param factor defines the life time factor to affect to the specified gradient
  16449. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16450. * @returns the current particle system
  16451. */
  16452. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16453. /**
  16454. * Remove a specific life time gradient
  16455. * @param gradient defines the gradient to remove
  16456. * @returns the current particle system
  16457. */
  16458. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16459. /**
  16460. * Gets the current list of life time gradients.
  16461. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16462. * @returns the list of life time gradients
  16463. */
  16464. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16465. /**
  16466. * Gets the current list of color gradients.
  16467. * You must use addColorGradient and removeColorGradient to udpate this list
  16468. * @returns the list of color gradients
  16469. */
  16470. getColorGradients(): Nullable<Array<ColorGradient>>;
  16471. /**
  16472. * Adds a new ramp gradient used to remap particle colors
  16473. * @param gradient defines the gradient to use (between 0 and 1)
  16474. * @param color defines the color to affect to the specified gradient
  16475. * @returns the current particle system
  16476. */
  16477. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16478. /**
  16479. * Gets the current list of ramp gradients.
  16480. * You must use addRampGradient and removeRampGradient to udpate this list
  16481. * @returns the list of ramp gradients
  16482. */
  16483. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16484. /** Gets or sets a boolean indicating that ramp gradients must be used
  16485. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16486. */
  16487. useRampGradients: boolean;
  16488. /**
  16489. * Adds a new color remap gradient
  16490. * @param gradient defines the gradient to use (between 0 and 1)
  16491. * @param min defines the color remap minimal range
  16492. * @param max defines the color remap maximal range
  16493. * @returns the current particle system
  16494. */
  16495. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16496. /**
  16497. * Gets the current list of color remap gradients.
  16498. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16499. * @returns the list of color remap gradients
  16500. */
  16501. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16502. /**
  16503. * Adds a new alpha remap gradient
  16504. * @param gradient defines the gradient to use (between 0 and 1)
  16505. * @param min defines the alpha remap minimal range
  16506. * @param max defines the alpha remap maximal range
  16507. * @returns the current particle system
  16508. */
  16509. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16510. /**
  16511. * Gets the current list of alpha remap gradients.
  16512. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16513. * @returns the list of alpha remap gradients
  16514. */
  16515. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16516. /**
  16517. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16518. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16519. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16520. * @returns the emitter
  16521. */
  16522. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16523. /**
  16524. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16525. * @param radius The radius of the hemisphere to emit from
  16526. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16527. * @returns the emitter
  16528. */
  16529. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16530. /**
  16531. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16532. * @param radius The radius of the sphere to emit from
  16533. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16534. * @returns the emitter
  16535. */
  16536. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16537. /**
  16538. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16539. * @param radius The radius of the sphere to emit from
  16540. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16541. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16542. * @returns the emitter
  16543. */
  16544. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16545. /**
  16546. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16547. * @param radius The radius of the emission cylinder
  16548. * @param height The height of the emission cylinder
  16549. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16550. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16551. * @returns the emitter
  16552. */
  16553. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16554. /**
  16555. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16556. * @param radius The radius of the cylinder to emit from
  16557. * @param height The height of the emission cylinder
  16558. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16559. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16560. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16561. * @returns the emitter
  16562. */
  16563. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16564. /**
  16565. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16566. * @param radius The radius of the cone to emit from
  16567. * @param angle The base angle of the cone
  16568. * @returns the emitter
  16569. */
  16570. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16571. /**
  16572. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16573. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16574. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16575. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16576. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16577. * @returns the emitter
  16578. */
  16579. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16580. /**
  16581. * Get hosting scene
  16582. * @returns the scene
  16583. */
  16584. getScene(): Scene;
  16585. }
  16586. }
  16587. declare module BABYLON {
  16588. /** @hidden */
  16589. export var linePixelShader: {
  16590. name: string;
  16591. shader: string;
  16592. };
  16593. }
  16594. declare module BABYLON {
  16595. /** @hidden */
  16596. export var lineVertexShader: {
  16597. name: string;
  16598. shader: string;
  16599. };
  16600. }
  16601. declare module BABYLON {
  16602. interface AbstractMesh {
  16603. /**
  16604. * Disables the mesh edge rendering mode
  16605. * @returns the currentAbstractMesh
  16606. */
  16607. disableEdgesRendering(): AbstractMesh;
  16608. /**
  16609. * Enables the edge rendering mode on the mesh.
  16610. * This mode makes the mesh edges visible
  16611. * @param epsilon defines the maximal distance between two angles to detect a face
  16612. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16613. * @returns the currentAbstractMesh
  16614. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16615. */
  16616. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16617. /**
  16618. * Gets the edgesRenderer associated with the mesh
  16619. */
  16620. edgesRenderer: Nullable<EdgesRenderer>;
  16621. }
  16622. interface LinesMesh {
  16623. /**
  16624. * Enables the edge rendering mode on the mesh.
  16625. * This mode makes the mesh edges visible
  16626. * @param epsilon defines the maximal distance between two angles to detect a face
  16627. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16628. * @returns the currentAbstractMesh
  16629. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16630. */
  16631. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16632. }
  16633. interface InstancedLinesMesh {
  16634. /**
  16635. * Enables the edge rendering mode on the mesh.
  16636. * This mode makes the mesh edges visible
  16637. * @param epsilon defines the maximal distance between two angles to detect a face
  16638. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16639. * @returns the current InstancedLinesMesh
  16640. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16641. */
  16642. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16643. }
  16644. /**
  16645. * Defines the minimum contract an Edges renderer should follow.
  16646. */
  16647. export interface IEdgesRenderer extends IDisposable {
  16648. /**
  16649. * Gets or sets a boolean indicating if the edgesRenderer is active
  16650. */
  16651. isEnabled: boolean;
  16652. /**
  16653. * Renders the edges of the attached mesh,
  16654. */
  16655. render(): void;
  16656. /**
  16657. * Checks wether or not the edges renderer is ready to render.
  16658. * @return true if ready, otherwise false.
  16659. */
  16660. isReady(): boolean;
  16661. }
  16662. /**
  16663. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16664. */
  16665. export class EdgesRenderer implements IEdgesRenderer {
  16666. /**
  16667. * Define the size of the edges with an orthographic camera
  16668. */
  16669. edgesWidthScalerForOrthographic: number;
  16670. /**
  16671. * Define the size of the edges with a perspective camera
  16672. */
  16673. edgesWidthScalerForPerspective: number;
  16674. protected _source: AbstractMesh;
  16675. protected _linesPositions: number[];
  16676. protected _linesNormals: number[];
  16677. protected _linesIndices: number[];
  16678. protected _epsilon: number;
  16679. protected _indicesCount: number;
  16680. protected _lineShader: ShaderMaterial;
  16681. protected _ib: WebGLBuffer;
  16682. protected _buffers: {
  16683. [key: string]: Nullable<VertexBuffer>;
  16684. };
  16685. protected _checkVerticesInsteadOfIndices: boolean;
  16686. private _meshRebuildObserver;
  16687. private _meshDisposeObserver;
  16688. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16689. isEnabled: boolean;
  16690. /**
  16691. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16692. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16693. * @param source Mesh used to create edges
  16694. * @param epsilon sum of angles in adjacency to check for edge
  16695. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16696. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16697. */
  16698. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16699. protected _prepareRessources(): void;
  16700. /** @hidden */
  16701. _rebuild(): void;
  16702. /**
  16703. * Releases the required resources for the edges renderer
  16704. */
  16705. dispose(): void;
  16706. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16707. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16708. /**
  16709. * Checks if the pair of p0 and p1 is en edge
  16710. * @param faceIndex
  16711. * @param edge
  16712. * @param faceNormals
  16713. * @param p0
  16714. * @param p1
  16715. * @private
  16716. */
  16717. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16718. /**
  16719. * push line into the position, normal and index buffer
  16720. * @protected
  16721. */
  16722. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16723. /**
  16724. * Generates lines edges from adjacencjes
  16725. * @private
  16726. */
  16727. _generateEdgesLines(): void;
  16728. /**
  16729. * Checks wether or not the edges renderer is ready to render.
  16730. * @return true if ready, otherwise false.
  16731. */
  16732. isReady(): boolean;
  16733. /**
  16734. * Renders the edges of the attached mesh,
  16735. */
  16736. render(): void;
  16737. }
  16738. /**
  16739. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16740. */
  16741. export class LineEdgesRenderer extends EdgesRenderer {
  16742. /**
  16743. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16744. * @param source LineMesh used to generate edges
  16745. * @param epsilon not important (specified angle for edge detection)
  16746. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16747. */
  16748. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16749. /**
  16750. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16751. */
  16752. _generateEdgesLines(): void;
  16753. }
  16754. }
  16755. declare module BABYLON {
  16756. /**
  16757. * This represents the object necessary to create a rendering group.
  16758. * This is exclusively used and created by the rendering manager.
  16759. * To modify the behavior, you use the available helpers in your scene or meshes.
  16760. * @hidden
  16761. */
  16762. export class RenderingGroup {
  16763. index: number;
  16764. private _scene;
  16765. private _opaqueSubMeshes;
  16766. private _transparentSubMeshes;
  16767. private _alphaTestSubMeshes;
  16768. private _depthOnlySubMeshes;
  16769. private _particleSystems;
  16770. private _spriteManagers;
  16771. private _opaqueSortCompareFn;
  16772. private _alphaTestSortCompareFn;
  16773. private _transparentSortCompareFn;
  16774. private _renderOpaque;
  16775. private _renderAlphaTest;
  16776. private _renderTransparent;
  16777. private _edgesRenderers;
  16778. onBeforeTransparentRendering: () => void;
  16779. /**
  16780. * Set the opaque sort comparison function.
  16781. * If null the sub meshes will be render in the order they were created
  16782. */
  16783. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16784. /**
  16785. * Set the alpha test sort comparison function.
  16786. * If null the sub meshes will be render in the order they were created
  16787. */
  16788. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16789. /**
  16790. * Set the transparent sort comparison function.
  16791. * If null the sub meshes will be render in the order they were created
  16792. */
  16793. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16794. /**
  16795. * Creates a new rendering group.
  16796. * @param index The rendering group index
  16797. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16798. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16799. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16800. */
  16801. 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>);
  16802. /**
  16803. * Render all the sub meshes contained in the group.
  16804. * @param customRenderFunction Used to override the default render behaviour of the group.
  16805. * @returns true if rendered some submeshes.
  16806. */
  16807. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16808. /**
  16809. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16810. * @param subMeshes The submeshes to render
  16811. */
  16812. private renderOpaqueSorted;
  16813. /**
  16814. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16815. * @param subMeshes The submeshes to render
  16816. */
  16817. private renderAlphaTestSorted;
  16818. /**
  16819. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16820. * @param subMeshes The submeshes to render
  16821. */
  16822. private renderTransparentSorted;
  16823. /**
  16824. * Renders the submeshes in a specified order.
  16825. * @param subMeshes The submeshes to sort before render
  16826. * @param sortCompareFn The comparison function use to sort
  16827. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16828. * @param transparent Specifies to activate blending if true
  16829. */
  16830. private static renderSorted;
  16831. /**
  16832. * Renders the submeshes in the order they were dispatched (no sort applied).
  16833. * @param subMeshes The submeshes to render
  16834. */
  16835. private static renderUnsorted;
  16836. /**
  16837. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16838. * are rendered back to front if in the same alpha index.
  16839. *
  16840. * @param a The first submesh
  16841. * @param b The second submesh
  16842. * @returns The result of the comparison
  16843. */
  16844. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16845. /**
  16846. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16847. * are rendered back to front.
  16848. *
  16849. * @param a The first submesh
  16850. * @param b The second submesh
  16851. * @returns The result of the comparison
  16852. */
  16853. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16854. /**
  16855. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16856. * are rendered front to back (prevent overdraw).
  16857. *
  16858. * @param a The first submesh
  16859. * @param b The second submesh
  16860. * @returns The result of the comparison
  16861. */
  16862. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16863. /**
  16864. * Resets the different lists of submeshes to prepare a new frame.
  16865. */
  16866. prepare(): void;
  16867. dispose(): void;
  16868. /**
  16869. * Inserts the submesh in its correct queue depending on its material.
  16870. * @param subMesh The submesh to dispatch
  16871. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16872. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16873. */
  16874. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16875. dispatchSprites(spriteManager: ISpriteManager): void;
  16876. dispatchParticles(particleSystem: IParticleSystem): void;
  16877. private _renderParticles;
  16878. private _renderSprites;
  16879. }
  16880. }
  16881. declare module BABYLON {
  16882. /**
  16883. * Interface describing the different options available in the rendering manager
  16884. * regarding Auto Clear between groups.
  16885. */
  16886. export interface IRenderingManagerAutoClearSetup {
  16887. /**
  16888. * Defines whether or not autoclear is enable.
  16889. */
  16890. autoClear: boolean;
  16891. /**
  16892. * Defines whether or not to autoclear the depth buffer.
  16893. */
  16894. depth: boolean;
  16895. /**
  16896. * Defines whether or not to autoclear the stencil buffer.
  16897. */
  16898. stencil: boolean;
  16899. }
  16900. /**
  16901. * This class is used by the onRenderingGroupObservable
  16902. */
  16903. export class RenderingGroupInfo {
  16904. /**
  16905. * The Scene that being rendered
  16906. */
  16907. scene: Scene;
  16908. /**
  16909. * The camera currently used for the rendering pass
  16910. */
  16911. camera: Nullable<Camera>;
  16912. /**
  16913. * The ID of the renderingGroup being processed
  16914. */
  16915. renderingGroupId: number;
  16916. }
  16917. /**
  16918. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16919. * It is enable to manage the different groups as well as the different necessary sort functions.
  16920. * This should not be used directly aside of the few static configurations
  16921. */
  16922. export class RenderingManager {
  16923. /**
  16924. * The max id used for rendering groups (not included)
  16925. */
  16926. static MAX_RENDERINGGROUPS: number;
  16927. /**
  16928. * The min id used for rendering groups (included)
  16929. */
  16930. static MIN_RENDERINGGROUPS: number;
  16931. /**
  16932. * Used to globally prevent autoclearing scenes.
  16933. */
  16934. static AUTOCLEAR: boolean;
  16935. /**
  16936. * @hidden
  16937. */
  16938. _useSceneAutoClearSetup: boolean;
  16939. private _scene;
  16940. private _renderingGroups;
  16941. private _depthStencilBufferAlreadyCleaned;
  16942. private _autoClearDepthStencil;
  16943. private _customOpaqueSortCompareFn;
  16944. private _customAlphaTestSortCompareFn;
  16945. private _customTransparentSortCompareFn;
  16946. private _renderingGroupInfo;
  16947. /**
  16948. * Instantiates a new rendering group for a particular scene
  16949. * @param scene Defines the scene the groups belongs to
  16950. */
  16951. constructor(scene: Scene);
  16952. private _clearDepthStencilBuffer;
  16953. /**
  16954. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16955. * @hidden
  16956. */
  16957. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16958. /**
  16959. * Resets the different information of the group to prepare a new frame
  16960. * @hidden
  16961. */
  16962. reset(): void;
  16963. /**
  16964. * Dispose and release the group and its associated resources.
  16965. * @hidden
  16966. */
  16967. dispose(): void;
  16968. /**
  16969. * Clear the info related to rendering groups preventing retention points during dispose.
  16970. */
  16971. freeRenderingGroups(): void;
  16972. private _prepareRenderingGroup;
  16973. /**
  16974. * Add a sprite manager to the rendering manager in order to render it this frame.
  16975. * @param spriteManager Define the sprite manager to render
  16976. */
  16977. dispatchSprites(spriteManager: ISpriteManager): void;
  16978. /**
  16979. * Add a particle system to the rendering manager in order to render it this frame.
  16980. * @param particleSystem Define the particle system to render
  16981. */
  16982. dispatchParticles(particleSystem: IParticleSystem): void;
  16983. /**
  16984. * Add a submesh to the manager in order to render it this frame
  16985. * @param subMesh The submesh to dispatch
  16986. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16987. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16988. */
  16989. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16990. /**
  16991. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16992. * This allowed control for front to back rendering or reversly depending of the special needs.
  16993. *
  16994. * @param renderingGroupId The rendering group id corresponding to its index
  16995. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16996. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16997. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16998. */
  16999. 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;
  17000. /**
  17001. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17002. *
  17003. * @param renderingGroupId The rendering group id corresponding to its index
  17004. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17005. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17006. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17007. */
  17008. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17009. /**
  17010. * Gets the current auto clear configuration for one rendering group of the rendering
  17011. * manager.
  17012. * @param index the rendering group index to get the information for
  17013. * @returns The auto clear setup for the requested rendering group
  17014. */
  17015. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17016. }
  17017. }
  17018. declare module BABYLON {
  17019. /**
  17020. * This Helps creating a texture that will be created from a camera in your scene.
  17021. * It is basically a dynamic texture that could be used to create special effects for instance.
  17022. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17023. */
  17024. export class RenderTargetTexture extends Texture {
  17025. isCube: boolean;
  17026. /**
  17027. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17028. */
  17029. static readonly REFRESHRATE_RENDER_ONCE: number;
  17030. /**
  17031. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17032. */
  17033. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17034. /**
  17035. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17036. * the central point of your effect and can save a lot of performances.
  17037. */
  17038. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17039. /**
  17040. * Use this predicate to dynamically define the list of mesh you want to render.
  17041. * If set, the renderList property will be overwritten.
  17042. */
  17043. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17044. private _renderList;
  17045. /**
  17046. * Use this list to define the list of mesh you want to render.
  17047. */
  17048. renderList: Nullable<Array<AbstractMesh>>;
  17049. private _hookArray;
  17050. /**
  17051. * Define if particles should be rendered in your texture.
  17052. */
  17053. renderParticles: boolean;
  17054. /**
  17055. * Define if sprites should be rendered in your texture.
  17056. */
  17057. renderSprites: boolean;
  17058. /**
  17059. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17060. */
  17061. coordinatesMode: number;
  17062. /**
  17063. * Define the camera used to render the texture.
  17064. */
  17065. activeCamera: Nullable<Camera>;
  17066. /**
  17067. * Override the render function of the texture with your own one.
  17068. */
  17069. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17070. /**
  17071. * Define if camera post processes should be use while rendering the texture.
  17072. */
  17073. useCameraPostProcesses: boolean;
  17074. /**
  17075. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17076. */
  17077. ignoreCameraViewport: boolean;
  17078. private _postProcessManager;
  17079. private _postProcesses;
  17080. private _resizeObserver;
  17081. /**
  17082. * An event triggered when the texture is unbind.
  17083. */
  17084. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17085. /**
  17086. * An event triggered when the texture is unbind.
  17087. */
  17088. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17089. private _onAfterUnbindObserver;
  17090. /**
  17091. * Set a after unbind callback in the texture.
  17092. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17093. */
  17094. onAfterUnbind: () => void;
  17095. /**
  17096. * An event triggered before rendering the texture
  17097. */
  17098. onBeforeRenderObservable: Observable<number>;
  17099. private _onBeforeRenderObserver;
  17100. /**
  17101. * Set a before render callback in the texture.
  17102. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17103. */
  17104. onBeforeRender: (faceIndex: number) => void;
  17105. /**
  17106. * An event triggered after rendering the texture
  17107. */
  17108. onAfterRenderObservable: Observable<number>;
  17109. private _onAfterRenderObserver;
  17110. /**
  17111. * Set a after render callback in the texture.
  17112. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17113. */
  17114. onAfterRender: (faceIndex: number) => void;
  17115. /**
  17116. * An event triggered after the texture clear
  17117. */
  17118. onClearObservable: Observable<Engine>;
  17119. private _onClearObserver;
  17120. /**
  17121. * Set a clear callback in the texture.
  17122. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17123. */
  17124. onClear: (Engine: Engine) => void;
  17125. /**
  17126. * Define the clear color of the Render Target if it should be different from the scene.
  17127. */
  17128. clearColor: Color4;
  17129. protected _size: number | {
  17130. width: number;
  17131. height: number;
  17132. };
  17133. protected _initialSizeParameter: number | {
  17134. width: number;
  17135. height: number;
  17136. } | {
  17137. ratio: number;
  17138. };
  17139. protected _sizeRatio: Nullable<number>;
  17140. /** @hidden */
  17141. _generateMipMaps: boolean;
  17142. protected _renderingManager: RenderingManager;
  17143. /** @hidden */
  17144. _waitingRenderList: string[];
  17145. protected _doNotChangeAspectRatio: boolean;
  17146. protected _currentRefreshId: number;
  17147. protected _refreshRate: number;
  17148. protected _textureMatrix: Matrix;
  17149. protected _samples: number;
  17150. protected _renderTargetOptions: RenderTargetCreationOptions;
  17151. /**
  17152. * Gets render target creation options that were used.
  17153. */
  17154. readonly renderTargetOptions: RenderTargetCreationOptions;
  17155. protected _engine: Engine;
  17156. protected _onRatioRescale(): void;
  17157. /**
  17158. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17159. * It must define where the camera used to render the texture is set
  17160. */
  17161. boundingBoxPosition: Vector3;
  17162. private _boundingBoxSize;
  17163. /**
  17164. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17165. * When defined, the cubemap will switch to local mode
  17166. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17167. * @example https://www.babylonjs-playground.com/#RNASML
  17168. */
  17169. boundingBoxSize: Vector3;
  17170. /**
  17171. * In case the RTT has been created with a depth texture, get the associated
  17172. * depth texture.
  17173. * Otherwise, return null.
  17174. */
  17175. depthStencilTexture: Nullable<InternalTexture>;
  17176. /**
  17177. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17178. * or used a shadow, depth texture...
  17179. * @param name The friendly name of the texture
  17180. * @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)
  17181. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17182. * @param generateMipMaps True if mip maps need to be generated after render.
  17183. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17184. * @param type The type of the buffer in the RTT (int, half float, float...)
  17185. * @param isCube True if a cube texture needs to be created
  17186. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17187. * @param generateDepthBuffer True to generate a depth buffer
  17188. * @param generateStencilBuffer True to generate a stencil buffer
  17189. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17190. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17191. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17192. */
  17193. constructor(name: string, size: number | {
  17194. width: number;
  17195. height: number;
  17196. } | {
  17197. ratio: number;
  17198. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17199. /**
  17200. * Creates a depth stencil texture.
  17201. * This is only available in WebGL 2 or with the depth texture extension available.
  17202. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17203. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17204. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17205. */
  17206. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17207. private _processSizeParameter;
  17208. /**
  17209. * Define the number of samples to use in case of MSAA.
  17210. * It defaults to one meaning no MSAA has been enabled.
  17211. */
  17212. samples: number;
  17213. /**
  17214. * Resets the refresh counter of the texture and start bak from scratch.
  17215. * Could be useful to regenerate the texture if it is setup to render only once.
  17216. */
  17217. resetRefreshCounter(): void;
  17218. /**
  17219. * Define the refresh rate of the texture or the rendering frequency.
  17220. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17221. */
  17222. refreshRate: number;
  17223. /**
  17224. * Adds a post process to the render target rendering passes.
  17225. * @param postProcess define the post process to add
  17226. */
  17227. addPostProcess(postProcess: PostProcess): void;
  17228. /**
  17229. * Clear all the post processes attached to the render target
  17230. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17231. */
  17232. clearPostProcesses(dispose?: boolean): void;
  17233. /**
  17234. * Remove one of the post process from the list of attached post processes to the texture
  17235. * @param postProcess define the post process to remove from the list
  17236. */
  17237. removePostProcess(postProcess: PostProcess): void;
  17238. /** @hidden */
  17239. _shouldRender(): boolean;
  17240. /**
  17241. * Gets the actual render size of the texture.
  17242. * @returns the width of the render size
  17243. */
  17244. getRenderSize(): number;
  17245. /**
  17246. * Gets the actual render width of the texture.
  17247. * @returns the width of the render size
  17248. */
  17249. getRenderWidth(): number;
  17250. /**
  17251. * Gets the actual render height of the texture.
  17252. * @returns the height of the render size
  17253. */
  17254. getRenderHeight(): number;
  17255. /**
  17256. * Get if the texture can be rescaled or not.
  17257. */
  17258. readonly canRescale: boolean;
  17259. /**
  17260. * Resize the texture using a ratio.
  17261. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17262. */
  17263. scale(ratio: number): void;
  17264. /**
  17265. * Get the texture reflection matrix used to rotate/transform the reflection.
  17266. * @returns the reflection matrix
  17267. */
  17268. getReflectionTextureMatrix(): Matrix;
  17269. /**
  17270. * Resize the texture to a new desired size.
  17271. * Be carrefull as it will recreate all the data in the new texture.
  17272. * @param size Define the new size. It can be:
  17273. * - a number for squared texture,
  17274. * - an object containing { width: number, height: number }
  17275. * - or an object containing a ratio { ratio: number }
  17276. */
  17277. resize(size: number | {
  17278. width: number;
  17279. height: number;
  17280. } | {
  17281. ratio: number;
  17282. }): void;
  17283. /**
  17284. * Renders all the objects from the render list into the texture.
  17285. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17286. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17287. */
  17288. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17289. private _bestReflectionRenderTargetDimension;
  17290. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17291. private renderToTarget;
  17292. /**
  17293. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17294. * This allowed control for front to back rendering or reversly depending of the special needs.
  17295. *
  17296. * @param renderingGroupId The rendering group id corresponding to its index
  17297. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17298. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17299. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17300. */
  17301. 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;
  17302. /**
  17303. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17304. *
  17305. * @param renderingGroupId The rendering group id corresponding to its index
  17306. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17307. */
  17308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17309. /**
  17310. * Clones the texture.
  17311. * @returns the cloned texture
  17312. */
  17313. clone(): RenderTargetTexture;
  17314. /**
  17315. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17316. * @returns The JSON representation of the texture
  17317. */
  17318. serialize(): any;
  17319. /**
  17320. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17321. */
  17322. disposeFramebufferObjects(): void;
  17323. /**
  17324. * Dispose the texture and release its associated resources.
  17325. */
  17326. dispose(): void;
  17327. /** @hidden */
  17328. _rebuild(): void;
  17329. /**
  17330. * Clear the info related to rendering groups preventing retention point in material dispose.
  17331. */
  17332. freeRenderingGroups(): void;
  17333. }
  17334. }
  17335. declare module BABYLON {
  17336. /**
  17337. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17338. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17339. * You can then easily use it as a reflectionTexture on a flat surface.
  17340. * In case the surface is not a plane, please consider relying on reflection probes.
  17341. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17342. */
  17343. export class MirrorTexture extends RenderTargetTexture {
  17344. private scene;
  17345. /**
  17346. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17347. * 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.
  17348. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17349. */
  17350. mirrorPlane: Plane;
  17351. /**
  17352. * Define the blur ratio used to blur the reflection if needed.
  17353. */
  17354. blurRatio: number;
  17355. /**
  17356. * Define the adaptive blur kernel used to blur the reflection if needed.
  17357. * This will autocompute the closest best match for the `blurKernel`
  17358. */
  17359. adaptiveBlurKernel: number;
  17360. /**
  17361. * Define the blur kernel used to blur the reflection if needed.
  17362. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17363. */
  17364. blurKernel: number;
  17365. /**
  17366. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17367. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17368. */
  17369. blurKernelX: number;
  17370. /**
  17371. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17372. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17373. */
  17374. blurKernelY: number;
  17375. private _autoComputeBlurKernel;
  17376. protected _onRatioRescale(): void;
  17377. private _updateGammaSpace;
  17378. private _imageProcessingConfigChangeObserver;
  17379. private _transformMatrix;
  17380. private _mirrorMatrix;
  17381. private _savedViewMatrix;
  17382. private _blurX;
  17383. private _blurY;
  17384. private _adaptiveBlurKernel;
  17385. private _blurKernelX;
  17386. private _blurKernelY;
  17387. private _blurRatio;
  17388. /**
  17389. * Instantiates a Mirror Texture.
  17390. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17391. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17392. * You can then easily use it as a reflectionTexture on a flat surface.
  17393. * In case the surface is not a plane, please consider relying on reflection probes.
  17394. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17395. * @param name
  17396. * @param size
  17397. * @param scene
  17398. * @param generateMipMaps
  17399. * @param type
  17400. * @param samplingMode
  17401. * @param generateDepthBuffer
  17402. */
  17403. constructor(name: string, size: number | {
  17404. width: number;
  17405. height: number;
  17406. } | {
  17407. ratio: number;
  17408. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17409. private _preparePostProcesses;
  17410. /**
  17411. * Clone the mirror texture.
  17412. * @returns the cloned texture
  17413. */
  17414. clone(): MirrorTexture;
  17415. /**
  17416. * Serialize the texture to a JSON representation you could use in Parse later on
  17417. * @returns the serialized JSON representation
  17418. */
  17419. serialize(): any;
  17420. /**
  17421. * Dispose the texture and release its associated resources.
  17422. */
  17423. dispose(): void;
  17424. }
  17425. }
  17426. declare module BABYLON {
  17427. /**
  17428. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17429. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17430. */
  17431. export class Texture extends BaseTexture {
  17432. /** @hidden */
  17433. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17434. /** @hidden */
  17435. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17436. /** @hidden */
  17437. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17438. /** nearest is mag = nearest and min = nearest and mip = linear */
  17439. static readonly NEAREST_SAMPLINGMODE: number;
  17440. /** nearest is mag = nearest and min = nearest and mip = linear */
  17441. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17442. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17443. static readonly BILINEAR_SAMPLINGMODE: number;
  17444. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17445. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17446. /** Trilinear is mag = linear and min = linear and mip = linear */
  17447. static readonly TRILINEAR_SAMPLINGMODE: number;
  17448. /** Trilinear is mag = linear and min = linear and mip = linear */
  17449. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17450. /** mag = nearest and min = nearest and mip = nearest */
  17451. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17452. /** mag = nearest and min = linear and mip = nearest */
  17453. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17454. /** mag = nearest and min = linear and mip = linear */
  17455. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17456. /** mag = nearest and min = linear and mip = none */
  17457. static readonly NEAREST_LINEAR: number;
  17458. /** mag = nearest and min = nearest and mip = none */
  17459. static readonly NEAREST_NEAREST: number;
  17460. /** mag = linear and min = nearest and mip = nearest */
  17461. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17462. /** mag = linear and min = nearest and mip = linear */
  17463. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17464. /** mag = linear and min = linear and mip = none */
  17465. static readonly LINEAR_LINEAR: number;
  17466. /** mag = linear and min = nearest and mip = none */
  17467. static readonly LINEAR_NEAREST: number;
  17468. /** Explicit coordinates mode */
  17469. static readonly EXPLICIT_MODE: number;
  17470. /** Spherical coordinates mode */
  17471. static readonly SPHERICAL_MODE: number;
  17472. /** Planar coordinates mode */
  17473. static readonly PLANAR_MODE: number;
  17474. /** Cubic coordinates mode */
  17475. static readonly CUBIC_MODE: number;
  17476. /** Projection coordinates mode */
  17477. static readonly PROJECTION_MODE: number;
  17478. /** Inverse Cubic coordinates mode */
  17479. static readonly SKYBOX_MODE: number;
  17480. /** Inverse Cubic coordinates mode */
  17481. static readonly INVCUBIC_MODE: number;
  17482. /** Equirectangular coordinates mode */
  17483. static readonly EQUIRECTANGULAR_MODE: number;
  17484. /** Equirectangular Fixed coordinates mode */
  17485. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17486. /** Equirectangular Fixed Mirrored coordinates mode */
  17487. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17488. /** Texture is not repeating outside of 0..1 UVs */
  17489. static readonly CLAMP_ADDRESSMODE: number;
  17490. /** Texture is repeating outside of 0..1 UVs */
  17491. static readonly WRAP_ADDRESSMODE: number;
  17492. /** Texture is repeating and mirrored */
  17493. static readonly MIRROR_ADDRESSMODE: number;
  17494. /**
  17495. * 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
  17496. */
  17497. static UseSerializedUrlIfAny: boolean;
  17498. /**
  17499. * Define the url of the texture.
  17500. */
  17501. url: Nullable<string>;
  17502. /**
  17503. * Define an offset on the texture to offset the u coordinates of the UVs
  17504. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17505. */
  17506. uOffset: number;
  17507. /**
  17508. * Define an offset on the texture to offset the v coordinates of the UVs
  17509. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17510. */
  17511. vOffset: number;
  17512. /**
  17513. * Define an offset on the texture to scale the u coordinates of the UVs
  17514. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17515. */
  17516. uScale: number;
  17517. /**
  17518. * Define an offset on the texture to scale the v coordinates of the UVs
  17519. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17520. */
  17521. vScale: number;
  17522. /**
  17523. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17524. * @see http://doc.babylonjs.com/how_to/more_materials
  17525. */
  17526. uAng: number;
  17527. /**
  17528. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17529. * @see http://doc.babylonjs.com/how_to/more_materials
  17530. */
  17531. vAng: number;
  17532. /**
  17533. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17534. * @see http://doc.babylonjs.com/how_to/more_materials
  17535. */
  17536. wAng: number;
  17537. /**
  17538. * Defines the center of rotation (U)
  17539. */
  17540. uRotationCenter: number;
  17541. /**
  17542. * Defines the center of rotation (V)
  17543. */
  17544. vRotationCenter: number;
  17545. /**
  17546. * Defines the center of rotation (W)
  17547. */
  17548. wRotationCenter: number;
  17549. /**
  17550. * Are mip maps generated for this texture or not.
  17551. */
  17552. readonly noMipmap: boolean;
  17553. private _noMipmap;
  17554. /** @hidden */
  17555. _invertY: boolean;
  17556. private _rowGenerationMatrix;
  17557. private _cachedTextureMatrix;
  17558. private _projectionModeMatrix;
  17559. private _t0;
  17560. private _t1;
  17561. private _t2;
  17562. private _cachedUOffset;
  17563. private _cachedVOffset;
  17564. private _cachedUScale;
  17565. private _cachedVScale;
  17566. private _cachedUAng;
  17567. private _cachedVAng;
  17568. private _cachedWAng;
  17569. private _cachedProjectionMatrixId;
  17570. private _cachedCoordinatesMode;
  17571. /** @hidden */
  17572. protected _initialSamplingMode: number;
  17573. /** @hidden */
  17574. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17575. private _deleteBuffer;
  17576. protected _format: Nullable<number>;
  17577. private _delayedOnLoad;
  17578. private _delayedOnError;
  17579. /**
  17580. * Observable triggered once the texture has been loaded.
  17581. */
  17582. onLoadObservable: Observable<Texture>;
  17583. protected _isBlocking: boolean;
  17584. /**
  17585. * Is the texture preventing material to render while loading.
  17586. * If false, a default texture will be used instead of the loading one during the preparation step.
  17587. */
  17588. isBlocking: boolean;
  17589. /**
  17590. * Get the current sampling mode associated with the texture.
  17591. */
  17592. readonly samplingMode: number;
  17593. /**
  17594. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17595. */
  17596. readonly invertY: boolean;
  17597. /**
  17598. * Instantiates a new texture.
  17599. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17600. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17601. * @param url define the url of the picture to load as a texture
  17602. * @param scene define the scene the texture will belong to
  17603. * @param noMipmap define if the texture will require mip maps or not
  17604. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17605. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17606. * @param onLoad define a callback triggered when the texture has been loaded
  17607. * @param onError define a callback triggered when an error occurred during the loading session
  17608. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17609. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17610. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17611. */
  17612. 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);
  17613. /**
  17614. * Update the url (and optional buffer) of this texture if url was null during construction.
  17615. * @param url the url of the texture
  17616. * @param buffer the buffer of the texture (defaults to null)
  17617. * @param onLoad callback called when the texture is loaded (defaults to null)
  17618. */
  17619. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17620. /**
  17621. * Finish the loading sequence of a texture flagged as delayed load.
  17622. * @hidden
  17623. */
  17624. delayLoad(): void;
  17625. private _prepareRowForTextureGeneration;
  17626. /**
  17627. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17628. * @returns the transform matrix of the texture.
  17629. */
  17630. getTextureMatrix(): Matrix;
  17631. /**
  17632. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17633. * @returns The reflection texture transform
  17634. */
  17635. getReflectionTextureMatrix(): Matrix;
  17636. /**
  17637. * Clones the texture.
  17638. * @returns the cloned texture
  17639. */
  17640. clone(): Texture;
  17641. /**
  17642. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17643. * @returns The JSON representation of the texture
  17644. */
  17645. serialize(): any;
  17646. /**
  17647. * Get the current class name of the texture useful for serialization or dynamic coding.
  17648. * @returns "Texture"
  17649. */
  17650. getClassName(): string;
  17651. /**
  17652. * Dispose the texture and release its associated resources.
  17653. */
  17654. dispose(): void;
  17655. /**
  17656. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17657. * @param parsedTexture Define the JSON representation of the texture
  17658. * @param scene Define the scene the parsed texture should be instantiated in
  17659. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17660. * @returns The parsed texture if successful
  17661. */
  17662. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17663. /**
  17664. * Creates a texture from its base 64 representation.
  17665. * @param data Define the base64 payload without the data: prefix
  17666. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17667. * @param scene Define the scene the texture should belong to
  17668. * @param noMipmap Forces the texture to not create mip map information if true
  17669. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17670. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17671. * @param onLoad define a callback triggered when the texture has been loaded
  17672. * @param onError define a callback triggered when an error occurred during the loading session
  17673. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17674. * @returns the created texture
  17675. */
  17676. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17677. /**
  17678. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17679. * @param data Define the base64 payload without the data: prefix
  17680. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17681. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17682. * @param scene Define the scene the texture should belong to
  17683. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17684. * @param noMipmap Forces the texture to not create mip map information if true
  17685. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17686. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17687. * @param onLoad define a callback triggered when the texture has been loaded
  17688. * @param onError define a callback triggered when an error occurred during the loading session
  17689. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17690. * @returns the created texture
  17691. */
  17692. 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;
  17693. }
  17694. }
  17695. declare module BABYLON {
  17696. /**
  17697. * Defines the options associated with the creation of a shader material.
  17698. */
  17699. export interface IShaderMaterialOptions {
  17700. /**
  17701. * Does the material work in alpha blend mode
  17702. */
  17703. needAlphaBlending: boolean;
  17704. /**
  17705. * Does the material work in alpha test mode
  17706. */
  17707. needAlphaTesting: boolean;
  17708. /**
  17709. * The list of attribute names used in the shader
  17710. */
  17711. attributes: string[];
  17712. /**
  17713. * The list of unifrom names used in the shader
  17714. */
  17715. uniforms: string[];
  17716. /**
  17717. * The list of UBO names used in the shader
  17718. */
  17719. uniformBuffers: string[];
  17720. /**
  17721. * The list of sampler names used in the shader
  17722. */
  17723. samplers: string[];
  17724. /**
  17725. * The list of defines used in the shader
  17726. */
  17727. defines: string[];
  17728. }
  17729. /**
  17730. * 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.
  17731. *
  17732. * This returned material effects how the mesh will look based on the code in the shaders.
  17733. *
  17734. * @see http://doc.babylonjs.com/how_to/shader_material
  17735. */
  17736. export class ShaderMaterial extends Material {
  17737. private _shaderPath;
  17738. private _options;
  17739. private _textures;
  17740. private _textureArrays;
  17741. private _floats;
  17742. private _ints;
  17743. private _floatsArrays;
  17744. private _colors3;
  17745. private _colors3Arrays;
  17746. private _colors4;
  17747. private _vectors2;
  17748. private _vectors3;
  17749. private _vectors4;
  17750. private _matrices;
  17751. private _matrices3x3;
  17752. private _matrices2x2;
  17753. private _vectors2Arrays;
  17754. private _vectors3Arrays;
  17755. private _cachedWorldViewMatrix;
  17756. private _renderId;
  17757. /**
  17758. * Instantiate a new shader material.
  17759. * 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.
  17760. * This returned material effects how the mesh will look based on the code in the shaders.
  17761. * @see http://doc.babylonjs.com/how_to/shader_material
  17762. * @param name Define the name of the material in the scene
  17763. * @param scene Define the scene the material belongs to
  17764. * @param shaderPath Defines the route to the shader code in one of three ways:
  17765. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17766. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17767. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17768. * @param options Define the options used to create the shader
  17769. */
  17770. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17771. /**
  17772. * Gets the current class name of the material e.g. "ShaderMaterial"
  17773. * Mainly use in serialization.
  17774. * @returns the class name
  17775. */
  17776. getClassName(): string;
  17777. /**
  17778. * Specifies if the material will require alpha blending
  17779. * @returns a boolean specifying if alpha blending is needed
  17780. */
  17781. needAlphaBlending(): boolean;
  17782. /**
  17783. * Specifies if this material should be rendered in alpha test mode
  17784. * @returns a boolean specifying if an alpha test is needed.
  17785. */
  17786. needAlphaTesting(): boolean;
  17787. private _checkUniform;
  17788. /**
  17789. * Set a texture in the shader.
  17790. * @param name Define the name of the uniform samplers as defined in the shader
  17791. * @param texture Define the texture to bind to this sampler
  17792. * @return the material itself allowing "fluent" like uniform updates
  17793. */
  17794. setTexture(name: string, texture: Texture): ShaderMaterial;
  17795. /**
  17796. * Set a texture array in the shader.
  17797. * @param name Define the name of the uniform sampler array as defined in the shader
  17798. * @param textures Define the list of textures to bind to this sampler
  17799. * @return the material itself allowing "fluent" like uniform updates
  17800. */
  17801. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17802. /**
  17803. * Set a float in the shader.
  17804. * @param name Define the name of the uniform as defined in the shader
  17805. * @param value Define the value to give to the uniform
  17806. * @return the material itself allowing "fluent" like uniform updates
  17807. */
  17808. setFloat(name: string, value: number): ShaderMaterial;
  17809. /**
  17810. * Set a int in the shader.
  17811. * @param name Define the name of the uniform as defined in the shader
  17812. * @param value Define the value to give to the uniform
  17813. * @return the material itself allowing "fluent" like uniform updates
  17814. */
  17815. setInt(name: string, value: number): ShaderMaterial;
  17816. /**
  17817. * Set an array of floats in the shader.
  17818. * @param name Define the name of the uniform as defined in the shader
  17819. * @param value Define the value to give to the uniform
  17820. * @return the material itself allowing "fluent" like uniform updates
  17821. */
  17822. setFloats(name: string, value: number[]): ShaderMaterial;
  17823. /**
  17824. * Set a vec3 in the shader from a Color3.
  17825. * @param name Define the name of the uniform as defined in the shader
  17826. * @param value Define the value to give to the uniform
  17827. * @return the material itself allowing "fluent" like uniform updates
  17828. */
  17829. setColor3(name: string, value: Color3): ShaderMaterial;
  17830. /**
  17831. * Set a vec3 array in the shader from a Color3 array.
  17832. * @param name Define the name of the uniform as defined in the shader
  17833. * @param value Define the value to give to the uniform
  17834. * @return the material itself allowing "fluent" like uniform updates
  17835. */
  17836. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17837. /**
  17838. * Set a vec4 in the shader from a Color4.
  17839. * @param name Define the name of the uniform as defined in the shader
  17840. * @param value Define the value to give to the uniform
  17841. * @return the material itself allowing "fluent" like uniform updates
  17842. */
  17843. setColor4(name: string, value: Color4): ShaderMaterial;
  17844. /**
  17845. * Set a vec2 in the shader from a Vector2.
  17846. * @param name Define the name of the uniform as defined in the shader
  17847. * @param value Define the value to give to the uniform
  17848. * @return the material itself allowing "fluent" like uniform updates
  17849. */
  17850. setVector2(name: string, value: Vector2): ShaderMaterial;
  17851. /**
  17852. * Set a vec3 in the shader from a Vector3.
  17853. * @param name Define the name of the uniform as defined in the shader
  17854. * @param value Define the value to give to the uniform
  17855. * @return the material itself allowing "fluent" like uniform updates
  17856. */
  17857. setVector3(name: string, value: Vector3): ShaderMaterial;
  17858. /**
  17859. * Set a vec4 in the shader from a Vector4.
  17860. * @param name Define the name of the uniform as defined in the shader
  17861. * @param value Define the value to give to the uniform
  17862. * @return the material itself allowing "fluent" like uniform updates
  17863. */
  17864. setVector4(name: string, value: Vector4): ShaderMaterial;
  17865. /**
  17866. * Set a mat4 in the shader from a Matrix.
  17867. * @param name Define the name of the uniform as defined in the shader
  17868. * @param value Define the value to give to the uniform
  17869. * @return the material itself allowing "fluent" like uniform updates
  17870. */
  17871. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17872. /**
  17873. * Set a mat3 in the shader from a Float32Array.
  17874. * @param name Define the name of the uniform as defined in the shader
  17875. * @param value Define the value to give to the uniform
  17876. * @return the material itself allowing "fluent" like uniform updates
  17877. */
  17878. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17879. /**
  17880. * Set a mat2 in the shader from a Float32Array.
  17881. * @param name Define the name of the uniform as defined in the shader
  17882. * @param value Define the value to give to the uniform
  17883. * @return the material itself allowing "fluent" like uniform updates
  17884. */
  17885. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17886. /**
  17887. * Set a vec2 array in the shader from a number array.
  17888. * @param name Define the name of the uniform as defined in the shader
  17889. * @param value Define the value to give to the uniform
  17890. * @return the material itself allowing "fluent" like uniform updates
  17891. */
  17892. setArray2(name: string, value: number[]): ShaderMaterial;
  17893. /**
  17894. * Set a vec3 array in the shader from a number array.
  17895. * @param name Define the name of the uniform as defined in the shader
  17896. * @param value Define the value to give to the uniform
  17897. * @return the material itself allowing "fluent" like uniform updates
  17898. */
  17899. setArray3(name: string, value: number[]): ShaderMaterial;
  17900. private _checkCache;
  17901. /**
  17902. * Checks if the material is ready to render the requested mesh
  17903. * @param mesh Define the mesh to render
  17904. * @param useInstances Define whether or not the material is used with instances
  17905. * @returns true if ready, otherwise false
  17906. */
  17907. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17908. /**
  17909. * Binds the world matrix to the material
  17910. * @param world defines the world transformation matrix
  17911. */
  17912. bindOnlyWorldMatrix(world: Matrix): void;
  17913. /**
  17914. * Binds the material to the mesh
  17915. * @param world defines the world transformation matrix
  17916. * @param mesh defines the mesh to bind the material to
  17917. */
  17918. bind(world: Matrix, mesh?: Mesh): void;
  17919. /**
  17920. * Gets the active textures from the material
  17921. * @returns an array of textures
  17922. */
  17923. getActiveTextures(): BaseTexture[];
  17924. /**
  17925. * Specifies if the material uses a texture
  17926. * @param texture defines the texture to check against the material
  17927. * @returns a boolean specifying if the material uses the texture
  17928. */
  17929. hasTexture(texture: BaseTexture): boolean;
  17930. /**
  17931. * Makes a duplicate of the material, and gives it a new name
  17932. * @param name defines the new name for the duplicated material
  17933. * @returns the cloned material
  17934. */
  17935. clone(name: string): ShaderMaterial;
  17936. /**
  17937. * Disposes the material
  17938. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17939. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17940. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17941. */
  17942. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17943. /**
  17944. * Serializes this material in a JSON representation
  17945. * @returns the serialized material object
  17946. */
  17947. serialize(): any;
  17948. /**
  17949. * Creates a shader material from parsed shader material data
  17950. * @param source defines the JSON represnetation of the material
  17951. * @param scene defines the hosting scene
  17952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17953. * @returns a new material
  17954. */
  17955. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17956. }
  17957. }
  17958. declare module BABYLON {
  17959. /** @hidden */
  17960. export var colorPixelShader: {
  17961. name: string;
  17962. shader: string;
  17963. };
  17964. }
  17965. declare module BABYLON {
  17966. /** @hidden */
  17967. export var colorVertexShader: {
  17968. name: string;
  17969. shader: string;
  17970. };
  17971. }
  17972. declare module BABYLON {
  17973. /**
  17974. * Line mesh
  17975. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17976. */
  17977. export class LinesMesh extends Mesh {
  17978. /**
  17979. * If vertex color should be applied to the mesh
  17980. */
  17981. useVertexColor?: boolean | undefined;
  17982. /**
  17983. * If vertex alpha should be applied to the mesh
  17984. */
  17985. useVertexAlpha?: boolean | undefined;
  17986. /**
  17987. * Color of the line (Default: White)
  17988. */
  17989. color: Color3;
  17990. /**
  17991. * Alpha of the line (Default: 1)
  17992. */
  17993. alpha: number;
  17994. /**
  17995. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17996. * This margin is expressed in world space coordinates, so its value may vary.
  17997. * Default value is 0.1
  17998. */
  17999. intersectionThreshold: number;
  18000. private _colorShader;
  18001. /**
  18002. * Creates a new LinesMesh
  18003. * @param name defines the name
  18004. * @param scene defines the hosting scene
  18005. * @param parent defines the parent mesh if any
  18006. * @param source defines the optional source LinesMesh used to clone data from
  18007. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18008. * When false, achieved by calling a clone(), also passing False.
  18009. * This will make creation of children, recursive.
  18010. * @param useVertexColor defines if this LinesMesh supports vertex color
  18011. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18012. */
  18013. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  18014. /**
  18015. * If vertex color should be applied to the mesh
  18016. */
  18017. useVertexColor?: boolean | undefined,
  18018. /**
  18019. * If vertex alpha should be applied to the mesh
  18020. */
  18021. useVertexAlpha?: boolean | undefined);
  18022. /**
  18023. * Returns the string "LineMesh"
  18024. */
  18025. getClassName(): string;
  18026. /**
  18027. * @hidden
  18028. */
  18029. /**
  18030. * @hidden
  18031. */
  18032. material: Material;
  18033. /**
  18034. * @hidden
  18035. */
  18036. readonly checkCollisions: boolean;
  18037. /** @hidden */
  18038. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  18039. /** @hidden */
  18040. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  18041. /**
  18042. * Disposes of the line mesh
  18043. * @param doNotRecurse If children should be disposed
  18044. */
  18045. dispose(doNotRecurse?: boolean): void;
  18046. /**
  18047. * Returns a new LineMesh object cloned from the current one.
  18048. */
  18049. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  18050. /**
  18051. * Creates a new InstancedLinesMesh object from the mesh model.
  18052. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18053. * @param name defines the name of the new instance
  18054. * @returns a new InstancedLinesMesh
  18055. */
  18056. createInstance(name: string): InstancedLinesMesh;
  18057. }
  18058. /**
  18059. * Creates an instance based on a source LinesMesh
  18060. */
  18061. export class InstancedLinesMesh extends InstancedMesh {
  18062. /**
  18063. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18064. * This margin is expressed in world space coordinates, so its value may vary.
  18065. * Initilized with the intersectionThreshold value of the source LinesMesh
  18066. */
  18067. intersectionThreshold: number;
  18068. constructor(name: string, source: LinesMesh);
  18069. /**
  18070. * Returns the string "InstancedLinesMesh".
  18071. */
  18072. getClassName(): string;
  18073. }
  18074. }
  18075. declare module BABYLON {
  18076. /**
  18077. * Mesh representing the gorund
  18078. */
  18079. export class GroundMesh extends Mesh {
  18080. /** If octree should be generated */
  18081. generateOctree: boolean;
  18082. private _heightQuads;
  18083. /** @hidden */
  18084. _subdivisionsX: number;
  18085. /** @hidden */
  18086. _subdivisionsY: number;
  18087. /** @hidden */
  18088. _width: number;
  18089. /** @hidden */
  18090. _height: number;
  18091. /** @hidden */
  18092. _minX: number;
  18093. /** @hidden */
  18094. _maxX: number;
  18095. /** @hidden */
  18096. _minZ: number;
  18097. /** @hidden */
  18098. _maxZ: number;
  18099. constructor(name: string, scene: Scene);
  18100. /**
  18101. * "GroundMesh"
  18102. * @returns "GroundMesh"
  18103. */
  18104. getClassName(): string;
  18105. /**
  18106. * The minimum of x and y subdivisions
  18107. */
  18108. readonly subdivisions: number;
  18109. /**
  18110. * X subdivisions
  18111. */
  18112. readonly subdivisionsX: number;
  18113. /**
  18114. * Y subdivisions
  18115. */
  18116. readonly subdivisionsY: number;
  18117. /**
  18118. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18119. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18120. * @param chunksCount the number of subdivisions for x and y
  18121. * @param octreeBlocksSize (Default: 32)
  18122. */
  18123. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18124. /**
  18125. * Returns a height (y) value in the Worl system :
  18126. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18127. * @param x x coordinate
  18128. * @param z z coordinate
  18129. * @returns the ground y position if (x, z) are outside the ground surface.
  18130. */
  18131. getHeightAtCoordinates(x: number, z: number): number;
  18132. /**
  18133. * Returns a normalized vector (Vector3) orthogonal to the ground
  18134. * at the ground coordinates (x, z) expressed in the World system.
  18135. * @param x x coordinate
  18136. * @param z z coordinate
  18137. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18138. */
  18139. getNormalAtCoordinates(x: number, z: number): Vector3;
  18140. /**
  18141. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18142. * at the ground coordinates (x, z) expressed in the World system.
  18143. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18144. * @param x x coordinate
  18145. * @param z z coordinate
  18146. * @param ref vector to store the result
  18147. * @returns the GroundMesh.
  18148. */
  18149. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18150. /**
  18151. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18152. * if the ground has been updated.
  18153. * This can be used in the render loop.
  18154. * @returns the GroundMesh.
  18155. */
  18156. updateCoordinateHeights(): GroundMesh;
  18157. private _getFacetAt;
  18158. private _initHeightQuads;
  18159. private _computeHeightQuads;
  18160. /**
  18161. * Serializes this ground mesh
  18162. * @param serializationObject object to write serialization to
  18163. */
  18164. serialize(serializationObject: any): void;
  18165. /**
  18166. * Parses a serialized ground mesh
  18167. * @param parsedMesh the serialized mesh
  18168. * @param scene the scene to create the ground mesh in
  18169. * @returns the created ground mesh
  18170. */
  18171. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18172. }
  18173. }
  18174. declare module BABYLON {
  18175. /**
  18176. * Interface for Physics-Joint data
  18177. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18178. */
  18179. export interface PhysicsJointData {
  18180. /**
  18181. * The main pivot of the joint
  18182. */
  18183. mainPivot?: Vector3;
  18184. /**
  18185. * The connected pivot of the joint
  18186. */
  18187. connectedPivot?: Vector3;
  18188. /**
  18189. * The main axis of the joint
  18190. */
  18191. mainAxis?: Vector3;
  18192. /**
  18193. * The connected axis of the joint
  18194. */
  18195. connectedAxis?: Vector3;
  18196. /**
  18197. * The collision of the joint
  18198. */
  18199. collision?: boolean;
  18200. /**
  18201. * Native Oimo/Cannon/Energy data
  18202. */
  18203. nativeParams?: any;
  18204. }
  18205. /**
  18206. * This is a holder class for the physics joint created by the physics plugin
  18207. * It holds a set of functions to control the underlying joint
  18208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18209. */
  18210. export class PhysicsJoint {
  18211. /**
  18212. * The type of the physics joint
  18213. */
  18214. type: number;
  18215. /**
  18216. * The data for the physics joint
  18217. */
  18218. jointData: PhysicsJointData;
  18219. private _physicsJoint;
  18220. protected _physicsPlugin: IPhysicsEnginePlugin;
  18221. /**
  18222. * Initializes the physics joint
  18223. * @param type The type of the physics joint
  18224. * @param jointData The data for the physics joint
  18225. */
  18226. constructor(
  18227. /**
  18228. * The type of the physics joint
  18229. */
  18230. type: number,
  18231. /**
  18232. * The data for the physics joint
  18233. */
  18234. jointData: PhysicsJointData);
  18235. /**
  18236. * Gets the physics joint
  18237. */
  18238. /**
  18239. * Sets the physics joint
  18240. */
  18241. physicsJoint: any;
  18242. /**
  18243. * Sets the physics plugin
  18244. */
  18245. physicsPlugin: IPhysicsEnginePlugin;
  18246. /**
  18247. * Execute a function that is physics-plugin specific.
  18248. * @param {Function} func the function that will be executed.
  18249. * It accepts two parameters: the physics world and the physics joint
  18250. */
  18251. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  18252. /**
  18253. * Distance-Joint type
  18254. */
  18255. static DistanceJoint: number;
  18256. /**
  18257. * Hinge-Joint type
  18258. */
  18259. static HingeJoint: number;
  18260. /**
  18261. * Ball-and-Socket joint type
  18262. */
  18263. static BallAndSocketJoint: number;
  18264. /**
  18265. * Wheel-Joint type
  18266. */
  18267. static WheelJoint: number;
  18268. /**
  18269. * Slider-Joint type
  18270. */
  18271. static SliderJoint: number;
  18272. /**
  18273. * Prismatic-Joint type
  18274. */
  18275. static PrismaticJoint: number;
  18276. /**
  18277. * Universal-Joint type
  18278. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  18279. */
  18280. static UniversalJoint: number;
  18281. /**
  18282. * Hinge-Joint 2 type
  18283. */
  18284. static Hinge2Joint: number;
  18285. /**
  18286. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  18287. */
  18288. static PointToPointJoint: number;
  18289. /**
  18290. * Spring-Joint type
  18291. */
  18292. static SpringJoint: number;
  18293. /**
  18294. * Lock-Joint type
  18295. */
  18296. static LockJoint: number;
  18297. }
  18298. /**
  18299. * A class representing a physics distance joint
  18300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18301. */
  18302. export class DistanceJoint extends PhysicsJoint {
  18303. /**
  18304. *
  18305. * @param jointData The data for the Distance-Joint
  18306. */
  18307. constructor(jointData: DistanceJointData);
  18308. /**
  18309. * Update the predefined distance.
  18310. * @param maxDistance The maximum preferred distance
  18311. * @param minDistance The minimum preferred distance
  18312. */
  18313. updateDistance(maxDistance: number, minDistance?: number): void;
  18314. }
  18315. /**
  18316. * Represents a Motor-Enabled Joint
  18317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18318. */
  18319. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  18320. /**
  18321. * Initializes the Motor-Enabled Joint
  18322. * @param type The type of the joint
  18323. * @param jointData The physica joint data for the joint
  18324. */
  18325. constructor(type: number, jointData: PhysicsJointData);
  18326. /**
  18327. * Set the motor values.
  18328. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18329. * @param force the force to apply
  18330. * @param maxForce max force for this motor.
  18331. */
  18332. setMotor(force?: number, maxForce?: number): void;
  18333. /**
  18334. * Set the motor's limits.
  18335. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18336. * @param upperLimit The upper limit of the motor
  18337. * @param lowerLimit The lower limit of the motor
  18338. */
  18339. setLimit(upperLimit: number, lowerLimit?: number): void;
  18340. }
  18341. /**
  18342. * This class represents a single physics Hinge-Joint
  18343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18344. */
  18345. export class HingeJoint extends MotorEnabledJoint {
  18346. /**
  18347. * Initializes the Hinge-Joint
  18348. * @param jointData The joint data for the Hinge-Joint
  18349. */
  18350. constructor(jointData: PhysicsJointData);
  18351. /**
  18352. * Set the motor values.
  18353. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18354. * @param {number} force the force to apply
  18355. * @param {number} maxForce max force for this motor.
  18356. */
  18357. setMotor(force?: number, maxForce?: number): void;
  18358. /**
  18359. * Set the motor's limits.
  18360. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18361. * @param upperLimit The upper limit of the motor
  18362. * @param lowerLimit The lower limit of the motor
  18363. */
  18364. setLimit(upperLimit: number, lowerLimit?: number): void;
  18365. }
  18366. /**
  18367. * This class represents a dual hinge physics joint (same as wheel joint)
  18368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18369. */
  18370. export class Hinge2Joint extends MotorEnabledJoint {
  18371. /**
  18372. * Initializes the Hinge2-Joint
  18373. * @param jointData The joint data for the Hinge2-Joint
  18374. */
  18375. constructor(jointData: PhysicsJointData);
  18376. /**
  18377. * Set the motor values.
  18378. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18379. * @param {number} targetSpeed the speed the motor is to reach
  18380. * @param {number} maxForce max force for this motor.
  18381. * @param {motorIndex} the motor's index, 0 or 1.
  18382. */
  18383. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  18384. /**
  18385. * Set the motor limits.
  18386. * Attention, this function is plugin specific. Engines won't react 100% the same.
  18387. * @param {number} upperLimit the upper limit
  18388. * @param {number} lowerLimit lower limit
  18389. * @param {motorIndex} the motor's index, 0 or 1.
  18390. */
  18391. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18392. }
  18393. /**
  18394. * Interface for a motor enabled joint
  18395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18396. */
  18397. export interface IMotorEnabledJoint {
  18398. /**
  18399. * Physics joint
  18400. */
  18401. physicsJoint: any;
  18402. /**
  18403. * Sets the motor of the motor-enabled joint
  18404. * @param force The force of the motor
  18405. * @param maxForce The maximum force of the motor
  18406. * @param motorIndex The index of the motor
  18407. */
  18408. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18409. /**
  18410. * Sets the limit of the motor
  18411. * @param upperLimit The upper limit of the motor
  18412. * @param lowerLimit The lower limit of the motor
  18413. * @param motorIndex The index of the motor
  18414. */
  18415. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18416. }
  18417. /**
  18418. * Joint data for a Distance-Joint
  18419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18420. */
  18421. export interface DistanceJointData extends PhysicsJointData {
  18422. /**
  18423. * Max distance the 2 joint objects can be apart
  18424. */
  18425. maxDistance: number;
  18426. }
  18427. /**
  18428. * Joint data from a spring joint
  18429. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18430. */
  18431. export interface SpringJointData extends PhysicsJointData {
  18432. /**
  18433. * Length of the spring
  18434. */
  18435. length: number;
  18436. /**
  18437. * Stiffness of the spring
  18438. */
  18439. stiffness: number;
  18440. /**
  18441. * Damping of the spring
  18442. */
  18443. damping: number;
  18444. /** this callback will be called when applying the force to the impostors. */
  18445. forceApplicationCallback: () => void;
  18446. }
  18447. }
  18448. declare module BABYLON {
  18449. /**
  18450. * Interface used to describe a physics joint
  18451. */
  18452. export interface PhysicsImpostorJoint {
  18453. /** Defines the main impostor to which the joint is linked */
  18454. mainImpostor: PhysicsImpostor;
  18455. /** Defines the impostor that is connected to the main impostor using this joint */
  18456. connectedImpostor: PhysicsImpostor;
  18457. /** Defines the joint itself */
  18458. joint: PhysicsJoint;
  18459. }
  18460. /** @hidden */
  18461. export interface IPhysicsEnginePlugin {
  18462. world: any;
  18463. name: string;
  18464. setGravity(gravity: Vector3): void;
  18465. setTimeStep(timeStep: number): void;
  18466. getTimeStep(): number;
  18467. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18468. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18469. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18470. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18471. removePhysicsBody(impostor: PhysicsImpostor): void;
  18472. generateJoint(joint: PhysicsImpostorJoint): void;
  18473. removeJoint(joint: PhysicsImpostorJoint): void;
  18474. isSupported(): boolean;
  18475. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18476. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18477. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18478. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18479. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18480. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18481. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18482. getBodyMass(impostor: PhysicsImpostor): number;
  18483. getBodyFriction(impostor: PhysicsImpostor): number;
  18484. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18485. getBodyRestitution(impostor: PhysicsImpostor): number;
  18486. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18487. sleepBody(impostor: PhysicsImpostor): void;
  18488. wakeUpBody(impostor: PhysicsImpostor): void;
  18489. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18490. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18491. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18492. getRadius(impostor: PhysicsImpostor): number;
  18493. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18494. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18495. dispose(): void;
  18496. }
  18497. /**
  18498. * Interface used to define a physics engine
  18499. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18500. */
  18501. export interface IPhysicsEngine {
  18502. /**
  18503. * Gets the gravity vector used by the simulation
  18504. */
  18505. gravity: Vector3;
  18506. /**
  18507. * Sets the gravity vector used by the simulation
  18508. * @param gravity defines the gravity vector to use
  18509. */
  18510. setGravity(gravity: Vector3): void;
  18511. /**
  18512. * Set the time step of the physics engine.
  18513. * Default is 1/60.
  18514. * To slow it down, enter 1/600 for example.
  18515. * To speed it up, 1/30
  18516. * @param newTimeStep the new timestep to apply to this world.
  18517. */
  18518. setTimeStep(newTimeStep: number): void;
  18519. /**
  18520. * Get the time step of the physics engine.
  18521. * @returns the current time step
  18522. */
  18523. getTimeStep(): number;
  18524. /**
  18525. * Release all resources
  18526. */
  18527. dispose(): void;
  18528. /**
  18529. * Gets the name of the current physics plugin
  18530. * @returns the name of the plugin
  18531. */
  18532. getPhysicsPluginName(): string;
  18533. /**
  18534. * Adding a new impostor for the impostor tracking.
  18535. * This will be done by the impostor itself.
  18536. * @param impostor the impostor to add
  18537. */
  18538. addImpostor(impostor: PhysicsImpostor): void;
  18539. /**
  18540. * Remove an impostor from the engine.
  18541. * This impostor and its mesh will not longer be updated by the physics engine.
  18542. * @param impostor the impostor to remove
  18543. */
  18544. removeImpostor(impostor: PhysicsImpostor): void;
  18545. /**
  18546. * Add a joint to the physics engine
  18547. * @param mainImpostor defines the main impostor to which the joint is added.
  18548. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18549. * @param joint defines the joint that will connect both impostors.
  18550. */
  18551. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18552. /**
  18553. * Removes a joint from the simulation
  18554. * @param mainImpostor defines the impostor used with the joint
  18555. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18556. * @param joint defines the joint to remove
  18557. */
  18558. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18559. /**
  18560. * Gets the current plugin used to run the simulation
  18561. * @returns current plugin
  18562. */
  18563. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18564. /**
  18565. * Gets the list of physic impostors
  18566. * @returns an array of PhysicsImpostor
  18567. */
  18568. getImpostors(): Array<PhysicsImpostor>;
  18569. /**
  18570. * Gets the impostor for a physics enabled object
  18571. * @param object defines the object impersonated by the impostor
  18572. * @returns the PhysicsImpostor or null if not found
  18573. */
  18574. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18575. /**
  18576. * Gets the impostor for a physics body object
  18577. * @param body defines physics body used by the impostor
  18578. * @returns the PhysicsImpostor or null if not found
  18579. */
  18580. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18581. /**
  18582. * Called by the scene. No need to call it.
  18583. * @param delta defines the timespam between frames
  18584. */
  18585. _step(delta: number): void;
  18586. }
  18587. }
  18588. declare module BABYLON {
  18589. /**
  18590. * The interface for the physics imposter parameters
  18591. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18592. */
  18593. export interface PhysicsImpostorParameters {
  18594. /**
  18595. * The mass of the physics imposter
  18596. */
  18597. mass: number;
  18598. /**
  18599. * The friction of the physics imposter
  18600. */
  18601. friction?: number;
  18602. /**
  18603. * The coefficient of restitution of the physics imposter
  18604. */
  18605. restitution?: number;
  18606. /**
  18607. * The native options of the physics imposter
  18608. */
  18609. nativeOptions?: any;
  18610. /**
  18611. * Specifies if the parent should be ignored
  18612. */
  18613. ignoreParent?: boolean;
  18614. /**
  18615. * Specifies if bi-directional transformations should be disabled
  18616. */
  18617. disableBidirectionalTransformation?: boolean;
  18618. }
  18619. /**
  18620. * Interface for a physics-enabled object
  18621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18622. */
  18623. export interface IPhysicsEnabledObject {
  18624. /**
  18625. * The position of the physics-enabled object
  18626. */
  18627. position: Vector3;
  18628. /**
  18629. * The rotation of the physics-enabled object
  18630. */
  18631. rotationQuaternion: Nullable<Quaternion>;
  18632. /**
  18633. * The scale of the physics-enabled object
  18634. */
  18635. scaling: Vector3;
  18636. /**
  18637. * The rotation of the physics-enabled object
  18638. */
  18639. rotation?: Vector3;
  18640. /**
  18641. * The parent of the physics-enabled object
  18642. */
  18643. parent?: any;
  18644. /**
  18645. * The bounding info of the physics-enabled object
  18646. * @returns The bounding info of the physics-enabled object
  18647. */
  18648. getBoundingInfo(): BoundingInfo;
  18649. /**
  18650. * Computes the world matrix
  18651. * @param force Specifies if the world matrix should be computed by force
  18652. * @returns A world matrix
  18653. */
  18654. computeWorldMatrix(force: boolean): Matrix;
  18655. /**
  18656. * Gets the world matrix
  18657. * @returns A world matrix
  18658. */
  18659. getWorldMatrix?(): Matrix;
  18660. /**
  18661. * Gets the child meshes
  18662. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18663. * @returns An array of abstract meshes
  18664. */
  18665. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18666. /**
  18667. * Gets the vertex data
  18668. * @param kind The type of vertex data
  18669. * @returns A nullable array of numbers, or a float32 array
  18670. */
  18671. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18672. /**
  18673. * Gets the indices from the mesh
  18674. * @returns A nullable array of index arrays
  18675. */
  18676. getIndices?(): Nullable<IndicesArray>;
  18677. /**
  18678. * Gets the scene from the mesh
  18679. * @returns the indices array or null
  18680. */
  18681. getScene?(): Scene;
  18682. /**
  18683. * Gets the absolute position from the mesh
  18684. * @returns the absolute position
  18685. */
  18686. getAbsolutePosition(): Vector3;
  18687. /**
  18688. * Gets the absolute pivot point from the mesh
  18689. * @returns the absolute pivot point
  18690. */
  18691. getAbsolutePivotPoint(): Vector3;
  18692. /**
  18693. * Rotates the mesh
  18694. * @param axis The axis of rotation
  18695. * @param amount The amount of rotation
  18696. * @param space The space of the rotation
  18697. * @returns The rotation transform node
  18698. */
  18699. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18700. /**
  18701. * Translates the mesh
  18702. * @param axis The axis of translation
  18703. * @param distance The distance of translation
  18704. * @param space The space of the translation
  18705. * @returns The transform node
  18706. */
  18707. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18708. /**
  18709. * Sets the absolute position of the mesh
  18710. * @param absolutePosition The absolute position of the mesh
  18711. * @returns The transform node
  18712. */
  18713. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18714. /**
  18715. * Gets the class name of the mesh
  18716. * @returns The class name
  18717. */
  18718. getClassName(): string;
  18719. }
  18720. /**
  18721. * Represents a physics imposter
  18722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18723. */
  18724. export class PhysicsImpostor {
  18725. /**
  18726. * The physics-enabled object used as the physics imposter
  18727. */
  18728. object: IPhysicsEnabledObject;
  18729. /**
  18730. * The type of the physics imposter
  18731. */
  18732. type: number;
  18733. private _options;
  18734. private _scene?;
  18735. /**
  18736. * The default object size of the imposter
  18737. */
  18738. static DEFAULT_OBJECT_SIZE: Vector3;
  18739. /**
  18740. * The identity quaternion of the imposter
  18741. */
  18742. static IDENTITY_QUATERNION: Quaternion;
  18743. /** @hidden */
  18744. _pluginData: any;
  18745. private _physicsEngine;
  18746. private _physicsBody;
  18747. private _bodyUpdateRequired;
  18748. private _onBeforePhysicsStepCallbacks;
  18749. private _onAfterPhysicsStepCallbacks;
  18750. /** @hidden */
  18751. _onPhysicsCollideCallbacks: Array<{
  18752. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  18753. otherImpostors: Array<PhysicsImpostor>;
  18754. }>;
  18755. private _deltaPosition;
  18756. private _deltaRotation;
  18757. private _deltaRotationConjugated;
  18758. private _parent;
  18759. private _isDisposed;
  18760. private static _tmpVecs;
  18761. private static _tmpQuat;
  18762. /**
  18763. * Specifies if the physics imposter is disposed
  18764. */
  18765. readonly isDisposed: boolean;
  18766. /**
  18767. * Gets the mass of the physics imposter
  18768. */
  18769. mass: number;
  18770. /**
  18771. * Gets the coefficient of friction
  18772. */
  18773. /**
  18774. * Sets the coefficient of friction
  18775. */
  18776. friction: number;
  18777. /**
  18778. * Gets the coefficient of restitution
  18779. */
  18780. /**
  18781. * Sets the coefficient of restitution
  18782. */
  18783. restitution: number;
  18784. /**
  18785. * The unique id of the physics imposter
  18786. * set by the physics engine when adding this impostor to the array
  18787. */
  18788. uniqueId: number;
  18789. private _joints;
  18790. /**
  18791. * Initializes the physics imposter
  18792. * @param object The physics-enabled object used as the physics imposter
  18793. * @param type The type of the physics imposter
  18794. * @param _options The options for the physics imposter
  18795. * @param _scene The Babylon scene
  18796. */
  18797. constructor(
  18798. /**
  18799. * The physics-enabled object used as the physics imposter
  18800. */
  18801. object: IPhysicsEnabledObject,
  18802. /**
  18803. * The type of the physics imposter
  18804. */
  18805. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18806. /**
  18807. * This function will completly initialize this impostor.
  18808. * It will create a new body - but only if this mesh has no parent.
  18809. * If it has, this impostor will not be used other than to define the impostor
  18810. * of the child mesh.
  18811. * @hidden
  18812. */
  18813. _init(): void;
  18814. private _getPhysicsParent;
  18815. /**
  18816. * Should a new body be generated.
  18817. * @returns boolean specifying if body initialization is required
  18818. */
  18819. isBodyInitRequired(): boolean;
  18820. /**
  18821. * Sets the updated scaling
  18822. * @param updated Specifies if the scaling is updated
  18823. */
  18824. setScalingUpdated(): void;
  18825. /**
  18826. * Force a regeneration of this or the parent's impostor's body.
  18827. * Use under cautious - This will remove all joints already implemented.
  18828. */
  18829. forceUpdate(): void;
  18830. /**
  18831. * Gets the body that holds this impostor. Either its own, or its parent.
  18832. */
  18833. /**
  18834. * Set the physics body. Used mainly by the physics engine/plugin
  18835. */
  18836. physicsBody: any;
  18837. /**
  18838. * Get the parent of the physics imposter
  18839. * @returns Physics imposter or null
  18840. */
  18841. /**
  18842. * Sets the parent of the physics imposter
  18843. */
  18844. parent: Nullable<PhysicsImpostor>;
  18845. /**
  18846. * Resets the update flags
  18847. */
  18848. resetUpdateFlags(): void;
  18849. /**
  18850. * Gets the object extend size
  18851. * @returns the object extend size
  18852. */
  18853. getObjectExtendSize(): Vector3;
  18854. /**
  18855. * Gets the object center
  18856. * @returns The object center
  18857. */
  18858. getObjectCenter(): Vector3;
  18859. /**
  18860. * Get a specific parametes from the options parameter
  18861. * @param paramName The object parameter name
  18862. * @returns The object parameter
  18863. */
  18864. getParam(paramName: string): any;
  18865. /**
  18866. * Sets a specific parameter in the options given to the physics plugin
  18867. * @param paramName The parameter name
  18868. * @param value The value of the parameter
  18869. */
  18870. setParam(paramName: string, value: number): void;
  18871. /**
  18872. * Specifically change the body's mass option. Won't recreate the physics body object
  18873. * @param mass The mass of the physics imposter
  18874. */
  18875. setMass(mass: number): void;
  18876. /**
  18877. * Gets the linear velocity
  18878. * @returns linear velocity or null
  18879. */
  18880. getLinearVelocity(): Nullable<Vector3>;
  18881. /**
  18882. * Sets the linear velocity
  18883. * @param velocity linear velocity or null
  18884. */
  18885. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18886. /**
  18887. * Gets the angular velocity
  18888. * @returns angular velocity or null
  18889. */
  18890. getAngularVelocity(): Nullable<Vector3>;
  18891. /**
  18892. * Sets the angular velocity
  18893. * @param velocity The velocity or null
  18894. */
  18895. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18896. /**
  18897. * Execute a function with the physics plugin native code
  18898. * Provide a function the will have two variables - the world object and the physics body object
  18899. * @param func The function to execute with the physics plugin native code
  18900. */
  18901. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18902. /**
  18903. * Register a function that will be executed before the physics world is stepping forward
  18904. * @param func The function to execute before the physics world is stepped forward
  18905. */
  18906. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18907. /**
  18908. * Unregister a function that will be executed before the physics world is stepping forward
  18909. * @param func The function to execute before the physics world is stepped forward
  18910. */
  18911. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18912. /**
  18913. * Register a function that will be executed after the physics step
  18914. * @param func The function to execute after physics step
  18915. */
  18916. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18917. /**
  18918. * Unregisters a function that will be executed after the physics step
  18919. * @param func The function to execute after physics step
  18920. */
  18921. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18922. /**
  18923. * register a function that will be executed when this impostor collides against a different body
  18924. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18925. * @param func Callback that is executed on collision
  18926. */
  18927. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18928. /**
  18929. * Unregisters the physics imposter on contact
  18930. * @param collideAgainst The physics object to collide against
  18931. * @param func Callback to execute on collision
  18932. */
  18933. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18934. private _tmpQuat;
  18935. private _tmpQuat2;
  18936. /**
  18937. * Get the parent rotation
  18938. * @returns The parent rotation
  18939. */
  18940. getParentsRotation(): Quaternion;
  18941. /**
  18942. * this function is executed by the physics engine.
  18943. */
  18944. beforeStep: () => void;
  18945. /**
  18946. * this function is executed by the physics engine
  18947. */
  18948. afterStep: () => void;
  18949. /**
  18950. * Legacy collision detection event support
  18951. */
  18952. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18953. /**
  18954. * event and body object due to cannon's event-based architecture.
  18955. */
  18956. onCollide: (e: {
  18957. body: any;
  18958. }) => void;
  18959. /**
  18960. * Apply a force
  18961. * @param force The force to apply
  18962. * @param contactPoint The contact point for the force
  18963. * @returns The physics imposter
  18964. */
  18965. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18966. /**
  18967. * Apply an impulse
  18968. * @param force The impulse force
  18969. * @param contactPoint The contact point for the impulse force
  18970. * @returns The physics imposter
  18971. */
  18972. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18973. /**
  18974. * A help function to create a joint
  18975. * @param otherImpostor A physics imposter used to create a joint
  18976. * @param jointType The type of joint
  18977. * @param jointData The data for the joint
  18978. * @returns The physics imposter
  18979. */
  18980. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18981. /**
  18982. * Add a joint to this impostor with a different impostor
  18983. * @param otherImpostor A physics imposter used to add a joint
  18984. * @param joint The joint to add
  18985. * @returns The physics imposter
  18986. */
  18987. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18988. /**
  18989. * Will keep this body still, in a sleep mode.
  18990. * @returns the physics imposter
  18991. */
  18992. sleep(): PhysicsImpostor;
  18993. /**
  18994. * Wake the body up.
  18995. * @returns The physics imposter
  18996. */
  18997. wakeUp(): PhysicsImpostor;
  18998. /**
  18999. * Clones the physics imposter
  19000. * @param newObject The physics imposter clones to this physics-enabled object
  19001. * @returns A nullable physics imposter
  19002. */
  19003. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19004. /**
  19005. * Disposes the physics imposter
  19006. */
  19007. dispose(): void;
  19008. /**
  19009. * Sets the delta position
  19010. * @param position The delta position amount
  19011. */
  19012. setDeltaPosition(position: Vector3): void;
  19013. /**
  19014. * Sets the delta rotation
  19015. * @param rotation The delta rotation amount
  19016. */
  19017. setDeltaRotation(rotation: Quaternion): void;
  19018. /**
  19019. * Gets the box size of the physics imposter and stores the result in the input parameter
  19020. * @param result Stores the box size
  19021. * @returns The physics imposter
  19022. */
  19023. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  19024. /**
  19025. * Gets the radius of the physics imposter
  19026. * @returns Radius of the physics imposter
  19027. */
  19028. getRadius(): number;
  19029. /**
  19030. * Sync a bone with this impostor
  19031. * @param bone The bone to sync to the impostor.
  19032. * @param boneMesh The mesh that the bone is influencing.
  19033. * @param jointPivot The pivot of the joint / bone in local space.
  19034. * @param distToJoint Optional distance from the impostor to the joint.
  19035. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19036. */
  19037. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  19038. /**
  19039. * Sync impostor to a bone
  19040. * @param bone The bone that the impostor will be synced to.
  19041. * @param boneMesh The mesh that the bone is influencing.
  19042. * @param jointPivot The pivot of the joint / bone in local space.
  19043. * @param distToJoint Optional distance from the impostor to the joint.
  19044. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  19045. * @param boneAxis Optional vector3 axis the bone is aligned with
  19046. */
  19047. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  19048. /**
  19049. * No-Imposter type
  19050. */
  19051. static NoImpostor: number;
  19052. /**
  19053. * Sphere-Imposter type
  19054. */
  19055. static SphereImpostor: number;
  19056. /**
  19057. * Box-Imposter type
  19058. */
  19059. static BoxImpostor: number;
  19060. /**
  19061. * Plane-Imposter type
  19062. */
  19063. static PlaneImpostor: number;
  19064. /**
  19065. * Mesh-imposter type
  19066. */
  19067. static MeshImpostor: number;
  19068. /**
  19069. * Cylinder-Imposter type
  19070. */
  19071. static CylinderImpostor: number;
  19072. /**
  19073. * Particle-Imposter type
  19074. */
  19075. static ParticleImpostor: number;
  19076. /**
  19077. * Heightmap-Imposter type
  19078. */
  19079. static HeightmapImpostor: number;
  19080. }
  19081. }
  19082. declare module BABYLON {
  19083. /**
  19084. * Class used to represent a specific level of detail of a mesh
  19085. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19086. */
  19087. export class MeshLODLevel {
  19088. /** Defines the distance where this level should star being displayed */
  19089. distance: number;
  19090. /** Defines the mesh to use to render this level */
  19091. mesh: Nullable<Mesh>;
  19092. /**
  19093. * Creates a new LOD level
  19094. * @param distance defines the distance where this level should star being displayed
  19095. * @param mesh defines the mesh to use to render this level
  19096. */
  19097. constructor(
  19098. /** Defines the distance where this level should star being displayed */
  19099. distance: number,
  19100. /** Defines the mesh to use to render this level */
  19101. mesh: Nullable<Mesh>);
  19102. }
  19103. /**
  19104. * @hidden
  19105. **/
  19106. export class _CreationDataStorage {
  19107. closePath?: boolean;
  19108. closeArray?: boolean;
  19109. idx: number[];
  19110. dashSize: number;
  19111. gapSize: number;
  19112. path3D: Path3D;
  19113. pathArray: Vector3[][];
  19114. arc: number;
  19115. radius: number;
  19116. cap: number;
  19117. tessellation: number;
  19118. }
  19119. /**
  19120. * @hidden
  19121. **/
  19122. class _InstanceDataStorage {
  19123. visibleInstances: any;
  19124. renderIdForInstances: number[];
  19125. batchCache: _InstancesBatch;
  19126. instancesBufferSize: number;
  19127. instancesBuffer: Nullable<Buffer>;
  19128. instancesData: Float32Array;
  19129. overridenInstanceCount: number;
  19130. }
  19131. /**
  19132. * @hidden
  19133. **/
  19134. export class _InstancesBatch {
  19135. mustReturn: boolean;
  19136. visibleInstances: Nullable<InstancedMesh[]>[];
  19137. renderSelf: boolean[];
  19138. }
  19139. /**
  19140. * Class used to represent renderable models
  19141. */
  19142. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  19143. /**
  19144. * Mesh side orientation : usually the external or front surface
  19145. */
  19146. static readonly FRONTSIDE: number;
  19147. /**
  19148. * Mesh side orientation : usually the internal or back surface
  19149. */
  19150. static readonly BACKSIDE: number;
  19151. /**
  19152. * Mesh side orientation : both internal and external or front and back surfaces
  19153. */
  19154. static readonly DOUBLESIDE: number;
  19155. /**
  19156. * Mesh side orientation : by default, `FRONTSIDE`
  19157. */
  19158. static readonly DEFAULTSIDE: number;
  19159. /**
  19160. * Mesh cap setting : no cap
  19161. */
  19162. static readonly NO_CAP: number;
  19163. /**
  19164. * Mesh cap setting : one cap at the beginning of the mesh
  19165. */
  19166. static readonly CAP_START: number;
  19167. /**
  19168. * Mesh cap setting : one cap at the end of the mesh
  19169. */
  19170. static readonly CAP_END: number;
  19171. /**
  19172. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  19173. */
  19174. static readonly CAP_ALL: number;
  19175. /**
  19176. * Gets the default side orientation.
  19177. * @param orientation the orientation to value to attempt to get
  19178. * @returns the default orientation
  19179. * @hidden
  19180. */
  19181. static _GetDefaultSideOrientation(orientation?: number): number;
  19182. private _onBeforeRenderObservable;
  19183. private _onBeforeBindObservable;
  19184. private _onAfterRenderObservable;
  19185. private _onBeforeDrawObservable;
  19186. /**
  19187. * An event triggered before rendering the mesh
  19188. */
  19189. readonly onBeforeRenderObservable: Observable<Mesh>;
  19190. /**
  19191. * An event triggered before binding the mesh
  19192. */
  19193. readonly onBeforeBindObservable: Observable<Mesh>;
  19194. /**
  19195. * An event triggered after rendering the mesh
  19196. */
  19197. readonly onAfterRenderObservable: Observable<Mesh>;
  19198. /**
  19199. * An event triggered before drawing the mesh
  19200. */
  19201. readonly onBeforeDrawObservable: Observable<Mesh>;
  19202. private _onBeforeDrawObserver;
  19203. /**
  19204. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  19205. */
  19206. onBeforeDraw: () => void;
  19207. /**
  19208. * Gets the delay loading state of the mesh (when delay loading is turned on)
  19209. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  19210. */
  19211. delayLoadState: number;
  19212. /**
  19213. * Gets the list of instances created from this mesh
  19214. * it is not supposed to be modified manually.
  19215. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  19216. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19217. */
  19218. instances: InstancedMesh[];
  19219. /**
  19220. * Gets the file containing delay loading data for this mesh
  19221. */
  19222. delayLoadingFile: string;
  19223. /** @hidden */
  19224. _binaryInfo: any;
  19225. private _LODLevels;
  19226. /**
  19227. * User defined function used to change how LOD level selection is done
  19228. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19229. */
  19230. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  19231. private _morphTargetManager;
  19232. /**
  19233. * Gets or sets the morph target manager
  19234. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19235. */
  19236. morphTargetManager: Nullable<MorphTargetManager>;
  19237. /** @hidden */
  19238. _creationDataStorage: Nullable<_CreationDataStorage>;
  19239. /** @hidden */
  19240. _geometry: Nullable<Geometry>;
  19241. /** @hidden */
  19242. _delayInfo: Array<string>;
  19243. /** @hidden */
  19244. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  19245. /** @hidden */
  19246. _instanceDataStorage: _InstanceDataStorage;
  19247. private _effectiveMaterial;
  19248. /** @hidden */
  19249. _shouldGenerateFlatShading: boolean;
  19250. private _preActivateId;
  19251. /** @hidden */
  19252. _originalBuilderSideOrientation: number;
  19253. /**
  19254. * Use this property to change the original side orientation defined at construction time
  19255. */
  19256. overrideMaterialSideOrientation: Nullable<number>;
  19257. private _areNormalsFrozen;
  19258. private _sourcePositions;
  19259. private _sourceNormals;
  19260. private _source;
  19261. private meshMap;
  19262. /**
  19263. * Gets the source mesh (the one used to clone this one from)
  19264. */
  19265. readonly source: Nullable<Mesh>;
  19266. /**
  19267. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19268. */
  19269. isUnIndexed: boolean;
  19270. /**
  19271. * @constructor
  19272. * @param name The value used by scene.getMeshByName() to do a lookup.
  19273. * @param scene The scene to add this mesh to.
  19274. * @param parent The parent of this mesh, if it has one
  19275. * @param source An optional Mesh from which geometry is shared, cloned.
  19276. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19277. * When false, achieved by calling a clone(), also passing False.
  19278. * This will make creation of children, recursive.
  19279. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19280. */
  19281. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19282. /**
  19283. * Gets the class name
  19284. * @returns the string "Mesh".
  19285. */
  19286. getClassName(): string;
  19287. /** @hidden */
  19288. readonly _isMesh: boolean;
  19289. /**
  19290. * Returns a description of this mesh
  19291. * @param fullDetails define if full details about this mesh must be used
  19292. * @returns a descriptive string representing this mesh
  19293. */
  19294. toString(fullDetails?: boolean): string;
  19295. /** @hidden */
  19296. _unBindEffect(): void;
  19297. /**
  19298. * Gets a boolean indicating if this mesh has LOD
  19299. */
  19300. readonly hasLODLevels: boolean;
  19301. /**
  19302. * Gets the list of MeshLODLevel associated with the current mesh
  19303. * @returns an array of MeshLODLevel
  19304. */
  19305. getLODLevels(): MeshLODLevel[];
  19306. private _sortLODLevels;
  19307. /**
  19308. * Add a mesh as LOD level triggered at the given distance.
  19309. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19310. * @param distance The distance from the center of the object to show this level
  19311. * @param mesh The mesh to be added as LOD level (can be null)
  19312. * @return This mesh (for chaining)
  19313. */
  19314. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19315. /**
  19316. * Returns the LOD level mesh at the passed distance or null if not found.
  19317. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19318. * @param distance The distance from the center of the object to show this level
  19319. * @returns a Mesh or `null`
  19320. */
  19321. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19322. /**
  19323. * Remove a mesh from the LOD array
  19324. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19325. * @param mesh defines the mesh to be removed
  19326. * @return This mesh (for chaining)
  19327. */
  19328. removeLODLevel(mesh: Mesh): Mesh;
  19329. /**
  19330. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19331. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19332. * @param camera defines the camera to use to compute distance
  19333. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19334. * @return This mesh (for chaining)
  19335. */
  19336. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19337. /**
  19338. * Gets the mesh internal Geometry object
  19339. */
  19340. readonly geometry: Nullable<Geometry>;
  19341. /**
  19342. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19343. * @returns the total number of vertices
  19344. */
  19345. getTotalVertices(): number;
  19346. /**
  19347. * Returns the content of an associated vertex buffer
  19348. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19349. * - VertexBuffer.PositionKind
  19350. * - VertexBuffer.UVKind
  19351. * - VertexBuffer.UV2Kind
  19352. * - VertexBuffer.UV3Kind
  19353. * - VertexBuffer.UV4Kind
  19354. * - VertexBuffer.UV5Kind
  19355. * - VertexBuffer.UV6Kind
  19356. * - VertexBuffer.ColorKind
  19357. * - VertexBuffer.MatricesIndicesKind
  19358. * - VertexBuffer.MatricesIndicesExtraKind
  19359. * - VertexBuffer.MatricesWeightsKind
  19360. * - VertexBuffer.MatricesWeightsExtraKind
  19361. * @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
  19362. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19363. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19364. */
  19365. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19366. /**
  19367. * Returns the mesh VertexBuffer object from the requested `kind`
  19368. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19369. * - VertexBuffer.PositionKind
  19370. * - VertexBuffer.UVKind
  19371. * - VertexBuffer.UV2Kind
  19372. * - VertexBuffer.UV3Kind
  19373. * - VertexBuffer.UV4Kind
  19374. * - VertexBuffer.UV5Kind
  19375. * - VertexBuffer.UV6Kind
  19376. * - VertexBuffer.ColorKind
  19377. * - VertexBuffer.MatricesIndicesKind
  19378. * - VertexBuffer.MatricesIndicesExtraKind
  19379. * - VertexBuffer.MatricesWeightsKind
  19380. * - VertexBuffer.MatricesWeightsExtraKind
  19381. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19382. */
  19383. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19384. /**
  19385. * Tests if a specific vertex buffer is associated with this mesh
  19386. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19387. * - VertexBuffer.PositionKind
  19388. * - VertexBuffer.UVKind
  19389. * - VertexBuffer.UV2Kind
  19390. * - VertexBuffer.UV3Kind
  19391. * - VertexBuffer.UV4Kind
  19392. * - VertexBuffer.UV5Kind
  19393. * - VertexBuffer.UV6Kind
  19394. * - VertexBuffer.ColorKind
  19395. * - VertexBuffer.MatricesIndicesKind
  19396. * - VertexBuffer.MatricesIndicesExtraKind
  19397. * - VertexBuffer.MatricesWeightsKind
  19398. * - VertexBuffer.MatricesWeightsExtraKind
  19399. * @returns a boolean
  19400. */
  19401. isVerticesDataPresent(kind: string): boolean;
  19402. /**
  19403. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19404. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19405. * - VertexBuffer.PositionKind
  19406. * - VertexBuffer.UVKind
  19407. * - VertexBuffer.UV2Kind
  19408. * - VertexBuffer.UV3Kind
  19409. * - VertexBuffer.UV4Kind
  19410. * - VertexBuffer.UV5Kind
  19411. * - VertexBuffer.UV6Kind
  19412. * - VertexBuffer.ColorKind
  19413. * - VertexBuffer.MatricesIndicesKind
  19414. * - VertexBuffer.MatricesIndicesExtraKind
  19415. * - VertexBuffer.MatricesWeightsKind
  19416. * - VertexBuffer.MatricesWeightsExtraKind
  19417. * @returns a boolean
  19418. */
  19419. isVertexBufferUpdatable(kind: string): boolean;
  19420. /**
  19421. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19422. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19423. * - VertexBuffer.PositionKind
  19424. * - VertexBuffer.UVKind
  19425. * - VertexBuffer.UV2Kind
  19426. * - VertexBuffer.UV3Kind
  19427. * - VertexBuffer.UV4Kind
  19428. * - VertexBuffer.UV5Kind
  19429. * - VertexBuffer.UV6Kind
  19430. * - VertexBuffer.ColorKind
  19431. * - VertexBuffer.MatricesIndicesKind
  19432. * - VertexBuffer.MatricesIndicesExtraKind
  19433. * - VertexBuffer.MatricesWeightsKind
  19434. * - VertexBuffer.MatricesWeightsExtraKind
  19435. * @returns an array of strings
  19436. */
  19437. getVerticesDataKinds(): string[];
  19438. /**
  19439. * Returns a positive integer : the total number of indices in this mesh geometry.
  19440. * @returns the numner of indices or zero if the mesh has no geometry.
  19441. */
  19442. getTotalIndices(): number;
  19443. /**
  19444. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19445. * @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.
  19446. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19447. * @returns the indices array or an empty array if the mesh has no geometry
  19448. */
  19449. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19450. readonly isBlocked: boolean;
  19451. /**
  19452. * Determine if the current mesh is ready to be rendered
  19453. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19454. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19455. * @returns true if all associated assets are ready (material, textures, shaders)
  19456. */
  19457. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19458. /**
  19459. * 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.
  19460. */
  19461. readonly areNormalsFrozen: boolean;
  19462. /**
  19463. * 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.
  19464. * @returns the current mesh
  19465. */
  19466. freezeNormals(): Mesh;
  19467. /**
  19468. * 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
  19469. * @returns the current mesh
  19470. */
  19471. unfreezeNormals(): Mesh;
  19472. /**
  19473. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19474. */
  19475. overridenInstanceCount: number;
  19476. /** @hidden */
  19477. _preActivate(): Mesh;
  19478. /** @hidden */
  19479. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19480. /** @hidden */
  19481. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19482. /**
  19483. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19484. * This means the mesh underlying bounding box and sphere are recomputed.
  19485. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19486. * @returns the current mesh
  19487. */
  19488. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19489. /** @hidden */
  19490. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19491. /**
  19492. * This function will subdivide the mesh into multiple submeshes
  19493. * @param count defines the expected number of submeshes
  19494. */
  19495. subdivide(count: number): void;
  19496. /**
  19497. * Copy a FloatArray into a specific associated vertex buffer
  19498. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19499. * - VertexBuffer.PositionKind
  19500. * - VertexBuffer.UVKind
  19501. * - VertexBuffer.UV2Kind
  19502. * - VertexBuffer.UV3Kind
  19503. * - VertexBuffer.UV4Kind
  19504. * - VertexBuffer.UV5Kind
  19505. * - VertexBuffer.UV6Kind
  19506. * - VertexBuffer.ColorKind
  19507. * - VertexBuffer.MatricesIndicesKind
  19508. * - VertexBuffer.MatricesIndicesExtraKind
  19509. * - VertexBuffer.MatricesWeightsKind
  19510. * - VertexBuffer.MatricesWeightsExtraKind
  19511. * @param data defines the data source
  19512. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19513. * @param stride defines the data stride size (can be null)
  19514. * @returns the current mesh
  19515. */
  19516. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19517. /**
  19518. * Flags an associated vertex buffer as updatable
  19519. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19520. * - VertexBuffer.PositionKind
  19521. * - VertexBuffer.UVKind
  19522. * - VertexBuffer.UV2Kind
  19523. * - VertexBuffer.UV3Kind
  19524. * - VertexBuffer.UV4Kind
  19525. * - VertexBuffer.UV5Kind
  19526. * - VertexBuffer.UV6Kind
  19527. * - VertexBuffer.ColorKind
  19528. * - VertexBuffer.MatricesIndicesKind
  19529. * - VertexBuffer.MatricesIndicesExtraKind
  19530. * - VertexBuffer.MatricesWeightsKind
  19531. * - VertexBuffer.MatricesWeightsExtraKind
  19532. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19533. */
  19534. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19535. /**
  19536. * Sets the mesh global Vertex Buffer
  19537. * @param buffer defines the buffer to use
  19538. * @returns the current mesh
  19539. */
  19540. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19541. /**
  19542. * Update a specific associated vertex buffer
  19543. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19544. * - VertexBuffer.PositionKind
  19545. * - VertexBuffer.UVKind
  19546. * - VertexBuffer.UV2Kind
  19547. * - VertexBuffer.UV3Kind
  19548. * - VertexBuffer.UV4Kind
  19549. * - VertexBuffer.UV5Kind
  19550. * - VertexBuffer.UV6Kind
  19551. * - VertexBuffer.ColorKind
  19552. * - VertexBuffer.MatricesIndicesKind
  19553. * - VertexBuffer.MatricesIndicesExtraKind
  19554. * - VertexBuffer.MatricesWeightsKind
  19555. * - VertexBuffer.MatricesWeightsExtraKind
  19556. * @param data defines the data source
  19557. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19558. * @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)
  19559. * @returns the current mesh
  19560. */
  19561. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19562. /**
  19563. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19564. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19565. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19566. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19567. * @returns the current mesh
  19568. */
  19569. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19570. /**
  19571. * Creates a un-shared specific occurence of the geometry for the mesh.
  19572. * @returns the current mesh
  19573. */
  19574. makeGeometryUnique(): Mesh;
  19575. /**
  19576. * Set the index buffer of this mesh
  19577. * @param indices defines the source data
  19578. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19579. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19580. * @returns the current mesh
  19581. */
  19582. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19583. /**
  19584. * Update the current index buffer
  19585. * @param indices defines the source data
  19586. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19587. * @returns the current mesh
  19588. */
  19589. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19590. /**
  19591. * Invert the geometry to move from a right handed system to a left handed one.
  19592. * @returns the current mesh
  19593. */
  19594. toLeftHanded(): Mesh;
  19595. /** @hidden */
  19596. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19597. /** @hidden */
  19598. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19599. /**
  19600. * Registers for this mesh a javascript function called just before the rendering process
  19601. * @param func defines the function to call before rendering this mesh
  19602. * @returns the current mesh
  19603. */
  19604. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19605. /**
  19606. * Disposes a previously registered javascript function called before the rendering
  19607. * @param func defines the function to remove
  19608. * @returns the current mesh
  19609. */
  19610. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19611. /**
  19612. * Registers for this mesh a javascript function called just after the rendering is complete
  19613. * @param func defines the function to call after rendering this mesh
  19614. * @returns the current mesh
  19615. */
  19616. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19617. /**
  19618. * Disposes a previously registered javascript function called after the rendering.
  19619. * @param func defines the function to remove
  19620. * @returns the current mesh
  19621. */
  19622. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19623. /** @hidden */
  19624. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19625. /** @hidden */
  19626. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  19627. /** @hidden */
  19628. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  19629. /**
  19630. * 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
  19631. * @param subMesh defines the subMesh to render
  19632. * @param enableAlphaMode defines if alpha mode can be changed
  19633. * @returns the current mesh
  19634. */
  19635. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  19636. private _onBeforeDraw;
  19637. /**
  19638. * Renormalize the mesh and patch it up if there are no weights
  19639. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  19640. * However in the case of zero weights then we set just a single influence to 1.
  19641. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  19642. */
  19643. cleanMatrixWeights(): void;
  19644. private normalizeSkinFourWeights;
  19645. private normalizeSkinWeightsAndExtra;
  19646. /**
  19647. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  19648. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  19649. * the user know there was an issue with importing the mesh
  19650. * @returns a validation object with skinned, valid and report string
  19651. */
  19652. validateSkinning(): {
  19653. skinned: boolean;
  19654. valid: boolean;
  19655. report: string;
  19656. };
  19657. /** @hidden */
  19658. _checkDelayState(): Mesh;
  19659. private _queueLoad;
  19660. /**
  19661. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19662. * A mesh is in the frustum if its bounding box intersects the frustum
  19663. * @param frustumPlanes defines the frustum to test
  19664. * @returns true if the mesh is in the frustum planes
  19665. */
  19666. isInFrustum(frustumPlanes: Plane[]): boolean;
  19667. /**
  19668. * Sets the mesh material by the material or multiMaterial `id` property
  19669. * @param id is a string identifying the material or the multiMaterial
  19670. * @returns the current mesh
  19671. */
  19672. setMaterialByID(id: string): Mesh;
  19673. /**
  19674. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  19675. * @returns an array of IAnimatable
  19676. */
  19677. getAnimatables(): IAnimatable[];
  19678. /**
  19679. * Modifies the mesh geometry according to the passed transformation matrix.
  19680. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  19681. * The mesh normals are modified using the same transformation.
  19682. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19683. * @param transform defines the transform matrix to use
  19684. * @see http://doc.babylonjs.com/resources/baking_transformations
  19685. * @returns the current mesh
  19686. */
  19687. bakeTransformIntoVertices(transform: Matrix): Mesh;
  19688. /**
  19689. * Modifies the mesh geometry according to its own current World Matrix.
  19690. * The mesh World Matrix is then reset.
  19691. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  19692. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19693. * @see http://doc.babylonjs.com/resources/baking_transformations
  19694. * @returns the current mesh
  19695. */
  19696. bakeCurrentTransformIntoVertices(): Mesh;
  19697. /** @hidden */
  19698. readonly _positions: Nullable<Vector3[]>;
  19699. /** @hidden */
  19700. _resetPointsArrayCache(): Mesh;
  19701. /** @hidden */
  19702. _generatePointsArray(): boolean;
  19703. /**
  19704. * Returns a new Mesh object generated from the current mesh properties.
  19705. * This method must not get confused with createInstance()
  19706. * @param name is a string, the name given to the new mesh
  19707. * @param newParent can be any Node object (default `null`)
  19708. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  19709. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  19710. * @returns a new mesh
  19711. */
  19712. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  19713. /**
  19714. * Releases resources associated with this mesh.
  19715. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19716. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19717. */
  19718. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19719. /**
  19720. * Modifies the mesh geometry according to a displacement map.
  19721. * 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.
  19722. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19723. * @param url is a string, the URL from the image file is to be downloaded.
  19724. * @param minHeight is the lower limit of the displacement.
  19725. * @param maxHeight is the upper limit of the displacement.
  19726. * @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.
  19727. * @param uvOffset is an optional vector2 used to offset UV.
  19728. * @param uvScale is an optional vector2 used to scale UV.
  19729. * @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.
  19730. * @returns the Mesh.
  19731. */
  19732. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19733. /**
  19734. * Modifies the mesh geometry according to a displacementMap buffer.
  19735. * 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.
  19736. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19737. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19738. * @param heightMapWidth is the width of the buffer image.
  19739. * @param heightMapHeight is the height of the buffer image.
  19740. * @param minHeight is the lower limit of the displacement.
  19741. * @param maxHeight is the upper limit of the displacement.
  19742. * @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.
  19743. * @param uvOffset is an optional vector2 used to offset UV.
  19744. * @param uvScale is an optional vector2 used to scale UV.
  19745. * @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.
  19746. * @returns the Mesh.
  19747. */
  19748. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19749. /**
  19750. * Modify the mesh to get a flat shading rendering.
  19751. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19752. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19753. * @returns current mesh
  19754. */
  19755. convertToFlatShadedMesh(): Mesh;
  19756. /**
  19757. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19758. * In other words, more vertices, no more indices and a single bigger VBO.
  19759. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19760. * @returns current mesh
  19761. */
  19762. convertToUnIndexedMesh(): Mesh;
  19763. /**
  19764. * Inverses facet orientations.
  19765. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19766. * @param flipNormals will also inverts the normals
  19767. * @returns current mesh
  19768. */
  19769. flipFaces(flipNormals?: boolean): Mesh;
  19770. /** @hidden */
  19771. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  19772. /** @hidden */
  19773. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  19774. /**
  19775. * Creates a new InstancedMesh object from the mesh model.
  19776. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19777. * @param name defines the name of the new instance
  19778. * @returns a new InstancedMesh
  19779. */
  19780. createInstance(name: string): InstancedMesh;
  19781. /**
  19782. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19783. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19784. * @returns the current mesh
  19785. */
  19786. synchronizeInstances(): Mesh;
  19787. /**
  19788. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19789. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19790. * This should be used together with the simplification to avoid disappearing triangles.
  19791. * @param successCallback an optional success callback to be called after the optimization finished.
  19792. * @returns the current mesh
  19793. */
  19794. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19795. /**
  19796. * Serialize current mesh
  19797. * @param serializationObject defines the object which will receive the serialization data
  19798. */
  19799. serialize(serializationObject: any): void;
  19800. /** @hidden */
  19801. _syncGeometryWithMorphTargetManager(): void;
  19802. /** @hidden */
  19803. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19804. /**
  19805. * Returns a new Mesh object parsed from the source provided.
  19806. * @param parsedMesh is the source
  19807. * @param scene defines the hosting scene
  19808. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19809. * @returns a new Mesh
  19810. */
  19811. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19812. /**
  19813. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19814. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19815. * @param name defines the name of the mesh to create
  19816. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19817. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19818. * @param closePath creates a seam between the first and the last points of each path of the path array
  19819. * @param offset is taken in account only if the `pathArray` is containing a single path
  19820. * @param scene defines the hosting scene
  19821. * @param updatable defines if the mesh must be flagged as updatable
  19822. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19823. * @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)
  19824. * @returns a new Mesh
  19825. */
  19826. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19827. /**
  19828. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19829. * @param name defines the name of the mesh to create
  19830. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19831. * @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
  19832. * @param scene defines the hosting scene
  19833. * @param updatable defines if the mesh must be flagged as updatable
  19834. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19835. * @returns a new Mesh
  19836. */
  19837. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19838. /**
  19839. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  19840. * @param name defines the name of the mesh to create
  19841. * @param size sets the size (float) of each box side (default 1)
  19842. * @param scene defines the hosting scene
  19843. * @param updatable defines if the mesh must be flagged as updatable
  19844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19845. * @returns a new Mesh
  19846. */
  19847. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19848. /**
  19849. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19850. * @param name defines the name of the mesh to create
  19851. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19852. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19853. * @param scene defines the hosting scene
  19854. * @param updatable defines if the mesh must be flagged as updatable
  19855. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19856. * @returns a new Mesh
  19857. */
  19858. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19859. /**
  19860. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19861. * @param name defines the name of the mesh to create
  19862. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19863. * @param diameterTop set the top cap diameter (floats, default 1)
  19864. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19865. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19866. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19867. * @param scene defines the hosting scene
  19868. * @param updatable defines if the mesh must be flagged as updatable
  19869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19870. * @returns a new Mesh
  19871. */
  19872. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19873. /**
  19874. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19875. * @param name defines the name of the mesh to create
  19876. * @param diameter sets the diameter size (float) of the torus (default 1)
  19877. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19878. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19879. * @param scene defines the hosting scene
  19880. * @param updatable defines if the mesh must be flagged as updatable
  19881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19882. * @returns a new Mesh
  19883. */
  19884. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19885. /**
  19886. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19887. * @param name defines the name of the mesh to create
  19888. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19889. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19890. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19891. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19892. * @param p the number of windings on X axis (positive integers, default 2)
  19893. * @param q the number of windings on Y axis (positive integers, default 3)
  19894. * @param scene defines the hosting scene
  19895. * @param updatable defines if the mesh must be flagged as updatable
  19896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19897. * @returns a new Mesh
  19898. */
  19899. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19900. /**
  19901. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19902. * @param name defines the name of the mesh to create
  19903. * @param points is an array successive Vector3
  19904. * @param scene defines the hosting scene
  19905. * @param updatable defines if the mesh must be flagged as updatable
  19906. * @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).
  19907. * @returns a new Mesh
  19908. */
  19909. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19910. /**
  19911. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19912. * @param name defines the name of the mesh to create
  19913. * @param points is an array successive Vector3
  19914. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19915. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19916. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19917. * @param scene defines the hosting scene
  19918. * @param updatable defines if the mesh must be flagged as updatable
  19919. * @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)
  19920. * @returns a new Mesh
  19921. */
  19922. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19923. /**
  19924. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19925. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19926. * 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.
  19927. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19928. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19929. * Remember you can only change the shape positions, not their number when updating a polygon.
  19930. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19931. * @param name defines the name of the mesh to create
  19932. * @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
  19933. * @param scene defines the hosting scene
  19934. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19935. * @param updatable defines if the mesh must be flagged as updatable
  19936. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19937. * @param earcutInjection can be used to inject your own earcut reference
  19938. * @returns a new Mesh
  19939. */
  19940. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19941. /**
  19942. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19943. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19944. * @param name defines the name of the mesh to create
  19945. * @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
  19946. * @param depth defines the height of extrusion
  19947. * @param scene defines the hosting scene
  19948. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19949. * @param updatable defines if the mesh must be flagged as updatable
  19950. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19951. * @param earcutInjection can be used to inject your own earcut reference
  19952. * @returns a new Mesh
  19953. */
  19954. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19955. /**
  19956. * Creates an extruded shape mesh.
  19957. * 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
  19958. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19959. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19960. * @param name defines the name of the mesh to create
  19961. * @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
  19962. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19963. * @param scale is the value to scale the shape
  19964. * @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
  19965. * @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
  19966. * @param scene defines the hosting scene
  19967. * @param updatable defines if the mesh must be flagged as updatable
  19968. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19969. * @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)
  19970. * @returns a new Mesh
  19971. */
  19972. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19973. /**
  19974. * Creates an custom extruded shape mesh.
  19975. * The custom extrusion is a parametric shape.
  19976. * It has no predefined shape. Its final shape will depend on the input parameters.
  19977. * Please consider using the same method from the MeshBuilder class instead
  19978. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19979. * @param name defines the name of the mesh to create
  19980. * @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
  19981. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19982. * @param scaleFunction is a custom Javascript function called on each path point
  19983. * @param rotationFunction is a custom Javascript function called on each path point
  19984. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19985. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19986. * @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
  19987. * @param scene defines the hosting scene
  19988. * @param updatable defines if the mesh must be flagged as updatable
  19989. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19990. * @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)
  19991. * @returns a new Mesh
  19992. */
  19993. 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;
  19994. /**
  19995. * Creates lathe mesh.
  19996. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19997. * Please consider using the same method from the MeshBuilder class instead
  19998. * @param name defines the name of the mesh to create
  19999. * @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
  20000. * @param radius is the radius value of the lathe
  20001. * @param tessellation is the side number of the lathe.
  20002. * @param scene defines the hosting scene
  20003. * @param updatable defines if the mesh must be flagged as updatable
  20004. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20005. * @returns a new Mesh
  20006. */
  20007. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20008. /**
  20009. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20010. * @param name defines the name of the mesh to create
  20011. * @param size sets the size (float) of both sides of the plane at once (default 1)
  20012. * @param scene defines the hosting scene
  20013. * @param updatable defines if the mesh must be flagged as updatable
  20014. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20015. * @returns a new Mesh
  20016. */
  20017. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20018. /**
  20019. * Creates a ground mesh.
  20020. * Please consider using the same method from the MeshBuilder class instead
  20021. * @param name defines the name of the mesh to create
  20022. * @param width set the width of the ground
  20023. * @param height set the height of the ground
  20024. * @param subdivisions sets the number of subdivisions per side
  20025. * @param scene defines the hosting scene
  20026. * @param updatable defines if the mesh must be flagged as updatable
  20027. * @returns a new Mesh
  20028. */
  20029. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  20030. /**
  20031. * Creates a tiled ground mesh.
  20032. * Please consider using the same method from the MeshBuilder class instead
  20033. * @param name defines the name of the mesh to create
  20034. * @param xmin set the ground minimum X coordinate
  20035. * @param zmin set the ground minimum Y coordinate
  20036. * @param xmax set the ground maximum X coordinate
  20037. * @param zmax set the ground maximum Z coordinate
  20038. * @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
  20039. * @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
  20040. * @param scene defines the hosting scene
  20041. * @param updatable defines if the mesh must be flagged as updatable
  20042. * @returns a new Mesh
  20043. */
  20044. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  20045. w: number;
  20046. h: number;
  20047. }, precision: {
  20048. w: number;
  20049. h: number;
  20050. }, scene: Scene, updatable?: boolean): Mesh;
  20051. /**
  20052. * Creates a ground mesh from a height map.
  20053. * Please consider using the same method from the MeshBuilder class instead
  20054. * @see http://doc.babylonjs.com/babylon101/height_map
  20055. * @param name defines the name of the mesh to create
  20056. * @param url sets the URL of the height map image resource
  20057. * @param width set the ground width size
  20058. * @param height set the ground height size
  20059. * @param subdivisions sets the number of subdivision per side
  20060. * @param minHeight is the minimum altitude on the ground
  20061. * @param maxHeight is the maximum altitude on the ground
  20062. * @param scene defines the hosting scene
  20063. * @param updatable defines if the mesh must be flagged as updatable
  20064. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  20065. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  20066. * @returns a new Mesh
  20067. */
  20068. 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;
  20069. /**
  20070. * Creates a tube mesh.
  20071. * The tube is a parametric shape.
  20072. * It has no predefined shape. Its final shape will depend on the input parameters.
  20073. * Please consider using the same method from the MeshBuilder class instead
  20074. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20075. * @param name defines the name of the mesh to create
  20076. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  20077. * @param radius sets the tube radius size
  20078. * @param tessellation is the number of sides on the tubular surface
  20079. * @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
  20080. * @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
  20081. * @param scene defines the hosting scene
  20082. * @param updatable defines if the mesh must be flagged as updatable
  20083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20084. * @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)
  20085. * @returns a new Mesh
  20086. */
  20087. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  20088. (i: number, distance: number): number;
  20089. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20090. /**
  20091. * Creates a polyhedron mesh.
  20092. * Please consider using the same method from the MeshBuilder class instead.
  20093. * * 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
  20094. * * The parameter `size` (positive float, default 1) sets the polygon size
  20095. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  20096. * * 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`
  20097. * * 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
  20098. * * 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)`)
  20099. * * 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
  20100. * * 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
  20101. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20102. * * 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
  20103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20104. * @param name defines the name of the mesh to create
  20105. * @param options defines the options used to create the mesh
  20106. * @param scene defines the hosting scene
  20107. * @returns a new Mesh
  20108. */
  20109. static CreatePolyhedron(name: string, options: {
  20110. type?: number;
  20111. size?: number;
  20112. sizeX?: number;
  20113. sizeY?: number;
  20114. sizeZ?: number;
  20115. custom?: any;
  20116. faceUV?: Vector4[];
  20117. faceColors?: Color4[];
  20118. updatable?: boolean;
  20119. sideOrientation?: number;
  20120. }, scene: Scene): Mesh;
  20121. /**
  20122. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  20123. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  20124. * * 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`)
  20125. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  20126. * * 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
  20127. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20128. * * 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
  20129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  20130. * @param name defines the name of the mesh
  20131. * @param options defines the options used to create the mesh
  20132. * @param scene defines the hosting scene
  20133. * @returns a new Mesh
  20134. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  20135. */
  20136. static CreateIcoSphere(name: string, options: {
  20137. radius?: number;
  20138. flat?: boolean;
  20139. subdivisions?: number;
  20140. sideOrientation?: number;
  20141. updatable?: boolean;
  20142. }, scene: Scene): Mesh;
  20143. /**
  20144. * Creates a decal mesh.
  20145. * Please consider using the same method from the MeshBuilder class instead.
  20146. * A decal is a mesh usually applied as a model onto the surface of another mesh
  20147. * @param name defines the name of the mesh
  20148. * @param sourceMesh defines the mesh receiving the decal
  20149. * @param position sets the position of the decal in world coordinates
  20150. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  20151. * @param size sets the decal scaling
  20152. * @param angle sets the angle to rotate the decal
  20153. * @returns a new Mesh
  20154. */
  20155. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  20156. /**
  20157. * Prepare internal position array for software CPU skinning
  20158. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  20159. */
  20160. setPositionsForCPUSkinning(): Float32Array;
  20161. /**
  20162. * Prepare internal normal array for software CPU skinning
  20163. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  20164. */
  20165. setNormalsForCPUSkinning(): Float32Array;
  20166. /**
  20167. * Updates the vertex buffer by applying transformation from the bones
  20168. * @param skeleton defines the skeleton to apply to current mesh
  20169. * @returns the current mesh
  20170. */
  20171. applySkeleton(skeleton: Skeleton): Mesh;
  20172. /**
  20173. * 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
  20174. * @param meshes defines the list of meshes to scan
  20175. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  20176. */
  20177. static MinMax(meshes: AbstractMesh[]): {
  20178. min: Vector3;
  20179. max: Vector3;
  20180. };
  20181. /**
  20182. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  20183. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  20184. * @returns a vector3
  20185. */
  20186. static Center(meshesOrMinMaxVector: {
  20187. min: Vector3;
  20188. max: Vector3;
  20189. } | AbstractMesh[]): Vector3;
  20190. /**
  20191. * Merge the array of meshes into a single mesh for performance reasons.
  20192. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  20193. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  20194. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  20195. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  20196. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  20197. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  20198. * @returns a new mesh
  20199. */
  20200. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  20201. /** @hidden */
  20202. addInstance(instance: InstancedMesh): void;
  20203. /** @hidden */
  20204. removeInstance(instance: InstancedMesh): void;
  20205. }
  20206. }
  20207. declare module BABYLON {
  20208. /**
  20209. * Base class for the main features of a material in Babylon.js
  20210. */
  20211. export class Material implements IAnimatable {
  20212. /**
  20213. * Returns the triangle fill mode
  20214. */
  20215. static readonly TriangleFillMode: number;
  20216. /**
  20217. * Returns the wireframe mode
  20218. */
  20219. static readonly WireFrameFillMode: number;
  20220. /**
  20221. * Returns the point fill mode
  20222. */
  20223. static readonly PointFillMode: number;
  20224. /**
  20225. * Returns the point list draw mode
  20226. */
  20227. static readonly PointListDrawMode: number;
  20228. /**
  20229. * Returns the line list draw mode
  20230. */
  20231. static readonly LineListDrawMode: number;
  20232. /**
  20233. * Returns the line loop draw mode
  20234. */
  20235. static readonly LineLoopDrawMode: number;
  20236. /**
  20237. * Returns the line strip draw mode
  20238. */
  20239. static readonly LineStripDrawMode: number;
  20240. /**
  20241. * Returns the triangle strip draw mode
  20242. */
  20243. static readonly TriangleStripDrawMode: number;
  20244. /**
  20245. * Returns the triangle fan draw mode
  20246. */
  20247. static readonly TriangleFanDrawMode: number;
  20248. /**
  20249. * Stores the clock-wise side orientation
  20250. */
  20251. static readonly ClockWiseSideOrientation: number;
  20252. /**
  20253. * Stores the counter clock-wise side orientation
  20254. */
  20255. static readonly CounterClockWiseSideOrientation: number;
  20256. /**
  20257. * The dirty texture flag value
  20258. */
  20259. static readonly TextureDirtyFlag: number;
  20260. /**
  20261. * The dirty light flag value
  20262. */
  20263. static readonly LightDirtyFlag: number;
  20264. /**
  20265. * The dirty fresnel flag value
  20266. */
  20267. static readonly FresnelDirtyFlag: number;
  20268. /**
  20269. * The dirty attribute flag value
  20270. */
  20271. static readonly AttributesDirtyFlag: number;
  20272. /**
  20273. * The dirty misc flag value
  20274. */
  20275. static readonly MiscDirtyFlag: number;
  20276. /**
  20277. * The all dirty flag value
  20278. */
  20279. static readonly AllDirtyFlag: number;
  20280. /**
  20281. * The ID of the material
  20282. */
  20283. id: string;
  20284. /**
  20285. * Gets or sets the unique id of the material
  20286. */
  20287. uniqueId: number;
  20288. /**
  20289. * The name of the material
  20290. */
  20291. name: string;
  20292. /**
  20293. * Gets or sets user defined metadata
  20294. */
  20295. metadata: any;
  20296. /**
  20297. * For internal use only. Please do not use.
  20298. */
  20299. reservedDataStore: any;
  20300. /**
  20301. * Specifies if the ready state should be checked on each call
  20302. */
  20303. checkReadyOnEveryCall: boolean;
  20304. /**
  20305. * Specifies if the ready state should be checked once
  20306. */
  20307. checkReadyOnlyOnce: boolean;
  20308. /**
  20309. * The state of the material
  20310. */
  20311. state: string;
  20312. /**
  20313. * The alpha value of the material
  20314. */
  20315. protected _alpha: number;
  20316. /**
  20317. * Sets the alpha value of the material
  20318. */
  20319. /**
  20320. * Gets the alpha value of the material
  20321. */
  20322. alpha: number;
  20323. /**
  20324. * Specifies if back face culling is enabled
  20325. */
  20326. protected _backFaceCulling: boolean;
  20327. /**
  20328. * Sets the back-face culling state
  20329. */
  20330. /**
  20331. * Gets the back-face culling state
  20332. */
  20333. backFaceCulling: boolean;
  20334. /**
  20335. * Stores the value for side orientation
  20336. */
  20337. sideOrientation: number;
  20338. /**
  20339. * Callback triggered when the material is compiled
  20340. */
  20341. onCompiled: (effect: Effect) => void;
  20342. /**
  20343. * Callback triggered when an error occurs
  20344. */
  20345. onError: (effect: Effect, errors: string) => void;
  20346. /**
  20347. * Callback triggered to get the render target textures
  20348. */
  20349. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  20350. /**
  20351. * Gets a boolean indicating that current material needs to register RTT
  20352. */
  20353. readonly hasRenderTargetTextures: boolean;
  20354. /**
  20355. * Specifies if the material should be serialized
  20356. */
  20357. doNotSerialize: boolean;
  20358. /**
  20359. * @hidden
  20360. */
  20361. _storeEffectOnSubMeshes: boolean;
  20362. /**
  20363. * Stores the animations for the material
  20364. */
  20365. animations: Array<Animation>;
  20366. /**
  20367. * An event triggered when the material is disposed
  20368. */
  20369. onDisposeObservable: Observable<Material>;
  20370. /**
  20371. * An observer which watches for dispose events
  20372. */
  20373. private _onDisposeObserver;
  20374. private _onUnBindObservable;
  20375. /**
  20376. * Called during a dispose event
  20377. */
  20378. onDispose: () => void;
  20379. private _onBindObservable;
  20380. /**
  20381. * An event triggered when the material is bound
  20382. */
  20383. readonly onBindObservable: Observable<AbstractMesh>;
  20384. /**
  20385. * An observer which watches for bind events
  20386. */
  20387. private _onBindObserver;
  20388. /**
  20389. * Called during a bind event
  20390. */
  20391. onBind: (Mesh: AbstractMesh) => void;
  20392. /**
  20393. * An event triggered when the material is unbound
  20394. */
  20395. readonly onUnBindObservable: Observable<Material>;
  20396. /**
  20397. * Stores the value of the alpha mode
  20398. */
  20399. private _alphaMode;
  20400. /**
  20401. * Sets the value of the alpha mode.
  20402. *
  20403. * | Value | Type | Description |
  20404. * | --- | --- | --- |
  20405. * | 0 | ALPHA_DISABLE | |
  20406. * | 1 | ALPHA_ADD | |
  20407. * | 2 | ALPHA_COMBINE | |
  20408. * | 3 | ALPHA_SUBTRACT | |
  20409. * | 4 | ALPHA_MULTIPLY | |
  20410. * | 5 | ALPHA_MAXIMIZED | |
  20411. * | 6 | ALPHA_ONEONE | |
  20412. * | 7 | ALPHA_PREMULTIPLIED | |
  20413. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20414. * | 9 | ALPHA_INTERPOLATE | |
  20415. * | 10 | ALPHA_SCREENMODE | |
  20416. *
  20417. */
  20418. /**
  20419. * Gets the value of the alpha mode
  20420. */
  20421. alphaMode: number;
  20422. /**
  20423. * Stores the state of the need depth pre-pass value
  20424. */
  20425. private _needDepthPrePass;
  20426. /**
  20427. * Sets the need depth pre-pass value
  20428. */
  20429. /**
  20430. * Gets the depth pre-pass value
  20431. */
  20432. needDepthPrePass: boolean;
  20433. /**
  20434. * Specifies if depth writing should be disabled
  20435. */
  20436. disableDepthWrite: boolean;
  20437. /**
  20438. * Specifies if depth writing should be forced
  20439. */
  20440. forceDepthWrite: boolean;
  20441. /**
  20442. * Specifies if there should be a separate pass for culling
  20443. */
  20444. separateCullingPass: boolean;
  20445. /**
  20446. * Stores the state specifing if fog should be enabled
  20447. */
  20448. private _fogEnabled;
  20449. /**
  20450. * Sets the state for enabling fog
  20451. */
  20452. /**
  20453. * Gets the value of the fog enabled state
  20454. */
  20455. fogEnabled: boolean;
  20456. /**
  20457. * Stores the size of points
  20458. */
  20459. pointSize: number;
  20460. /**
  20461. * Stores the z offset value
  20462. */
  20463. zOffset: number;
  20464. /**
  20465. * Gets a value specifying if wireframe mode is enabled
  20466. */
  20467. /**
  20468. * Sets the state of wireframe mode
  20469. */
  20470. wireframe: boolean;
  20471. /**
  20472. * Gets the value specifying if point clouds are enabled
  20473. */
  20474. /**
  20475. * Sets the state of point cloud mode
  20476. */
  20477. pointsCloud: boolean;
  20478. /**
  20479. * Gets the material fill mode
  20480. */
  20481. /**
  20482. * Sets the material fill mode
  20483. */
  20484. fillMode: number;
  20485. /**
  20486. * @hidden
  20487. * Stores the effects for the material
  20488. */
  20489. _effect: Nullable<Effect>;
  20490. /**
  20491. * @hidden
  20492. * Specifies if the material was previously ready
  20493. */
  20494. _wasPreviouslyReady: boolean;
  20495. /**
  20496. * Specifies if uniform buffers should be used
  20497. */
  20498. private _useUBO;
  20499. /**
  20500. * Stores a reference to the scene
  20501. */
  20502. private _scene;
  20503. /**
  20504. * Stores the fill mode state
  20505. */
  20506. private _fillMode;
  20507. /**
  20508. * Specifies if the depth write state should be cached
  20509. */
  20510. private _cachedDepthWriteState;
  20511. /**
  20512. * Stores the uniform buffer
  20513. */
  20514. protected _uniformBuffer: UniformBuffer;
  20515. /** @hidden */
  20516. _indexInSceneMaterialArray: number;
  20517. /** @hidden */
  20518. meshMap: Nullable<{
  20519. [id: string]: AbstractMesh | undefined;
  20520. }>;
  20521. /**
  20522. * Creates a material instance
  20523. * @param name defines the name of the material
  20524. * @param scene defines the scene to reference
  20525. * @param doNotAdd specifies if the material should be added to the scene
  20526. */
  20527. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20528. /**
  20529. * Returns a string representation of the current material
  20530. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20531. * @returns a string with material information
  20532. */
  20533. toString(fullDetails?: boolean): string;
  20534. /**
  20535. * Gets the class name of the material
  20536. * @returns a string with the class name of the material
  20537. */
  20538. getClassName(): string;
  20539. /**
  20540. * Specifies if updates for the material been locked
  20541. */
  20542. readonly isFrozen: boolean;
  20543. /**
  20544. * Locks updates for the material
  20545. */
  20546. freeze(): void;
  20547. /**
  20548. * Unlocks updates for the material
  20549. */
  20550. unfreeze(): void;
  20551. /**
  20552. * Specifies if the material is ready to be used
  20553. * @param mesh defines the mesh to check
  20554. * @param useInstances specifies if instances should be used
  20555. * @returns a boolean indicating if the material is ready to be used
  20556. */
  20557. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20558. /**
  20559. * Specifies that the submesh is ready to be used
  20560. * @param mesh defines the mesh to check
  20561. * @param subMesh defines which submesh to check
  20562. * @param useInstances specifies that instances should be used
  20563. * @returns a boolean indicating that the submesh is ready or not
  20564. */
  20565. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20566. /**
  20567. * Returns the material effect
  20568. * @returns the effect associated with the material
  20569. */
  20570. getEffect(): Nullable<Effect>;
  20571. /**
  20572. * Returns the current scene
  20573. * @returns a Scene
  20574. */
  20575. getScene(): Scene;
  20576. /**
  20577. * Specifies if the material will require alpha blending
  20578. * @returns a boolean specifying if alpha blending is needed
  20579. */
  20580. needAlphaBlending(): boolean;
  20581. /**
  20582. * Specifies if the mesh will require alpha blending
  20583. * @param mesh defines the mesh to check
  20584. * @returns a boolean specifying if alpha blending is needed for the mesh
  20585. */
  20586. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20587. /**
  20588. * Specifies if this material should be rendered in alpha test mode
  20589. * @returns a boolean specifying if an alpha test is needed.
  20590. */
  20591. needAlphaTesting(): boolean;
  20592. /**
  20593. * Gets the texture used for the alpha test
  20594. * @returns the texture to use for alpha testing
  20595. */
  20596. getAlphaTestTexture(): Nullable<BaseTexture>;
  20597. /**
  20598. * Marks the material to indicate that it needs to be re-calculated
  20599. */
  20600. markDirty(): void;
  20601. /** @hidden */
  20602. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20603. /**
  20604. * Binds the material to the mesh
  20605. * @param world defines the world transformation matrix
  20606. * @param mesh defines the mesh to bind the material to
  20607. */
  20608. bind(world: Matrix, mesh?: Mesh): void;
  20609. /**
  20610. * Binds the submesh to the material
  20611. * @param world defines the world transformation matrix
  20612. * @param mesh defines the mesh containing the submesh
  20613. * @param subMesh defines the submesh to bind the material to
  20614. */
  20615. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20616. /**
  20617. * Binds the world matrix to the material
  20618. * @param world defines the world transformation matrix
  20619. */
  20620. bindOnlyWorldMatrix(world: Matrix): void;
  20621. /**
  20622. * Binds the scene's uniform buffer to the effect.
  20623. * @param effect defines the effect to bind to the scene uniform buffer
  20624. * @param sceneUbo defines the uniform buffer storing scene data
  20625. */
  20626. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20627. /**
  20628. * Binds the view matrix to the effect
  20629. * @param effect defines the effect to bind the view matrix to
  20630. */
  20631. bindView(effect: Effect): void;
  20632. /**
  20633. * Binds the view projection matrix to the effect
  20634. * @param effect defines the effect to bind the view projection matrix to
  20635. */
  20636. bindViewProjection(effect: Effect): void;
  20637. /**
  20638. * Specifies if material alpha testing should be turned on for the mesh
  20639. * @param mesh defines the mesh to check
  20640. */
  20641. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20642. /**
  20643. * Processes to execute after binding the material to a mesh
  20644. * @param mesh defines the rendered mesh
  20645. */
  20646. protected _afterBind(mesh?: Mesh): void;
  20647. /**
  20648. * Unbinds the material from the mesh
  20649. */
  20650. unbind(): void;
  20651. /**
  20652. * Gets the active textures from the material
  20653. * @returns an array of textures
  20654. */
  20655. getActiveTextures(): BaseTexture[];
  20656. /**
  20657. * Specifies if the material uses a texture
  20658. * @param texture defines the texture to check against the material
  20659. * @returns a boolean specifying if the material uses the texture
  20660. */
  20661. hasTexture(texture: BaseTexture): boolean;
  20662. /**
  20663. * Makes a duplicate of the material, and gives it a new name
  20664. * @param name defines the new name for the duplicated material
  20665. * @returns the cloned material
  20666. */
  20667. clone(name: string): Nullable<Material>;
  20668. /**
  20669. * Gets the meshes bound to the material
  20670. * @returns an array of meshes bound to the material
  20671. */
  20672. getBindedMeshes(): AbstractMesh[];
  20673. /**
  20674. * Force shader compilation
  20675. * @param mesh defines the mesh associated with this material
  20676. * @param onCompiled defines a function to execute once the material is compiled
  20677. * @param options defines the options to configure the compilation
  20678. */
  20679. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20680. clipPlane: boolean;
  20681. }>): void;
  20682. /**
  20683. * Force shader compilation
  20684. * @param mesh defines the mesh that will use this material
  20685. * @param options defines additional options for compiling the shaders
  20686. * @returns a promise that resolves when the compilation completes
  20687. */
  20688. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20689. clipPlane: boolean;
  20690. }>): Promise<void>;
  20691. private static readonly _ImageProcessingDirtyCallBack;
  20692. private static readonly _TextureDirtyCallBack;
  20693. private static readonly _FresnelDirtyCallBack;
  20694. private static readonly _MiscDirtyCallBack;
  20695. private static readonly _LightsDirtyCallBack;
  20696. private static readonly _AttributeDirtyCallBack;
  20697. private static _FresnelAndMiscDirtyCallBack;
  20698. private static _TextureAndMiscDirtyCallBack;
  20699. private static readonly _DirtyCallbackArray;
  20700. private static readonly _RunDirtyCallBacks;
  20701. /**
  20702. * Marks a define in the material to indicate that it needs to be re-computed
  20703. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20704. */
  20705. markAsDirty(flag: number): void;
  20706. /**
  20707. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20708. * @param func defines a function which checks material defines against the submeshes
  20709. */
  20710. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20711. /**
  20712. * Indicates that image processing needs to be re-calculated for all submeshes
  20713. */
  20714. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20715. /**
  20716. * Indicates that textures need to be re-calculated for all submeshes
  20717. */
  20718. protected _markAllSubMeshesAsTexturesDirty(): void;
  20719. /**
  20720. * Indicates that fresnel needs to be re-calculated for all submeshes
  20721. */
  20722. protected _markAllSubMeshesAsFresnelDirty(): void;
  20723. /**
  20724. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20725. */
  20726. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20727. /**
  20728. * Indicates that lights need to be re-calculated for all submeshes
  20729. */
  20730. protected _markAllSubMeshesAsLightsDirty(): void;
  20731. /**
  20732. * Indicates that attributes need to be re-calculated for all submeshes
  20733. */
  20734. protected _markAllSubMeshesAsAttributesDirty(): void;
  20735. /**
  20736. * Indicates that misc needs to be re-calculated for all submeshes
  20737. */
  20738. protected _markAllSubMeshesAsMiscDirty(): void;
  20739. /**
  20740. * Indicates that textures and misc need to be re-calculated for all submeshes
  20741. */
  20742. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20743. /**
  20744. * Disposes the material
  20745. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20746. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20747. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20748. */
  20749. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20750. /** @hidden */
  20751. private releaseVertexArrayObject;
  20752. /**
  20753. * Serializes this material
  20754. * @returns the serialized material object
  20755. */
  20756. serialize(): any;
  20757. /**
  20758. * Creates a material from parsed material data
  20759. * @param parsedMaterial defines parsed material data
  20760. * @param scene defines the hosting scene
  20761. * @param rootUrl defines the root URL to use to load textures
  20762. * @returns a new material
  20763. */
  20764. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  20765. }
  20766. }
  20767. declare module BABYLON {
  20768. /**
  20769. * Base class for submeshes
  20770. */
  20771. export class BaseSubMesh {
  20772. /** @hidden */
  20773. _materialDefines: Nullable<MaterialDefines>;
  20774. /** @hidden */
  20775. _materialEffect: Nullable<Effect>;
  20776. /**
  20777. * Gets associated effect
  20778. */
  20779. readonly effect: Nullable<Effect>;
  20780. /**
  20781. * Sets associated effect (effect used to render this submesh)
  20782. * @param effect defines the effect to associate with
  20783. * @param defines defines the set of defines used to compile this effect
  20784. */
  20785. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20786. }
  20787. /**
  20788. * Defines a subdivision inside a mesh
  20789. */
  20790. export class SubMesh extends BaseSubMesh implements ICullable {
  20791. /** the material index to use */
  20792. materialIndex: number;
  20793. /** vertex index start */
  20794. verticesStart: number;
  20795. /** vertices count */
  20796. verticesCount: number;
  20797. /** index start */
  20798. indexStart: number;
  20799. /** indices count */
  20800. indexCount: number;
  20801. /** @hidden */
  20802. _linesIndexCount: number;
  20803. private _mesh;
  20804. private _renderingMesh;
  20805. private _boundingInfo;
  20806. private _linesIndexBuffer;
  20807. /** @hidden */
  20808. _lastColliderWorldVertices: Nullable<Vector3[]>;
  20809. /** @hidden */
  20810. _trianglePlanes: Plane[];
  20811. /** @hidden */
  20812. _lastColliderTransformMatrix: Matrix;
  20813. /** @hidden */
  20814. _renderId: number;
  20815. /** @hidden */
  20816. _alphaIndex: number;
  20817. /** @hidden */
  20818. _distanceToCamera: number;
  20819. /** @hidden */
  20820. _id: number;
  20821. private _currentMaterial;
  20822. /**
  20823. * Add a new submesh to a mesh
  20824. * @param materialIndex defines the material index to use
  20825. * @param verticesStart defines vertex index start
  20826. * @param verticesCount defines vertices count
  20827. * @param indexStart defines index start
  20828. * @param indexCount defines indices count
  20829. * @param mesh defines the parent mesh
  20830. * @param renderingMesh defines an optional rendering mesh
  20831. * @param createBoundingBox defines if bounding box should be created for this submesh
  20832. * @returns the new submesh
  20833. */
  20834. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20835. /**
  20836. * Creates a new submesh
  20837. * @param materialIndex defines the material index to use
  20838. * @param verticesStart defines vertex index start
  20839. * @param verticesCount defines vertices count
  20840. * @param indexStart defines index start
  20841. * @param indexCount defines indices count
  20842. * @param mesh defines the parent mesh
  20843. * @param renderingMesh defines an optional rendering mesh
  20844. * @param createBoundingBox defines if bounding box should be created for this submesh
  20845. */
  20846. constructor(
  20847. /** the material index to use */
  20848. materialIndex: number,
  20849. /** vertex index start */
  20850. verticesStart: number,
  20851. /** vertices count */
  20852. verticesCount: number,
  20853. /** index start */
  20854. indexStart: number,
  20855. /** indices count */
  20856. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20857. /**
  20858. * Returns true if this submesh covers the entire parent mesh
  20859. * @ignorenaming
  20860. */
  20861. readonly IsGlobal: boolean;
  20862. /**
  20863. * Returns the submesh BoudingInfo object
  20864. * @returns current bounding info (or mesh's one if the submesh is global)
  20865. */
  20866. getBoundingInfo(): BoundingInfo;
  20867. /**
  20868. * Sets the submesh BoundingInfo
  20869. * @param boundingInfo defines the new bounding info to use
  20870. * @returns the SubMesh
  20871. */
  20872. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20873. /**
  20874. * Returns the mesh of the current submesh
  20875. * @return the parent mesh
  20876. */
  20877. getMesh(): AbstractMesh;
  20878. /**
  20879. * Returns the rendering mesh of the submesh
  20880. * @returns the rendering mesh (could be different from parent mesh)
  20881. */
  20882. getRenderingMesh(): Mesh;
  20883. /**
  20884. * Returns the submesh material
  20885. * @returns null or the current material
  20886. */
  20887. getMaterial(): Nullable<Material>;
  20888. /**
  20889. * Sets a new updated BoundingInfo object to the submesh
  20890. * @returns the SubMesh
  20891. */
  20892. refreshBoundingInfo(): SubMesh;
  20893. /** @hidden */
  20894. _checkCollision(collider: Collider): boolean;
  20895. /**
  20896. * Updates the submesh BoundingInfo
  20897. * @param world defines the world matrix to use to update the bounding info
  20898. * @returns the submesh
  20899. */
  20900. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20901. /**
  20902. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20903. * @param frustumPlanes defines the frustum planes
  20904. * @returns true if the submesh is intersecting with the frustum
  20905. */
  20906. isInFrustum(frustumPlanes: Plane[]): boolean;
  20907. /**
  20908. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20909. * @param frustumPlanes defines the frustum planes
  20910. * @returns true if the submesh is inside the frustum
  20911. */
  20912. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20913. /**
  20914. * Renders the submesh
  20915. * @param enableAlphaMode defines if alpha needs to be used
  20916. * @returns the submesh
  20917. */
  20918. render(enableAlphaMode: boolean): SubMesh;
  20919. /**
  20920. * @hidden
  20921. */
  20922. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  20923. /**
  20924. * Checks if the submesh intersects with a ray
  20925. * @param ray defines the ray to test
  20926. * @returns true is the passed ray intersects the submesh bounding box
  20927. */
  20928. canIntersects(ray: Ray): boolean;
  20929. /**
  20930. * Intersects current submesh with a ray
  20931. * @param ray defines the ray to test
  20932. * @param positions defines mesh's positions array
  20933. * @param indices defines mesh's indices array
  20934. * @param fastCheck defines if only bounding info should be used
  20935. * @returns intersection info or null if no intersection
  20936. */
  20937. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  20938. /** @hidden */
  20939. private _intersectLines;
  20940. /** @hidden */
  20941. private _intersectTriangles;
  20942. /** @hidden */
  20943. _rebuild(): void;
  20944. /**
  20945. * Creates a new submesh from the passed mesh
  20946. * @param newMesh defines the new hosting mesh
  20947. * @param newRenderingMesh defines an optional rendering mesh
  20948. * @returns the new submesh
  20949. */
  20950. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20951. /**
  20952. * Release associated resources
  20953. */
  20954. dispose(): void;
  20955. /**
  20956. * Gets the class name
  20957. * @returns the string "SubMesh".
  20958. */
  20959. getClassName(): string;
  20960. /**
  20961. * Creates a new submesh from indices data
  20962. * @param materialIndex the index of the main mesh material
  20963. * @param startIndex the index where to start the copy in the mesh indices array
  20964. * @param indexCount the number of indices to copy then from the startIndex
  20965. * @param mesh the main mesh to create the submesh from
  20966. * @param renderingMesh the optional rendering mesh
  20967. * @returns a new submesh
  20968. */
  20969. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20970. }
  20971. }
  20972. declare module BABYLON {
  20973. /**
  20974. * Class used to store geometry data (vertex buffers + index buffer)
  20975. */
  20976. export class Geometry implements IGetSetVerticesData {
  20977. /**
  20978. * Gets or sets the ID of the geometry
  20979. */
  20980. id: string;
  20981. /**
  20982. * Gets or sets the unique ID of the geometry
  20983. */
  20984. uniqueId: number;
  20985. /**
  20986. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20987. */
  20988. delayLoadState: number;
  20989. /**
  20990. * Gets the file containing the data to load when running in delay load state
  20991. */
  20992. delayLoadingFile: Nullable<string>;
  20993. /**
  20994. * Callback called when the geometry is updated
  20995. */
  20996. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20997. private _scene;
  20998. private _engine;
  20999. private _meshes;
  21000. private _totalVertices;
  21001. /** @hidden */
  21002. _indices: IndicesArray;
  21003. /** @hidden */
  21004. _vertexBuffers: {
  21005. [key: string]: VertexBuffer;
  21006. };
  21007. private _isDisposed;
  21008. private _extend;
  21009. private _boundingBias;
  21010. /** @hidden */
  21011. _delayInfo: Array<string>;
  21012. private _indexBuffer;
  21013. private _indexBufferIsUpdatable;
  21014. /** @hidden */
  21015. _boundingInfo: Nullable<BoundingInfo>;
  21016. /** @hidden */
  21017. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21018. /** @hidden */
  21019. _softwareSkinningFrameId: number;
  21020. private _vertexArrayObjects;
  21021. private _updatable;
  21022. /** @hidden */
  21023. _positions: Nullable<Vector3[]>;
  21024. /**
  21025. * 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
  21026. */
  21027. /**
  21028. * 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
  21029. */
  21030. boundingBias: Vector2;
  21031. /**
  21032. * Static function used to attach a new empty geometry to a mesh
  21033. * @param mesh defines the mesh to attach the geometry to
  21034. * @returns the new Geometry
  21035. */
  21036. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21037. /**
  21038. * Creates a new geometry
  21039. * @param id defines the unique ID
  21040. * @param scene defines the hosting scene
  21041. * @param vertexData defines the VertexData used to get geometry data
  21042. * @param updatable defines if geometry must be updatable (false by default)
  21043. * @param mesh defines the mesh that will be associated with the geometry
  21044. */
  21045. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21046. /**
  21047. * Gets the current extend of the geometry
  21048. */
  21049. readonly extend: {
  21050. minimum: Vector3;
  21051. maximum: Vector3;
  21052. };
  21053. /**
  21054. * Gets the hosting scene
  21055. * @returns the hosting Scene
  21056. */
  21057. getScene(): Scene;
  21058. /**
  21059. * Gets the hosting engine
  21060. * @returns the hosting Engine
  21061. */
  21062. getEngine(): Engine;
  21063. /**
  21064. * Defines if the geometry is ready to use
  21065. * @returns true if the geometry is ready to be used
  21066. */
  21067. isReady(): boolean;
  21068. /**
  21069. * Gets a value indicating that the geometry should not be serialized
  21070. */
  21071. readonly doNotSerialize: boolean;
  21072. /** @hidden */
  21073. _rebuild(): void;
  21074. /**
  21075. * Affects all geometry data in one call
  21076. * @param vertexData defines the geometry data
  21077. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21078. */
  21079. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21080. /**
  21081. * Set specific vertex data
  21082. * @param kind defines the data kind (Position, normal, etc...)
  21083. * @param data defines the vertex data to use
  21084. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21085. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21086. */
  21087. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21088. /**
  21089. * Removes a specific vertex data
  21090. * @param kind defines the data kind (Position, normal, etc...)
  21091. */
  21092. removeVerticesData(kind: string): void;
  21093. /**
  21094. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21095. * @param buffer defines the vertex buffer to use
  21096. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21097. */
  21098. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21099. /**
  21100. * Update a specific vertex buffer
  21101. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21102. * It will do nothing if the buffer is not updatable
  21103. * @param kind defines the data kind (Position, normal, etc...)
  21104. * @param data defines the data to use
  21105. * @param offset defines the offset in the target buffer where to store the data
  21106. * @param useBytes set to true if the offset is in bytes
  21107. */
  21108. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21109. /**
  21110. * Update a specific vertex buffer
  21111. * This function will create a new buffer if the current one is not updatable
  21112. * @param kind defines the data kind (Position, normal, etc...)
  21113. * @param data defines the data to use
  21114. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21115. */
  21116. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21117. private _updateBoundingInfo;
  21118. /** @hidden */
  21119. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21120. /**
  21121. * Gets total number of vertices
  21122. * @returns the total number of vertices
  21123. */
  21124. getTotalVertices(): number;
  21125. /**
  21126. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21127. * @param kind defines the data kind (Position, normal, etc...)
  21128. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21129. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21130. * @returns a float array containing vertex data
  21131. */
  21132. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21133. /**
  21134. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21135. * @param kind defines the data kind (Position, normal, etc...)
  21136. * @returns true if the vertex buffer with the specified kind is updatable
  21137. */
  21138. isVertexBufferUpdatable(kind: string): boolean;
  21139. /**
  21140. * Gets a specific vertex buffer
  21141. * @param kind defines the data kind (Position, normal, etc...)
  21142. * @returns a VertexBuffer
  21143. */
  21144. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21145. /**
  21146. * Returns all vertex buffers
  21147. * @return an object holding all vertex buffers indexed by kind
  21148. */
  21149. getVertexBuffers(): Nullable<{
  21150. [key: string]: VertexBuffer;
  21151. }>;
  21152. /**
  21153. * Gets a boolean indicating if specific vertex buffer is present
  21154. * @param kind defines the data kind (Position, normal, etc...)
  21155. * @returns true if data is present
  21156. */
  21157. isVerticesDataPresent(kind: string): boolean;
  21158. /**
  21159. * Gets a list of all attached data kinds (Position, normal, etc...)
  21160. * @returns a list of string containing all kinds
  21161. */
  21162. getVerticesDataKinds(): string[];
  21163. /**
  21164. * Update index buffer
  21165. * @param indices defines the indices to store in the index buffer
  21166. * @param offset defines the offset in the target buffer where to store the data
  21167. */
  21168. updateIndices(indices: IndicesArray, offset?: number): void;
  21169. /**
  21170. * Creates a new index buffer
  21171. * @param indices defines the indices to store in the index buffer
  21172. * @param totalVertices defines the total number of vertices (could be null)
  21173. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21174. */
  21175. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21176. /**
  21177. * Return the total number of indices
  21178. * @returns the total number of indices
  21179. */
  21180. getTotalIndices(): number;
  21181. /**
  21182. * Gets the index buffer array
  21183. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21184. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21185. * @returns the index buffer array
  21186. */
  21187. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21188. /**
  21189. * Gets the index buffer
  21190. * @return the index buffer
  21191. */
  21192. getIndexBuffer(): Nullable<WebGLBuffer>;
  21193. /** @hidden */
  21194. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21195. /**
  21196. * Release the associated resources for a specific mesh
  21197. * @param mesh defines the source mesh
  21198. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21199. */
  21200. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21201. /**
  21202. * Apply current geometry to a given mesh
  21203. * @param mesh defines the mesh to apply geometry to
  21204. */
  21205. applyToMesh(mesh: Mesh): void;
  21206. private _updateExtend;
  21207. private _applyToMesh;
  21208. private notifyUpdate;
  21209. /**
  21210. * Load the geometry if it was flagged as delay loaded
  21211. * @param scene defines the hosting scene
  21212. * @param onLoaded defines a callback called when the geometry is loaded
  21213. */
  21214. load(scene: Scene, onLoaded?: () => void): void;
  21215. private _queueLoad;
  21216. /**
  21217. * Invert the geometry to move from a right handed system to a left handed one.
  21218. */
  21219. toLeftHanded(): void;
  21220. /** @hidden */
  21221. _resetPointsArrayCache(): void;
  21222. /** @hidden */
  21223. _generatePointsArray(): boolean;
  21224. /**
  21225. * Gets a value indicating if the geometry is disposed
  21226. * @returns true if the geometry was disposed
  21227. */
  21228. isDisposed(): boolean;
  21229. private _disposeVertexArrayObjects;
  21230. /**
  21231. * Free all associated resources
  21232. */
  21233. dispose(): void;
  21234. /**
  21235. * Clone the current geometry into a new geometry
  21236. * @param id defines the unique ID of the new geometry
  21237. * @returns a new geometry object
  21238. */
  21239. copy(id: string): Geometry;
  21240. /**
  21241. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21242. * @return a JSON representation of the current geometry data (without the vertices data)
  21243. */
  21244. serialize(): any;
  21245. private toNumberArray;
  21246. /**
  21247. * Serialize all vertices data into a JSON oject
  21248. * @returns a JSON representation of the current geometry data
  21249. */
  21250. serializeVerticeData(): any;
  21251. /**
  21252. * Extracts a clone of a mesh geometry
  21253. * @param mesh defines the source mesh
  21254. * @param id defines the unique ID of the new geometry object
  21255. * @returns the new geometry object
  21256. */
  21257. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21258. /**
  21259. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21260. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21261. * Be aware Math.random() could cause collisions, but:
  21262. * "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"
  21263. * @returns a string containing a new GUID
  21264. */
  21265. static RandomId(): string;
  21266. /** @hidden */
  21267. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21268. private static _CleanMatricesWeights;
  21269. /**
  21270. * Create a new geometry from persisted data (Using .babylon file format)
  21271. * @param parsedVertexData defines the persisted data
  21272. * @param scene defines the hosting scene
  21273. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21274. * @returns the new geometry object
  21275. */
  21276. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21277. }
  21278. }
  21279. declare module BABYLON {
  21280. /**
  21281. * Define an interface for all classes that will get and set the data on vertices
  21282. */
  21283. export interface IGetSetVerticesData {
  21284. /**
  21285. * Gets a boolean indicating if specific vertex data is present
  21286. * @param kind defines the vertex data kind to use
  21287. * @returns true is data kind is present
  21288. */
  21289. isVerticesDataPresent(kind: string): boolean;
  21290. /**
  21291. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21292. * @param kind defines the data kind (Position, normal, etc...)
  21293. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21294. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21295. * @returns a float array containing vertex data
  21296. */
  21297. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21298. /**
  21299. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21300. * @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.
  21301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21302. * @returns the indices array or an empty array if the mesh has no geometry
  21303. */
  21304. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21305. /**
  21306. * Set specific vertex data
  21307. * @param kind defines the data kind (Position, normal, etc...)
  21308. * @param data defines the vertex data to use
  21309. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21310. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21311. */
  21312. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21313. /**
  21314. * Update a specific associated vertex buffer
  21315. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21316. * - VertexBuffer.PositionKind
  21317. * - VertexBuffer.UVKind
  21318. * - VertexBuffer.UV2Kind
  21319. * - VertexBuffer.UV3Kind
  21320. * - VertexBuffer.UV4Kind
  21321. * - VertexBuffer.UV5Kind
  21322. * - VertexBuffer.UV6Kind
  21323. * - VertexBuffer.ColorKind
  21324. * - VertexBuffer.MatricesIndicesKind
  21325. * - VertexBuffer.MatricesIndicesExtraKind
  21326. * - VertexBuffer.MatricesWeightsKind
  21327. * - VertexBuffer.MatricesWeightsExtraKind
  21328. * @param data defines the data source
  21329. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21330. * @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)
  21331. */
  21332. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21333. /**
  21334. * Creates a new index buffer
  21335. * @param indices defines the indices to store in the index buffer
  21336. * @param totalVertices defines the total number of vertices (could be null)
  21337. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21338. */
  21339. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21340. }
  21341. /**
  21342. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21343. */
  21344. export class VertexData {
  21345. /**
  21346. * Mesh side orientation : usually the external or front surface
  21347. */
  21348. static readonly FRONTSIDE: number;
  21349. /**
  21350. * Mesh side orientation : usually the internal or back surface
  21351. */
  21352. static readonly BACKSIDE: number;
  21353. /**
  21354. * Mesh side orientation : both internal and external or front and back surfaces
  21355. */
  21356. static readonly DOUBLESIDE: number;
  21357. /**
  21358. * Mesh side orientation : by default, `FRONTSIDE`
  21359. */
  21360. static readonly DEFAULTSIDE: number;
  21361. /**
  21362. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21363. */
  21364. positions: Nullable<FloatArray>;
  21365. /**
  21366. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21367. */
  21368. normals: Nullable<FloatArray>;
  21369. /**
  21370. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21371. */
  21372. tangents: Nullable<FloatArray>;
  21373. /**
  21374. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21375. */
  21376. uvs: Nullable<FloatArray>;
  21377. /**
  21378. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21379. */
  21380. uvs2: Nullable<FloatArray>;
  21381. /**
  21382. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21383. */
  21384. uvs3: Nullable<FloatArray>;
  21385. /**
  21386. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21387. */
  21388. uvs4: Nullable<FloatArray>;
  21389. /**
  21390. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21391. */
  21392. uvs5: Nullable<FloatArray>;
  21393. /**
  21394. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21395. */
  21396. uvs6: Nullable<FloatArray>;
  21397. /**
  21398. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21399. */
  21400. colors: Nullable<FloatArray>;
  21401. /**
  21402. * 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).
  21403. */
  21404. matricesIndices: Nullable<FloatArray>;
  21405. /**
  21406. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21407. */
  21408. matricesWeights: Nullable<FloatArray>;
  21409. /**
  21410. * An array extending the number of possible indices
  21411. */
  21412. matricesIndicesExtra: Nullable<FloatArray>;
  21413. /**
  21414. * An array extending the number of possible weights when the number of indices is extended
  21415. */
  21416. matricesWeightsExtra: Nullable<FloatArray>;
  21417. /**
  21418. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21419. */
  21420. indices: Nullable<IndicesArray>;
  21421. /**
  21422. * Uses the passed data array to set the set the values for the specified kind of data
  21423. * @param data a linear array of floating numbers
  21424. * @param kind the type of data that is being set, eg positions, colors etc
  21425. */
  21426. set(data: FloatArray, kind: string): void;
  21427. /**
  21428. * Associates the vertexData to the passed Mesh.
  21429. * Sets it as updatable or not (default `false`)
  21430. * @param mesh the mesh the vertexData is applied to
  21431. * @param updatable when used and having the value true allows new data to update the vertexData
  21432. * @returns the VertexData
  21433. */
  21434. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21435. /**
  21436. * Associates the vertexData to the passed Geometry.
  21437. * Sets it as updatable or not (default `false`)
  21438. * @param geometry the geometry the vertexData is applied to
  21439. * @param updatable when used and having the value true allows new data to update the vertexData
  21440. * @returns VertexData
  21441. */
  21442. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21443. /**
  21444. * Updates the associated mesh
  21445. * @param mesh the mesh to be updated
  21446. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21447. * @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
  21448. * @returns VertexData
  21449. */
  21450. updateMesh(mesh: Mesh): VertexData;
  21451. /**
  21452. * Updates the associated geometry
  21453. * @param geometry the geometry to be updated
  21454. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21455. * @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
  21456. * @returns VertexData.
  21457. */
  21458. updateGeometry(geometry: Geometry): VertexData;
  21459. private _applyTo;
  21460. private _update;
  21461. /**
  21462. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21463. * @param matrix the transforming matrix
  21464. * @returns the VertexData
  21465. */
  21466. transform(matrix: Matrix): VertexData;
  21467. /**
  21468. * Merges the passed VertexData into the current one
  21469. * @param other the VertexData to be merged into the current one
  21470. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21471. * @returns the modified VertexData
  21472. */
  21473. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21474. private _mergeElement;
  21475. private _validate;
  21476. /**
  21477. * Serializes the VertexData
  21478. * @returns a serialized object
  21479. */
  21480. serialize(): any;
  21481. /**
  21482. * Extracts the vertexData from a mesh
  21483. * @param mesh the mesh from which to extract the VertexData
  21484. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21485. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21486. * @returns the object VertexData associated to the passed mesh
  21487. */
  21488. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21489. /**
  21490. * Extracts the vertexData from the geometry
  21491. * @param geometry the geometry from which to extract the VertexData
  21492. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21493. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21494. * @returns the object VertexData associated to the passed mesh
  21495. */
  21496. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21497. private static _ExtractFrom;
  21498. /**
  21499. * Creates the VertexData for a Ribbon
  21500. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21501. * * pathArray array of paths, each of which an array of successive Vector3
  21502. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21503. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21504. * * 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
  21505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21506. * * 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)
  21507. * * 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)
  21508. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21509. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21510. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21511. * @returns the VertexData of the ribbon
  21512. */
  21513. static CreateRibbon(options: {
  21514. pathArray: Vector3[][];
  21515. closeArray?: boolean;
  21516. closePath?: boolean;
  21517. offset?: number;
  21518. sideOrientation?: number;
  21519. frontUVs?: Vector4;
  21520. backUVs?: Vector4;
  21521. invertUV?: boolean;
  21522. uvs?: Vector2[];
  21523. colors?: Color4[];
  21524. }): VertexData;
  21525. /**
  21526. * Creates the VertexData for a box
  21527. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21528. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21529. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21530. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21531. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21532. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21533. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21535. * * 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)
  21536. * * 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)
  21537. * @returns the VertexData of the box
  21538. */
  21539. static CreateBox(options: {
  21540. size?: number;
  21541. width?: number;
  21542. height?: number;
  21543. depth?: number;
  21544. faceUV?: Vector4[];
  21545. faceColors?: Color4[];
  21546. sideOrientation?: number;
  21547. frontUVs?: Vector4;
  21548. backUVs?: Vector4;
  21549. }): VertexData;
  21550. /**
  21551. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21552. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21553. * * segments sets the number of horizontal strips optional, default 32
  21554. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21555. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21556. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21557. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21558. * * 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
  21559. * * 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
  21560. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21561. * * 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)
  21562. * * 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)
  21563. * @returns the VertexData of the ellipsoid
  21564. */
  21565. static CreateSphere(options: {
  21566. segments?: number;
  21567. diameter?: number;
  21568. diameterX?: number;
  21569. diameterY?: number;
  21570. diameterZ?: number;
  21571. arc?: number;
  21572. slice?: number;
  21573. sideOrientation?: number;
  21574. frontUVs?: Vector4;
  21575. backUVs?: Vector4;
  21576. }): VertexData;
  21577. /**
  21578. * Creates the VertexData for a cylinder, cone or prism
  21579. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21580. * * height sets the height (y direction) of the cylinder, optional, default 2
  21581. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21582. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21583. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21584. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21585. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21586. * * 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
  21587. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21588. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21589. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21590. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21592. * * 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)
  21593. * * 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)
  21594. * @returns the VertexData of the cylinder, cone or prism
  21595. */
  21596. static CreateCylinder(options: {
  21597. height?: number;
  21598. diameterTop?: number;
  21599. diameterBottom?: number;
  21600. diameter?: number;
  21601. tessellation?: number;
  21602. subdivisions?: number;
  21603. arc?: number;
  21604. faceColors?: Color4[];
  21605. faceUV?: Vector4[];
  21606. hasRings?: boolean;
  21607. enclose?: boolean;
  21608. sideOrientation?: number;
  21609. frontUVs?: Vector4;
  21610. backUVs?: Vector4;
  21611. }): VertexData;
  21612. /**
  21613. * Creates the VertexData for a torus
  21614. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21615. * * diameter the diameter of the torus, optional default 1
  21616. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21617. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21618. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21619. * * 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)
  21620. * * 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)
  21621. * @returns the VertexData of the torus
  21622. */
  21623. static CreateTorus(options: {
  21624. diameter?: number;
  21625. thickness?: number;
  21626. tessellation?: number;
  21627. sideOrientation?: number;
  21628. frontUVs?: Vector4;
  21629. backUVs?: Vector4;
  21630. }): VertexData;
  21631. /**
  21632. * Creates the VertexData of the LineSystem
  21633. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21634. * - lines an array of lines, each line being an array of successive Vector3
  21635. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21636. * @returns the VertexData of the LineSystem
  21637. */
  21638. static CreateLineSystem(options: {
  21639. lines: Vector3[][];
  21640. colors?: Nullable<Color4[][]>;
  21641. }): VertexData;
  21642. /**
  21643. * Create the VertexData for a DashedLines
  21644. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21645. * - points an array successive Vector3
  21646. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21647. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21648. * - dashNb the intended total number of dashes, optional, default 200
  21649. * @returns the VertexData for the DashedLines
  21650. */
  21651. static CreateDashedLines(options: {
  21652. points: Vector3[];
  21653. dashSize?: number;
  21654. gapSize?: number;
  21655. dashNb?: number;
  21656. }): VertexData;
  21657. /**
  21658. * Creates the VertexData for a Ground
  21659. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21660. * - width the width (x direction) of the ground, optional, default 1
  21661. * - height the height (z direction) of the ground, optional, default 1
  21662. * - subdivisions the number of subdivisions per side, optional, default 1
  21663. * @returns the VertexData of the Ground
  21664. */
  21665. static CreateGround(options: {
  21666. width?: number;
  21667. height?: number;
  21668. subdivisions?: number;
  21669. subdivisionsX?: number;
  21670. subdivisionsY?: number;
  21671. }): VertexData;
  21672. /**
  21673. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21674. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21675. * * xmin the ground minimum X coordinate, optional, default -1
  21676. * * zmin the ground minimum Z coordinate, optional, default -1
  21677. * * xmax the ground maximum X coordinate, optional, default 1
  21678. * * zmax the ground maximum Z coordinate, optional, default 1
  21679. * * 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}
  21680. * * 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}
  21681. * @returns the VertexData of the TiledGround
  21682. */
  21683. static CreateTiledGround(options: {
  21684. xmin: number;
  21685. zmin: number;
  21686. xmax: number;
  21687. zmax: number;
  21688. subdivisions?: {
  21689. w: number;
  21690. h: number;
  21691. };
  21692. precision?: {
  21693. w: number;
  21694. h: number;
  21695. };
  21696. }): VertexData;
  21697. /**
  21698. * Creates the VertexData of the Ground designed from a heightmap
  21699. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21700. * * width the width (x direction) of the ground
  21701. * * height the height (z direction) of the ground
  21702. * * subdivisions the number of subdivisions per side
  21703. * * minHeight the minimum altitude on the ground, optional, default 0
  21704. * * maxHeight the maximum altitude on the ground, optional default 1
  21705. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21706. * * buffer the array holding the image color data
  21707. * * bufferWidth the width of image
  21708. * * bufferHeight the height of image
  21709. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21710. * @returns the VertexData of the Ground designed from a heightmap
  21711. */
  21712. static CreateGroundFromHeightMap(options: {
  21713. width: number;
  21714. height: number;
  21715. subdivisions: number;
  21716. minHeight: number;
  21717. maxHeight: number;
  21718. colorFilter: Color3;
  21719. buffer: Uint8Array;
  21720. bufferWidth: number;
  21721. bufferHeight: number;
  21722. alphaFilter: number;
  21723. }): VertexData;
  21724. /**
  21725. * Creates the VertexData for a Plane
  21726. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21727. * * size sets the width and height of the plane to the value of size, optional default 1
  21728. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21729. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21731. * * 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)
  21732. * * 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)
  21733. * @returns the VertexData of the box
  21734. */
  21735. static CreatePlane(options: {
  21736. size?: number;
  21737. width?: number;
  21738. height?: number;
  21739. sideOrientation?: number;
  21740. frontUVs?: Vector4;
  21741. backUVs?: Vector4;
  21742. }): VertexData;
  21743. /**
  21744. * Creates the VertexData of the Disc or regular Polygon
  21745. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21746. * * radius the radius of the disc, optional default 0.5
  21747. * * tessellation the number of polygon sides, optional, default 64
  21748. * * 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
  21749. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21750. * * 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)
  21751. * * 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)
  21752. * @returns the VertexData of the box
  21753. */
  21754. static CreateDisc(options: {
  21755. radius?: number;
  21756. tessellation?: number;
  21757. arc?: number;
  21758. sideOrientation?: number;
  21759. frontUVs?: Vector4;
  21760. backUVs?: Vector4;
  21761. }): VertexData;
  21762. /**
  21763. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21764. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21765. * @param polygon a mesh built from polygonTriangulation.build()
  21766. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21767. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21768. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21769. * @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)
  21770. * @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)
  21771. * @returns the VertexData of the Polygon
  21772. */
  21773. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21774. /**
  21775. * Creates the VertexData of the IcoSphere
  21776. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21777. * * radius the radius of the IcoSphere, optional default 1
  21778. * * radiusX allows stretching in the x direction, optional, default radius
  21779. * * radiusY allows stretching in the y direction, optional, default radius
  21780. * * radiusZ allows stretching in the z direction, optional, default radius
  21781. * * flat when true creates a flat shaded mesh, optional, default true
  21782. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21783. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21784. * * 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)
  21785. * * 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)
  21786. * @returns the VertexData of the IcoSphere
  21787. */
  21788. static CreateIcoSphere(options: {
  21789. radius?: number;
  21790. radiusX?: number;
  21791. radiusY?: number;
  21792. radiusZ?: number;
  21793. flat?: boolean;
  21794. subdivisions?: number;
  21795. sideOrientation?: number;
  21796. frontUVs?: Vector4;
  21797. backUVs?: Vector4;
  21798. }): VertexData;
  21799. /**
  21800. * Creates the VertexData for a Polyhedron
  21801. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21802. * * type provided types are:
  21803. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21804. * * 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)
  21805. * * size the size of the IcoSphere, optional default 1
  21806. * * sizeX allows stretching in the x direction, optional, default size
  21807. * * sizeY allows stretching in the y direction, optional, default size
  21808. * * sizeZ allows stretching in the z direction, optional, default size
  21809. * * 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
  21810. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21811. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21812. * * flat when true creates a flat shaded mesh, optional, default true
  21813. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21814. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21815. * * 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)
  21816. * * 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)
  21817. * @returns the VertexData of the Polyhedron
  21818. */
  21819. static CreatePolyhedron(options: {
  21820. type?: number;
  21821. size?: number;
  21822. sizeX?: number;
  21823. sizeY?: number;
  21824. sizeZ?: number;
  21825. custom?: any;
  21826. faceUV?: Vector4[];
  21827. faceColors?: Color4[];
  21828. flat?: boolean;
  21829. sideOrientation?: number;
  21830. frontUVs?: Vector4;
  21831. backUVs?: Vector4;
  21832. }): VertexData;
  21833. /**
  21834. * Creates the VertexData for a TorusKnot
  21835. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21836. * * radius the radius of the torus knot, optional, default 2
  21837. * * tube the thickness of the tube, optional, default 0.5
  21838. * * radialSegments the number of sides on each tube segments, optional, default 32
  21839. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21840. * * p the number of windings around the z axis, optional, default 2
  21841. * * q the number of windings around the x axis, optional, default 3
  21842. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21843. * * 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)
  21844. * * 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)
  21845. * @returns the VertexData of the Torus Knot
  21846. */
  21847. static CreateTorusKnot(options: {
  21848. radius?: number;
  21849. tube?: number;
  21850. radialSegments?: number;
  21851. tubularSegments?: number;
  21852. p?: number;
  21853. q?: number;
  21854. sideOrientation?: number;
  21855. frontUVs?: Vector4;
  21856. backUVs?: Vector4;
  21857. }): VertexData;
  21858. /**
  21859. * Compute normals for given positions and indices
  21860. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21861. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21862. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21863. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21864. * * facetNormals : optional array of facet normals (vector3)
  21865. * * facetPositions : optional array of facet positions (vector3)
  21866. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21867. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21868. * * bInfo : optional bounding info, required for facetPartitioning computation
  21869. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21870. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21871. * * useRightHandedSystem: optional boolean to for right handed system computation
  21872. * * depthSort : optional boolean to enable the facet depth sort computation
  21873. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21874. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21875. */
  21876. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21877. facetNormals?: any;
  21878. facetPositions?: any;
  21879. facetPartitioning?: any;
  21880. ratio?: number;
  21881. bInfo?: any;
  21882. bbSize?: Vector3;
  21883. subDiv?: any;
  21884. useRightHandedSystem?: boolean;
  21885. depthSort?: boolean;
  21886. distanceTo?: Vector3;
  21887. depthSortedFacets?: any;
  21888. }): void;
  21889. /** @hidden */
  21890. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21891. /**
  21892. * Applies VertexData created from the imported parameters to the geometry
  21893. * @param parsedVertexData the parsed data from an imported file
  21894. * @param geometry the geometry to apply the VertexData to
  21895. */
  21896. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21897. }
  21898. }
  21899. declare module BABYLON {
  21900. /**
  21901. * Class containing static functions to help procedurally build meshes
  21902. */
  21903. export class DiscBuilder {
  21904. /**
  21905. * Creates a plane polygonal mesh. By default, this is a disc
  21906. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  21907. * * 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
  21908. * * 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
  21909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  21910. * * 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
  21911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21912. * @param name defines the name of the mesh
  21913. * @param options defines the options used to create the mesh
  21914. * @param scene defines the hosting scene
  21915. * @returns the plane polygonal mesh
  21916. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  21917. */
  21918. static CreateDisc(name: string, options: {
  21919. radius?: number;
  21920. tessellation?: number;
  21921. arc?: number;
  21922. updatable?: boolean;
  21923. sideOrientation?: number;
  21924. frontUVs?: Vector4;
  21925. backUVs?: Vector4;
  21926. }, scene?: Nullable<Scene>): Mesh;
  21927. }
  21928. }
  21929. declare module BABYLON {
  21930. /**
  21931. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  21932. *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.
  21933. * The SPS is also a particle system. It provides some methods to manage the particles.
  21934. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  21935. *
  21936. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  21937. */
  21938. export class SolidParticleSystem implements IDisposable {
  21939. /**
  21940. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  21941. * Example : var p = SPS.particles[i];
  21942. */
  21943. particles: SolidParticle[];
  21944. /**
  21945. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  21946. */
  21947. nbParticles: number;
  21948. /**
  21949. * If the particles must ever face the camera (default false). Useful for planar particles.
  21950. */
  21951. billboard: boolean;
  21952. /**
  21953. * Recompute normals when adding a shape
  21954. */
  21955. recomputeNormals: boolean;
  21956. /**
  21957. * This a counter ofr your own usage. It's not set by any SPS functions.
  21958. */
  21959. counter: number;
  21960. /**
  21961. * The SPS name. This name is also given to the underlying mesh.
  21962. */
  21963. name: string;
  21964. /**
  21965. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  21966. */
  21967. mesh: Mesh;
  21968. /**
  21969. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  21970. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  21971. */
  21972. vars: any;
  21973. /**
  21974. * This array is populated when the SPS is set as 'pickable'.
  21975. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  21976. * Each element of this array is an object `{idx: int, faceId: int}`.
  21977. * `idx` is the picked particle index in the `SPS.particles` array
  21978. * `faceId` is the picked face index counted within this particle.
  21979. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  21980. */
  21981. pickedParticles: {
  21982. idx: number;
  21983. faceId: number;
  21984. }[];
  21985. /**
  21986. * This array is populated when `enableDepthSort` is set to true.
  21987. * Each element of this array is an instance of the class DepthSortedParticle.
  21988. */
  21989. depthSortedParticles: DepthSortedParticle[];
  21990. /**
  21991. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  21992. * @hidden
  21993. */
  21994. _bSphereOnly: boolean;
  21995. /**
  21996. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  21997. * @hidden
  21998. */
  21999. _bSphereRadiusFactor: number;
  22000. private _scene;
  22001. private _positions;
  22002. private _indices;
  22003. private _normals;
  22004. private _colors;
  22005. private _uvs;
  22006. private _indices32;
  22007. private _positions32;
  22008. private _normals32;
  22009. private _fixedNormal32;
  22010. private _colors32;
  22011. private _uvs32;
  22012. private _index;
  22013. private _updatable;
  22014. private _pickable;
  22015. private _isVisibilityBoxLocked;
  22016. private _alwaysVisible;
  22017. private _depthSort;
  22018. private _shapeCounter;
  22019. private _copy;
  22020. private _color;
  22021. private _computeParticleColor;
  22022. private _computeParticleTexture;
  22023. private _computeParticleRotation;
  22024. private _computeParticleVertex;
  22025. private _computeBoundingBox;
  22026. private _depthSortParticles;
  22027. private _camera;
  22028. private _mustUnrotateFixedNormals;
  22029. private _particlesIntersect;
  22030. private _needs32Bits;
  22031. /**
  22032. * Creates a SPS (Solid Particle System) object.
  22033. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22034. * @param scene (Scene) is the scene in which the SPS is added.
  22035. * @param options defines the options of the sps e.g.
  22036. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22037. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22038. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22039. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22040. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22041. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22042. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22043. */
  22044. constructor(name: string, scene: Scene, options?: {
  22045. updatable?: boolean;
  22046. isPickable?: boolean;
  22047. enableDepthSort?: boolean;
  22048. particleIntersection?: boolean;
  22049. boundingSphereOnly?: boolean;
  22050. bSphereRadiusFactor?: number;
  22051. });
  22052. /**
  22053. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22054. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22055. * @returns the created mesh
  22056. */
  22057. buildMesh(): Mesh;
  22058. /**
  22059. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22060. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22061. * Thus the particles generated from `digest()` have their property `position` set yet.
  22062. * @param mesh ( Mesh ) is the mesh to be digested
  22063. * @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
  22064. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22065. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22066. * @returns the current SPS
  22067. */
  22068. digest(mesh: Mesh, options?: {
  22069. facetNb?: number;
  22070. number?: number;
  22071. delta?: number;
  22072. }): SolidParticleSystem;
  22073. private _unrotateFixedNormals;
  22074. private _resetCopy;
  22075. private _meshBuilder;
  22076. private _posToShape;
  22077. private _uvsToShapeUV;
  22078. private _addParticle;
  22079. /**
  22080. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22081. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22082. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22083. * @param nb (positive integer) the number of particles to be created from this model
  22084. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22085. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22086. * @returns the number of shapes in the system
  22087. */
  22088. addShape(mesh: Mesh, nb: number, options?: {
  22089. positionFunction?: any;
  22090. vertexFunction?: any;
  22091. }): number;
  22092. private _rebuildParticle;
  22093. /**
  22094. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22095. * @returns the SPS.
  22096. */
  22097. rebuildMesh(): SolidParticleSystem;
  22098. /**
  22099. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22100. * This method calls `updateParticle()` for each particle of the SPS.
  22101. * For an animated SPS, it is usually called within the render loop.
  22102. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22103. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22104. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22105. * @returns the SPS.
  22106. */
  22107. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22108. /**
  22109. * Disposes the SPS.
  22110. */
  22111. dispose(): void;
  22112. /**
  22113. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22114. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22115. * @returns the SPS.
  22116. */
  22117. refreshVisibleSize(): SolidParticleSystem;
  22118. /**
  22119. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22120. * @param size the size (float) of the visibility box
  22121. * note : this doesn't lock the SPS mesh bounding box.
  22122. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22123. */
  22124. setVisibilityBox(size: number): void;
  22125. /**
  22126. * Gets whether the SPS as always visible or not
  22127. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22128. */
  22129. /**
  22130. * Sets the SPS as always visible or not
  22131. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22132. */
  22133. isAlwaysVisible: boolean;
  22134. /**
  22135. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22136. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22137. */
  22138. /**
  22139. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22140. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22141. */
  22142. isVisibilityBoxLocked: boolean;
  22143. /**
  22144. * Tells to `setParticles()` to compute the particle rotations or not.
  22145. * Default value : true. The SPS is faster when it's set to false.
  22146. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22147. */
  22148. /**
  22149. * Gets if `setParticles()` computes the particle rotations or not.
  22150. * Default value : true. The SPS is faster when it's set to false.
  22151. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22152. */
  22153. computeParticleRotation: boolean;
  22154. /**
  22155. * Tells to `setParticles()` to compute the particle colors or not.
  22156. * Default value : true. The SPS is faster when it's set to false.
  22157. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22158. */
  22159. /**
  22160. * Gets if `setParticles()` computes the particle colors or not.
  22161. * Default value : true. The SPS is faster when it's set to false.
  22162. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22163. */
  22164. computeParticleColor: boolean;
  22165. /**
  22166. * Gets if `setParticles()` computes the particle textures or not.
  22167. * Default value : true. The SPS is faster when it's set to false.
  22168. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22169. */
  22170. computeParticleTexture: boolean;
  22171. /**
  22172. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22173. * Default value : false. The SPS is faster when it's set to false.
  22174. * Note : the particle custom vertex positions aren't stored values.
  22175. */
  22176. /**
  22177. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22178. * Default value : false. The SPS is faster when it's set to false.
  22179. * Note : the particle custom vertex positions aren't stored values.
  22180. */
  22181. computeParticleVertex: boolean;
  22182. /**
  22183. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22184. */
  22185. /**
  22186. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22187. */
  22188. computeBoundingBox: boolean;
  22189. /**
  22190. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22191. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22192. * Default : `true`
  22193. */
  22194. /**
  22195. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22196. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22197. * Default : `true`
  22198. */
  22199. depthSortParticles: boolean;
  22200. /**
  22201. * This function does nothing. It may be overwritten to set all the particle first values.
  22202. * The SPS doesn't call this function, you may have to call it by your own.
  22203. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22204. */
  22205. initParticles(): void;
  22206. /**
  22207. * This function does nothing. It may be overwritten to recycle a particle.
  22208. * The SPS doesn't call this function, you may have to call it by your own.
  22209. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22210. * @param particle The particle to recycle
  22211. * @returns the recycled particle
  22212. */
  22213. recycleParticle(particle: SolidParticle): SolidParticle;
  22214. /**
  22215. * Updates a particle : this function should be overwritten by the user.
  22216. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22217. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22218. * @example : just set a particle position or velocity and recycle conditions
  22219. * @param particle The particle to update
  22220. * @returns the updated particle
  22221. */
  22222. updateParticle(particle: SolidParticle): SolidParticle;
  22223. /**
  22224. * Updates a vertex of a particle : it can be overwritten by the user.
  22225. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22226. * @param particle the current particle
  22227. * @param vertex the current index of the current particle
  22228. * @param pt the index of the current vertex in the particle shape
  22229. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22230. * @example : just set a vertex particle position
  22231. * @returns the updated vertex
  22232. */
  22233. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22234. /**
  22235. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22236. * This does nothing and may be overwritten by the user.
  22237. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22238. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22239. * @param update the boolean update value actually passed to setParticles()
  22240. */
  22241. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22242. /**
  22243. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22244. * This will be passed three parameters.
  22245. * This does nothing and may be overwritten by the user.
  22246. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22247. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22248. * @param update the boolean update value actually passed to setParticles()
  22249. */
  22250. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22251. }
  22252. }
  22253. declare module BABYLON {
  22254. /**
  22255. * Represents one particle of a solid particle system.
  22256. */
  22257. export class SolidParticle {
  22258. /**
  22259. * particle global index
  22260. */
  22261. idx: number;
  22262. /**
  22263. * The color of the particle
  22264. */
  22265. color: Nullable<Color4>;
  22266. /**
  22267. * The world space position of the particle.
  22268. */
  22269. position: Vector3;
  22270. /**
  22271. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22272. */
  22273. rotation: Vector3;
  22274. /**
  22275. * The world space rotation quaternion of the particle.
  22276. */
  22277. rotationQuaternion: Nullable<Quaternion>;
  22278. /**
  22279. * The scaling of the particle.
  22280. */
  22281. scaling: Vector3;
  22282. /**
  22283. * The uvs of the particle.
  22284. */
  22285. uvs: Vector4;
  22286. /**
  22287. * The current speed of the particle.
  22288. */
  22289. velocity: Vector3;
  22290. /**
  22291. * The pivot point in the particle local space.
  22292. */
  22293. pivot: Vector3;
  22294. /**
  22295. * Must the particle be translated from its pivot point in its local space ?
  22296. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22297. * Default : false
  22298. */
  22299. translateFromPivot: boolean;
  22300. /**
  22301. * Is the particle active or not ?
  22302. */
  22303. alive: boolean;
  22304. /**
  22305. * Is the particle visible or not ?
  22306. */
  22307. isVisible: boolean;
  22308. /**
  22309. * Index of this particle in the global "positions" array (Internal use)
  22310. * @hidden
  22311. */
  22312. _pos: number;
  22313. /**
  22314. * @hidden Index of this particle in the global "indices" array (Internal use)
  22315. */
  22316. _ind: number;
  22317. /**
  22318. * @hidden ModelShape of this particle (Internal use)
  22319. */
  22320. _model: ModelShape;
  22321. /**
  22322. * ModelShape id of this particle
  22323. */
  22324. shapeId: number;
  22325. /**
  22326. * Index of the particle in its shape id (Internal use)
  22327. */
  22328. idxInShape: number;
  22329. /**
  22330. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22331. */
  22332. _modelBoundingInfo: BoundingInfo;
  22333. /**
  22334. * @hidden Particle BoundingInfo object (Internal use)
  22335. */
  22336. _boundingInfo: BoundingInfo;
  22337. /**
  22338. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22339. */
  22340. _sps: SolidParticleSystem;
  22341. /**
  22342. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22343. */
  22344. _stillInvisible: boolean;
  22345. /**
  22346. * @hidden Last computed particle rotation matrix
  22347. */
  22348. _rotationMatrix: number[];
  22349. /**
  22350. * Parent particle Id, if any.
  22351. * Default null.
  22352. */
  22353. parentId: Nullable<number>;
  22354. /**
  22355. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22356. * The possible values are :
  22357. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22358. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22359. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22360. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22361. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22362. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22363. * */
  22364. cullingStrategy: number;
  22365. /**
  22366. * @hidden Internal global position in the SPS.
  22367. */
  22368. _globalPosition: Vector3;
  22369. /**
  22370. * Creates a Solid Particle object.
  22371. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22372. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22373. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22374. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22375. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22376. * @param shapeId (integer) is the model shape identifier in the SPS.
  22377. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22378. * @param sps defines the sps it is associated to
  22379. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22380. */
  22381. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22382. /**
  22383. * Legacy support, changed scale to scaling
  22384. */
  22385. /**
  22386. * Legacy support, changed scale to scaling
  22387. */
  22388. scale: Vector3;
  22389. /**
  22390. * Legacy support, changed quaternion to rotationQuaternion
  22391. */
  22392. /**
  22393. * Legacy support, changed quaternion to rotationQuaternion
  22394. */
  22395. quaternion: Nullable<Quaternion>;
  22396. /**
  22397. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22398. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22399. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22400. * @returns true if it intersects
  22401. */
  22402. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22403. /**
  22404. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22405. * A particle is in the frustum if its bounding box intersects the frustum
  22406. * @param frustumPlanes defines the frustum to test
  22407. * @returns true if the particle is in the frustum planes
  22408. */
  22409. isInFrustum(frustumPlanes: Plane[]): boolean;
  22410. /**
  22411. * get the rotation matrix of the particle
  22412. * @hidden
  22413. */
  22414. getRotationMatrix(m: Matrix): void;
  22415. }
  22416. /**
  22417. * Represents the shape of the model used by one particle of a solid particle system.
  22418. * SPS internal tool, don't use it manually.
  22419. */
  22420. export class ModelShape {
  22421. /**
  22422. * The shape id
  22423. * @hidden
  22424. */
  22425. shapeID: number;
  22426. /**
  22427. * flat array of model positions (internal use)
  22428. * @hidden
  22429. */
  22430. _shape: Vector3[];
  22431. /**
  22432. * flat array of model UVs (internal use)
  22433. * @hidden
  22434. */
  22435. _shapeUV: number[];
  22436. /**
  22437. * length of the shape in the model indices array (internal use)
  22438. * @hidden
  22439. */
  22440. _indicesLength: number;
  22441. /**
  22442. * Custom position function (internal use)
  22443. * @hidden
  22444. */
  22445. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22446. /**
  22447. * Custom vertex function (internal use)
  22448. * @hidden
  22449. */
  22450. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22451. /**
  22452. * 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.
  22453. * SPS internal tool, don't use it manually.
  22454. * @hidden
  22455. */
  22456. 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>);
  22457. }
  22458. /**
  22459. * Represents a Depth Sorted Particle in the solid particle system.
  22460. */
  22461. export class DepthSortedParticle {
  22462. /**
  22463. * Index of the particle in the "indices" array
  22464. */
  22465. ind: number;
  22466. /**
  22467. * Length of the particle shape in the "indices" array
  22468. */
  22469. indicesLength: number;
  22470. /**
  22471. * Squared distance from the particle to the camera
  22472. */
  22473. sqDistance: number;
  22474. }
  22475. }
  22476. declare module BABYLON {
  22477. /**
  22478. * Class used to store all common mesh properties
  22479. */
  22480. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  22481. /** No occlusion */
  22482. static OCCLUSION_TYPE_NONE: number;
  22483. /** Occlusion set to optimisitic */
  22484. static OCCLUSION_TYPE_OPTIMISTIC: number;
  22485. /** Occlusion set to strict */
  22486. static OCCLUSION_TYPE_STRICT: number;
  22487. /** Use an accurante occlusion algorithm */
  22488. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  22489. /** Use a conservative occlusion algorithm */
  22490. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  22491. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  22492. * Test order :
  22493. * Is the bounding sphere outside the frustum ?
  22494. * If not, are the bounding box vertices outside the frustum ?
  22495. * It not, then the cullable object is in the frustum.
  22496. */
  22497. static readonly CULLINGSTRATEGY_STANDARD: number;
  22498. /** Culling strategy : Bounding Sphere Only.
  22499. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  22500. * It's also less accurate than the standard because some not visible objects can still be selected.
  22501. * Test : is the bounding sphere outside the frustum ?
  22502. * If not, then the cullable object is in the frustum.
  22503. */
  22504. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  22505. /** Culling strategy : Optimistic Inclusion.
  22506. * This in an inclusion test first, then the standard exclusion test.
  22507. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  22508. * 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.
  22509. * Anyway, it's as accurate as the standard strategy.
  22510. * Test :
  22511. * Is the cullable object bounding sphere center in the frustum ?
  22512. * If not, apply the default culling strategy.
  22513. */
  22514. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  22515. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  22516. * This in an inclusion test first, then the bounding sphere only exclusion test.
  22517. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  22518. * 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.
  22519. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  22520. * Test :
  22521. * Is the cullable object bounding sphere center in the frustum ?
  22522. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  22523. */
  22524. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  22525. /**
  22526. * No billboard
  22527. */
  22528. static readonly BILLBOARDMODE_NONE: number;
  22529. /** Billboard on X axis */
  22530. static readonly BILLBOARDMODE_X: number;
  22531. /** Billboard on Y axis */
  22532. static readonly BILLBOARDMODE_Y: number;
  22533. /** Billboard on Z axis */
  22534. static readonly BILLBOARDMODE_Z: number;
  22535. /** Billboard on all axes */
  22536. static readonly BILLBOARDMODE_ALL: number;
  22537. private _facetData;
  22538. /**
  22539. * The culling strategy to use to check whether the mesh must be rendered or not.
  22540. * This value can be changed at any time and will be used on the next render mesh selection.
  22541. * The possible values are :
  22542. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22543. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22544. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22545. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22546. * Please read each static variable documentation to get details about the culling process.
  22547. * */
  22548. cullingStrategy: number;
  22549. /**
  22550. * Gets the number of facets in the mesh
  22551. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22552. */
  22553. readonly facetNb: number;
  22554. /**
  22555. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  22556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22557. */
  22558. partitioningSubdivisions: number;
  22559. /**
  22560. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  22561. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  22562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  22563. */
  22564. partitioningBBoxRatio: number;
  22565. /**
  22566. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  22567. * Works only for updatable meshes.
  22568. * Doesn't work with multi-materials
  22569. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22570. */
  22571. mustDepthSortFacets: boolean;
  22572. /**
  22573. * The location (Vector3) where the facet depth sort must be computed from.
  22574. * By default, the active camera position.
  22575. * Used only when facet depth sort is enabled
  22576. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  22577. */
  22578. facetDepthSortFrom: Vector3;
  22579. /**
  22580. * gets a boolean indicating if facetData is enabled
  22581. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  22582. */
  22583. readonly isFacetDataEnabled: boolean;
  22584. /** @hidden */
  22585. _updateNonUniformScalingState(value: boolean): boolean;
  22586. /**
  22587. * An event triggered when this mesh collides with another one
  22588. */
  22589. onCollideObservable: Observable<AbstractMesh>;
  22590. private _onCollideObserver;
  22591. /** Set a function to call when this mesh collides with another one */
  22592. onCollide: () => void;
  22593. /**
  22594. * An event triggered when the collision's position changes
  22595. */
  22596. onCollisionPositionChangeObservable: Observable<Vector3>;
  22597. private _onCollisionPositionChangeObserver;
  22598. /** Set a function to call when the collision's position changes */
  22599. onCollisionPositionChange: () => void;
  22600. /**
  22601. * An event triggered when material is changed
  22602. */
  22603. onMaterialChangedObservable: Observable<AbstractMesh>;
  22604. /**
  22605. * Gets or sets the orientation for POV movement & rotation
  22606. */
  22607. definedFacingForward: boolean;
  22608. /** @hidden */
  22609. _occlusionQuery: Nullable<WebGLQuery>;
  22610. private _visibility;
  22611. /**
  22612. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22613. */
  22614. /**
  22615. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  22616. */
  22617. visibility: number;
  22618. /** Gets or sets the alpha index used to sort transparent meshes
  22619. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  22620. */
  22621. alphaIndex: number;
  22622. /**
  22623. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  22624. */
  22625. isVisible: boolean;
  22626. /**
  22627. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  22628. */
  22629. isPickable: boolean;
  22630. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  22631. showSubMeshesBoundingBox: boolean;
  22632. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  22633. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  22634. */
  22635. isBlocker: boolean;
  22636. /**
  22637. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  22638. */
  22639. enablePointerMoveEvents: boolean;
  22640. /**
  22641. * Specifies the rendering group id for this mesh (0 by default)
  22642. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  22643. */
  22644. renderingGroupId: number;
  22645. private _material;
  22646. /** Gets or sets current material */
  22647. material: Nullable<Material>;
  22648. private _receiveShadows;
  22649. /**
  22650. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  22651. * @see http://doc.babylonjs.com/babylon101/shadows
  22652. */
  22653. receiveShadows: boolean;
  22654. /** Defines color to use when rendering outline */
  22655. outlineColor: Color3;
  22656. /** Define width to use when rendering outline */
  22657. outlineWidth: number;
  22658. /** Defines color to use when rendering overlay */
  22659. overlayColor: Color3;
  22660. /** Defines alpha to use when rendering overlay */
  22661. overlayAlpha: number;
  22662. private _hasVertexAlpha;
  22663. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  22664. hasVertexAlpha: boolean;
  22665. private _useVertexColors;
  22666. /** 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) */
  22667. useVertexColors: boolean;
  22668. private _computeBonesUsingShaders;
  22669. /**
  22670. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  22671. */
  22672. computeBonesUsingShaders: boolean;
  22673. private _numBoneInfluencers;
  22674. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  22675. numBoneInfluencers: number;
  22676. private _applyFog;
  22677. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  22678. applyFog: boolean;
  22679. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  22680. useOctreeForRenderingSelection: boolean;
  22681. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  22682. useOctreeForPicking: boolean;
  22683. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  22684. useOctreeForCollisions: boolean;
  22685. private _layerMask;
  22686. /**
  22687. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  22688. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  22689. */
  22690. layerMask: number;
  22691. /**
  22692. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  22693. */
  22694. alwaysSelectAsActiveMesh: boolean;
  22695. /**
  22696. * Gets or sets the current action manager
  22697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  22698. */
  22699. actionManager: Nullable<AbstractActionManager>;
  22700. private _checkCollisions;
  22701. private _collisionMask;
  22702. private _collisionGroup;
  22703. /**
  22704. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  22705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22706. */
  22707. ellipsoid: Vector3;
  22708. /**
  22709. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  22710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  22711. */
  22712. ellipsoidOffset: Vector3;
  22713. private _collider;
  22714. private _oldPositionForCollisions;
  22715. private _diffPositionForCollisions;
  22716. /**
  22717. * Gets or sets a collision mask used to mask collisions (default is -1).
  22718. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22719. */
  22720. collisionMask: number;
  22721. /**
  22722. * Gets or sets the current collision group mask (-1 by default).
  22723. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  22724. */
  22725. collisionGroup: number;
  22726. /**
  22727. * Defines edge width used when edgesRenderer is enabled
  22728. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22729. */
  22730. edgesWidth: number;
  22731. /**
  22732. * Defines edge color used when edgesRenderer is enabled
  22733. * @see https://www.babylonjs-playground.com/#10OJSG#13
  22734. */
  22735. edgesColor: Color4;
  22736. /** @hidden */
  22737. _edgesRenderer: Nullable<IEdgesRenderer>;
  22738. /** @hidden */
  22739. _masterMesh: Nullable<AbstractMesh>;
  22740. /** @hidden */
  22741. _boundingInfo: Nullable<BoundingInfo>;
  22742. /** @hidden */
  22743. _renderId: number;
  22744. /**
  22745. * Gets or sets the list of subMeshes
  22746. * @see http://doc.babylonjs.com/how_to/multi_materials
  22747. */
  22748. subMeshes: SubMesh[];
  22749. /** @hidden */
  22750. _intersectionsInProgress: AbstractMesh[];
  22751. /** @hidden */
  22752. _unIndexed: boolean;
  22753. /** @hidden */
  22754. _lightSources: Light[];
  22755. /** @hidden */
  22756. readonly _positions: Nullable<Vector3[]>;
  22757. /** @hidden */
  22758. _waitingActions: any;
  22759. /** @hidden */
  22760. _waitingFreezeWorldMatrix: Nullable<boolean>;
  22761. private _skeleton;
  22762. /** @hidden */
  22763. _bonesTransformMatrices: Nullable<Float32Array>;
  22764. /**
  22765. * Gets or sets a skeleton to apply skining transformations
  22766. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  22767. */
  22768. skeleton: Nullable<Skeleton>;
  22769. /**
  22770. * An event triggered when the mesh is rebuilt.
  22771. */
  22772. onRebuildObservable: Observable<AbstractMesh>;
  22773. /**
  22774. * Creates a new AbstractMesh
  22775. * @param name defines the name of the mesh
  22776. * @param scene defines the hosting scene
  22777. */
  22778. constructor(name: string, scene?: Nullable<Scene>);
  22779. /**
  22780. * Returns the string "AbstractMesh"
  22781. * @returns "AbstractMesh"
  22782. */
  22783. getClassName(): string;
  22784. /**
  22785. * Gets a string representation of the current mesh
  22786. * @param fullDetails defines a boolean indicating if full details must be included
  22787. * @returns a string representation of the current mesh
  22788. */
  22789. toString(fullDetails?: boolean): string;
  22790. /** @hidden */
  22791. _rebuild(): void;
  22792. /** @hidden */
  22793. _resyncLightSources(): void;
  22794. /** @hidden */
  22795. _resyncLighSource(light: Light): void;
  22796. /** @hidden */
  22797. _unBindEffect(): void;
  22798. /** @hidden */
  22799. _removeLightSource(light: Light): void;
  22800. private _markSubMeshesAsDirty;
  22801. /** @hidden */
  22802. _markSubMeshesAsLightDirty(): void;
  22803. /** @hidden */
  22804. _markSubMeshesAsAttributesDirty(): void;
  22805. /** @hidden */
  22806. _markSubMeshesAsMiscDirty(): void;
  22807. /**
  22808. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  22809. */
  22810. scaling: Vector3;
  22811. /**
  22812. * Returns true if the mesh is blocked. Implemented by child classes
  22813. */
  22814. readonly isBlocked: boolean;
  22815. /**
  22816. * Returns the mesh itself by default. Implemented by child classes
  22817. * @param camera defines the camera to use to pick the right LOD level
  22818. * @returns the currentAbstractMesh
  22819. */
  22820. getLOD(camera: Camera): Nullable<AbstractMesh>;
  22821. /**
  22822. * Returns 0 by default. Implemented by child classes
  22823. * @returns an integer
  22824. */
  22825. getTotalVertices(): number;
  22826. /**
  22827. * Returns a positive integer : the total number of indices in this mesh geometry.
  22828. * @returns the numner of indices or zero if the mesh has no geometry.
  22829. */
  22830. getTotalIndices(): number;
  22831. /**
  22832. * Returns null by default. Implemented by child classes
  22833. * @returns null
  22834. */
  22835. getIndices(): Nullable<IndicesArray>;
  22836. /**
  22837. * Returns the array of the requested vertex data kind. Implemented by child classes
  22838. * @param kind defines the vertex data kind to use
  22839. * @returns null
  22840. */
  22841. getVerticesData(kind: string): Nullable<FloatArray>;
  22842. /**
  22843. * Sets the vertex data of the mesh geometry for the requested `kind`.
  22844. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  22845. * Note that a new underlying VertexBuffer object is created each call.
  22846. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  22847. * @param kind defines vertex data kind:
  22848. * * VertexBuffer.PositionKind
  22849. * * VertexBuffer.UVKind
  22850. * * VertexBuffer.UV2Kind
  22851. * * VertexBuffer.UV3Kind
  22852. * * VertexBuffer.UV4Kind
  22853. * * VertexBuffer.UV5Kind
  22854. * * VertexBuffer.UV6Kind
  22855. * * VertexBuffer.ColorKind
  22856. * * VertexBuffer.MatricesIndicesKind
  22857. * * VertexBuffer.MatricesIndicesExtraKind
  22858. * * VertexBuffer.MatricesWeightsKind
  22859. * * VertexBuffer.MatricesWeightsExtraKind
  22860. * @param data defines the data source
  22861. * @param updatable defines if the data must be flagged as updatable (or static)
  22862. * @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
  22863. * @returns the current mesh
  22864. */
  22865. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  22866. /**
  22867. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  22868. * If the mesh has no geometry, it is simply returned as it is.
  22869. * @param kind defines vertex data kind:
  22870. * * VertexBuffer.PositionKind
  22871. * * VertexBuffer.UVKind
  22872. * * VertexBuffer.UV2Kind
  22873. * * VertexBuffer.UV3Kind
  22874. * * VertexBuffer.UV4Kind
  22875. * * VertexBuffer.UV5Kind
  22876. * * VertexBuffer.UV6Kind
  22877. * * VertexBuffer.ColorKind
  22878. * * VertexBuffer.MatricesIndicesKind
  22879. * * VertexBuffer.MatricesIndicesExtraKind
  22880. * * VertexBuffer.MatricesWeightsKind
  22881. * * VertexBuffer.MatricesWeightsExtraKind
  22882. * @param data defines the data source
  22883. * @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
  22884. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  22885. * @returns the current mesh
  22886. */
  22887. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  22888. /**
  22889. * Sets the mesh indices,
  22890. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  22891. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  22892. * @param totalVertices Defines the total number of vertices
  22893. * @returns the current mesh
  22894. */
  22895. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  22896. /**
  22897. * Gets a boolean indicating if specific vertex data is present
  22898. * @param kind defines the vertex data kind to use
  22899. * @returns true is data kind is present
  22900. */
  22901. isVerticesDataPresent(kind: string): boolean;
  22902. /**
  22903. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  22904. * @returns a BoundingInfo
  22905. */
  22906. getBoundingInfo(): BoundingInfo;
  22907. /**
  22908. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  22909. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  22910. * @returns the current mesh
  22911. */
  22912. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  22913. /**
  22914. * Overwrite the current bounding info
  22915. * @param boundingInfo defines the new bounding info
  22916. * @returns the current mesh
  22917. */
  22918. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  22919. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  22920. readonly useBones: boolean;
  22921. /** @hidden */
  22922. _preActivate(): void;
  22923. /** @hidden */
  22924. _preActivateForIntermediateRendering(renderId: number): void;
  22925. /** @hidden */
  22926. _activate(renderId: number): void;
  22927. /**
  22928. * Gets the current world matrix
  22929. * @returns a Matrix
  22930. */
  22931. getWorldMatrix(): Matrix;
  22932. /** @hidden */
  22933. _getWorldMatrixDeterminant(): number;
  22934. /**
  22935. * Perform relative position change from the point of view of behind the front of the mesh.
  22936. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22937. * Supports definition of mesh facing forward or backward
  22938. * @param amountRight defines the distance on the right axis
  22939. * @param amountUp defines the distance on the up axis
  22940. * @param amountForward defines the distance on the forward axis
  22941. * @returns the current mesh
  22942. */
  22943. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  22944. /**
  22945. * Calculate relative position change from the point of view of behind the front of the mesh.
  22946. * This is performed taking into account the meshes current rotation, so you do not have to care.
  22947. * Supports definition of mesh facing forward or backward
  22948. * @param amountRight defines the distance on the right axis
  22949. * @param amountUp defines the distance on the up axis
  22950. * @param amountForward defines the distance on the forward axis
  22951. * @returns the new displacement vector
  22952. */
  22953. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  22954. /**
  22955. * Perform relative rotation change from the point of view of behind the front of the mesh.
  22956. * Supports definition of mesh facing forward or backward
  22957. * @param flipBack defines the flip
  22958. * @param twirlClockwise defines the twirl
  22959. * @param tiltRight defines the tilt
  22960. * @returns the current mesh
  22961. */
  22962. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  22963. /**
  22964. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  22965. * Supports definition of mesh facing forward or backward.
  22966. * @param flipBack defines the flip
  22967. * @param twirlClockwise defines the twirl
  22968. * @param tiltRight defines the tilt
  22969. * @returns the new rotation vector
  22970. */
  22971. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  22972. /**
  22973. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  22974. * @param includeDescendants Include bounding info from descendants as well (true by default)
  22975. * @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
  22976. * @returns the new bounding vectors
  22977. */
  22978. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  22979. min: Vector3;
  22980. max: Vector3;
  22981. };
  22982. /**
  22983. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  22984. * This means the mesh underlying bounding box and sphere are recomputed.
  22985. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  22986. * @returns the current mesh
  22987. */
  22988. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  22989. /** @hidden */
  22990. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  22991. /** @hidden */
  22992. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  22993. /** @hidden */
  22994. _updateBoundingInfo(): AbstractMesh;
  22995. /** @hidden */
  22996. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  22997. /** @hidden */
  22998. protected _afterComputeWorldMatrix(): void;
  22999. /**
  23000. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23001. * A mesh is in the frustum if its bounding box intersects the frustum
  23002. * @param frustumPlanes defines the frustum to test
  23003. * @returns true if the mesh is in the frustum planes
  23004. */
  23005. isInFrustum(frustumPlanes: Plane[]): boolean;
  23006. /**
  23007. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23008. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23009. * @param frustumPlanes defines the frustum to test
  23010. * @returns true if the mesh is completely in the frustum planes
  23011. */
  23012. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23013. /**
  23014. * True if the mesh intersects another mesh or a SolidParticle object
  23015. * @param mesh defines a target mesh or SolidParticle to test
  23016. * @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)
  23017. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23018. * @returns true if there is an intersection
  23019. */
  23020. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23021. /**
  23022. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23023. * @param point defines the point to test
  23024. * @returns true if there is an intersection
  23025. */
  23026. intersectsPoint(point: Vector3): boolean;
  23027. /**
  23028. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23029. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23030. */
  23031. checkCollisions: boolean;
  23032. /**
  23033. * Gets Collider object used to compute collisions (not physics)
  23034. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23035. */
  23036. readonly collider: Collider;
  23037. /**
  23038. * Move the mesh using collision engine
  23039. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23040. * @param displacement defines the requested displacement vector
  23041. * @returns the current mesh
  23042. */
  23043. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23044. private _onCollisionPositionChange;
  23045. /** @hidden */
  23046. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23047. /** @hidden */
  23048. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23049. /** @hidden */
  23050. _checkCollision(collider: Collider): AbstractMesh;
  23051. /** @hidden */
  23052. _generatePointsArray(): boolean;
  23053. /**
  23054. * Checks if the passed Ray intersects with the mesh
  23055. * @param ray defines the ray to use
  23056. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23057. * @returns the picking info
  23058. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23059. */
  23060. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23061. /**
  23062. * Clones the current mesh
  23063. * @param name defines the mesh name
  23064. * @param newParent defines the new mesh parent
  23065. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23066. * @returns the new mesh
  23067. */
  23068. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23069. /**
  23070. * Disposes all the submeshes of the current meshnp
  23071. * @returns the current mesh
  23072. */
  23073. releaseSubMeshes(): AbstractMesh;
  23074. /**
  23075. * Releases resources associated with this abstract mesh.
  23076. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23077. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23078. */
  23079. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23080. /**
  23081. * Adds the passed mesh as a child to the current mesh
  23082. * @param mesh defines the child mesh
  23083. * @returns the current mesh
  23084. */
  23085. addChild(mesh: AbstractMesh): AbstractMesh;
  23086. /**
  23087. * Removes the passed mesh from the current mesh children list
  23088. * @param mesh defines the child mesh
  23089. * @returns the current mesh
  23090. */
  23091. removeChild(mesh: AbstractMesh): AbstractMesh;
  23092. /** @hidden */
  23093. private _initFacetData;
  23094. /**
  23095. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23096. * This method can be called within the render loop.
  23097. * 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
  23098. * @returns the current mesh
  23099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23100. */
  23101. updateFacetData(): AbstractMesh;
  23102. /**
  23103. * Returns the facetLocalNormals array.
  23104. * The normals are expressed in the mesh local spac
  23105. * @returns an array of Vector3
  23106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23107. */
  23108. getFacetLocalNormals(): Vector3[];
  23109. /**
  23110. * Returns the facetLocalPositions array.
  23111. * The facet positions are expressed in the mesh local space
  23112. * @returns an array of Vector3
  23113. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23114. */
  23115. getFacetLocalPositions(): Vector3[];
  23116. /**
  23117. * Returns the facetLocalPartioning array
  23118. * @returns an array of array of numbers
  23119. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23120. */
  23121. getFacetLocalPartitioning(): number[][];
  23122. /**
  23123. * Returns the i-th facet position in the world system.
  23124. * This method allocates a new Vector3 per call
  23125. * @param i defines the facet index
  23126. * @returns a new Vector3
  23127. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23128. */
  23129. getFacetPosition(i: number): Vector3;
  23130. /**
  23131. * Sets the reference Vector3 with the i-th facet position in the world system
  23132. * @param i defines the facet index
  23133. * @param ref defines the target vector
  23134. * @returns the current mesh
  23135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23136. */
  23137. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23138. /**
  23139. * Returns the i-th facet normal in the world system.
  23140. * This method allocates a new Vector3 per call
  23141. * @param i defines the facet index
  23142. * @returns a new Vector3
  23143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23144. */
  23145. getFacetNormal(i: number): Vector3;
  23146. /**
  23147. * Sets the reference Vector3 with the i-th facet normal in the world system
  23148. * @param i defines the facet index
  23149. * @param ref defines the target vector
  23150. * @returns the current mesh
  23151. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23152. */
  23153. getFacetNormalToRef(i: number, ref: Vector3): this;
  23154. /**
  23155. * 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)
  23156. * @param x defines x coordinate
  23157. * @param y defines y coordinate
  23158. * @param z defines z coordinate
  23159. * @returns the array of facet indexes
  23160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23161. */
  23162. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23163. /**
  23164. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23165. * @param projected sets as the (x,y,z) world projection on the facet
  23166. * @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
  23167. * @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
  23168. * @param x defines x coordinate
  23169. * @param y defines y coordinate
  23170. * @param z defines z coordinate
  23171. * @returns the face index if found (or null instead)
  23172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23173. */
  23174. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23175. /**
  23176. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23177. * @param projected sets as the (x,y,z) local projection on the facet
  23178. * @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
  23179. * @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
  23180. * @param x defines x coordinate
  23181. * @param y defines y coordinate
  23182. * @param z defines z coordinate
  23183. * @returns the face index if found (or null instead)
  23184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23185. */
  23186. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23187. /**
  23188. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23189. * @returns the parameters
  23190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23191. */
  23192. getFacetDataParameters(): any;
  23193. /**
  23194. * Disables the feature FacetData and frees the related memory
  23195. * @returns the current mesh
  23196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23197. */
  23198. disableFacetData(): AbstractMesh;
  23199. /**
  23200. * Updates the AbstractMesh indices array
  23201. * @param indices defines the data source
  23202. * @returns the current mesh
  23203. */
  23204. updateIndices(indices: IndicesArray): AbstractMesh;
  23205. /**
  23206. * Creates new normals data for the mesh
  23207. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23208. * @returns the current mesh
  23209. */
  23210. createNormals(updatable: boolean): AbstractMesh;
  23211. /**
  23212. * Align the mesh with a normal
  23213. * @param normal defines the normal to use
  23214. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23215. * @returns the current mesh
  23216. */
  23217. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23218. /** @hidden */
  23219. _checkOcclusionQuery(): boolean;
  23220. }
  23221. }
  23222. declare module BABYLON {
  23223. /**
  23224. * Class used to handle skinning animations
  23225. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23226. */
  23227. export class Skeleton implements IAnimatable {
  23228. /** defines the skeleton name */
  23229. name: string;
  23230. /** defines the skeleton Id */
  23231. id: string;
  23232. /**
  23233. * Defines the list of child bones
  23234. */
  23235. bones: Bone[];
  23236. /**
  23237. * Defines an estimate of the dimension of the skeleton at rest
  23238. */
  23239. dimensionsAtRest: Vector3;
  23240. /**
  23241. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  23242. */
  23243. needInitialSkinMatrix: boolean;
  23244. /**
  23245. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  23246. */
  23247. overrideMesh: Nullable<AbstractMesh>;
  23248. /**
  23249. * Gets the list of animations attached to this skeleton
  23250. */
  23251. animations: Array<Animation>;
  23252. private _scene;
  23253. private _isDirty;
  23254. private _transformMatrices;
  23255. private _transformMatrixTexture;
  23256. private _meshesWithPoseMatrix;
  23257. private _animatables;
  23258. private _identity;
  23259. private _synchronizedWithMesh;
  23260. private _ranges;
  23261. private _lastAbsoluteTransformsUpdateId;
  23262. private _canUseTextureForBones;
  23263. /** @hidden */
  23264. _numBonesWithLinkedTransformNode: number;
  23265. /**
  23266. * Specifies if the skeleton should be serialized
  23267. */
  23268. doNotSerialize: boolean;
  23269. /**
  23270. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  23271. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  23272. */
  23273. useTextureToStoreBoneMatrices: boolean;
  23274. private _animationPropertiesOverride;
  23275. /**
  23276. * Gets or sets the animation properties override
  23277. */
  23278. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23279. /**
  23280. * An observable triggered before computing the skeleton's matrices
  23281. */
  23282. onBeforeComputeObservable: Observable<Skeleton>;
  23283. /**
  23284. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  23285. */
  23286. readonly isUsingTextureForMatrices: boolean;
  23287. /**
  23288. * Creates a new skeleton
  23289. * @param name defines the skeleton name
  23290. * @param id defines the skeleton Id
  23291. * @param scene defines the hosting scene
  23292. */
  23293. constructor(
  23294. /** defines the skeleton name */
  23295. name: string,
  23296. /** defines the skeleton Id */
  23297. id: string, scene: Scene);
  23298. /**
  23299. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  23300. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  23301. * @returns a Float32Array containing matrices data
  23302. */
  23303. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  23304. /**
  23305. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  23306. * @returns a raw texture containing the data
  23307. */
  23308. getTransformMatrixTexture(): Nullable<RawTexture>;
  23309. /**
  23310. * Gets the current hosting scene
  23311. * @returns a scene object
  23312. */
  23313. getScene(): Scene;
  23314. /**
  23315. * Gets a string representing the current skeleton data
  23316. * @param fullDetails defines a boolean indicating if we want a verbose version
  23317. * @returns a string representing the current skeleton data
  23318. */
  23319. toString(fullDetails?: boolean): string;
  23320. /**
  23321. * Get bone's index searching by name
  23322. * @param name defines bone's name to search for
  23323. * @return the indice of the bone. Returns -1 if not found
  23324. */
  23325. getBoneIndexByName(name: string): number;
  23326. /**
  23327. * Creater a new animation range
  23328. * @param name defines the name of the range
  23329. * @param from defines the start key
  23330. * @param to defines the end key
  23331. */
  23332. createAnimationRange(name: string, from: number, to: number): void;
  23333. /**
  23334. * Delete a specific animation range
  23335. * @param name defines the name of the range
  23336. * @param deleteFrames defines if frames must be removed as well
  23337. */
  23338. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23339. /**
  23340. * Gets a specific animation range
  23341. * @param name defines the name of the range to look for
  23342. * @returns the requested animation range or null if not found
  23343. */
  23344. getAnimationRange(name: string): Nullable<AnimationRange>;
  23345. /**
  23346. * Gets the list of all animation ranges defined on this skeleton
  23347. * @returns an array
  23348. */
  23349. getAnimationRanges(): Nullable<AnimationRange>[];
  23350. /**
  23351. * Copy animation range from a source skeleton.
  23352. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  23353. * @param source defines the source skeleton
  23354. * @param name defines the name of the range to copy
  23355. * @param rescaleAsRequired defines if rescaling must be applied if required
  23356. * @returns true if operation was successful
  23357. */
  23358. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  23359. /**
  23360. * Forces the skeleton to go to rest pose
  23361. */
  23362. returnToRest(): void;
  23363. private _getHighestAnimationFrame;
  23364. /**
  23365. * Begin a specific animation range
  23366. * @param name defines the name of the range to start
  23367. * @param loop defines if looping must be turned on (false by default)
  23368. * @param speedRatio defines the speed ratio to apply (1 by default)
  23369. * @param onAnimationEnd defines a callback which will be called when animation will end
  23370. * @returns a new animatable
  23371. */
  23372. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23373. /** @hidden */
  23374. _markAsDirty(): void;
  23375. /** @hidden */
  23376. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23377. /** @hidden */
  23378. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23379. private _computeTransformMatrices;
  23380. /**
  23381. * Build all resources required to render a skeleton
  23382. */
  23383. prepare(): void;
  23384. /**
  23385. * Gets the list of animatables currently running for this skeleton
  23386. * @returns an array of animatables
  23387. */
  23388. getAnimatables(): IAnimatable[];
  23389. /**
  23390. * Clone the current skeleton
  23391. * @param name defines the name of the new skeleton
  23392. * @param id defines the id of the enw skeleton
  23393. * @returns the new skeleton
  23394. */
  23395. clone(name: string, id: string): Skeleton;
  23396. /**
  23397. * Enable animation blending for this skeleton
  23398. * @param blendingSpeed defines the blending speed to apply
  23399. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23400. */
  23401. enableBlending(blendingSpeed?: number): void;
  23402. /**
  23403. * Releases all resources associated with the current skeleton
  23404. */
  23405. dispose(): void;
  23406. /**
  23407. * Serialize the skeleton in a JSON object
  23408. * @returns a JSON object
  23409. */
  23410. serialize(): any;
  23411. /**
  23412. * Creates a new skeleton from serialized data
  23413. * @param parsedSkeleton defines the serialized data
  23414. * @param scene defines the hosting scene
  23415. * @returns a new skeleton
  23416. */
  23417. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23418. /**
  23419. * Compute all node absolute transforms
  23420. * @param forceUpdate defines if computation must be done even if cache is up to date
  23421. */
  23422. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  23423. /**
  23424. * Gets the root pose matrix
  23425. * @returns a matrix
  23426. */
  23427. getPoseMatrix(): Nullable<Matrix>;
  23428. /**
  23429. * Sorts bones per internal index
  23430. */
  23431. sortBones(): void;
  23432. private _sortBones;
  23433. }
  23434. }
  23435. declare module BABYLON {
  23436. /**
  23437. * Class used to store bone information
  23438. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23439. */
  23440. export class Bone extends Node {
  23441. /**
  23442. * defines the bone name
  23443. */
  23444. name: string;
  23445. private static _tmpVecs;
  23446. private static _tmpQuat;
  23447. private static _tmpMats;
  23448. /**
  23449. * Gets the list of child bones
  23450. */
  23451. children: Bone[];
  23452. /** Gets the animations associated with this bone */
  23453. animations: Animation[];
  23454. /**
  23455. * Gets or sets bone length
  23456. */
  23457. length: number;
  23458. /**
  23459. * @hidden Internal only
  23460. * Set this value to map this bone to a different index in the transform matrices
  23461. * Set this value to -1 to exclude the bone from the transform matrices
  23462. */
  23463. _index: Nullable<number>;
  23464. private _skeleton;
  23465. private _localMatrix;
  23466. private _restPose;
  23467. private _baseMatrix;
  23468. private _absoluteTransform;
  23469. private _invertedAbsoluteTransform;
  23470. private _parent;
  23471. private _scalingDeterminant;
  23472. private _worldTransform;
  23473. private _localScaling;
  23474. private _localRotation;
  23475. private _localPosition;
  23476. private _needToDecompose;
  23477. private _needToCompose;
  23478. /** @hidden */
  23479. _linkedTransformNode: Nullable<TransformNode>;
  23480. /** @hidden */
  23481. /** @hidden */
  23482. _matrix: Matrix;
  23483. /**
  23484. * Create a new bone
  23485. * @param name defines the bone name
  23486. * @param skeleton defines the parent skeleton
  23487. * @param parentBone defines the parent (can be null if the bone is the root)
  23488. * @param localMatrix defines the local matrix
  23489. * @param restPose defines the rest pose matrix
  23490. * @param baseMatrix defines the base matrix
  23491. * @param index defines index of the bone in the hiearchy
  23492. */
  23493. constructor(
  23494. /**
  23495. * defines the bone name
  23496. */
  23497. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  23498. /**
  23499. * Gets the parent skeleton
  23500. * @returns a skeleton
  23501. */
  23502. getSkeleton(): Skeleton;
  23503. /**
  23504. * Gets parent bone
  23505. * @returns a bone or null if the bone is the root of the bone hierarchy
  23506. */
  23507. getParent(): Nullable<Bone>;
  23508. /**
  23509. * Sets the parent bone
  23510. * @param parent defines the parent (can be null if the bone is the root)
  23511. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23512. */
  23513. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  23514. /**
  23515. * Gets the local matrix
  23516. * @returns a matrix
  23517. */
  23518. getLocalMatrix(): Matrix;
  23519. /**
  23520. * Gets the base matrix (initial matrix which remains unchanged)
  23521. * @returns a matrix
  23522. */
  23523. getBaseMatrix(): Matrix;
  23524. /**
  23525. * Gets the rest pose matrix
  23526. * @returns a matrix
  23527. */
  23528. getRestPose(): Matrix;
  23529. /**
  23530. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  23531. */
  23532. getWorldMatrix(): Matrix;
  23533. /**
  23534. * Sets the local matrix to rest pose matrix
  23535. */
  23536. returnToRest(): void;
  23537. /**
  23538. * Gets the inverse of the absolute transform matrix.
  23539. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  23540. * @returns a matrix
  23541. */
  23542. getInvertedAbsoluteTransform(): Matrix;
  23543. /**
  23544. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  23545. * @returns a matrix
  23546. */
  23547. getAbsoluteTransform(): Matrix;
  23548. /**
  23549. * Links with the given transform node.
  23550. * The local matrix of this bone is copied from the transform node every frame.
  23551. * @param transformNode defines the transform node to link to
  23552. */
  23553. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  23554. /** Gets or sets current position (in local space) */
  23555. position: Vector3;
  23556. /** Gets or sets current rotation (in local space) */
  23557. rotation: Vector3;
  23558. /** Gets or sets current rotation quaternion (in local space) */
  23559. rotationQuaternion: Quaternion;
  23560. /** Gets or sets current scaling (in local space) */
  23561. scaling: Vector3;
  23562. /**
  23563. * Gets the animation properties override
  23564. */
  23565. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23566. private _decompose;
  23567. private _compose;
  23568. /**
  23569. * Update the base and local matrices
  23570. * @param matrix defines the new base or local matrix
  23571. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  23572. * @param updateLocalMatrix defines if the local matrix should be updated
  23573. */
  23574. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  23575. /** @hidden */
  23576. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  23577. /**
  23578. * Flag the bone as dirty (Forcing it to update everything)
  23579. */
  23580. markAsDirty(): void;
  23581. private _markAsDirtyAndCompose;
  23582. private _markAsDirtyAndDecompose;
  23583. /**
  23584. * Translate the bone in local or world space
  23585. * @param vec The amount to translate the bone
  23586. * @param space The space that the translation is in
  23587. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23588. */
  23589. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23590. /**
  23591. * Set the postion of the bone in local or world space
  23592. * @param position The position to set the bone
  23593. * @param space The space that the position is in
  23594. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23595. */
  23596. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23597. /**
  23598. * Set the absolute position of the bone (world space)
  23599. * @param position The position to set the bone
  23600. * @param mesh The mesh that this bone is attached to
  23601. */
  23602. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  23603. /**
  23604. * Scale the bone on the x, y and z axes (in local space)
  23605. * @param x The amount to scale the bone on the x axis
  23606. * @param y The amount to scale the bone on the y axis
  23607. * @param z The amount to scale the bone on the z axis
  23608. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  23609. */
  23610. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  23611. /**
  23612. * Set the bone scaling in local space
  23613. * @param scale defines the scaling vector
  23614. */
  23615. setScale(scale: Vector3): void;
  23616. /**
  23617. * Gets the current scaling in local space
  23618. * @returns the current scaling vector
  23619. */
  23620. getScale(): Vector3;
  23621. /**
  23622. * Gets the current scaling in local space and stores it in a target vector
  23623. * @param result defines the target vector
  23624. */
  23625. getScaleToRef(result: Vector3): void;
  23626. /**
  23627. * Set the yaw, pitch, and roll of the bone in local or world space
  23628. * @param yaw The rotation of the bone on the y axis
  23629. * @param pitch The rotation of the bone on the x axis
  23630. * @param roll The rotation of the bone on the z axis
  23631. * @param space The space that the axes of rotation are in
  23632. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23633. */
  23634. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  23635. /**
  23636. * Add a rotation to the bone on an axis in local or world space
  23637. * @param axis The axis to rotate the bone on
  23638. * @param amount The amount to rotate the bone
  23639. * @param space The space that the axis is in
  23640. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23641. */
  23642. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  23643. /**
  23644. * Set the rotation of the bone to a particular axis angle in local or world space
  23645. * @param axis The axis to rotate the bone on
  23646. * @param angle The angle that the bone should be rotated to
  23647. * @param space The space that the axis is in
  23648. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23649. */
  23650. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  23651. /**
  23652. * Set the euler rotation of the bone in local of world space
  23653. * @param rotation The euler rotation that the bone should be set to
  23654. * @param space The space that the rotation is in
  23655. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23656. */
  23657. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  23658. /**
  23659. * Set the quaternion rotation of the bone in local of world space
  23660. * @param quat The quaternion rotation that the bone should be set to
  23661. * @param space The space that the rotation is in
  23662. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23663. */
  23664. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  23665. /**
  23666. * Set the rotation matrix of the bone in local of world space
  23667. * @param rotMat The rotation matrix that the bone should be set to
  23668. * @param space The space that the rotation is in
  23669. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23670. */
  23671. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  23672. private _rotateWithMatrix;
  23673. private _getNegativeRotationToRef;
  23674. /**
  23675. * Get the position of the bone in local or world space
  23676. * @param space The space that the returned position is in
  23677. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23678. * @returns The position of the bone
  23679. */
  23680. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23681. /**
  23682. * Copy the position of the bone to a vector3 in local or world space
  23683. * @param space The space that the returned position is in
  23684. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23685. * @param result The vector3 to copy the position to
  23686. */
  23687. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  23688. /**
  23689. * Get the absolute position of the bone (world space)
  23690. * @param mesh The mesh that this bone is attached to
  23691. * @returns The absolute position of the bone
  23692. */
  23693. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  23694. /**
  23695. * Copy the absolute position of the bone (world space) to the result param
  23696. * @param mesh The mesh that this bone is attached to
  23697. * @param result The vector3 to copy the absolute position to
  23698. */
  23699. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  23700. /**
  23701. * Compute the absolute transforms of this bone and its children
  23702. */
  23703. computeAbsoluteTransforms(): void;
  23704. /**
  23705. * Get the world direction from an axis that is in the local space of the bone
  23706. * @param localAxis The local direction that is used to compute the world direction
  23707. * @param mesh The mesh that this bone is attached to
  23708. * @returns The world direction
  23709. */
  23710. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23711. /**
  23712. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  23713. * @param localAxis The local direction that is used to compute the world direction
  23714. * @param mesh The mesh that this bone is attached to
  23715. * @param result The vector3 that the world direction will be copied to
  23716. */
  23717. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23718. /**
  23719. * Get the euler rotation of the bone in local or world space
  23720. * @param space The space that the rotation should be in
  23721. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23722. * @returns The euler rotation
  23723. */
  23724. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  23725. /**
  23726. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  23727. * @param space The space that the rotation should be in
  23728. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23729. * @param result The vector3 that the rotation should be copied to
  23730. */
  23731. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23732. /**
  23733. * Get the quaternion rotation of the bone in either local or world space
  23734. * @param space The space that the rotation should be in
  23735. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23736. * @returns The quaternion rotation
  23737. */
  23738. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  23739. /**
  23740. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  23741. * @param space The space that the rotation should be in
  23742. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23743. * @param result The quaternion that the rotation should be copied to
  23744. */
  23745. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  23746. /**
  23747. * Get the rotation matrix of the bone in local or world space
  23748. * @param space The space that the rotation should be in
  23749. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23750. * @returns The rotation matrix
  23751. */
  23752. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  23753. /**
  23754. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  23755. * @param space The space that the rotation should be in
  23756. * @param mesh The mesh that this bone is attached to. This is only used in world space
  23757. * @param result The quaternion that the rotation should be copied to
  23758. */
  23759. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  23760. /**
  23761. * Get the world position of a point that is in the local space of the bone
  23762. * @param position The local position
  23763. * @param mesh The mesh that this bone is attached to
  23764. * @returns The world position
  23765. */
  23766. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23767. /**
  23768. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  23769. * @param position The local position
  23770. * @param mesh The mesh that this bone is attached to
  23771. * @param result The vector3 that the world position should be copied to
  23772. */
  23773. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23774. /**
  23775. * Get the local position of a point that is in world space
  23776. * @param position The world position
  23777. * @param mesh The mesh that this bone is attached to
  23778. * @returns The local position
  23779. */
  23780. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  23781. /**
  23782. * Get the local position of a point that is in world space and copy it to the result param
  23783. * @param position The world position
  23784. * @param mesh The mesh that this bone is attached to
  23785. * @param result The vector3 that the local position should be copied to
  23786. */
  23787. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  23788. }
  23789. }
  23790. declare module BABYLON {
  23791. /**
  23792. * Class used to store an actual running animation
  23793. */
  23794. export class Animatable {
  23795. /** defines the target object */
  23796. target: any;
  23797. /** defines the starting frame number (default is 0) */
  23798. fromFrame: number;
  23799. /** defines the ending frame number (default is 100) */
  23800. toFrame: number;
  23801. /** defines if the animation must loop (default is false) */
  23802. loopAnimation: boolean;
  23803. /** defines a callback to call when animation ends if it is not looping */
  23804. onAnimationEnd?: (() => void) | null | undefined;
  23805. /** defines a callback to call when animation loops */
  23806. onAnimationLoop?: (() => void) | null | undefined;
  23807. private _localDelayOffset;
  23808. private _pausedDelay;
  23809. private _runtimeAnimations;
  23810. private _paused;
  23811. private _scene;
  23812. private _speedRatio;
  23813. private _weight;
  23814. private _syncRoot;
  23815. /**
  23816. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  23817. * This will only apply for non looping animation (default is true)
  23818. */
  23819. disposeOnEnd: boolean;
  23820. /**
  23821. * Gets a boolean indicating if the animation has started
  23822. */
  23823. animationStarted: boolean;
  23824. /**
  23825. * Observer raised when the animation ends
  23826. */
  23827. onAnimationEndObservable: Observable<Animatable>;
  23828. /**
  23829. * Observer raised when the animation loops
  23830. */
  23831. onAnimationLoopObservable: Observable<Animatable>;
  23832. /**
  23833. * Gets the root Animatable used to synchronize and normalize animations
  23834. */
  23835. readonly syncRoot: Animatable;
  23836. /**
  23837. * Gets the current frame of the first RuntimeAnimation
  23838. * Used to synchronize Animatables
  23839. */
  23840. readonly masterFrame: number;
  23841. /**
  23842. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  23843. */
  23844. weight: number;
  23845. /**
  23846. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  23847. */
  23848. speedRatio: number;
  23849. /**
  23850. * Creates a new Animatable
  23851. * @param scene defines the hosting scene
  23852. * @param target defines the target object
  23853. * @param fromFrame defines the starting frame number (default is 0)
  23854. * @param toFrame defines the ending frame number (default is 100)
  23855. * @param loopAnimation defines if the animation must loop (default is false)
  23856. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  23857. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  23858. * @param animations defines a group of animation to add to the new Animatable
  23859. * @param onAnimationLoop defines a callback to call when animation loops
  23860. */
  23861. constructor(scene: Scene,
  23862. /** defines the target object */
  23863. target: any,
  23864. /** defines the starting frame number (default is 0) */
  23865. fromFrame?: number,
  23866. /** defines the ending frame number (default is 100) */
  23867. toFrame?: number,
  23868. /** defines if the animation must loop (default is false) */
  23869. loopAnimation?: boolean, speedRatio?: number,
  23870. /** defines a callback to call when animation ends if it is not looping */
  23871. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  23872. /** defines a callback to call when animation loops */
  23873. onAnimationLoop?: (() => void) | null | undefined);
  23874. /**
  23875. * Synchronize and normalize current Animatable with a source Animatable
  23876. * This is useful when using animation weights and when animations are not of the same length
  23877. * @param root defines the root Animatable to synchronize with
  23878. * @returns the current Animatable
  23879. */
  23880. syncWith(root: Animatable): Animatable;
  23881. /**
  23882. * Gets the list of runtime animations
  23883. * @returns an array of RuntimeAnimation
  23884. */
  23885. getAnimations(): RuntimeAnimation[];
  23886. /**
  23887. * Adds more animations to the current animatable
  23888. * @param target defines the target of the animations
  23889. * @param animations defines the new animations to add
  23890. */
  23891. appendAnimations(target: any, animations: Animation[]): void;
  23892. /**
  23893. * Gets the source animation for a specific property
  23894. * @param property defines the propertyu to look for
  23895. * @returns null or the source animation for the given property
  23896. */
  23897. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  23898. /**
  23899. * Gets the runtime animation for a specific property
  23900. * @param property defines the propertyu to look for
  23901. * @returns null or the runtime animation for the given property
  23902. */
  23903. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  23904. /**
  23905. * Resets the animatable to its original state
  23906. */
  23907. reset(): void;
  23908. /**
  23909. * Allows the animatable to blend with current running animations
  23910. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23911. * @param blendingSpeed defines the blending speed to use
  23912. */
  23913. enableBlending(blendingSpeed: number): void;
  23914. /**
  23915. * Disable animation blending
  23916. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23917. */
  23918. disableBlending(): void;
  23919. /**
  23920. * Jump directly to a given frame
  23921. * @param frame defines the frame to jump to
  23922. */
  23923. goToFrame(frame: number): void;
  23924. /**
  23925. * Pause the animation
  23926. */
  23927. pause(): void;
  23928. /**
  23929. * Restart the animation
  23930. */
  23931. restart(): void;
  23932. private _raiseOnAnimationEnd;
  23933. /**
  23934. * Stop and delete the current animation
  23935. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  23936. * @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)
  23937. */
  23938. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  23939. /**
  23940. * Wait asynchronously for the animation to end
  23941. * @returns a promise which will be fullfilled when the animation ends
  23942. */
  23943. waitAsync(): Promise<Animatable>;
  23944. /** @hidden */
  23945. _animate(delay: number): boolean;
  23946. }
  23947. interface Scene {
  23948. /** @hidden */
  23949. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  23950. /** @hidden */
  23951. _processLateAnimationBindingsForMatrices(holder: {
  23952. totalWeight: number;
  23953. animations: RuntimeAnimation[];
  23954. originalValue: Matrix;
  23955. }): any;
  23956. /** @hidden */
  23957. _processLateAnimationBindingsForQuaternions(holder: {
  23958. totalWeight: number;
  23959. animations: RuntimeAnimation[];
  23960. originalValue: Quaternion;
  23961. }, refQuaternion: Quaternion): Quaternion;
  23962. /** @hidden */
  23963. _processLateAnimationBindings(): void;
  23964. /**
  23965. * Will start the animation sequence of a given target
  23966. * @param target defines the target
  23967. * @param from defines from which frame should animation start
  23968. * @param to defines until which frame should animation run.
  23969. * @param weight defines the weight to apply to the animation (1.0 by default)
  23970. * @param loop defines if the animation loops
  23971. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23972. * @param onAnimationEnd defines the function to be executed when the animation ends
  23973. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23974. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  23975. * @param onAnimationLoop defines the callback to call when an animation loops
  23976. * @returns the animatable object created for this animation
  23977. */
  23978. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23979. /**
  23980. * Will start the animation sequence of a given target
  23981. * @param target defines the target
  23982. * @param from defines from which frame should animation start
  23983. * @param to defines until which frame should animation run.
  23984. * @param loop defines if the animation loops
  23985. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  23986. * @param onAnimationEnd defines the function to be executed when the animation ends
  23987. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  23988. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  23989. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  23990. * @param onAnimationLoop defines the callback to call when an animation loops
  23991. * @returns the animatable object created for this animation
  23992. */
  23993. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  23994. /**
  23995. * Will start the animation sequence of a given target and its hierarchy
  23996. * @param target defines the target
  23997. * @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.
  23998. * @param from defines from which frame should animation start
  23999. * @param to defines until which frame should animation run.
  24000. * @param loop defines if the animation loops
  24001. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24002. * @param onAnimationEnd defines the function to be executed when the animation ends
  24003. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24004. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24005. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24006. * @param onAnimationLoop defines the callback to call when an animation loops
  24007. * @returns the list of created animatables
  24008. */
  24009. 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[];
  24010. /**
  24011. * Begin a new animation on a given node
  24012. * @param target defines the target where the animation will take place
  24013. * @param animations defines the list of animations to start
  24014. * @param from defines the initial value
  24015. * @param to defines the final value
  24016. * @param loop defines if you want animation to loop (off by default)
  24017. * @param speedRatio defines the speed ratio to apply to all animations
  24018. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24019. * @param onAnimationLoop defines the callback to call when an animation loops
  24020. * @returns the list of created animatables
  24021. */
  24022. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  24023. /**
  24024. * Begin a new animation on a given node and its hierarchy
  24025. * @param target defines the root node where the animation will take place
  24026. * @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.
  24027. * @param animations defines the list of animations to start
  24028. * @param from defines the initial value
  24029. * @param to defines the final value
  24030. * @param loop defines if you want animation to loop (off by default)
  24031. * @param speedRatio defines the speed ratio to apply to all animations
  24032. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24033. * @param onAnimationLoop defines the callback to call when an animation loops
  24034. * @returns the list of animatables created for all nodes
  24035. */
  24036. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  24037. /**
  24038. * Gets the animatable associated with a specific target
  24039. * @param target defines the target of the animatable
  24040. * @returns the required animatable if found
  24041. */
  24042. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24043. /**
  24044. * Gets all animatables associated with a given target
  24045. * @param target defines the target to look animatables for
  24046. * @returns an array of Animatables
  24047. */
  24048. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24049. /**
  24050. * Will stop the animation of the given target
  24051. * @param target - the target
  24052. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  24053. * @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)
  24054. */
  24055. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  24056. /**
  24057. * Stops and removes all animations that have been applied to the scene
  24058. */
  24059. stopAllAnimations(): void;
  24060. }
  24061. interface Bone {
  24062. /**
  24063. * Copy an animation range from another bone
  24064. * @param source defines the source bone
  24065. * @param rangeName defines the range name to copy
  24066. * @param frameOffset defines the frame offset
  24067. * @param rescaleAsRequired defines if rescaling must be applied if required
  24068. * @param skelDimensionsRatio defines the scaling ratio
  24069. * @returns true if operation was successful
  24070. */
  24071. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24072. }
  24073. }
  24074. declare module BABYLON {
  24075. /**
  24076. * Defines how a node can be built from a string name.
  24077. */
  24078. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24079. /**
  24080. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24081. */
  24082. export class Node implements IBehaviorAware<Node> {
  24083. /** @hidden */
  24084. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24085. private static _NodeConstructors;
  24086. /**
  24087. * Add a new node constructor
  24088. * @param type defines the type name of the node to construct
  24089. * @param constructorFunc defines the constructor function
  24090. */
  24091. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24092. /**
  24093. * Returns a node constructor based on type name
  24094. * @param type defines the type name
  24095. * @param name defines the new node name
  24096. * @param scene defines the hosting scene
  24097. * @param options defines optional options to transmit to constructors
  24098. * @returns the new constructor or null
  24099. */
  24100. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24101. /**
  24102. * Gets or sets the name of the node
  24103. */
  24104. name: string;
  24105. /**
  24106. * Gets or sets the id of the node
  24107. */
  24108. id: string;
  24109. /**
  24110. * Gets or sets the unique id of the node
  24111. */
  24112. uniqueId: number;
  24113. /**
  24114. * Gets or sets a string used to store user defined state for the node
  24115. */
  24116. state: string;
  24117. /**
  24118. * Gets or sets an object used to store user defined information for the node
  24119. */
  24120. metadata: any;
  24121. /**
  24122. * For internal use only. Please do not use.
  24123. */
  24124. reservedDataStore: any;
  24125. /**
  24126. * Gets or sets a boolean used to define if the node must be serialized
  24127. */
  24128. doNotSerialize: boolean;
  24129. /** @hidden */
  24130. _isDisposed: boolean;
  24131. /**
  24132. * Gets a list of Animations associated with the node
  24133. */
  24134. animations: Animation[];
  24135. protected _ranges: {
  24136. [name: string]: Nullable<AnimationRange>;
  24137. };
  24138. /**
  24139. * Callback raised when the node is ready to be used
  24140. */
  24141. onReady: (node: Node) => void;
  24142. private _isEnabled;
  24143. private _isParentEnabled;
  24144. private _isReady;
  24145. /** @hidden */
  24146. _currentRenderId: number;
  24147. private _parentRenderId;
  24148. protected _childRenderId: number;
  24149. /** @hidden */
  24150. _waitingParentId: Nullable<string>;
  24151. /** @hidden */
  24152. _scene: Scene;
  24153. /** @hidden */
  24154. _cache: any;
  24155. private _parentNode;
  24156. private _children;
  24157. /** @hidden */
  24158. _worldMatrix: Matrix;
  24159. /** @hidden */
  24160. _worldMatrixDeterminant: number;
  24161. /** @hidden */
  24162. private _sceneRootNodesIndex;
  24163. /**
  24164. * Gets a boolean indicating if the node has been disposed
  24165. * @returns true if the node was disposed
  24166. */
  24167. isDisposed(): boolean;
  24168. /**
  24169. * Gets or sets the parent of the node
  24170. */
  24171. parent: Nullable<Node>;
  24172. private addToSceneRootNodes;
  24173. private removeFromSceneRootNodes;
  24174. private _animationPropertiesOverride;
  24175. /**
  24176. * Gets or sets the animation properties override
  24177. */
  24178. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24179. /**
  24180. * Gets a string idenfifying the name of the class
  24181. * @returns "Node" string
  24182. */
  24183. getClassName(): string;
  24184. /** @hidden */
  24185. readonly _isNode: boolean;
  24186. /**
  24187. * An event triggered when the mesh is disposed
  24188. */
  24189. onDisposeObservable: Observable<Node>;
  24190. private _onDisposeObserver;
  24191. /**
  24192. * Sets a callback that will be raised when the node will be disposed
  24193. */
  24194. onDispose: () => void;
  24195. /**
  24196. * Creates a new Node
  24197. * @param name the name and id to be given to this node
  24198. * @param scene the scene this node will be added to
  24199. * @param addToRootNodes the node will be added to scene.rootNodes
  24200. */
  24201. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24202. /**
  24203. * Gets the scene of the node
  24204. * @returns a scene
  24205. */
  24206. getScene(): Scene;
  24207. /**
  24208. * Gets the engine of the node
  24209. * @returns a Engine
  24210. */
  24211. getEngine(): Engine;
  24212. private _behaviors;
  24213. /**
  24214. * Attach a behavior to the node
  24215. * @see http://doc.babylonjs.com/features/behaviour
  24216. * @param behavior defines the behavior to attach
  24217. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24218. * @returns the current Node
  24219. */
  24220. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24221. /**
  24222. * Remove an attached behavior
  24223. * @see http://doc.babylonjs.com/features/behaviour
  24224. * @param behavior defines the behavior to attach
  24225. * @returns the current Node
  24226. */
  24227. removeBehavior(behavior: Behavior<Node>): Node;
  24228. /**
  24229. * Gets the list of attached behaviors
  24230. * @see http://doc.babylonjs.com/features/behaviour
  24231. */
  24232. readonly behaviors: Behavior<Node>[];
  24233. /**
  24234. * Gets an attached behavior by name
  24235. * @param name defines the name of the behavior to look for
  24236. * @see http://doc.babylonjs.com/features/behaviour
  24237. * @returns null if behavior was not found else the requested behavior
  24238. */
  24239. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24240. /**
  24241. * Returns the latest update of the World matrix
  24242. * @returns a Matrix
  24243. */
  24244. getWorldMatrix(): Matrix;
  24245. /** @hidden */
  24246. _getWorldMatrixDeterminant(): number;
  24247. /**
  24248. * Returns directly the latest state of the mesh World matrix.
  24249. * A Matrix is returned.
  24250. */
  24251. readonly worldMatrixFromCache: Matrix;
  24252. /** @hidden */
  24253. _initCache(): void;
  24254. /** @hidden */
  24255. updateCache(force?: boolean): void;
  24256. /** @hidden */
  24257. _updateCache(ignoreParentClass?: boolean): void;
  24258. /** @hidden */
  24259. _isSynchronized(): boolean;
  24260. /** @hidden */
  24261. _markSyncedWithParent(): void;
  24262. /** @hidden */
  24263. isSynchronizedWithParent(): boolean;
  24264. /** @hidden */
  24265. isSynchronized(): boolean;
  24266. /**
  24267. * Is this node ready to be used/rendered
  24268. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24269. * @return true if the node is ready
  24270. */
  24271. isReady(completeCheck?: boolean): boolean;
  24272. /**
  24273. * Is this node enabled?
  24274. * 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
  24275. * @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
  24276. * @return whether this node (and its parent) is enabled
  24277. */
  24278. isEnabled(checkAncestors?: boolean): boolean;
  24279. /** @hidden */
  24280. protected _syncParentEnabledState(): void;
  24281. /**
  24282. * Set the enabled state of this node
  24283. * @param value defines the new enabled state
  24284. */
  24285. setEnabled(value: boolean): void;
  24286. /**
  24287. * Is this node a descendant of the given node?
  24288. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24289. * @param ancestor defines the parent node to inspect
  24290. * @returns a boolean indicating if this node is a descendant of the given node
  24291. */
  24292. isDescendantOf(ancestor: Node): boolean;
  24293. /** @hidden */
  24294. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24295. /**
  24296. * Will return all nodes that have this node as ascendant
  24297. * @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
  24298. * @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
  24299. * @return all children nodes of all types
  24300. */
  24301. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24302. /**
  24303. * Get all child-meshes of this node
  24304. * @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)
  24305. * @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
  24306. * @returns an array of AbstractMesh
  24307. */
  24308. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24309. /**
  24310. * Get all direct children of this node
  24311. * @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
  24312. * @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)
  24313. * @returns an array of Node
  24314. */
  24315. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24316. /** @hidden */
  24317. _setReady(state: boolean): void;
  24318. /**
  24319. * Get an animation by name
  24320. * @param name defines the name of the animation to look for
  24321. * @returns null if not found else the requested animation
  24322. */
  24323. getAnimationByName(name: string): Nullable<Animation>;
  24324. /**
  24325. * Creates an animation range for this node
  24326. * @param name defines the name of the range
  24327. * @param from defines the starting key
  24328. * @param to defines the end key
  24329. */
  24330. createAnimationRange(name: string, from: number, to: number): void;
  24331. /**
  24332. * Delete a specific animation range
  24333. * @param name defines the name of the range to delete
  24334. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24335. */
  24336. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24337. /**
  24338. * Get an animation range by name
  24339. * @param name defines the name of the animation range to look for
  24340. * @returns null if not found else the requested animation range
  24341. */
  24342. getAnimationRange(name: string): Nullable<AnimationRange>;
  24343. /**
  24344. * Will start the animation sequence
  24345. * @param name defines the range frames for animation sequence
  24346. * @param loop defines if the animation should loop (false by default)
  24347. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24348. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24349. * @returns the object created for this animation. If range does not exist, it will return null
  24350. */
  24351. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24352. /**
  24353. * Serialize animation ranges into a JSON compatible object
  24354. * @returns serialization object
  24355. */
  24356. serializeAnimationRanges(): any;
  24357. /**
  24358. * Computes the world matrix of the node
  24359. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24360. * @returns the world matrix
  24361. */
  24362. computeWorldMatrix(force?: boolean): Matrix;
  24363. /**
  24364. * Releases resources associated with this node.
  24365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24367. */
  24368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24369. /**
  24370. * Parse animation range data from a serialization object and store them into a given node
  24371. * @param node defines where to store the animation ranges
  24372. * @param parsedNode defines the serialization object to read data from
  24373. * @param scene defines the hosting scene
  24374. */
  24375. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24376. }
  24377. }
  24378. declare module BABYLON {
  24379. /**
  24380. * Class used to store any kind of animation
  24381. */
  24382. export class Animation {
  24383. /**Name of the animation */
  24384. name: string;
  24385. /**Property to animate */
  24386. targetProperty: string;
  24387. /**The frames per second of the animation */
  24388. framePerSecond: number;
  24389. /**The data type of the animation */
  24390. dataType: number;
  24391. /**The loop mode of the animation */
  24392. loopMode?: number | undefined;
  24393. /**Specifies if blending should be enabled */
  24394. enableBlending?: boolean | undefined;
  24395. /**
  24396. * Use matrix interpolation instead of using direct key value when animating matrices
  24397. */
  24398. static AllowMatricesInterpolation: boolean;
  24399. /**
  24400. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24401. */
  24402. static AllowMatrixDecomposeForInterpolation: boolean;
  24403. /**
  24404. * Stores the key frames of the animation
  24405. */
  24406. private _keys;
  24407. /**
  24408. * Stores the easing function of the animation
  24409. */
  24410. private _easingFunction;
  24411. /**
  24412. * @hidden Internal use only
  24413. */
  24414. _runtimeAnimations: RuntimeAnimation[];
  24415. /**
  24416. * The set of event that will be linked to this animation
  24417. */
  24418. private _events;
  24419. /**
  24420. * Stores an array of target property paths
  24421. */
  24422. targetPropertyPath: string[];
  24423. /**
  24424. * Stores the blending speed of the animation
  24425. */
  24426. blendingSpeed: number;
  24427. /**
  24428. * Stores the animation ranges for the animation
  24429. */
  24430. private _ranges;
  24431. /**
  24432. * @hidden Internal use
  24433. */
  24434. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24435. /**
  24436. * Sets up an animation
  24437. * @param property The property to animate
  24438. * @param animationType The animation type to apply
  24439. * @param framePerSecond The frames per second of the animation
  24440. * @param easingFunction The easing function used in the animation
  24441. * @returns The created animation
  24442. */
  24443. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24444. /**
  24445. * Create and start an animation on a node
  24446. * @param name defines the name of the global animation that will be run on all nodes
  24447. * @param node defines the root node where the animation will take place
  24448. * @param targetProperty defines property to animate
  24449. * @param framePerSecond defines the number of frame per second yo use
  24450. * @param totalFrame defines the number of frames in total
  24451. * @param from defines the initial value
  24452. * @param to defines the final value
  24453. * @param loopMode defines which loop mode you want to use (off by default)
  24454. * @param easingFunction defines the easing function to use (linear by default)
  24455. * @param onAnimationEnd defines the callback to call when animation end
  24456. * @returns the animatable created for this animation
  24457. */
  24458. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24459. /**
  24460. * Create and start an animation on a node and its descendants
  24461. * @param name defines the name of the global animation that will be run on all nodes
  24462. * @param node defines the root node where the animation will take place
  24463. * @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
  24464. * @param targetProperty defines property to animate
  24465. * @param framePerSecond defines the number of frame per second to use
  24466. * @param totalFrame defines the number of frames in total
  24467. * @param from defines the initial value
  24468. * @param to defines the final value
  24469. * @param loopMode defines which loop mode you want to use (off by default)
  24470. * @param easingFunction defines the easing function to use (linear by default)
  24471. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24472. * @returns the list of animatables created for all nodes
  24473. * @example https://www.babylonjs-playground.com/#MH0VLI
  24474. */
  24475. 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[]>;
  24476. /**
  24477. * Creates a new animation, merges it with the existing animations and starts it
  24478. * @param name Name of the animation
  24479. * @param node Node which contains the scene that begins the animations
  24480. * @param targetProperty Specifies which property to animate
  24481. * @param framePerSecond The frames per second of the animation
  24482. * @param totalFrame The total number of frames
  24483. * @param from The frame at the beginning of the animation
  24484. * @param to The frame at the end of the animation
  24485. * @param loopMode Specifies the loop mode of the animation
  24486. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24487. * @param onAnimationEnd Callback to run once the animation is complete
  24488. * @returns Nullable animation
  24489. */
  24490. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24491. /**
  24492. * Transition property of an host to the target Value
  24493. * @param property The property to transition
  24494. * @param targetValue The target Value of the property
  24495. * @param host The object where the property to animate belongs
  24496. * @param scene Scene used to run the animation
  24497. * @param frameRate Framerate (in frame/s) to use
  24498. * @param transition The transition type we want to use
  24499. * @param duration The duration of the animation, in milliseconds
  24500. * @param onAnimationEnd Callback trigger at the end of the animation
  24501. * @returns Nullable animation
  24502. */
  24503. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24504. /**
  24505. * Return the array of runtime animations currently using this animation
  24506. */
  24507. readonly runtimeAnimations: RuntimeAnimation[];
  24508. /**
  24509. * Specifies if any of the runtime animations are currently running
  24510. */
  24511. readonly hasRunningRuntimeAnimations: boolean;
  24512. /**
  24513. * Initializes the animation
  24514. * @param name Name of the animation
  24515. * @param targetProperty Property to animate
  24516. * @param framePerSecond The frames per second of the animation
  24517. * @param dataType The data type of the animation
  24518. * @param loopMode The loop mode of the animation
  24519. * @param enableBlending Specifies if blending should be enabled
  24520. */
  24521. constructor(
  24522. /**Name of the animation */
  24523. name: string,
  24524. /**Property to animate */
  24525. targetProperty: string,
  24526. /**The frames per second of the animation */
  24527. framePerSecond: number,
  24528. /**The data type of the animation */
  24529. dataType: number,
  24530. /**The loop mode of the animation */
  24531. loopMode?: number | undefined,
  24532. /**Specifies if blending should be enabled */
  24533. enableBlending?: boolean | undefined);
  24534. /**
  24535. * Converts the animation to a string
  24536. * @param fullDetails support for multiple levels of logging within scene loading
  24537. * @returns String form of the animation
  24538. */
  24539. toString(fullDetails?: boolean): string;
  24540. /**
  24541. * Add an event to this animation
  24542. * @param event Event to add
  24543. */
  24544. addEvent(event: AnimationEvent): void;
  24545. /**
  24546. * Remove all events found at the given frame
  24547. * @param frame The frame to remove events from
  24548. */
  24549. removeEvents(frame: number): void;
  24550. /**
  24551. * Retrieves all the events from the animation
  24552. * @returns Events from the animation
  24553. */
  24554. getEvents(): AnimationEvent[];
  24555. /**
  24556. * Creates an animation range
  24557. * @param name Name of the animation range
  24558. * @param from Starting frame of the animation range
  24559. * @param to Ending frame of the animation
  24560. */
  24561. createRange(name: string, from: number, to: number): void;
  24562. /**
  24563. * Deletes an animation range by name
  24564. * @param name Name of the animation range to delete
  24565. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24566. */
  24567. deleteRange(name: string, deleteFrames?: boolean): void;
  24568. /**
  24569. * Gets the animation range by name, or null if not defined
  24570. * @param name Name of the animation range
  24571. * @returns Nullable animation range
  24572. */
  24573. getRange(name: string): Nullable<AnimationRange>;
  24574. /**
  24575. * Gets the key frames from the animation
  24576. * @returns The key frames of the animation
  24577. */
  24578. getKeys(): Array<IAnimationKey>;
  24579. /**
  24580. * Gets the highest frame rate of the animation
  24581. * @returns Highest frame rate of the animation
  24582. */
  24583. getHighestFrame(): number;
  24584. /**
  24585. * Gets the easing function of the animation
  24586. * @returns Easing function of the animation
  24587. */
  24588. getEasingFunction(): IEasingFunction;
  24589. /**
  24590. * Sets the easing function of the animation
  24591. * @param easingFunction A custom mathematical formula for animation
  24592. */
  24593. setEasingFunction(easingFunction: EasingFunction): void;
  24594. /**
  24595. * Interpolates a scalar linearly
  24596. * @param startValue Start value of the animation curve
  24597. * @param endValue End value of the animation curve
  24598. * @param gradient Scalar amount to interpolate
  24599. * @returns Interpolated scalar value
  24600. */
  24601. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24602. /**
  24603. * Interpolates a scalar cubically
  24604. * @param startValue Start value of the animation curve
  24605. * @param outTangent End tangent of the animation
  24606. * @param endValue End value of the animation curve
  24607. * @param inTangent Start tangent of the animation curve
  24608. * @param gradient Scalar amount to interpolate
  24609. * @returns Interpolated scalar value
  24610. */
  24611. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24612. /**
  24613. * Interpolates a quaternion using a spherical linear interpolation
  24614. * @param startValue Start value of the animation curve
  24615. * @param endValue End value of the animation curve
  24616. * @param gradient Scalar amount to interpolate
  24617. * @returns Interpolated quaternion value
  24618. */
  24619. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24620. /**
  24621. * Interpolates a quaternion cubically
  24622. * @param startValue Start value of the animation curve
  24623. * @param outTangent End tangent of the animation curve
  24624. * @param endValue End value of the animation curve
  24625. * @param inTangent Start tangent of the animation curve
  24626. * @param gradient Scalar amount to interpolate
  24627. * @returns Interpolated quaternion value
  24628. */
  24629. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24630. /**
  24631. * Interpolates a Vector3 linearl
  24632. * @param startValue Start value of the animation curve
  24633. * @param endValue End value of the animation curve
  24634. * @param gradient Scalar amount to interpolate
  24635. * @returns Interpolated scalar value
  24636. */
  24637. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24638. /**
  24639. * Interpolates a Vector3 cubically
  24640. * @param startValue Start value of the animation curve
  24641. * @param outTangent End tangent of the animation
  24642. * @param endValue End value of the animation curve
  24643. * @param inTangent Start tangent of the animation curve
  24644. * @param gradient Scalar amount to interpolate
  24645. * @returns InterpolatedVector3 value
  24646. */
  24647. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24648. /**
  24649. * Interpolates a Vector2 linearly
  24650. * @param startValue Start value of the animation curve
  24651. * @param endValue End value of the animation curve
  24652. * @param gradient Scalar amount to interpolate
  24653. * @returns Interpolated Vector2 value
  24654. */
  24655. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24656. /**
  24657. * Interpolates a Vector2 cubically
  24658. * @param startValue Start value of the animation curve
  24659. * @param outTangent End tangent of the animation
  24660. * @param endValue End value of the animation curve
  24661. * @param inTangent Start tangent of the animation curve
  24662. * @param gradient Scalar amount to interpolate
  24663. * @returns Interpolated Vector2 value
  24664. */
  24665. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24666. /**
  24667. * Interpolates a size linearly
  24668. * @param startValue Start value of the animation curve
  24669. * @param endValue End value of the animation curve
  24670. * @param gradient Scalar amount to interpolate
  24671. * @returns Interpolated Size value
  24672. */
  24673. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24674. /**
  24675. * Interpolates a Color3 linearly
  24676. * @param startValue Start value of the animation curve
  24677. * @param endValue End value of the animation curve
  24678. * @param gradient Scalar amount to interpolate
  24679. * @returns Interpolated Color3 value
  24680. */
  24681. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24682. /**
  24683. * @hidden Internal use only
  24684. */
  24685. _getKeyValue(value: any): any;
  24686. /**
  24687. * @hidden Internal use only
  24688. */
  24689. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24690. /**
  24691. * Defines the function to use to interpolate matrices
  24692. * @param startValue defines the start matrix
  24693. * @param endValue defines the end matrix
  24694. * @param gradient defines the gradient between both matrices
  24695. * @param result defines an optional target matrix where to store the interpolation
  24696. * @returns the interpolated matrix
  24697. */
  24698. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24699. /**
  24700. * Makes a copy of the animation
  24701. * @returns Cloned animation
  24702. */
  24703. clone(): Animation;
  24704. /**
  24705. * Sets the key frames of the animation
  24706. * @param values The animation key frames to set
  24707. */
  24708. setKeys(values: Array<IAnimationKey>): void;
  24709. /**
  24710. * Serializes the animation to an object
  24711. * @returns Serialized object
  24712. */
  24713. serialize(): any;
  24714. /**
  24715. * Float animation type
  24716. */
  24717. private static _ANIMATIONTYPE_FLOAT;
  24718. /**
  24719. * Vector3 animation type
  24720. */
  24721. private static _ANIMATIONTYPE_VECTOR3;
  24722. /**
  24723. * Quaternion animation type
  24724. */
  24725. private static _ANIMATIONTYPE_QUATERNION;
  24726. /**
  24727. * Matrix animation type
  24728. */
  24729. private static _ANIMATIONTYPE_MATRIX;
  24730. /**
  24731. * Color3 animation type
  24732. */
  24733. private static _ANIMATIONTYPE_COLOR3;
  24734. /**
  24735. * Vector2 animation type
  24736. */
  24737. private static _ANIMATIONTYPE_VECTOR2;
  24738. /**
  24739. * Size animation type
  24740. */
  24741. private static _ANIMATIONTYPE_SIZE;
  24742. /**
  24743. * Relative Loop Mode
  24744. */
  24745. private static _ANIMATIONLOOPMODE_RELATIVE;
  24746. /**
  24747. * Cycle Loop Mode
  24748. */
  24749. private static _ANIMATIONLOOPMODE_CYCLE;
  24750. /**
  24751. * Constant Loop Mode
  24752. */
  24753. private static _ANIMATIONLOOPMODE_CONSTANT;
  24754. /**
  24755. * Get the float animation type
  24756. */
  24757. static readonly ANIMATIONTYPE_FLOAT: number;
  24758. /**
  24759. * Get the Vector3 animation type
  24760. */
  24761. static readonly ANIMATIONTYPE_VECTOR3: number;
  24762. /**
  24763. * Get the Vector2 animation type
  24764. */
  24765. static readonly ANIMATIONTYPE_VECTOR2: number;
  24766. /**
  24767. * Get the Size animation type
  24768. */
  24769. static readonly ANIMATIONTYPE_SIZE: number;
  24770. /**
  24771. * Get the Quaternion animation type
  24772. */
  24773. static readonly ANIMATIONTYPE_QUATERNION: number;
  24774. /**
  24775. * Get the Matrix animation type
  24776. */
  24777. static readonly ANIMATIONTYPE_MATRIX: number;
  24778. /**
  24779. * Get the Color3 animation type
  24780. */
  24781. static readonly ANIMATIONTYPE_COLOR3: number;
  24782. /**
  24783. * Get the Relative Loop Mode
  24784. */
  24785. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  24786. /**
  24787. * Get the Cycle Loop Mode
  24788. */
  24789. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  24790. /**
  24791. * Get the Constant Loop Mode
  24792. */
  24793. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  24794. /** @hidden */
  24795. static _UniversalLerp(left: any, right: any, amount: number): any;
  24796. /**
  24797. * Parses an animation object and creates an animation
  24798. * @param parsedAnimation Parsed animation object
  24799. * @returns Animation object
  24800. */
  24801. static Parse(parsedAnimation: any): Animation;
  24802. /**
  24803. * Appends the serialized animations from the source animations
  24804. * @param source Source containing the animations
  24805. * @param destination Target to store the animations
  24806. */
  24807. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  24808. }
  24809. }
  24810. declare module BABYLON {
  24811. /**
  24812. * Base class of all the textures in babylon.
  24813. * It groups all the common properties the materials, post process, lights... might need
  24814. * in order to make a correct use of the texture.
  24815. */
  24816. export class BaseTexture implements IAnimatable {
  24817. /**
  24818. * Default anisotropic filtering level for the application.
  24819. * It is set to 4 as a good tradeoff between perf and quality.
  24820. */
  24821. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  24822. /**
  24823. * Gets or sets the unique id of the texture
  24824. */
  24825. uniqueId: number;
  24826. /**
  24827. * Define the name of the texture.
  24828. */
  24829. name: string;
  24830. /**
  24831. * Gets or sets an object used to store user defined information.
  24832. */
  24833. metadata: any;
  24834. /**
  24835. * For internal use only. Please do not use.
  24836. */
  24837. reservedDataStore: any;
  24838. private _hasAlpha;
  24839. /**
  24840. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  24841. */
  24842. hasAlpha: boolean;
  24843. /**
  24844. * Defines if the alpha value should be determined via the rgb values.
  24845. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  24846. */
  24847. getAlphaFromRGB: boolean;
  24848. /**
  24849. * Intensity or strength of the texture.
  24850. * It is commonly used by materials to fine tune the intensity of the texture
  24851. */
  24852. level: number;
  24853. /**
  24854. * Define the UV chanel to use starting from 0 and defaulting to 0.
  24855. * This is part of the texture as textures usually maps to one uv set.
  24856. */
  24857. coordinatesIndex: number;
  24858. private _coordinatesMode;
  24859. /**
  24860. * How a texture is mapped.
  24861. *
  24862. * | Value | Type | Description |
  24863. * | ----- | ----------------------------------- | ----------- |
  24864. * | 0 | EXPLICIT_MODE | |
  24865. * | 1 | SPHERICAL_MODE | |
  24866. * | 2 | PLANAR_MODE | |
  24867. * | 3 | CUBIC_MODE | |
  24868. * | 4 | PROJECTION_MODE | |
  24869. * | 5 | SKYBOX_MODE | |
  24870. * | 6 | INVCUBIC_MODE | |
  24871. * | 7 | EQUIRECTANGULAR_MODE | |
  24872. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  24873. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  24874. */
  24875. coordinatesMode: number;
  24876. /**
  24877. * | Value | Type | Description |
  24878. * | ----- | ------------------ | ----------- |
  24879. * | 0 | CLAMP_ADDRESSMODE | |
  24880. * | 1 | WRAP_ADDRESSMODE | |
  24881. * | 2 | MIRROR_ADDRESSMODE | |
  24882. */
  24883. wrapU: number;
  24884. /**
  24885. * | Value | Type | Description |
  24886. * | ----- | ------------------ | ----------- |
  24887. * | 0 | CLAMP_ADDRESSMODE | |
  24888. * | 1 | WRAP_ADDRESSMODE | |
  24889. * | 2 | MIRROR_ADDRESSMODE | |
  24890. */
  24891. wrapV: number;
  24892. /**
  24893. * | Value | Type | Description |
  24894. * | ----- | ------------------ | ----------- |
  24895. * | 0 | CLAMP_ADDRESSMODE | |
  24896. * | 1 | WRAP_ADDRESSMODE | |
  24897. * | 2 | MIRROR_ADDRESSMODE | |
  24898. */
  24899. wrapR: number;
  24900. /**
  24901. * With compliant hardware and browser (supporting anisotropic filtering)
  24902. * this defines the level of anisotropic filtering in the texture.
  24903. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  24904. */
  24905. anisotropicFilteringLevel: number;
  24906. /**
  24907. * Define if the texture is a cube texture or if false a 2d texture.
  24908. */
  24909. isCube: boolean;
  24910. /**
  24911. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  24912. */
  24913. is3D: boolean;
  24914. /**
  24915. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  24916. * HDR texture are usually stored in linear space.
  24917. * This only impacts the PBR and Background materials
  24918. */
  24919. gammaSpace: boolean;
  24920. /**
  24921. * Gets whether or not the texture contains RGBD data.
  24922. */
  24923. readonly isRGBD: boolean;
  24924. /**
  24925. * Is Z inverted in the texture (useful in a cube texture).
  24926. */
  24927. invertZ: boolean;
  24928. /**
  24929. * Are mip maps generated for this texture or not.
  24930. */
  24931. readonly noMipmap: boolean;
  24932. /**
  24933. * @hidden
  24934. */
  24935. lodLevelInAlpha: boolean;
  24936. /**
  24937. * With prefiltered texture, defined the offset used during the prefiltering steps.
  24938. */
  24939. lodGenerationOffset: number;
  24940. /**
  24941. * With prefiltered texture, defined the scale used during the prefiltering steps.
  24942. */
  24943. lodGenerationScale: number;
  24944. /**
  24945. * Define if the texture is a render target.
  24946. */
  24947. isRenderTarget: boolean;
  24948. /**
  24949. * Define the unique id of the texture in the scene.
  24950. */
  24951. readonly uid: string;
  24952. /**
  24953. * Return a string representation of the texture.
  24954. * @returns the texture as a string
  24955. */
  24956. toString(): string;
  24957. /**
  24958. * Get the class name of the texture.
  24959. * @returns "BaseTexture"
  24960. */
  24961. getClassName(): string;
  24962. /**
  24963. * Define the list of animation attached to the texture.
  24964. */
  24965. animations: Animation[];
  24966. /**
  24967. * An event triggered when the texture is disposed.
  24968. */
  24969. onDisposeObservable: Observable<BaseTexture>;
  24970. private _onDisposeObserver;
  24971. /**
  24972. * Callback triggered when the texture has been disposed.
  24973. * Kept for back compatibility, you can use the onDisposeObservable instead.
  24974. */
  24975. onDispose: () => void;
  24976. /**
  24977. * Define the current state of the loading sequence when in delayed load mode.
  24978. */
  24979. delayLoadState: number;
  24980. private _scene;
  24981. /** @hidden */
  24982. _texture: Nullable<InternalTexture>;
  24983. private _uid;
  24984. /**
  24985. * Define if the texture is preventinga material to render or not.
  24986. * If not and the texture is not ready, the engine will use a default black texture instead.
  24987. */
  24988. readonly isBlocking: boolean;
  24989. /**
  24990. * Instantiates a new BaseTexture.
  24991. * Base class of all the textures in babylon.
  24992. * It groups all the common properties the materials, post process, lights... might need
  24993. * in order to make a correct use of the texture.
  24994. * @param scene Define the scene the texture blongs to
  24995. */
  24996. constructor(scene: Nullable<Scene>);
  24997. /**
  24998. * Get the scene the texture belongs to.
  24999. * @returns the scene or null if undefined
  25000. */
  25001. getScene(): Nullable<Scene>;
  25002. /**
  25003. * Get the texture transform matrix used to offset tile the texture for istance.
  25004. * @returns the transformation matrix
  25005. */
  25006. getTextureMatrix(): Matrix;
  25007. /**
  25008. * Get the texture reflection matrix used to rotate/transform the reflection.
  25009. * @returns the reflection matrix
  25010. */
  25011. getReflectionTextureMatrix(): Matrix;
  25012. /**
  25013. * Get the underlying lower level texture from Babylon.
  25014. * @returns the insternal texture
  25015. */
  25016. getInternalTexture(): Nullable<InternalTexture>;
  25017. /**
  25018. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25019. * @returns true if ready or not blocking
  25020. */
  25021. isReadyOrNotBlocking(): boolean;
  25022. /**
  25023. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25024. * @returns true if fully ready
  25025. */
  25026. isReady(): boolean;
  25027. private _cachedSize;
  25028. /**
  25029. * Get the size of the texture.
  25030. * @returns the texture size.
  25031. */
  25032. getSize(): ISize;
  25033. /**
  25034. * Get the base size of the texture.
  25035. * It can be different from the size if the texture has been resized for POT for instance
  25036. * @returns the base size
  25037. */
  25038. getBaseSize(): ISize;
  25039. /**
  25040. * Update the sampling mode of the texture.
  25041. * Default is Trilinear mode.
  25042. *
  25043. * | Value | Type | Description |
  25044. * | ----- | ------------------ | ----------- |
  25045. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25046. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25047. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25048. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25049. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25050. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25051. * | 7 | NEAREST_LINEAR | |
  25052. * | 8 | NEAREST_NEAREST | |
  25053. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25054. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25055. * | 11 | LINEAR_LINEAR | |
  25056. * | 12 | LINEAR_NEAREST | |
  25057. *
  25058. * > _mag_: magnification filter (close to the viewer)
  25059. * > _min_: minification filter (far from the viewer)
  25060. * > _mip_: filter used between mip map levels
  25061. *@param samplingMode Define the new sampling mode of the texture
  25062. */
  25063. updateSamplingMode(samplingMode: number): void;
  25064. /**
  25065. * Scales the texture if is `canRescale()`
  25066. * @param ratio the resize factor we want to use to rescale
  25067. */
  25068. scale(ratio: number): void;
  25069. /**
  25070. * Get if the texture can rescale.
  25071. */
  25072. readonly canRescale: boolean;
  25073. /** @hidden */
  25074. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25075. /** @hidden */
  25076. _rebuild(): void;
  25077. /**
  25078. * Triggers the load sequence in delayed load mode.
  25079. */
  25080. delayLoad(): void;
  25081. /**
  25082. * Clones the texture.
  25083. * @returns the cloned texture
  25084. */
  25085. clone(): Nullable<BaseTexture>;
  25086. /**
  25087. * Get the texture underlying type (INT, FLOAT...)
  25088. */
  25089. readonly textureType: number;
  25090. /**
  25091. * Get the texture underlying format (RGB, RGBA...)
  25092. */
  25093. readonly textureFormat: number;
  25094. /**
  25095. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25096. * This will returns an RGBA array buffer containing either in values (0-255) or
  25097. * float values (0-1) depending of the underlying buffer type.
  25098. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25099. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25100. * @param buffer defines a user defined buffer to fill with data (can be null)
  25101. * @returns The Array buffer containing the pixels data.
  25102. */
  25103. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25104. /**
  25105. * Release and destroy the underlying lower level texture aka internalTexture.
  25106. */
  25107. releaseInternalTexture(): void;
  25108. /**
  25109. * Get the polynomial representation of the texture data.
  25110. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25111. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25112. */
  25113. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25114. /** @hidden */
  25115. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25116. /** @hidden */
  25117. readonly _lodTextureMid: Nullable<BaseTexture>;
  25118. /** @hidden */
  25119. readonly _lodTextureLow: Nullable<BaseTexture>;
  25120. /**
  25121. * Dispose the texture and release its associated resources.
  25122. */
  25123. dispose(): void;
  25124. /**
  25125. * Serialize the texture into a JSON representation that can be parsed later on.
  25126. * @returns the JSON representation of the texture
  25127. */
  25128. serialize(): any;
  25129. /**
  25130. * Helper function to be called back once a list of texture contains only ready textures.
  25131. * @param textures Define the list of textures to wait for
  25132. * @param callback Define the callback triggered once the entire list will be ready
  25133. */
  25134. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25135. }
  25136. }
  25137. declare module BABYLON {
  25138. /**
  25139. * Uniform buffer objects.
  25140. *
  25141. * Handles blocks of uniform on the GPU.
  25142. *
  25143. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25144. *
  25145. * For more information, please refer to :
  25146. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25147. */
  25148. export class UniformBuffer {
  25149. private _engine;
  25150. private _buffer;
  25151. private _data;
  25152. private _bufferData;
  25153. private _dynamic?;
  25154. private _uniformLocations;
  25155. private _uniformSizes;
  25156. private _uniformLocationPointer;
  25157. private _needSync;
  25158. private _noUBO;
  25159. private _currentEffect;
  25160. private static _MAX_UNIFORM_SIZE;
  25161. private static _tempBuffer;
  25162. /**
  25163. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25164. * This is dynamic to allow compat with webgl 1 and 2.
  25165. * You will need to pass the name of the uniform as well as the value.
  25166. */
  25167. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25168. /**
  25169. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25170. * This is dynamic to allow compat with webgl 1 and 2.
  25171. * You will need to pass the name of the uniform as well as the value.
  25172. */
  25173. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25174. /**
  25175. * Lambda to Update a single float in a uniform buffer.
  25176. * This is dynamic to allow compat with webgl 1 and 2.
  25177. * You will need to pass the name of the uniform as well as the value.
  25178. */
  25179. updateFloat: (name: string, x: number) => void;
  25180. /**
  25181. * Lambda to Update a vec2 of float in a uniform buffer.
  25182. * This is dynamic to allow compat with webgl 1 and 2.
  25183. * You will need to pass the name of the uniform as well as the value.
  25184. */
  25185. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25186. /**
  25187. * Lambda to Update a vec3 of float in a uniform buffer.
  25188. * This is dynamic to allow compat with webgl 1 and 2.
  25189. * You will need to pass the name of the uniform as well as the value.
  25190. */
  25191. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25192. /**
  25193. * Lambda to Update a vec4 of float in a uniform buffer.
  25194. * This is dynamic to allow compat with webgl 1 and 2.
  25195. * You will need to pass the name of the uniform as well as the value.
  25196. */
  25197. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25198. /**
  25199. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25200. * This is dynamic to allow compat with webgl 1 and 2.
  25201. * You will need to pass the name of the uniform as well as the value.
  25202. */
  25203. updateMatrix: (name: string, mat: Matrix) => void;
  25204. /**
  25205. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25206. * This is dynamic to allow compat with webgl 1 and 2.
  25207. * You will need to pass the name of the uniform as well as the value.
  25208. */
  25209. updateVector3: (name: string, vector: Vector3) => void;
  25210. /**
  25211. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25212. * This is dynamic to allow compat with webgl 1 and 2.
  25213. * You will need to pass the name of the uniform as well as the value.
  25214. */
  25215. updateVector4: (name: string, vector: Vector4) => void;
  25216. /**
  25217. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25218. * This is dynamic to allow compat with webgl 1 and 2.
  25219. * You will need to pass the name of the uniform as well as the value.
  25220. */
  25221. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25222. /**
  25223. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25224. * This is dynamic to allow compat with webgl 1 and 2.
  25225. * You will need to pass the name of the uniform as well as the value.
  25226. */
  25227. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25228. /**
  25229. * Instantiates a new Uniform buffer objects.
  25230. *
  25231. * Handles blocks of uniform on the GPU.
  25232. *
  25233. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25234. *
  25235. * For more information, please refer to :
  25236. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25237. * @param engine Define the engine the buffer is associated with
  25238. * @param data Define the data contained in the buffer
  25239. * @param dynamic Define if the buffer is updatable
  25240. */
  25241. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25242. /**
  25243. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25244. * or just falling back on setUniformXXX calls.
  25245. */
  25246. readonly useUbo: boolean;
  25247. /**
  25248. * Indicates if the WebGL underlying uniform buffer is in sync
  25249. * with the javascript cache data.
  25250. */
  25251. readonly isSync: boolean;
  25252. /**
  25253. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25254. * Also, a dynamic UniformBuffer will disable cache verification and always
  25255. * update the underlying WebGL uniform buffer to the GPU.
  25256. * @returns if Dynamic, otherwise false
  25257. */
  25258. isDynamic(): boolean;
  25259. /**
  25260. * The data cache on JS side.
  25261. * @returns the underlying data as a float array
  25262. */
  25263. getData(): Float32Array;
  25264. /**
  25265. * The underlying WebGL Uniform buffer.
  25266. * @returns the webgl buffer
  25267. */
  25268. getBuffer(): Nullable<WebGLBuffer>;
  25269. /**
  25270. * std140 layout specifies how to align data within an UBO structure.
  25271. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25272. * for specs.
  25273. */
  25274. private _fillAlignment;
  25275. /**
  25276. * Adds an uniform in the buffer.
  25277. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25278. * for the layout to be correct !
  25279. * @param name Name of the uniform, as used in the uniform block in the shader.
  25280. * @param size Data size, or data directly.
  25281. */
  25282. addUniform(name: string, size: number | number[]): void;
  25283. /**
  25284. * Adds a Matrix 4x4 to the uniform buffer.
  25285. * @param name Name of the uniform, as used in the uniform block in the shader.
  25286. * @param mat A 4x4 matrix.
  25287. */
  25288. addMatrix(name: string, mat: Matrix): void;
  25289. /**
  25290. * Adds a vec2 to the uniform buffer.
  25291. * @param name Name of the uniform, as used in the uniform block in the shader.
  25292. * @param x Define the x component value of the vec2
  25293. * @param y Define the y component value of the vec2
  25294. */
  25295. addFloat2(name: string, x: number, y: number): void;
  25296. /**
  25297. * Adds a vec3 to the uniform buffer.
  25298. * @param name Name of the uniform, as used in the uniform block in the shader.
  25299. * @param x Define the x component value of the vec3
  25300. * @param y Define the y component value of the vec3
  25301. * @param z Define the z component value of the vec3
  25302. */
  25303. addFloat3(name: string, x: number, y: number, z: number): void;
  25304. /**
  25305. * Adds a vec3 to the uniform buffer.
  25306. * @param name Name of the uniform, as used in the uniform block in the shader.
  25307. * @param color Define the vec3 from a Color
  25308. */
  25309. addColor3(name: string, color: Color3): void;
  25310. /**
  25311. * Adds a vec4 to the uniform buffer.
  25312. * @param name Name of the uniform, as used in the uniform block in the shader.
  25313. * @param color Define the rgb components from a Color
  25314. * @param alpha Define the a component of the vec4
  25315. */
  25316. addColor4(name: string, color: Color3, alpha: number): void;
  25317. /**
  25318. * Adds a vec3 to the uniform buffer.
  25319. * @param name Name of the uniform, as used in the uniform block in the shader.
  25320. * @param vector Define the vec3 components from a Vector
  25321. */
  25322. addVector3(name: string, vector: Vector3): void;
  25323. /**
  25324. * Adds a Matrix 3x3 to the uniform buffer.
  25325. * @param name Name of the uniform, as used in the uniform block in the shader.
  25326. */
  25327. addMatrix3x3(name: string): void;
  25328. /**
  25329. * Adds a Matrix 2x2 to the uniform buffer.
  25330. * @param name Name of the uniform, as used in the uniform block in the shader.
  25331. */
  25332. addMatrix2x2(name: string): void;
  25333. /**
  25334. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25335. */
  25336. create(): void;
  25337. /** @hidden */
  25338. _rebuild(): void;
  25339. /**
  25340. * Updates the WebGL Uniform Buffer on the GPU.
  25341. * If the `dynamic` flag is set to true, no cache comparison is done.
  25342. * Otherwise, the buffer will be updated only if the cache differs.
  25343. */
  25344. update(): void;
  25345. /**
  25346. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25347. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25348. * @param data Define the flattened data
  25349. * @param size Define the size of the data.
  25350. */
  25351. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25352. private _updateMatrix3x3ForUniform;
  25353. private _updateMatrix3x3ForEffect;
  25354. private _updateMatrix2x2ForEffect;
  25355. private _updateMatrix2x2ForUniform;
  25356. private _updateFloatForEffect;
  25357. private _updateFloatForUniform;
  25358. private _updateFloat2ForEffect;
  25359. private _updateFloat2ForUniform;
  25360. private _updateFloat3ForEffect;
  25361. private _updateFloat3ForUniform;
  25362. private _updateFloat4ForEffect;
  25363. private _updateFloat4ForUniform;
  25364. private _updateMatrixForEffect;
  25365. private _updateMatrixForUniform;
  25366. private _updateVector3ForEffect;
  25367. private _updateVector3ForUniform;
  25368. private _updateVector4ForEffect;
  25369. private _updateVector4ForUniform;
  25370. private _updateColor3ForEffect;
  25371. private _updateColor3ForUniform;
  25372. private _updateColor4ForEffect;
  25373. private _updateColor4ForUniform;
  25374. /**
  25375. * Sets a sampler uniform on the effect.
  25376. * @param name Define the name of the sampler.
  25377. * @param texture Define the texture to set in the sampler
  25378. */
  25379. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25380. /**
  25381. * Directly updates the value of the uniform in the cache AND on the GPU.
  25382. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25383. * @param data Define the flattened data
  25384. */
  25385. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25386. /**
  25387. * Binds this uniform buffer to an effect.
  25388. * @param effect Define the effect to bind the buffer to
  25389. * @param name Name of the uniform block in the shader.
  25390. */
  25391. bindToEffect(effect: Effect, name: string): void;
  25392. /**
  25393. * Disposes the uniform buffer.
  25394. */
  25395. dispose(): void;
  25396. }
  25397. }
  25398. declare module BABYLON {
  25399. /**
  25400. * This represents the required contract to create a new type of texture loader.
  25401. */
  25402. export interface IInternalTextureLoader {
  25403. /**
  25404. * Defines wether the loader supports cascade loading the different faces.
  25405. */
  25406. supportCascades: boolean;
  25407. /**
  25408. * This returns if the loader support the current file information.
  25409. * @param extension defines the file extension of the file being loaded
  25410. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25411. * @param fallback defines the fallback internal texture if any
  25412. * @param isBase64 defines whether the texture is encoded as a base64
  25413. * @param isBuffer defines whether the texture data are stored as a buffer
  25414. * @returns true if the loader can load the specified file
  25415. */
  25416. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25417. /**
  25418. * Transform the url before loading if required.
  25419. * @param rootUrl the url of the texture
  25420. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25421. * @returns the transformed texture
  25422. */
  25423. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25424. /**
  25425. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25426. * @param rootUrl the url of the texture
  25427. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25428. * @returns the fallback texture
  25429. */
  25430. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25431. /**
  25432. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25433. * @param data contains the texture data
  25434. * @param texture defines the BabylonJS internal texture
  25435. * @param createPolynomials will be true if polynomials have been requested
  25436. * @param onLoad defines the callback to trigger once the texture is ready
  25437. * @param onError defines the callback to trigger in case of error
  25438. */
  25439. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25440. /**
  25441. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25442. * @param data contains the texture data
  25443. * @param texture defines the BabylonJS internal texture
  25444. * @param callback defines the method to call once ready to upload
  25445. */
  25446. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25447. }
  25448. }
  25449. declare module BABYLON {
  25450. /**
  25451. * Creation options of the multi render target texture.
  25452. */
  25453. export interface IMultiRenderTargetOptions {
  25454. /**
  25455. * Define if the texture needs to create mip maps after render.
  25456. */
  25457. generateMipMaps?: boolean;
  25458. /**
  25459. * Define the types of all the draw buffers we want to create
  25460. */
  25461. types?: number[];
  25462. /**
  25463. * Define the sampling modes of all the draw buffers we want to create
  25464. */
  25465. samplingModes?: number[];
  25466. /**
  25467. * Define if a depth buffer is required
  25468. */
  25469. generateDepthBuffer?: boolean;
  25470. /**
  25471. * Define if a stencil buffer is required
  25472. */
  25473. generateStencilBuffer?: boolean;
  25474. /**
  25475. * Define if a depth texture is required instead of a depth buffer
  25476. */
  25477. generateDepthTexture?: boolean;
  25478. /**
  25479. * Define the number of desired draw buffers
  25480. */
  25481. textureCount?: number;
  25482. /**
  25483. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25484. */
  25485. doNotChangeAspectRatio?: boolean;
  25486. /**
  25487. * Define the default type of the buffers we are creating
  25488. */
  25489. defaultType?: number;
  25490. }
  25491. /**
  25492. * A multi render target, like a render target provides the ability to render to a texture.
  25493. * Unlike the render target, it can render to several draw buffers in one draw.
  25494. * This is specially interesting in deferred rendering or for any effects requiring more than
  25495. * just one color from a single pass.
  25496. */
  25497. export class MultiRenderTarget extends RenderTargetTexture {
  25498. private _internalTextures;
  25499. private _textures;
  25500. private _multiRenderTargetOptions;
  25501. /**
  25502. * Get if draw buffers are currently supported by the used hardware and browser.
  25503. */
  25504. readonly isSupported: boolean;
  25505. /**
  25506. * Get the list of textures generated by the multi render target.
  25507. */
  25508. readonly textures: Texture[];
  25509. /**
  25510. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25511. */
  25512. readonly depthTexture: Texture;
  25513. /**
  25514. * Set the wrapping mode on U of all the textures we are rendering to.
  25515. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25516. */
  25517. wrapU: number;
  25518. /**
  25519. * Set the wrapping mode on V of all the textures we are rendering to.
  25520. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25521. */
  25522. wrapV: number;
  25523. /**
  25524. * Instantiate a new multi render target texture.
  25525. * A multi render target, like a render target provides the ability to render to a texture.
  25526. * Unlike the render target, it can render to several draw buffers in one draw.
  25527. * This is specially interesting in deferred rendering or for any effects requiring more than
  25528. * just one color from a single pass.
  25529. * @param name Define the name of the texture
  25530. * @param size Define the size of the buffers to render to
  25531. * @param count Define the number of target we are rendering into
  25532. * @param scene Define the scene the texture belongs to
  25533. * @param options Define the options used to create the multi render target
  25534. */
  25535. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25536. /** @hidden */
  25537. _rebuild(): void;
  25538. private _createInternalTextures;
  25539. private _createTextures;
  25540. /**
  25541. * Define the number of samples used if MSAA is enabled.
  25542. */
  25543. samples: number;
  25544. /**
  25545. * Resize all the textures in the multi render target.
  25546. * Be carrefull as it will recreate all the data in the new texture.
  25547. * @param size Define the new size
  25548. */
  25549. resize(size: any): void;
  25550. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25551. /**
  25552. * Dispose the render targets and their associated resources
  25553. */
  25554. dispose(): void;
  25555. /**
  25556. * Release all the underlying texture used as draw buffers.
  25557. */
  25558. releaseInternalTextures(): void;
  25559. }
  25560. }
  25561. declare module BABYLON {
  25562. /**
  25563. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25564. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25565. */
  25566. export class Analyser {
  25567. /**
  25568. * Gets or sets the smoothing
  25569. * @ignorenaming
  25570. */
  25571. SMOOTHING: number;
  25572. /**
  25573. * Gets or sets the FFT table size
  25574. * @ignorenaming
  25575. */
  25576. FFT_SIZE: number;
  25577. /**
  25578. * Gets or sets the bar graph amplitude
  25579. * @ignorenaming
  25580. */
  25581. BARGRAPHAMPLITUDE: number;
  25582. /**
  25583. * Gets or sets the position of the debug canvas
  25584. * @ignorenaming
  25585. */
  25586. DEBUGCANVASPOS: {
  25587. x: number;
  25588. y: number;
  25589. };
  25590. /**
  25591. * Gets or sets the debug canvas size
  25592. * @ignorenaming
  25593. */
  25594. DEBUGCANVASSIZE: {
  25595. width: number;
  25596. height: number;
  25597. };
  25598. private _byteFreqs;
  25599. private _byteTime;
  25600. private _floatFreqs;
  25601. private _webAudioAnalyser;
  25602. private _debugCanvas;
  25603. private _debugCanvasContext;
  25604. private _scene;
  25605. private _registerFunc;
  25606. private _audioEngine;
  25607. /**
  25608. * Creates a new analyser
  25609. * @param scene defines hosting scene
  25610. */
  25611. constructor(scene: Scene);
  25612. /**
  25613. * Get the number of data values you will have to play with for the visualization
  25614. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25615. * @returns a number
  25616. */
  25617. getFrequencyBinCount(): number;
  25618. /**
  25619. * Gets the current frequency data as a byte array
  25620. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25621. * @returns a Uint8Array
  25622. */
  25623. getByteFrequencyData(): Uint8Array;
  25624. /**
  25625. * Gets the current waveform as a byte array
  25626. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25627. * @returns a Uint8Array
  25628. */
  25629. getByteTimeDomainData(): Uint8Array;
  25630. /**
  25631. * Gets the current frequency data as a float array
  25632. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25633. * @returns a Float32Array
  25634. */
  25635. getFloatFrequencyData(): Float32Array;
  25636. /**
  25637. * Renders the debug canvas
  25638. */
  25639. drawDebugCanvas(): void;
  25640. /**
  25641. * Stops rendering the debug canvas and removes it
  25642. */
  25643. stopDebugCanvas(): void;
  25644. /**
  25645. * Connects two audio nodes
  25646. * @param inputAudioNode defines first node to connect
  25647. * @param outputAudioNode defines second node to connect
  25648. */
  25649. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25650. /**
  25651. * Releases all associated resources
  25652. */
  25653. dispose(): void;
  25654. }
  25655. }
  25656. declare module BABYLON {
  25657. /**
  25658. * This represents an audio engine and it is responsible
  25659. * to play, synchronize and analyse sounds throughout the application.
  25660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25661. */
  25662. export interface IAudioEngine extends IDisposable {
  25663. /**
  25664. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25665. */
  25666. readonly canUseWebAudio: boolean;
  25667. /**
  25668. * Gets the current AudioContext if available.
  25669. */
  25670. readonly audioContext: Nullable<AudioContext>;
  25671. /**
  25672. * The master gain node defines the global audio volume of your audio engine.
  25673. */
  25674. readonly masterGain: GainNode;
  25675. /**
  25676. * Gets whether or not mp3 are supported by your browser.
  25677. */
  25678. readonly isMP3supported: boolean;
  25679. /**
  25680. * Gets whether or not ogg are supported by your browser.
  25681. */
  25682. readonly isOGGsupported: boolean;
  25683. /**
  25684. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25685. * @ignoreNaming
  25686. */
  25687. WarnedWebAudioUnsupported: boolean;
  25688. /**
  25689. * Defines if the audio engine relies on a custom unlocked button.
  25690. * In this case, the embedded button will not be displayed.
  25691. */
  25692. useCustomUnlockedButton: boolean;
  25693. /**
  25694. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25695. */
  25696. readonly unlocked: boolean;
  25697. /**
  25698. * Event raised when audio has been unlocked on the browser.
  25699. */
  25700. onAudioUnlockedObservable: Observable<AudioEngine>;
  25701. /**
  25702. * Event raised when audio has been locked on the browser.
  25703. */
  25704. onAudioLockedObservable: Observable<AudioEngine>;
  25705. /**
  25706. * Flags the audio engine in Locked state.
  25707. * This happens due to new browser policies preventing audio to autoplay.
  25708. */
  25709. lock(): void;
  25710. /**
  25711. * Unlocks the audio engine once a user action has been done on the dom.
  25712. * This is helpful to resume play once browser policies have been satisfied.
  25713. */
  25714. unlock(): void;
  25715. }
  25716. /**
  25717. * This represents the default audio engine used in babylon.
  25718. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25720. */
  25721. export class AudioEngine implements IAudioEngine {
  25722. private _audioContext;
  25723. private _audioContextInitialized;
  25724. private _muteButton;
  25725. private _hostElement;
  25726. /**
  25727. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25728. */
  25729. canUseWebAudio: boolean;
  25730. /**
  25731. * The master gain node defines the global audio volume of your audio engine.
  25732. */
  25733. masterGain: GainNode;
  25734. /**
  25735. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25736. * @ignoreNaming
  25737. */
  25738. WarnedWebAudioUnsupported: boolean;
  25739. /**
  25740. * Gets whether or not mp3 are supported by your browser.
  25741. */
  25742. isMP3supported: boolean;
  25743. /**
  25744. * Gets whether or not ogg are supported by your browser.
  25745. */
  25746. isOGGsupported: boolean;
  25747. /**
  25748. * Gets whether audio has been unlocked on the device.
  25749. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25750. * a user interaction has happened.
  25751. */
  25752. unlocked: boolean;
  25753. /**
  25754. * Defines if the audio engine relies on a custom unlocked button.
  25755. * In this case, the embedded button will not be displayed.
  25756. */
  25757. useCustomUnlockedButton: boolean;
  25758. /**
  25759. * Event raised when audio has been unlocked on the browser.
  25760. */
  25761. onAudioUnlockedObservable: Observable<AudioEngine>;
  25762. /**
  25763. * Event raised when audio has been locked on the browser.
  25764. */
  25765. onAudioLockedObservable: Observable<AudioEngine>;
  25766. /**
  25767. * Gets the current AudioContext if available.
  25768. */
  25769. readonly audioContext: Nullable<AudioContext>;
  25770. private _connectedAnalyser;
  25771. /**
  25772. * Instantiates a new audio engine.
  25773. *
  25774. * There should be only one per page as some browsers restrict the number
  25775. * of audio contexts you can create.
  25776. * @param hostElement defines the host element where to display the mute icon if necessary
  25777. */
  25778. constructor(hostElement?: Nullable<HTMLElement>);
  25779. /**
  25780. * Flags the audio engine in Locked state.
  25781. * This happens due to new browser policies preventing audio to autoplay.
  25782. */
  25783. lock(): void;
  25784. /**
  25785. * Unlocks the audio engine once a user action has been done on the dom.
  25786. * This is helpful to resume play once browser policies have been satisfied.
  25787. */
  25788. unlock(): void;
  25789. private _resumeAudioContext;
  25790. private _initializeAudioContext;
  25791. private _tryToRun;
  25792. private _triggerRunningState;
  25793. private _triggerSuspendedState;
  25794. private _displayMuteButton;
  25795. private _moveButtonToTopLeft;
  25796. private _onResize;
  25797. private _hideMuteButton;
  25798. /**
  25799. * Destroy and release the resources associated with the audio ccontext.
  25800. */
  25801. dispose(): void;
  25802. /**
  25803. * Gets the global volume sets on the master gain.
  25804. * @returns the global volume if set or -1 otherwise
  25805. */
  25806. getGlobalVolume(): number;
  25807. /**
  25808. * Sets the global volume of your experience (sets on the master gain).
  25809. * @param newVolume Defines the new global volume of the application
  25810. */
  25811. setGlobalVolume(newVolume: number): void;
  25812. /**
  25813. * Connect the audio engine to an audio analyser allowing some amazing
  25814. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  25815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  25816. * @param analyser The analyser to connect to the engine
  25817. */
  25818. connectToAnalyser(analyser: Analyser): void;
  25819. }
  25820. }
  25821. declare module BABYLON {
  25822. /**
  25823. * Interface used to present a loading screen while loading a scene
  25824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25825. */
  25826. export interface ILoadingScreen {
  25827. /**
  25828. * Function called to display the loading screen
  25829. */
  25830. displayLoadingUI: () => void;
  25831. /**
  25832. * Function called to hide the loading screen
  25833. */
  25834. hideLoadingUI: () => void;
  25835. /**
  25836. * Gets or sets the color to use for the background
  25837. */
  25838. loadingUIBackgroundColor: string;
  25839. /**
  25840. * Gets or sets the text to display while loading
  25841. */
  25842. loadingUIText: string;
  25843. }
  25844. /**
  25845. * Class used for the default loading screen
  25846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  25847. */
  25848. export class DefaultLoadingScreen implements ILoadingScreen {
  25849. private _renderingCanvas;
  25850. private _loadingText;
  25851. private _loadingDivBackgroundColor;
  25852. private _loadingDiv;
  25853. private _loadingTextDiv;
  25854. /**
  25855. * Creates a new default loading screen
  25856. * @param _renderingCanvas defines the canvas used to render the scene
  25857. * @param _loadingText defines the default text to display
  25858. * @param _loadingDivBackgroundColor defines the default background color
  25859. */
  25860. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  25861. /**
  25862. * Function called to display the loading screen
  25863. */
  25864. displayLoadingUI(): void;
  25865. /**
  25866. * Function called to hide the loading screen
  25867. */
  25868. hideLoadingUI(): void;
  25869. /**
  25870. * Gets or sets the text to display while loading
  25871. */
  25872. loadingUIText: string;
  25873. /**
  25874. * Gets or sets the color to use for the background
  25875. */
  25876. loadingUIBackgroundColor: string;
  25877. private _resizeLoadingUI;
  25878. }
  25879. }
  25880. declare module BABYLON {
  25881. /**
  25882. * Settings for finer control over video usage
  25883. */
  25884. export interface VideoTextureSettings {
  25885. /**
  25886. * Applies `autoplay` to video, if specified
  25887. */
  25888. autoPlay?: boolean;
  25889. /**
  25890. * Applies `loop` to video, if specified
  25891. */
  25892. loop?: boolean;
  25893. /**
  25894. * Automatically updates internal texture from video at every frame in the render loop
  25895. */
  25896. autoUpdateTexture: boolean;
  25897. /**
  25898. * Image src displayed during the video loading or until the user interacts with the video.
  25899. */
  25900. poster?: string;
  25901. }
  25902. /**
  25903. * If you want to display a video in your scene, this is the special texture for that.
  25904. * This special texture works similar to other textures, with the exception of a few parameters.
  25905. * @see https://doc.babylonjs.com/how_to/video_texture
  25906. */
  25907. export class VideoTexture extends Texture {
  25908. /**
  25909. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  25910. */
  25911. readonly autoUpdateTexture: boolean;
  25912. /**
  25913. * The video instance used by the texture internally
  25914. */
  25915. readonly video: HTMLVideoElement;
  25916. private _onUserActionRequestedObservable;
  25917. /**
  25918. * Event triggerd when a dom action is required by the user to play the video.
  25919. * This happens due to recent changes in browser policies preventing video to auto start.
  25920. */
  25921. readonly onUserActionRequestedObservable: Observable<Texture>;
  25922. private _generateMipMaps;
  25923. private _engine;
  25924. private _stillImageCaptured;
  25925. private _displayingPosterTexture;
  25926. private _settings;
  25927. private _createInternalTextureOnEvent;
  25928. /**
  25929. * Creates a video texture.
  25930. * If you want to display a video in your scene, this is the special texture for that.
  25931. * This special texture works similar to other textures, with the exception of a few parameters.
  25932. * @see https://doc.babylonjs.com/how_to/video_texture
  25933. * @param name optional name, will detect from video source, if not defined
  25934. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  25935. * @param scene is obviously the current scene.
  25936. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  25937. * @param invertY is false by default but can be used to invert video on Y axis
  25938. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  25939. * @param settings allows finer control over video usage
  25940. */
  25941. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  25942. private _getName;
  25943. private _getVideo;
  25944. private _createInternalTexture;
  25945. private reset;
  25946. /**
  25947. * @hidden Internal method to initiate `update`.
  25948. */
  25949. _rebuild(): void;
  25950. /**
  25951. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  25952. */
  25953. update(): void;
  25954. /**
  25955. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  25956. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  25957. */
  25958. updateTexture(isVisible: boolean): void;
  25959. protected _updateInternalTexture: () => void;
  25960. /**
  25961. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  25962. * @param url New url.
  25963. */
  25964. updateURL(url: string): void;
  25965. /**
  25966. * Dispose the texture and release its associated resources.
  25967. */
  25968. dispose(): void;
  25969. /**
  25970. * Creates a video texture straight from your WebCam video feed.
  25971. * @param scene Define the scene the texture should be created in
  25972. * @param onReady Define a callback to triggered once the texture will be ready
  25973. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  25974. */
  25975. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  25976. minWidth: number;
  25977. maxWidth: number;
  25978. minHeight: number;
  25979. maxHeight: number;
  25980. deviceId: string;
  25981. }): void;
  25982. }
  25983. }
  25984. declare module BABYLON {
  25985. /**
  25986. * Interface for attribute information associated with buffer instanciation
  25987. */
  25988. export class InstancingAttributeInfo {
  25989. /**
  25990. * Index/offset of the attribute in the vertex shader
  25991. */
  25992. index: number;
  25993. /**
  25994. * size of the attribute, 1, 2, 3 or 4
  25995. */
  25996. attributeSize: number;
  25997. /**
  25998. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  25999. * default is FLOAT
  26000. */
  26001. attribyteType: number;
  26002. /**
  26003. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26004. */
  26005. normalized: boolean;
  26006. /**
  26007. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26008. */
  26009. offset: number;
  26010. /**
  26011. * Name of the GLSL attribute, for debugging purpose only
  26012. */
  26013. attributeName: string;
  26014. }
  26015. /**
  26016. * Define options used to create a depth texture
  26017. */
  26018. export class DepthTextureCreationOptions {
  26019. /** Specifies whether or not a stencil should be allocated in the texture */
  26020. generateStencil?: boolean;
  26021. /** Specifies whether or not bilinear filtering is enable on the texture */
  26022. bilinearFiltering?: boolean;
  26023. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26024. comparisonFunction?: number;
  26025. /** Specifies if the created texture is a cube texture */
  26026. isCube?: boolean;
  26027. }
  26028. /**
  26029. * Class used to describe the capabilities of the engine relatively to the current browser
  26030. */
  26031. export class EngineCapabilities {
  26032. /** Maximum textures units per fragment shader */
  26033. maxTexturesImageUnits: number;
  26034. /** Maximum texture units per vertex shader */
  26035. maxVertexTextureImageUnits: number;
  26036. /** Maximum textures units in the entire pipeline */
  26037. maxCombinedTexturesImageUnits: number;
  26038. /** Maximum texture size */
  26039. maxTextureSize: number;
  26040. /** Maximum cube texture size */
  26041. maxCubemapTextureSize: number;
  26042. /** Maximum render texture size */
  26043. maxRenderTextureSize: number;
  26044. /** Maximum number of vertex attributes */
  26045. maxVertexAttribs: number;
  26046. /** Maximum number of varyings */
  26047. maxVaryingVectors: number;
  26048. /** Maximum number of uniforms per vertex shader */
  26049. maxVertexUniformVectors: number;
  26050. /** Maximum number of uniforms per fragment shader */
  26051. maxFragmentUniformVectors: number;
  26052. /** Defines if standard derivates (dx/dy) are supported */
  26053. standardDerivatives: boolean;
  26054. /** Defines if s3tc texture compression is supported */
  26055. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26056. /** Defines if pvrtc texture compression is supported */
  26057. pvrtc: any;
  26058. /** Defines if etc1 texture compression is supported */
  26059. etc1: any;
  26060. /** Defines if etc2 texture compression is supported */
  26061. etc2: any;
  26062. /** Defines if astc texture compression is supported */
  26063. astc: any;
  26064. /** Defines if float textures are supported */
  26065. textureFloat: boolean;
  26066. /** Defines if vertex array objects are supported */
  26067. vertexArrayObject: boolean;
  26068. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26069. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26070. /** Gets the maximum level of anisotropy supported */
  26071. maxAnisotropy: number;
  26072. /** Defines if instancing is supported */
  26073. instancedArrays: boolean;
  26074. /** Defines if 32 bits indices are supported */
  26075. uintIndices: boolean;
  26076. /** Defines if high precision shaders are supported */
  26077. highPrecisionShaderSupported: boolean;
  26078. /** Defines if depth reading in the fragment shader is supported */
  26079. fragmentDepthSupported: boolean;
  26080. /** Defines if float texture linear filtering is supported*/
  26081. textureFloatLinearFiltering: boolean;
  26082. /** Defines if rendering to float textures is supported */
  26083. textureFloatRender: boolean;
  26084. /** Defines if half float textures are supported*/
  26085. textureHalfFloat: boolean;
  26086. /** Defines if half float texture linear filtering is supported*/
  26087. textureHalfFloatLinearFiltering: boolean;
  26088. /** Defines if rendering to half float textures is supported */
  26089. textureHalfFloatRender: boolean;
  26090. /** Defines if textureLOD shader command is supported */
  26091. textureLOD: boolean;
  26092. /** Defines if draw buffers extension is supported */
  26093. drawBuffersExtension: boolean;
  26094. /** Defines if depth textures are supported */
  26095. depthTextureExtension: boolean;
  26096. /** Defines if float color buffer are supported */
  26097. colorBufferFloat: boolean;
  26098. /** Gets disjoint timer query extension (null if not supported) */
  26099. timerQuery: EXT_disjoint_timer_query;
  26100. /** Defines if timestamp can be used with timer query */
  26101. canUseTimestampForTimerQuery: boolean;
  26102. /** Function used to let the system compiles shaders in background */
  26103. parallelShaderCompile: {
  26104. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26105. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26106. COMPLETION_STATUS_KHR: number;
  26107. };
  26108. }
  26109. /** Interface defining initialization parameters for Engine class */
  26110. export interface EngineOptions extends WebGLContextAttributes {
  26111. /**
  26112. * Defines if the engine should no exceed a specified device ratio
  26113. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26114. */
  26115. limitDeviceRatio?: number;
  26116. /**
  26117. * Defines if webvr should be enabled automatically
  26118. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26119. */
  26120. autoEnableWebVR?: boolean;
  26121. /**
  26122. * Defines if webgl2 should be turned off even if supported
  26123. * @see http://doc.babylonjs.com/features/webgl2
  26124. */
  26125. disableWebGL2Support?: boolean;
  26126. /**
  26127. * Defines if webaudio should be initialized as well
  26128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26129. */
  26130. audioEngine?: boolean;
  26131. /**
  26132. * Defines if animations should run using a deterministic lock step
  26133. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26134. */
  26135. deterministicLockstep?: boolean;
  26136. /** Defines the maximum steps to use with deterministic lock step mode */
  26137. lockstepMaxSteps?: number;
  26138. /**
  26139. * Defines that engine should ignore context lost events
  26140. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26141. */
  26142. doNotHandleContextLost?: boolean;
  26143. /**
  26144. * Defines that engine should ignore modifying touch action attribute and style
  26145. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26146. */
  26147. doNotHandleTouchAction?: boolean;
  26148. }
  26149. /**
  26150. * Defines the interface used by display changed events
  26151. */
  26152. export interface IDisplayChangedEventArgs {
  26153. /** Gets the vrDisplay object (if any) */
  26154. vrDisplay: Nullable<any>;
  26155. /** Gets a boolean indicating if webVR is supported */
  26156. vrSupported: boolean;
  26157. }
  26158. /**
  26159. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26160. */
  26161. export class Engine {
  26162. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26163. static ExceptionList: ({
  26164. key: string;
  26165. capture: string;
  26166. captureConstraint: number;
  26167. targets: string[];
  26168. } | {
  26169. key: string;
  26170. capture: null;
  26171. captureConstraint: null;
  26172. targets: string[];
  26173. })[];
  26174. /** Gets the list of created engines */
  26175. static readonly Instances: Engine[];
  26176. /**
  26177. * Gets the latest created engine
  26178. */
  26179. static readonly LastCreatedEngine: Nullable<Engine>;
  26180. /**
  26181. * Gets the latest created scene
  26182. */
  26183. static readonly LastCreatedScene: Nullable<Scene>;
  26184. /**
  26185. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26186. * @param flag defines which part of the materials must be marked as dirty
  26187. * @param predicate defines a predicate used to filter which materials should be affected
  26188. */
  26189. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26190. /**
  26191. * Hidden
  26192. */
  26193. static _TextureLoaders: IInternalTextureLoader[];
  26194. /** Defines that alpha blending is disabled */
  26195. static readonly ALPHA_DISABLE: number;
  26196. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26197. static readonly ALPHA_ADD: number;
  26198. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26199. static readonly ALPHA_COMBINE: number;
  26200. /** Defines that alpha blending to DEST - SRC * DEST */
  26201. static readonly ALPHA_SUBTRACT: number;
  26202. /** Defines that alpha blending to SRC * DEST */
  26203. static readonly ALPHA_MULTIPLY: number;
  26204. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26205. static readonly ALPHA_MAXIMIZED: number;
  26206. /** Defines that alpha blending to SRC + DEST */
  26207. static readonly ALPHA_ONEONE: number;
  26208. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26209. static readonly ALPHA_PREMULTIPLIED: number;
  26210. /**
  26211. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26212. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26213. */
  26214. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26215. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26216. static readonly ALPHA_INTERPOLATE: number;
  26217. /**
  26218. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26219. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26220. */
  26221. static readonly ALPHA_SCREENMODE: number;
  26222. /** Defines that the ressource is not delayed*/
  26223. static readonly DELAYLOADSTATE_NONE: number;
  26224. /** Defines that the ressource was successfully delay loaded */
  26225. static readonly DELAYLOADSTATE_LOADED: number;
  26226. /** Defines that the ressource is currently delay loading */
  26227. static readonly DELAYLOADSTATE_LOADING: number;
  26228. /** Defines that the ressource is delayed and has not started loading */
  26229. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26230. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26231. static readonly NEVER: number;
  26232. /** 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 */
  26233. static readonly ALWAYS: number;
  26234. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26235. static readonly LESS: number;
  26236. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26237. static readonly EQUAL: number;
  26238. /** 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 */
  26239. static readonly LEQUAL: number;
  26240. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26241. static readonly GREATER: number;
  26242. /** 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 */
  26243. static readonly GEQUAL: number;
  26244. /** 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 */
  26245. static readonly NOTEQUAL: number;
  26246. /** Passed to stencilOperation to specify that stencil value must be kept */
  26247. static readonly KEEP: number;
  26248. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26249. static readonly REPLACE: number;
  26250. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26251. static readonly INCR: number;
  26252. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26253. static readonly DECR: number;
  26254. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26255. static readonly INVERT: number;
  26256. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26257. static readonly INCR_WRAP: number;
  26258. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26259. static readonly DECR_WRAP: number;
  26260. /** Texture is not repeating outside of 0..1 UVs */
  26261. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26262. /** Texture is repeating outside of 0..1 UVs */
  26263. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26264. /** Texture is repeating and mirrored */
  26265. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26266. /** ALPHA */
  26267. static readonly TEXTUREFORMAT_ALPHA: number;
  26268. /** LUMINANCE */
  26269. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26270. /** LUMINANCE_ALPHA */
  26271. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26272. /** RGB */
  26273. static readonly TEXTUREFORMAT_RGB: number;
  26274. /** RGBA */
  26275. static readonly TEXTUREFORMAT_RGBA: number;
  26276. /** RED */
  26277. static readonly TEXTUREFORMAT_RED: number;
  26278. /** RED (2nd reference) */
  26279. static readonly TEXTUREFORMAT_R: number;
  26280. /** RG */
  26281. static readonly TEXTUREFORMAT_RG: number;
  26282. /** RED_INTEGER */
  26283. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26284. /** RED_INTEGER (2nd reference) */
  26285. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26286. /** RG_INTEGER */
  26287. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26288. /** RGB_INTEGER */
  26289. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26290. /** RGBA_INTEGER */
  26291. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26292. /** UNSIGNED_BYTE */
  26293. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26294. /** UNSIGNED_BYTE (2nd reference) */
  26295. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26296. /** FLOAT */
  26297. static readonly TEXTURETYPE_FLOAT: number;
  26298. /** HALF_FLOAT */
  26299. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26300. /** BYTE */
  26301. static readonly TEXTURETYPE_BYTE: number;
  26302. /** SHORT */
  26303. static readonly TEXTURETYPE_SHORT: number;
  26304. /** UNSIGNED_SHORT */
  26305. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26306. /** INT */
  26307. static readonly TEXTURETYPE_INT: number;
  26308. /** UNSIGNED_INT */
  26309. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26310. /** UNSIGNED_SHORT_4_4_4_4 */
  26311. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26312. /** UNSIGNED_SHORT_5_5_5_1 */
  26313. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26314. /** UNSIGNED_SHORT_5_6_5 */
  26315. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26316. /** UNSIGNED_INT_2_10_10_10_REV */
  26317. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26318. /** UNSIGNED_INT_24_8 */
  26319. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26320. /** UNSIGNED_INT_10F_11F_11F_REV */
  26321. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26322. /** UNSIGNED_INT_5_9_9_9_REV */
  26323. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26324. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26325. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26326. /** nearest is mag = nearest and min = nearest and mip = linear */
  26327. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26328. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26329. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26330. /** Trilinear is mag = linear and min = linear and mip = linear */
  26331. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26332. /** nearest is mag = nearest and min = nearest and mip = linear */
  26333. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26334. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26335. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26336. /** Trilinear is mag = linear and min = linear and mip = linear */
  26337. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26338. /** mag = nearest and min = nearest and mip = nearest */
  26339. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26340. /** mag = nearest and min = linear and mip = nearest */
  26341. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26342. /** mag = nearest and min = linear and mip = linear */
  26343. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26344. /** mag = nearest and min = linear and mip = none */
  26345. static readonly TEXTURE_NEAREST_LINEAR: number;
  26346. /** mag = nearest and min = nearest and mip = none */
  26347. static readonly TEXTURE_NEAREST_NEAREST: number;
  26348. /** mag = linear and min = nearest and mip = nearest */
  26349. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26350. /** mag = linear and min = nearest and mip = linear */
  26351. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26352. /** mag = linear and min = linear and mip = none */
  26353. static readonly TEXTURE_LINEAR_LINEAR: number;
  26354. /** mag = linear and min = nearest and mip = none */
  26355. static readonly TEXTURE_LINEAR_NEAREST: number;
  26356. /** Explicit coordinates mode */
  26357. static readonly TEXTURE_EXPLICIT_MODE: number;
  26358. /** Spherical coordinates mode */
  26359. static readonly TEXTURE_SPHERICAL_MODE: number;
  26360. /** Planar coordinates mode */
  26361. static readonly TEXTURE_PLANAR_MODE: number;
  26362. /** Cubic coordinates mode */
  26363. static readonly TEXTURE_CUBIC_MODE: number;
  26364. /** Projection coordinates mode */
  26365. static readonly TEXTURE_PROJECTION_MODE: number;
  26366. /** Skybox coordinates mode */
  26367. static readonly TEXTURE_SKYBOX_MODE: number;
  26368. /** Inverse Cubic coordinates mode */
  26369. static readonly TEXTURE_INVCUBIC_MODE: number;
  26370. /** Equirectangular coordinates mode */
  26371. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26372. /** Equirectangular Fixed coordinates mode */
  26373. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26374. /** Equirectangular Fixed Mirrored coordinates mode */
  26375. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26376. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26377. static readonly SCALEMODE_FLOOR: number;
  26378. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26379. static readonly SCALEMODE_NEAREST: number;
  26380. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26381. static readonly SCALEMODE_CEILING: number;
  26382. /**
  26383. * Returns the current version of the framework
  26384. */
  26385. static readonly Version: string;
  26386. /**
  26387. * Returns a string describing the current engine
  26388. */
  26389. readonly description: string;
  26390. /**
  26391. * Gets or sets the epsilon value used by collision engine
  26392. */
  26393. static CollisionsEpsilon: number;
  26394. /**
  26395. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26396. */
  26397. static ShadersRepository: string;
  26398. /**
  26399. * Method called to create the default loading screen.
  26400. * This can be overriden in your own app.
  26401. * @param canvas The rendering canvas element
  26402. * @returns The loading screen
  26403. */
  26404. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26405. /**
  26406. * Method called to create the default rescale post process on each engine.
  26407. */
  26408. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26409. /**
  26410. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26411. */
  26412. forcePOTTextures: boolean;
  26413. /**
  26414. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26415. */
  26416. isFullscreen: boolean;
  26417. /**
  26418. * Gets a boolean indicating if the pointer is currently locked
  26419. */
  26420. isPointerLock: boolean;
  26421. /**
  26422. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26423. */
  26424. cullBackFaces: boolean;
  26425. /**
  26426. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26427. */
  26428. renderEvenInBackground: boolean;
  26429. /**
  26430. * Gets or sets a boolean indicating that cache can be kept between frames
  26431. */
  26432. preventCacheWipeBetweenFrames: boolean;
  26433. /**
  26434. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26435. **/
  26436. enableOfflineSupport: boolean;
  26437. /**
  26438. * 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)
  26439. **/
  26440. disableManifestCheck: boolean;
  26441. /**
  26442. * Gets the list of created scenes
  26443. */
  26444. scenes: Scene[];
  26445. /**
  26446. * Event raised when a new scene is created
  26447. */
  26448. onNewSceneAddedObservable: Observable<Scene>;
  26449. /**
  26450. * Gets the list of created postprocesses
  26451. */
  26452. postProcesses: PostProcess[];
  26453. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26454. validateShaderPrograms: boolean;
  26455. /**
  26456. * Observable event triggered each time the rendering canvas is resized
  26457. */
  26458. onResizeObservable: Observable<Engine>;
  26459. /**
  26460. * Observable event triggered each time the canvas loses focus
  26461. */
  26462. onCanvasBlurObservable: Observable<Engine>;
  26463. /**
  26464. * Observable event triggered each time the canvas gains focus
  26465. */
  26466. onCanvasFocusObservable: Observable<Engine>;
  26467. /**
  26468. * Observable event triggered each time the canvas receives pointerout event
  26469. */
  26470. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26471. /**
  26472. * Observable event triggered before each texture is initialized
  26473. */
  26474. onBeforeTextureInitObservable: Observable<Texture>;
  26475. private _vrDisplay;
  26476. private _vrSupported;
  26477. private _oldSize;
  26478. private _oldHardwareScaleFactor;
  26479. private _vrExclusivePointerMode;
  26480. private _webVRInitPromise;
  26481. /**
  26482. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26483. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26484. */
  26485. readonly isInVRExclusivePointerMode: boolean;
  26486. /**
  26487. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26488. */
  26489. disableUniformBuffers: boolean;
  26490. /** @hidden */
  26491. _uniformBuffers: UniformBuffer[];
  26492. /**
  26493. * Gets a boolean indicating that the engine supports uniform buffers
  26494. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26495. */
  26496. readonly supportsUniformBuffers: boolean;
  26497. /**
  26498. * Observable raised when the engine begins a new frame
  26499. */
  26500. onBeginFrameObservable: Observable<Engine>;
  26501. /**
  26502. * If set, will be used to request the next animation frame for the render loop
  26503. */
  26504. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26505. /**
  26506. * Observable raised when the engine ends the current frame
  26507. */
  26508. onEndFrameObservable: Observable<Engine>;
  26509. /**
  26510. * Observable raised when the engine is about to compile a shader
  26511. */
  26512. onBeforeShaderCompilationObservable: Observable<Engine>;
  26513. /**
  26514. * Observable raised when the engine has jsut compiled a shader
  26515. */
  26516. onAfterShaderCompilationObservable: Observable<Engine>;
  26517. /** @hidden */
  26518. _gl: WebGLRenderingContext;
  26519. private _renderingCanvas;
  26520. private _windowIsBackground;
  26521. private _webGLVersion;
  26522. /**
  26523. * Gets a boolean indicating that only power of 2 textures are supported
  26524. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26525. */
  26526. readonly needPOTTextures: boolean;
  26527. /** @hidden */
  26528. _badOS: boolean;
  26529. /** @hidden */
  26530. _badDesktopOS: boolean;
  26531. /**
  26532. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26533. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26534. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26535. */
  26536. disableTextureBindingOptimization: boolean;
  26537. /**
  26538. * Gets the audio engine
  26539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26540. * @ignorenaming
  26541. */
  26542. static audioEngine: IAudioEngine;
  26543. /**
  26544. * Default AudioEngine factory responsible of creating the Audio Engine.
  26545. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26546. */
  26547. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26548. /**
  26549. * Default offline support factory responsible of creating a tool used to store data locally.
  26550. * By default, this will create a Database object if the workload has been embedded.
  26551. */
  26552. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26553. private _onFocus;
  26554. private _onBlur;
  26555. private _onCanvasPointerOut;
  26556. private _onCanvasBlur;
  26557. private _onCanvasFocus;
  26558. private _onFullscreenChange;
  26559. private _onPointerLockChange;
  26560. private _onVRDisplayPointerRestricted;
  26561. private _onVRDisplayPointerUnrestricted;
  26562. private _onVrDisplayConnect;
  26563. private _onVrDisplayDisconnect;
  26564. private _onVrDisplayPresentChange;
  26565. /**
  26566. * Observable signaled when VR display mode changes
  26567. */
  26568. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26569. /**
  26570. * Observable signaled when VR request present is complete
  26571. */
  26572. onVRRequestPresentComplete: Observable<boolean>;
  26573. /**
  26574. * Observable signaled when VR request present starts
  26575. */
  26576. onVRRequestPresentStart: Observable<Engine>;
  26577. private _hardwareScalingLevel;
  26578. /** @hidden */
  26579. protected _caps: EngineCapabilities;
  26580. private _pointerLockRequested;
  26581. private _isStencilEnable;
  26582. private _colorWrite;
  26583. private _loadingScreen;
  26584. /** @hidden */
  26585. _drawCalls: PerfCounter;
  26586. /** @hidden */
  26587. _textureCollisions: PerfCounter;
  26588. private _glVersion;
  26589. private _glRenderer;
  26590. private _glVendor;
  26591. private _videoTextureSupported;
  26592. private _renderingQueueLaunched;
  26593. private _activeRenderLoops;
  26594. private _deterministicLockstep;
  26595. private _lockstepMaxSteps;
  26596. /**
  26597. * Observable signaled when a context lost event is raised
  26598. */
  26599. onContextLostObservable: Observable<Engine>;
  26600. /**
  26601. * Observable signaled when a context restored event is raised
  26602. */
  26603. onContextRestoredObservable: Observable<Engine>;
  26604. private _onContextLost;
  26605. private _onContextRestored;
  26606. private _contextWasLost;
  26607. private _doNotHandleContextLost;
  26608. /**
  26609. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26611. */
  26612. doNotHandleContextLost: boolean;
  26613. private _performanceMonitor;
  26614. private _fps;
  26615. private _deltaTime;
  26616. /**
  26617. * Turn this value on if you want to pause FPS computation when in background
  26618. */
  26619. disablePerformanceMonitorInBackground: boolean;
  26620. /**
  26621. * Gets the performance monitor attached to this engine
  26622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26623. */
  26624. readonly performanceMonitor: PerformanceMonitor;
  26625. /** @hidden */
  26626. protected _depthCullingState: _DepthCullingState;
  26627. /** @hidden */
  26628. protected _stencilState: _StencilState;
  26629. /** @hidden */
  26630. protected _alphaState: _AlphaState;
  26631. /** @hidden */
  26632. protected _alphaMode: number;
  26633. protected _internalTexturesCache: InternalTexture[];
  26634. /** @hidden */
  26635. protected _activeChannel: number;
  26636. private _currentTextureChannel;
  26637. /** @hidden */
  26638. protected _boundTexturesCache: {
  26639. [key: string]: Nullable<InternalTexture>;
  26640. };
  26641. /** @hidden */
  26642. protected _currentEffect: Nullable<Effect>;
  26643. /** @hidden */
  26644. protected _currentProgram: Nullable<WebGLProgram>;
  26645. private _compiledEffects;
  26646. private _vertexAttribArraysEnabled;
  26647. /** @hidden */
  26648. protected _cachedViewport: Nullable<Viewport>;
  26649. private _cachedVertexArrayObject;
  26650. /** @hidden */
  26651. protected _cachedVertexBuffers: any;
  26652. /** @hidden */
  26653. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26654. /** @hidden */
  26655. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26656. /** @hidden */
  26657. protected _currentRenderTarget: Nullable<InternalTexture>;
  26658. private _uintIndicesCurrentlySet;
  26659. private _currentBoundBuffer;
  26660. /** @hidden */
  26661. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26662. private _currentBufferPointers;
  26663. private _currentInstanceLocations;
  26664. private _currentInstanceBuffers;
  26665. private _textureUnits;
  26666. private _firstBoundInternalTextureTracker;
  26667. private _lastBoundInternalTextureTracker;
  26668. private _workingCanvas;
  26669. private _workingContext;
  26670. private _rescalePostProcess;
  26671. private _dummyFramebuffer;
  26672. private _externalData;
  26673. private _bindedRenderFunction;
  26674. private _vaoRecordInProgress;
  26675. private _mustWipeVertexAttributes;
  26676. private _emptyTexture;
  26677. private _emptyCubeTexture;
  26678. private _emptyTexture3D;
  26679. /** @hidden */
  26680. _frameHandler: number;
  26681. private _nextFreeTextureSlots;
  26682. private _maxSimultaneousTextures;
  26683. private _activeRequests;
  26684. private _texturesSupported;
  26685. private _textureFormatInUse;
  26686. /**
  26687. * Gets the list of texture formats supported
  26688. */
  26689. readonly texturesSupported: Array<string>;
  26690. /**
  26691. * Gets the list of texture formats in use
  26692. */
  26693. readonly textureFormatInUse: Nullable<string>;
  26694. /**
  26695. * Gets the current viewport
  26696. */
  26697. readonly currentViewport: Nullable<Viewport>;
  26698. /**
  26699. * Gets the default empty texture
  26700. */
  26701. readonly emptyTexture: InternalTexture;
  26702. /**
  26703. * Gets the default empty 3D texture
  26704. */
  26705. readonly emptyTexture3D: InternalTexture;
  26706. /**
  26707. * Gets the default empty cube texture
  26708. */
  26709. readonly emptyCubeTexture: InternalTexture;
  26710. /**
  26711. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26712. */
  26713. readonly premultipliedAlpha: boolean;
  26714. /**
  26715. * Creates a new engine
  26716. * @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
  26717. * @param antialias defines enable antialiasing (default: false)
  26718. * @param options defines further options to be sent to the getContext() function
  26719. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26720. */
  26721. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26722. private _disableTouchAction;
  26723. private _rebuildInternalTextures;
  26724. private _rebuildEffects;
  26725. /**
  26726. * Gets a boolean indicating if all created effects are ready
  26727. * @returns true if all effects are ready
  26728. */
  26729. areAllEffectsReady(): boolean;
  26730. private _rebuildBuffers;
  26731. private _initGLContext;
  26732. /**
  26733. * Gets version of the current webGL context
  26734. */
  26735. readonly webGLVersion: number;
  26736. /**
  26737. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26738. */
  26739. readonly isStencilEnable: boolean;
  26740. private _prepareWorkingCanvas;
  26741. /**
  26742. * Reset the texture cache to empty state
  26743. */
  26744. resetTextureCache(): void;
  26745. /**
  26746. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  26747. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26748. * @returns true if engine is in deterministic lock step mode
  26749. */
  26750. isDeterministicLockStep(): boolean;
  26751. /**
  26752. * Gets the max steps when engine is running in deterministic lock step
  26753. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26754. * @returns the max steps
  26755. */
  26756. getLockstepMaxSteps(): number;
  26757. /**
  26758. * Gets an object containing information about the current webGL context
  26759. * @returns an object containing the vender, the renderer and the version of the current webGL context
  26760. */
  26761. getGlInfo(): {
  26762. vendor: string;
  26763. renderer: string;
  26764. version: string;
  26765. };
  26766. /**
  26767. * Gets current aspect ratio
  26768. * @param camera defines the camera to use to get the aspect ratio
  26769. * @param useScreen defines if screen size must be used (or the current render target if any)
  26770. * @returns a number defining the aspect ratio
  26771. */
  26772. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  26773. /**
  26774. * Gets current screen aspect ratio
  26775. * @returns a number defining the aspect ratio
  26776. */
  26777. getScreenAspectRatio(): number;
  26778. /**
  26779. * Gets the current render width
  26780. * @param useScreen defines if screen size must be used (or the current render target if any)
  26781. * @returns a number defining the current render width
  26782. */
  26783. getRenderWidth(useScreen?: boolean): number;
  26784. /**
  26785. * Gets the current render height
  26786. * @param useScreen defines if screen size must be used (or the current render target if any)
  26787. * @returns a number defining the current render height
  26788. */
  26789. getRenderHeight(useScreen?: boolean): number;
  26790. /**
  26791. * Gets the HTML canvas attached with the current webGL context
  26792. * @returns a HTML canvas
  26793. */
  26794. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  26795. /**
  26796. * Gets the client rect of the HTML canvas attached with the current webGL context
  26797. * @returns a client rectanglee
  26798. */
  26799. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  26800. /**
  26801. * Defines the hardware scaling level.
  26802. * By default the hardware scaling level is computed from the window device ratio.
  26803. * 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.
  26804. * @param level defines the level to use
  26805. */
  26806. setHardwareScalingLevel(level: number): void;
  26807. /**
  26808. * Gets the current hardware scaling level.
  26809. * By default the hardware scaling level is computed from the window device ratio.
  26810. * 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.
  26811. * @returns a number indicating the current hardware scaling level
  26812. */
  26813. getHardwareScalingLevel(): number;
  26814. /**
  26815. * Gets the list of loaded textures
  26816. * @returns an array containing all loaded textures
  26817. */
  26818. getLoadedTexturesCache(): InternalTexture[];
  26819. /**
  26820. * Gets the object containing all engine capabilities
  26821. * @returns the EngineCapabilities object
  26822. */
  26823. getCaps(): EngineCapabilities;
  26824. /**
  26825. * Gets the current depth function
  26826. * @returns a number defining the depth function
  26827. */
  26828. getDepthFunction(): Nullable<number>;
  26829. /**
  26830. * Sets the current depth function
  26831. * @param depthFunc defines the function to use
  26832. */
  26833. setDepthFunction(depthFunc: number): void;
  26834. /**
  26835. * Sets the current depth function to GREATER
  26836. */
  26837. setDepthFunctionToGreater(): void;
  26838. /**
  26839. * Sets the current depth function to GEQUAL
  26840. */
  26841. setDepthFunctionToGreaterOrEqual(): void;
  26842. /**
  26843. * Sets the current depth function to LESS
  26844. */
  26845. setDepthFunctionToLess(): void;
  26846. /**
  26847. * Sets the current depth function to LEQUAL
  26848. */
  26849. setDepthFunctionToLessOrEqual(): void;
  26850. /**
  26851. * Gets a boolean indicating if stencil buffer is enabled
  26852. * @returns the current stencil buffer state
  26853. */
  26854. getStencilBuffer(): boolean;
  26855. /**
  26856. * Enable or disable the stencil buffer
  26857. * @param enable defines if the stencil buffer must be enabled or disabled
  26858. */
  26859. setStencilBuffer(enable: boolean): void;
  26860. /**
  26861. * Gets the current stencil mask
  26862. * @returns a number defining the new stencil mask to use
  26863. */
  26864. getStencilMask(): number;
  26865. /**
  26866. * Sets the current stencil mask
  26867. * @param mask defines the new stencil mask to use
  26868. */
  26869. setStencilMask(mask: number): void;
  26870. /**
  26871. * Gets the current stencil function
  26872. * @returns a number defining the stencil function to use
  26873. */
  26874. getStencilFunction(): number;
  26875. /**
  26876. * Gets the current stencil reference value
  26877. * @returns a number defining the stencil reference value to use
  26878. */
  26879. getStencilFunctionReference(): number;
  26880. /**
  26881. * Gets the current stencil mask
  26882. * @returns a number defining the stencil mask to use
  26883. */
  26884. getStencilFunctionMask(): number;
  26885. /**
  26886. * Sets the current stencil function
  26887. * @param stencilFunc defines the new stencil function to use
  26888. */
  26889. setStencilFunction(stencilFunc: number): void;
  26890. /**
  26891. * Sets the current stencil reference
  26892. * @param reference defines the new stencil reference to use
  26893. */
  26894. setStencilFunctionReference(reference: number): void;
  26895. /**
  26896. * Sets the current stencil mask
  26897. * @param mask defines the new stencil mask to use
  26898. */
  26899. setStencilFunctionMask(mask: number): void;
  26900. /**
  26901. * Gets the current stencil operation when stencil fails
  26902. * @returns a number defining stencil operation to use when stencil fails
  26903. */
  26904. getStencilOperationFail(): number;
  26905. /**
  26906. * Gets the current stencil operation when depth fails
  26907. * @returns a number defining stencil operation to use when depth fails
  26908. */
  26909. getStencilOperationDepthFail(): number;
  26910. /**
  26911. * Gets the current stencil operation when stencil passes
  26912. * @returns a number defining stencil operation to use when stencil passes
  26913. */
  26914. getStencilOperationPass(): number;
  26915. /**
  26916. * Sets the stencil operation to use when stencil fails
  26917. * @param operation defines the stencil operation to use when stencil fails
  26918. */
  26919. setStencilOperationFail(operation: number): void;
  26920. /**
  26921. * Sets the stencil operation to use when depth fails
  26922. * @param operation defines the stencil operation to use when depth fails
  26923. */
  26924. setStencilOperationDepthFail(operation: number): void;
  26925. /**
  26926. * Sets the stencil operation to use when stencil passes
  26927. * @param operation defines the stencil operation to use when stencil passes
  26928. */
  26929. setStencilOperationPass(operation: number): void;
  26930. /**
  26931. * Sets a boolean indicating if the dithering state is enabled or disabled
  26932. * @param value defines the dithering state
  26933. */
  26934. setDitheringState(value: boolean): void;
  26935. /**
  26936. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  26937. * @param value defines the rasterizer state
  26938. */
  26939. setRasterizerState(value: boolean): void;
  26940. /**
  26941. * stop executing a render loop function and remove it from the execution array
  26942. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  26943. */
  26944. stopRenderLoop(renderFunction?: () => void): void;
  26945. /** @hidden */
  26946. _renderLoop(): void;
  26947. /**
  26948. * Register and execute a render loop. The engine can have more than one render function
  26949. * @param renderFunction defines the function to continuously execute
  26950. */
  26951. runRenderLoop(renderFunction: () => void): void;
  26952. /**
  26953. * Toggle full screen mode
  26954. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26955. */
  26956. switchFullscreen(requestPointerLock: boolean): void;
  26957. /**
  26958. * Enters full screen mode
  26959. * @param requestPointerLock defines if a pointer lock should be requested from the user
  26960. */
  26961. enterFullscreen(requestPointerLock: boolean): void;
  26962. /**
  26963. * Exits full screen mode
  26964. */
  26965. exitFullscreen(): void;
  26966. /**
  26967. * Clear the current render buffer or the current render target (if any is set up)
  26968. * @param color defines the color to use
  26969. * @param backBuffer defines if the back buffer must be cleared
  26970. * @param depth defines if the depth buffer must be cleared
  26971. * @param stencil defines if the stencil buffer must be cleared
  26972. */
  26973. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  26974. /**
  26975. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  26976. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26977. * @param y defines the y-coordinate of the corner of the clear rectangle
  26978. * @param width defines the width of the clear rectangle
  26979. * @param height defines the height of the clear rectangle
  26980. * @param clearColor defines the clear color
  26981. */
  26982. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  26983. /**
  26984. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  26985. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  26986. * @param y defines the y-coordinate of the corner of the clear rectangle
  26987. * @param width defines the width of the clear rectangle
  26988. * @param height defines the height of the clear rectangle
  26989. */
  26990. enableScissor(x: number, y: number, width: number, height: number): void;
  26991. /**
  26992. * Disable previously set scissor test rectangle
  26993. */
  26994. disableScissor(): void;
  26995. private _viewportCached;
  26996. /** @hidden */
  26997. _viewport(x: number, y: number, width: number, height: number): void;
  26998. /**
  26999. * Set the WebGL's viewport
  27000. * @param viewport defines the viewport element to be used
  27001. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27002. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27003. */
  27004. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27005. /**
  27006. * Directly set the WebGL Viewport
  27007. * @param x defines the x coordinate of the viewport (in screen space)
  27008. * @param y defines the y coordinate of the viewport (in screen space)
  27009. * @param width defines the width of the viewport (in screen space)
  27010. * @param height defines the height of the viewport (in screen space)
  27011. * @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
  27012. */
  27013. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27014. /**
  27015. * Begin a new frame
  27016. */
  27017. beginFrame(): void;
  27018. /**
  27019. * Enf the current frame
  27020. */
  27021. endFrame(): void;
  27022. /**
  27023. * Resize the view according to the canvas' size
  27024. */
  27025. resize(): void;
  27026. /**
  27027. * Force a specific size of the canvas
  27028. * @param width defines the new canvas' width
  27029. * @param height defines the new canvas' height
  27030. */
  27031. setSize(width: number, height: number): void;
  27032. /**
  27033. * Gets a boolean indicating if a webVR device was detected
  27034. * @returns true if a webVR device was detected
  27035. */
  27036. isVRDevicePresent(): boolean;
  27037. /**
  27038. * Gets the current webVR device
  27039. * @returns the current webVR device (or null)
  27040. */
  27041. getVRDevice(): any;
  27042. /**
  27043. * Initializes a webVR display and starts listening to display change events
  27044. * The onVRDisplayChangedObservable will be notified upon these changes
  27045. * @returns The onVRDisplayChangedObservable
  27046. */
  27047. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27048. /**
  27049. * Initializes a webVR display and starts listening to display change events
  27050. * The onVRDisplayChangedObservable will be notified upon these changes
  27051. * @returns A promise containing a VRDisplay and if vr is supported
  27052. */
  27053. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27054. /**
  27055. * Call this function to switch to webVR mode
  27056. * Will do nothing if webVR is not supported or if there is no webVR device
  27057. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27058. */
  27059. enableVR(): void;
  27060. /**
  27061. * Call this function to leave webVR mode
  27062. * Will do nothing if webVR is not supported or if there is no webVR device
  27063. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27064. */
  27065. disableVR(): void;
  27066. private _onVRFullScreenTriggered;
  27067. private _getVRDisplaysAsync;
  27068. /**
  27069. * Binds the frame buffer to the specified texture.
  27070. * @param texture The texture to render to or null for the default canvas
  27071. * @param faceIndex The face of the texture to render to in case of cube texture
  27072. * @param requiredWidth The width of the target to render to
  27073. * @param requiredHeight The height of the target to render to
  27074. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27075. * @param depthStencilTexture The depth stencil texture to use to render
  27076. * @param lodLevel defines le lod level to bind to the frame buffer
  27077. */
  27078. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27079. private bindUnboundFramebuffer;
  27080. /**
  27081. * Unbind the current render target texture from the webGL context
  27082. * @param texture defines the render target texture to unbind
  27083. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27084. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27085. */
  27086. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27087. /**
  27088. * Unbind a list of render target textures from the webGL context
  27089. * This is used only when drawBuffer extension or webGL2 are active
  27090. * @param textures defines the render target textures to unbind
  27091. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27092. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27093. */
  27094. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27095. /**
  27096. * Force the mipmap generation for the given render target texture
  27097. * @param texture defines the render target texture to use
  27098. */
  27099. generateMipMapsForCubemap(texture: InternalTexture): void;
  27100. /**
  27101. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27102. */
  27103. flushFramebuffer(): void;
  27104. /**
  27105. * Unbind the current render target and bind the default framebuffer
  27106. */
  27107. restoreDefaultFramebuffer(): void;
  27108. /**
  27109. * Create an uniform buffer
  27110. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27111. * @param elements defines the content of the uniform buffer
  27112. * @returns the webGL uniform buffer
  27113. */
  27114. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27115. /**
  27116. * Create a dynamic uniform buffer
  27117. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27118. * @param elements defines the content of the uniform buffer
  27119. * @returns the webGL uniform buffer
  27120. */
  27121. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27122. /**
  27123. * Update an existing uniform buffer
  27124. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27125. * @param uniformBuffer defines the target uniform buffer
  27126. * @param elements defines the content to update
  27127. * @param offset defines the offset in the uniform buffer where update should start
  27128. * @param count defines the size of the data to update
  27129. */
  27130. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27131. private _resetVertexBufferBinding;
  27132. /**
  27133. * Creates a vertex buffer
  27134. * @param data the data for the vertex buffer
  27135. * @returns the new WebGL static buffer
  27136. */
  27137. createVertexBuffer(data: DataArray): WebGLBuffer;
  27138. /**
  27139. * Creates a dynamic vertex buffer
  27140. * @param data the data for the dynamic vertex buffer
  27141. * @returns the new WebGL dynamic buffer
  27142. */
  27143. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27144. /**
  27145. * Update a dynamic index buffer
  27146. * @param indexBuffer defines the target index buffer
  27147. * @param indices defines the data to update
  27148. * @param offset defines the offset in the target index buffer where update should start
  27149. */
  27150. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27151. /**
  27152. * Updates a dynamic vertex buffer.
  27153. * @param vertexBuffer the vertex buffer to update
  27154. * @param data the data used to update the vertex buffer
  27155. * @param byteOffset the byte offset of the data
  27156. * @param byteLength the byte length of the data
  27157. */
  27158. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27159. private _resetIndexBufferBinding;
  27160. /**
  27161. * Creates a new index buffer
  27162. * @param indices defines the content of the index buffer
  27163. * @param updatable defines if the index buffer must be updatable
  27164. * @returns a new webGL buffer
  27165. */
  27166. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27167. /**
  27168. * Bind a webGL buffer to the webGL context
  27169. * @param buffer defines the buffer to bind
  27170. */
  27171. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27172. /**
  27173. * Bind an uniform buffer to the current webGL context
  27174. * @param buffer defines the buffer to bind
  27175. */
  27176. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27177. /**
  27178. * Bind a buffer to the current webGL context at a given location
  27179. * @param buffer defines the buffer to bind
  27180. * @param location defines the index where to bind the buffer
  27181. */
  27182. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27183. /**
  27184. * Bind a specific block at a given index in a specific shader program
  27185. * @param shaderProgram defines the shader program
  27186. * @param blockName defines the block name
  27187. * @param index defines the index where to bind the block
  27188. */
  27189. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27190. private bindIndexBuffer;
  27191. private bindBuffer;
  27192. /**
  27193. * update the bound buffer with the given data
  27194. * @param data defines the data to update
  27195. */
  27196. updateArrayBuffer(data: Float32Array): void;
  27197. private _vertexAttribPointer;
  27198. private _bindIndexBufferWithCache;
  27199. private _bindVertexBuffersAttributes;
  27200. /**
  27201. * Records a vertex array object
  27202. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27203. * @param vertexBuffers defines the list of vertex buffers to store
  27204. * @param indexBuffer defines the index buffer to store
  27205. * @param effect defines the effect to store
  27206. * @returns the new vertex array object
  27207. */
  27208. recordVertexArrayObject(vertexBuffers: {
  27209. [key: string]: VertexBuffer;
  27210. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27211. /**
  27212. * Bind a specific vertex array object
  27213. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27214. * @param vertexArrayObject defines the vertex array object to bind
  27215. * @param indexBuffer defines the index buffer to bind
  27216. */
  27217. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27218. /**
  27219. * Bind webGl buffers directly to the webGL context
  27220. * @param vertexBuffer defines the vertex buffer to bind
  27221. * @param indexBuffer defines the index buffer to bind
  27222. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27223. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27224. * @param effect defines the effect associated with the vertex buffer
  27225. */
  27226. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27227. private _unbindVertexArrayObject;
  27228. /**
  27229. * Bind a list of vertex buffers to the webGL context
  27230. * @param vertexBuffers defines the list of vertex buffers to bind
  27231. * @param indexBuffer defines the index buffer to bind
  27232. * @param effect defines the effect associated with the vertex buffers
  27233. */
  27234. bindBuffers(vertexBuffers: {
  27235. [key: string]: Nullable<VertexBuffer>;
  27236. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27237. /**
  27238. * Unbind all instance attributes
  27239. */
  27240. unbindInstanceAttributes(): void;
  27241. /**
  27242. * Release and free the memory of a vertex array object
  27243. * @param vao defines the vertex array object to delete
  27244. */
  27245. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27246. /** @hidden */
  27247. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27248. /**
  27249. * Creates a webGL buffer to use with instanciation
  27250. * @param capacity defines the size of the buffer
  27251. * @returns the webGL buffer
  27252. */
  27253. createInstancesBuffer(capacity: number): WebGLBuffer;
  27254. /**
  27255. * Delete a webGL buffer used with instanciation
  27256. * @param buffer defines the webGL buffer to delete
  27257. */
  27258. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27259. /**
  27260. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27261. * @param instancesBuffer defines the webGL buffer to update and bind
  27262. * @param data defines the data to store in the buffer
  27263. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27264. */
  27265. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27266. /**
  27267. * Apply all cached states (depth, culling, stencil and alpha)
  27268. */
  27269. applyStates(): void;
  27270. /**
  27271. * Send a draw order
  27272. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27273. * @param indexStart defines the starting index
  27274. * @param indexCount defines the number of index to draw
  27275. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27276. */
  27277. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27278. /**
  27279. * Draw a list of points
  27280. * @param verticesStart defines the index of first vertex to draw
  27281. * @param verticesCount defines the count of vertices to draw
  27282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27283. */
  27284. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27285. /**
  27286. * Draw a list of unindexed primitives
  27287. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27288. * @param verticesStart defines the index of first vertex to draw
  27289. * @param verticesCount defines the count of vertices to draw
  27290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27291. */
  27292. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27293. /**
  27294. * Draw a list of indexed primitives
  27295. * @param fillMode defines the primitive to use
  27296. * @param indexStart defines the starting index
  27297. * @param indexCount defines the number of index to draw
  27298. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27299. */
  27300. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27301. /**
  27302. * Draw a list of unindexed primitives
  27303. * @param fillMode defines the primitive to use
  27304. * @param verticesStart defines the index of first vertex to draw
  27305. * @param verticesCount defines the count of vertices to draw
  27306. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27307. */
  27308. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27309. private _drawMode;
  27310. /** @hidden */
  27311. _releaseEffect(effect: Effect): void;
  27312. /** @hidden */
  27313. _deleteProgram(program: WebGLProgram): void;
  27314. /**
  27315. * Create a new effect (used to store vertex/fragment shaders)
  27316. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27317. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27318. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27319. * @param samplers defines an array of string used to represent textures
  27320. * @param defines defines the string containing the defines to use to compile the shaders
  27321. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27322. * @param onCompiled defines a function to call when the effect creation is successful
  27323. * @param onError defines a function to call when the effect creation has failed
  27324. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27325. * @returns the new Effect
  27326. */
  27327. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  27328. private _compileShader;
  27329. private _compileRawShader;
  27330. /**
  27331. * Directly creates a webGL program
  27332. * @param vertexCode defines the vertex shader code to use
  27333. * @param fragmentCode defines the fragment shader code to use
  27334. * @param context defines the webGL context to use (if not set, the current one will be used)
  27335. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27336. * @returns the new webGL program
  27337. */
  27338. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27339. /**
  27340. * Creates a webGL program
  27341. * @param vertexCode defines the vertex shader code to use
  27342. * @param fragmentCode defines the fragment shader code to use
  27343. * @param defines defines the string containing the defines to use to compile the shaders
  27344. * @param context defines the webGL context to use (if not set, the current one will be used)
  27345. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27346. * @returns the new webGL program
  27347. */
  27348. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27349. private _createShaderProgram;
  27350. private _finalizeProgram;
  27351. /** @hidden */
  27352. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27353. /** @hidden */
  27354. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27355. /**
  27356. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27357. * @param shaderProgram defines the webGL program to use
  27358. * @param uniformsNames defines the list of uniform names
  27359. * @returns an array of webGL uniform locations
  27360. */
  27361. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27362. /**
  27363. * Gets the lsit of active attributes for a given webGL program
  27364. * @param shaderProgram defines the webGL program to use
  27365. * @param attributesNames defines the list of attribute names to get
  27366. * @returns an array of indices indicating the offset of each attribute
  27367. */
  27368. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27369. /**
  27370. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27371. * @param effect defines the effect to activate
  27372. */
  27373. enableEffect(effect: Nullable<Effect>): void;
  27374. /**
  27375. * Set the value of an uniform to an array of int32
  27376. * @param uniform defines the webGL uniform location where to store the value
  27377. * @param array defines the array of int32 to store
  27378. */
  27379. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27380. /**
  27381. * Set the value of an uniform to an array of int32 (stored as vec2)
  27382. * @param uniform defines the webGL uniform location where to store the value
  27383. * @param array defines the array of int32 to store
  27384. */
  27385. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27386. /**
  27387. * Set the value of an uniform to an array of int32 (stored as vec3)
  27388. * @param uniform defines the webGL uniform location where to store the value
  27389. * @param array defines the array of int32 to store
  27390. */
  27391. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27392. /**
  27393. * Set the value of an uniform to an array of int32 (stored as vec4)
  27394. * @param uniform defines the webGL uniform location where to store the value
  27395. * @param array defines the array of int32 to store
  27396. */
  27397. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27398. /**
  27399. * Set the value of an uniform to an array of float32
  27400. * @param uniform defines the webGL uniform location where to store the value
  27401. * @param array defines the array of float32 to store
  27402. */
  27403. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27404. /**
  27405. * Set the value of an uniform to an array of float32 (stored as vec2)
  27406. * @param uniform defines the webGL uniform location where to store the value
  27407. * @param array defines the array of float32 to store
  27408. */
  27409. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27410. /**
  27411. * Set the value of an uniform to an array of float32 (stored as vec3)
  27412. * @param uniform defines the webGL uniform location where to store the value
  27413. * @param array defines the array of float32 to store
  27414. */
  27415. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27416. /**
  27417. * Set the value of an uniform to an array of float32 (stored as vec4)
  27418. * @param uniform defines the webGL uniform location where to store the value
  27419. * @param array defines the array of float32 to store
  27420. */
  27421. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27422. /**
  27423. * Set the value of an uniform to an array of number
  27424. * @param uniform defines the webGL uniform location where to store the value
  27425. * @param array defines the array of number to store
  27426. */
  27427. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27428. /**
  27429. * Set the value of an uniform to an array of number (stored as vec2)
  27430. * @param uniform defines the webGL uniform location where to store the value
  27431. * @param array defines the array of number to store
  27432. */
  27433. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27434. /**
  27435. * Set the value of an uniform to an array of number (stored as vec3)
  27436. * @param uniform defines the webGL uniform location where to store the value
  27437. * @param array defines the array of number to store
  27438. */
  27439. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27440. /**
  27441. * Set the value of an uniform to an array of number (stored as vec4)
  27442. * @param uniform defines the webGL uniform location where to store the value
  27443. * @param array defines the array of number to store
  27444. */
  27445. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27446. /**
  27447. * Set the value of an uniform to an array of float32 (stored as matrices)
  27448. * @param uniform defines the webGL uniform location where to store the value
  27449. * @param matrices defines the array of float32 to store
  27450. */
  27451. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27452. /**
  27453. * Set the value of an uniform to a matrix
  27454. * @param uniform defines the webGL uniform location where to store the value
  27455. * @param matrix defines the matrix to store
  27456. */
  27457. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27458. /**
  27459. * Set the value of an uniform to a matrix (3x3)
  27460. * @param uniform defines the webGL uniform location where to store the value
  27461. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27462. */
  27463. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27464. /**
  27465. * Set the value of an uniform to a matrix (2x2)
  27466. * @param uniform defines the webGL uniform location where to store the value
  27467. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27468. */
  27469. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27470. /**
  27471. * Set the value of an uniform to a number (int)
  27472. * @param uniform defines the webGL uniform location where to store the value
  27473. * @param value defines the int number to store
  27474. */
  27475. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27476. /**
  27477. * Set the value of an uniform to a number (float)
  27478. * @param uniform defines the webGL uniform location where to store the value
  27479. * @param value defines the float number to store
  27480. */
  27481. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27482. /**
  27483. * Set the value of an uniform to a vec2
  27484. * @param uniform defines the webGL uniform location where to store the value
  27485. * @param x defines the 1st component of the value
  27486. * @param y defines the 2nd component of the value
  27487. */
  27488. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27489. /**
  27490. * Set the value of an uniform to a vec3
  27491. * @param uniform defines the webGL uniform location where to store the value
  27492. * @param x defines the 1st component of the value
  27493. * @param y defines the 2nd component of the value
  27494. * @param z defines the 3rd component of the value
  27495. */
  27496. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27497. /**
  27498. * Set the value of an uniform to a boolean
  27499. * @param uniform defines the webGL uniform location where to store the value
  27500. * @param bool defines the boolean to store
  27501. */
  27502. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27503. /**
  27504. * Set the value of an uniform to a vec4
  27505. * @param uniform defines the webGL uniform location where to store the value
  27506. * @param x defines the 1st component of the value
  27507. * @param y defines the 2nd component of the value
  27508. * @param z defines the 3rd component of the value
  27509. * @param w defines the 4th component of the value
  27510. */
  27511. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27512. /**
  27513. * Set the value of an uniform to a Color3
  27514. * @param uniform defines the webGL uniform location where to store the value
  27515. * @param color3 defines the color to store
  27516. */
  27517. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27518. /**
  27519. * Set the value of an uniform to a Color3 and an alpha value
  27520. * @param uniform defines the webGL uniform location where to store the value
  27521. * @param color3 defines the color to store
  27522. * @param alpha defines the alpha component to store
  27523. */
  27524. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27525. /**
  27526. * Sets a Color4 on a uniform variable
  27527. * @param uniform defines the uniform location
  27528. * @param color4 defines the value to be set
  27529. */
  27530. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27531. /**
  27532. * Set various states to the webGL context
  27533. * @param culling defines backface culling state
  27534. * @param zOffset defines the value to apply to zOffset (0 by default)
  27535. * @param force defines if states must be applied even if cache is up to date
  27536. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27537. */
  27538. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27539. /**
  27540. * Set the z offset to apply to current rendering
  27541. * @param value defines the offset to apply
  27542. */
  27543. setZOffset(value: number): void;
  27544. /**
  27545. * Gets the current value of the zOffset
  27546. * @returns the current zOffset state
  27547. */
  27548. getZOffset(): number;
  27549. /**
  27550. * Enable or disable depth buffering
  27551. * @param enable defines the state to set
  27552. */
  27553. setDepthBuffer(enable: boolean): void;
  27554. /**
  27555. * Gets a boolean indicating if depth writing is enabled
  27556. * @returns the current depth writing state
  27557. */
  27558. getDepthWrite(): boolean;
  27559. /**
  27560. * Enable or disable depth writing
  27561. * @param enable defines the state to set
  27562. */
  27563. setDepthWrite(enable: boolean): void;
  27564. /**
  27565. * Enable or disable color writing
  27566. * @param enable defines the state to set
  27567. */
  27568. setColorWrite(enable: boolean): void;
  27569. /**
  27570. * Gets a boolean indicating if color writing is enabled
  27571. * @returns the current color writing state
  27572. */
  27573. getColorWrite(): boolean;
  27574. /**
  27575. * Sets alpha constants used by some alpha blending modes
  27576. * @param r defines the red component
  27577. * @param g defines the green component
  27578. * @param b defines the blue component
  27579. * @param a defines the alpha component
  27580. */
  27581. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27582. /**
  27583. * Sets the current alpha mode
  27584. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27585. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27586. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27587. */
  27588. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27589. /**
  27590. * Gets the current alpha mode
  27591. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27592. * @returns the current alpha mode
  27593. */
  27594. getAlphaMode(): number;
  27595. /**
  27596. * Clears the list of texture accessible through engine.
  27597. * This can help preventing texture load conflict due to name collision.
  27598. */
  27599. clearInternalTexturesCache(): void;
  27600. /**
  27601. * Force the entire cache to be cleared
  27602. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27603. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27604. */
  27605. wipeCaches(bruteForce?: boolean): void;
  27606. /**
  27607. * Set the compressed texture format to use, based on the formats you have, and the formats
  27608. * supported by the hardware / browser.
  27609. *
  27610. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27611. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27612. * to API arguments needed to compressed textures. This puts the burden on the container
  27613. * generator to house the arcane code for determining these for current & future formats.
  27614. *
  27615. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27616. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27617. *
  27618. * Note: The result of this call is not taken into account when a texture is base64.
  27619. *
  27620. * @param formatsAvailable defines the list of those format families you have created
  27621. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27622. *
  27623. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27624. * @returns The extension selected.
  27625. */
  27626. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27627. private _getSamplingParameters;
  27628. private _partialLoadImg;
  27629. private _cascadeLoadImgs;
  27630. /** @hidden */
  27631. _createTexture(): WebGLTexture;
  27632. /**
  27633. * Usually called from Texture.ts.
  27634. * Passed information to create a WebGLTexture
  27635. * @param urlArg defines a value which contains one of the following:
  27636. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27637. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27638. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27640. * @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)
  27641. * @param scene needed for loading to the correct scene
  27642. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27643. * @param onLoad optional callback to be called upon successful completion
  27644. * @param onError optional callback to be called upon failure
  27645. * @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
  27646. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27647. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27648. * @param forcedExtension defines the extension to use to pick the right loader
  27649. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27650. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27651. */
  27652. 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;
  27653. private _rescaleTexture;
  27654. /**
  27655. * Update a raw texture
  27656. * @param texture defines the texture to update
  27657. * @param data defines the data to store in the texture
  27658. * @param format defines the format of the data
  27659. * @param invertY defines if data must be stored with Y axis inverted
  27660. * @param compression defines the compression used (null by default)
  27661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27662. */
  27663. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27664. /**
  27665. * Creates a raw texture
  27666. * @param data defines the data to store in the texture
  27667. * @param width defines the width of the texture
  27668. * @param height defines the height of the texture
  27669. * @param format defines the format of the data
  27670. * @param generateMipMaps defines if the engine should generate the mip levels
  27671. * @param invertY defines if data must be stored with Y axis inverted
  27672. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27673. * @param compression defines the compression used (null by default)
  27674. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27675. * @returns the raw texture inside an InternalTexture
  27676. */
  27677. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27678. private _unpackFlipYCached;
  27679. /**
  27680. * In case you are sharing the context with other applications, it might
  27681. * be interested to not cache the unpack flip y state to ensure a consistent
  27682. * value would be set.
  27683. */
  27684. enableUnpackFlipYCached: boolean;
  27685. /** @hidden */
  27686. _unpackFlipY(value: boolean): void;
  27687. /** @hidden */
  27688. _getUnpackAlignement(): number;
  27689. /**
  27690. * Creates a dynamic texture
  27691. * @param width defines the width of the texture
  27692. * @param height defines the height of the texture
  27693. * @param generateMipMaps defines if the engine should generate the mip levels
  27694. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27695. * @returns the dynamic texture inside an InternalTexture
  27696. */
  27697. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27698. /**
  27699. * Update the sampling mode of a given texture
  27700. * @param samplingMode defines the required sampling mode
  27701. * @param texture defines the texture to update
  27702. */
  27703. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27704. /**
  27705. * Update the content of a dynamic texture
  27706. * @param texture defines the texture to update
  27707. * @param canvas defines the canvas containing the source
  27708. * @param invertY defines if data must be stored with Y axis inverted
  27709. * @param premulAlpha defines if alpha is stored as premultiplied
  27710. * @param format defines the format of the data
  27711. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27712. */
  27713. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27714. /**
  27715. * Update a video texture
  27716. * @param texture defines the texture to update
  27717. * @param video defines the video element to use
  27718. * @param invertY defines if data must be stored with Y axis inverted
  27719. */
  27720. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27721. /**
  27722. * Updates a depth texture Comparison Mode and Function.
  27723. * If the comparison Function is equal to 0, the mode will be set to none.
  27724. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27725. * @param texture The texture to set the comparison function for
  27726. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27727. */
  27728. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27729. private _setupDepthStencilTexture;
  27730. /**
  27731. * Creates a depth stencil texture.
  27732. * This is only available in WebGL 2 or with the depth texture extension available.
  27733. * @param size The size of face edge in the texture.
  27734. * @param options The options defining the texture.
  27735. * @returns The texture
  27736. */
  27737. createDepthStencilTexture(size: number | {
  27738. width: number;
  27739. height: number;
  27740. }, options: DepthTextureCreationOptions): InternalTexture;
  27741. /**
  27742. * Creates a depth stencil texture.
  27743. * This is only available in WebGL 2 or with the depth texture extension available.
  27744. * @param size The size of face edge in the texture.
  27745. * @param options The options defining the texture.
  27746. * @returns The texture
  27747. */
  27748. private _createDepthStencilTexture;
  27749. /**
  27750. * Creates a depth stencil cube texture.
  27751. * This is only available in WebGL 2.
  27752. * @param size The size of face edge in the cube texture.
  27753. * @param options The options defining the cube texture.
  27754. * @returns The cube texture
  27755. */
  27756. private _createDepthStencilCubeTexture;
  27757. /**
  27758. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  27759. * @param renderTarget The render target to set the frame buffer for
  27760. */
  27761. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  27762. /**
  27763. * Creates a new render target texture
  27764. * @param size defines the size of the texture
  27765. * @param options defines the options used to create the texture
  27766. * @returns a new render target texture stored in an InternalTexture
  27767. */
  27768. createRenderTargetTexture(size: number | {
  27769. width: number;
  27770. height: number;
  27771. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  27772. /**
  27773. * Create a multi render target texture
  27774. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  27775. * @param size defines the size of the texture
  27776. * @param options defines the creation options
  27777. * @returns the cube texture as an InternalTexture
  27778. */
  27779. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  27780. private _setupFramebufferDepthAttachments;
  27781. /**
  27782. * Updates the sample count of a render target texture
  27783. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27784. * @param texture defines the texture to update
  27785. * @param samples defines the sample count to set
  27786. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27787. */
  27788. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  27789. /**
  27790. * Update the sample count for a given multiple render target texture
  27791. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  27792. * @param textures defines the textures to update
  27793. * @param samples defines the sample count to set
  27794. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  27795. */
  27796. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  27797. /** @hidden */
  27798. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27799. /** @hidden */
  27800. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27801. /** @hidden */
  27802. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  27803. /** @hidden */
  27804. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  27805. /**
  27806. * Creates a new render target cube texture
  27807. * @param size defines the size of the texture
  27808. * @param options defines the options used to create the texture
  27809. * @returns a new render target cube texture stored in an InternalTexture
  27810. */
  27811. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  27812. /**
  27813. * Creates a cube texture
  27814. * @param rootUrl defines the url where the files to load is located
  27815. * @param scene defines the current scene
  27816. * @param files defines the list of files to load (1 per face)
  27817. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  27818. * @param onLoad defines an optional callback raised when the texture is loaded
  27819. * @param onError defines an optional callback raised if there is an issue to load the texture
  27820. * @param format defines the format of the data
  27821. * @param forcedExtension defines the extension to use to pick the right loader
  27822. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  27823. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  27824. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  27825. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  27826. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  27827. * @returns the cube texture as an InternalTexture
  27828. */
  27829. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  27830. /**
  27831. * @hidden
  27832. */
  27833. _setCubeMapTextureParams(loadMipmap: boolean): void;
  27834. /**
  27835. * Update a raw cube texture
  27836. * @param texture defines the texture to udpdate
  27837. * @param data defines the data to store
  27838. * @param format defines the data format
  27839. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27840. * @param invertY defines if data must be stored with Y axis inverted
  27841. * @param compression defines the compression used (null by default)
  27842. * @param level defines which level of the texture to update
  27843. */
  27844. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  27845. /**
  27846. * Creates a new raw cube texture
  27847. * @param data defines the array of data to use to create each face
  27848. * @param size defines the size of the textures
  27849. * @param format defines the format of the data
  27850. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27851. * @param generateMipMaps defines if the engine should generate the mip levels
  27852. * @param invertY defines if data must be stored with Y axis inverted
  27853. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27854. * @param compression defines the compression used (null by default)
  27855. * @returns the cube texture as an InternalTexture
  27856. */
  27857. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  27858. /**
  27859. * Creates a new raw cube texture from a specified url
  27860. * @param url defines the url where the data is located
  27861. * @param scene defines the current scene
  27862. * @param size defines the size of the textures
  27863. * @param format defines the format of the data
  27864. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  27865. * @param noMipmap defines if the engine should avoid generating the mip levels
  27866. * @param callback defines a callback used to extract texture data from loaded data
  27867. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  27868. * @param onLoad defines a callback called when texture is loaded
  27869. * @param onError defines a callback called if there is an error
  27870. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27871. * @param invertY defines if data must be stored with Y axis inverted
  27872. * @returns the cube texture as an InternalTexture
  27873. */
  27874. 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;
  27875. /**
  27876. * Update a raw 3D texture
  27877. * @param texture defines the texture to update
  27878. * @param data defines the data to store
  27879. * @param format defines the data format
  27880. * @param invertY defines if data must be stored with Y axis inverted
  27881. * @param compression defines the used compression (can be null)
  27882. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  27883. */
  27884. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  27885. /**
  27886. * Creates a new raw 3D texture
  27887. * @param data defines the data used to create the texture
  27888. * @param width defines the width of the texture
  27889. * @param height defines the height of the texture
  27890. * @param depth defines the depth of the texture
  27891. * @param format defines the format of the texture
  27892. * @param generateMipMaps defines if the engine must generate mip levels
  27893. * @param invertY defines if data must be stored with Y axis inverted
  27894. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  27895. * @param compression defines the compressed used (can be null)
  27896. * @param textureType defines the compressed used (can be null)
  27897. * @returns a new raw 3D texture (stored in an InternalTexture)
  27898. */
  27899. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  27900. private _prepareWebGLTextureContinuation;
  27901. private _prepareWebGLTexture;
  27902. private _convertRGBtoRGBATextureData;
  27903. /** @hidden */
  27904. _releaseFramebufferObjects(texture: InternalTexture): void;
  27905. /** @hidden */
  27906. _releaseTexture(texture: InternalTexture): void;
  27907. private setProgram;
  27908. private _boundUniforms;
  27909. /**
  27910. * Binds an effect to the webGL context
  27911. * @param effect defines the effect to bind
  27912. */
  27913. bindSamplers(effect: Effect): void;
  27914. private _moveBoundTextureOnTop;
  27915. private _getCorrectTextureChannel;
  27916. private _linkTrackers;
  27917. private _removeDesignatedSlot;
  27918. private _activateCurrentTexture;
  27919. /** @hidden */
  27920. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  27921. /** @hidden */
  27922. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  27923. /**
  27924. * Sets a texture to the webGL context from a postprocess
  27925. * @param channel defines the channel to use
  27926. * @param postProcess defines the source postprocess
  27927. */
  27928. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  27929. /**
  27930. * Binds the output of the passed in post process to the texture channel specified
  27931. * @param channel The channel the texture should be bound to
  27932. * @param postProcess The post process which's output should be bound
  27933. */
  27934. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  27935. /**
  27936. * Unbind all textures from the webGL context
  27937. */
  27938. unbindAllTextures(): void;
  27939. /**
  27940. * Sets a texture to the according uniform.
  27941. * @param channel The texture channel
  27942. * @param uniform The uniform to set
  27943. * @param texture The texture to apply
  27944. */
  27945. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  27946. /**
  27947. * Sets a depth stencil texture from a render target to the according uniform.
  27948. * @param channel The texture channel
  27949. * @param uniform The uniform to set
  27950. * @param texture The render target texture containing the depth stencil texture to apply
  27951. */
  27952. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  27953. private _bindSamplerUniformToChannel;
  27954. private _getTextureWrapMode;
  27955. private _setTexture;
  27956. /**
  27957. * Sets an array of texture to the webGL context
  27958. * @param channel defines the channel where the texture array must be set
  27959. * @param uniform defines the associated uniform location
  27960. * @param textures defines the array of textures to bind
  27961. */
  27962. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  27963. /** @hidden */
  27964. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  27965. private _setTextureParameterFloat;
  27966. private _setTextureParameterInteger;
  27967. /**
  27968. * Reads pixels from the current frame buffer. Please note that this function can be slow
  27969. * @param x defines the x coordinate of the rectangle where pixels must be read
  27970. * @param y defines the y coordinate of the rectangle where pixels must be read
  27971. * @param width defines the width of the rectangle where pixels must be read
  27972. * @param height defines the height of the rectangle where pixels must be read
  27973. * @returns a Uint8Array containing RGBA colors
  27974. */
  27975. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  27976. /**
  27977. * Add an externaly attached data from its key.
  27978. * This method call will fail and return false, if such key already exists.
  27979. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  27980. * @param key the unique key that identifies the data
  27981. * @param data the data object to associate to the key for this Engine instance
  27982. * @return true if no such key were already present and the data was added successfully, false otherwise
  27983. */
  27984. addExternalData<T>(key: string, data: T): boolean;
  27985. /**
  27986. * Get an externaly attached data from its key
  27987. * @param key the unique key that identifies the data
  27988. * @return the associated data, if present (can be null), or undefined if not present
  27989. */
  27990. getExternalData<T>(key: string): T;
  27991. /**
  27992. * Get an externaly attached data from its key, create it using a factory if it's not already present
  27993. * @param key the unique key that identifies the data
  27994. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  27995. * @return the associated data, can be null if the factory returned null.
  27996. */
  27997. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  27998. /**
  27999. * Remove an externaly attached data from the Engine instance
  28000. * @param key the unique key that identifies the data
  28001. * @return true if the data was successfully removed, false if it doesn't exist
  28002. */
  28003. removeExternalData(key: string): boolean;
  28004. /**
  28005. * Unbind all vertex attributes from the webGL context
  28006. */
  28007. unbindAllAttributes(): void;
  28008. /**
  28009. * 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
  28010. */
  28011. releaseEffects(): void;
  28012. /**
  28013. * Dispose and release all associated resources
  28014. */
  28015. dispose(): void;
  28016. /**
  28017. * Display the loading screen
  28018. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28019. */
  28020. displayLoadingUI(): void;
  28021. /**
  28022. * Hide the loading screen
  28023. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28024. */
  28025. hideLoadingUI(): void;
  28026. /**
  28027. * Gets the current loading screen object
  28028. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28029. */
  28030. /**
  28031. * Sets the current loading screen object
  28032. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28033. */
  28034. loadingScreen: ILoadingScreen;
  28035. /**
  28036. * Sets the current loading screen text
  28037. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28038. */
  28039. loadingUIText: string;
  28040. /**
  28041. * Sets the current loading screen background color
  28042. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28043. */
  28044. loadingUIBackgroundColor: string;
  28045. /**
  28046. * Attach a new callback raised when context lost event is fired
  28047. * @param callback defines the callback to call
  28048. */
  28049. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28050. /**
  28051. * Attach a new callback raised when context restored event is fired
  28052. * @param callback defines the callback to call
  28053. */
  28054. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28055. /**
  28056. * Gets the source code of the vertex shader associated with a specific webGL program
  28057. * @param program defines the program to use
  28058. * @returns a string containing the source code of the vertex shader associated with the program
  28059. */
  28060. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28061. /**
  28062. * Gets the source code of the fragment shader associated with a specific webGL program
  28063. * @param program defines the program to use
  28064. * @returns a string containing the source code of the fragment shader associated with the program
  28065. */
  28066. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28067. /**
  28068. * Get the current error code of the webGL context
  28069. * @returns the error code
  28070. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28071. */
  28072. getError(): number;
  28073. /**
  28074. * Gets the current framerate
  28075. * @returns a number representing the framerate
  28076. */
  28077. getFps(): number;
  28078. /**
  28079. * Gets the time spent between current and previous frame
  28080. * @returns a number representing the delta time in ms
  28081. */
  28082. getDeltaTime(): number;
  28083. private _measureFps;
  28084. /** @hidden */
  28085. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28086. private _canRenderToFloatFramebuffer;
  28087. private _canRenderToHalfFloatFramebuffer;
  28088. private _canRenderToFramebuffer;
  28089. /** @hidden */
  28090. _getWebGLTextureType(type: number): number;
  28091. private _getInternalFormat;
  28092. /** @hidden */
  28093. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28094. /** @hidden */
  28095. _getRGBAMultiSampleBufferFormat(type: number): number;
  28096. /** @hidden */
  28097. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  28098. /** @hidden */
  28099. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28100. private _partialLoadFile;
  28101. private _cascadeLoadFiles;
  28102. /**
  28103. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28104. * @returns true if the engine can be created
  28105. * @ignorenaming
  28106. */
  28107. static isSupported(): boolean;
  28108. }
  28109. }
  28110. declare module BABYLON {
  28111. /**
  28112. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28113. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28114. */
  28115. export class EffectFallbacks {
  28116. private _defines;
  28117. private _currentRank;
  28118. private _maxRank;
  28119. private _mesh;
  28120. /**
  28121. * Removes the fallback from the bound mesh.
  28122. */
  28123. unBindMesh(): void;
  28124. /**
  28125. * Adds a fallback on the specified property.
  28126. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28127. * @param define The name of the define in the shader
  28128. */
  28129. addFallback(rank: number, define: string): void;
  28130. /**
  28131. * Sets the mesh to use CPU skinning when needing to fallback.
  28132. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28133. * @param mesh The mesh to use the fallbacks.
  28134. */
  28135. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28136. /**
  28137. * Checks to see if more fallbacks are still availible.
  28138. */
  28139. readonly isMoreFallbacks: boolean;
  28140. /**
  28141. * Removes the defines that shoould be removed when falling back.
  28142. * @param currentDefines defines the current define statements for the shader.
  28143. * @param effect defines the current effect we try to compile
  28144. * @returns The resulting defines with defines of the current rank removed.
  28145. */
  28146. reduce(currentDefines: string, effect: Effect): string;
  28147. }
  28148. /**
  28149. * Options to be used when creating an effect.
  28150. */
  28151. export class EffectCreationOptions {
  28152. /**
  28153. * Atrributes that will be used in the shader.
  28154. */
  28155. attributes: string[];
  28156. /**
  28157. * Uniform varible names that will be set in the shader.
  28158. */
  28159. uniformsNames: string[];
  28160. /**
  28161. * Uniform buffer varible names that will be set in the shader.
  28162. */
  28163. uniformBuffersNames: string[];
  28164. /**
  28165. * Sampler texture variable names that will be set in the shader.
  28166. */
  28167. samplers: string[];
  28168. /**
  28169. * Define statements that will be set in the shader.
  28170. */
  28171. defines: any;
  28172. /**
  28173. * Possible fallbacks for this effect to improve performance when needed.
  28174. */
  28175. fallbacks: Nullable<EffectFallbacks>;
  28176. /**
  28177. * Callback that will be called when the shader is compiled.
  28178. */
  28179. onCompiled: Nullable<(effect: Effect) => void>;
  28180. /**
  28181. * Callback that will be called if an error occurs during shader compilation.
  28182. */
  28183. onError: Nullable<(effect: Effect, errors: string) => void>;
  28184. /**
  28185. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28186. */
  28187. indexParameters: any;
  28188. /**
  28189. * Max number of lights that can be used in the shader.
  28190. */
  28191. maxSimultaneousLights: number;
  28192. /**
  28193. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28194. */
  28195. transformFeedbackVaryings: Nullable<string[]>;
  28196. }
  28197. /**
  28198. * Effect containing vertex and fragment shader that can be executed on an object.
  28199. */
  28200. export class Effect {
  28201. /**
  28202. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28203. */
  28204. static ShadersRepository: string;
  28205. /**
  28206. * Name of the effect.
  28207. */
  28208. name: any;
  28209. /**
  28210. * String container all the define statements that should be set on the shader.
  28211. */
  28212. defines: string;
  28213. /**
  28214. * Callback that will be called when the shader is compiled.
  28215. */
  28216. onCompiled: Nullable<(effect: Effect) => void>;
  28217. /**
  28218. * Callback that will be called if an error occurs during shader compilation.
  28219. */
  28220. onError: Nullable<(effect: Effect, errors: string) => void>;
  28221. /**
  28222. * Callback that will be called when effect is bound.
  28223. */
  28224. onBind: Nullable<(effect: Effect) => void>;
  28225. /**
  28226. * Unique ID of the effect.
  28227. */
  28228. uniqueId: number;
  28229. /**
  28230. * Observable that will be called when the shader is compiled.
  28231. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28232. */
  28233. onCompileObservable: Observable<Effect>;
  28234. /**
  28235. * Observable that will be called if an error occurs during shader compilation.
  28236. */
  28237. onErrorObservable: Observable<Effect>;
  28238. /** @hidden */
  28239. _onBindObservable: Nullable<Observable<Effect>>;
  28240. /**
  28241. * Observable that will be called when effect is bound.
  28242. */
  28243. readonly onBindObservable: Observable<Effect>;
  28244. /** @hidden */
  28245. _bonesComputationForcedToCPU: boolean;
  28246. private static _uniqueIdSeed;
  28247. private _engine;
  28248. private _uniformBuffersNames;
  28249. private _uniformsNames;
  28250. private _samplers;
  28251. private _isReady;
  28252. private _compilationError;
  28253. private _attributesNames;
  28254. private _attributes;
  28255. private _uniforms;
  28256. /**
  28257. * Key for the effect.
  28258. * @hidden
  28259. */
  28260. _key: string;
  28261. private _indexParameters;
  28262. private _fallbacks;
  28263. private _vertexSourceCode;
  28264. private _fragmentSourceCode;
  28265. private _vertexSourceCodeOverride;
  28266. private _fragmentSourceCodeOverride;
  28267. private _transformFeedbackVaryings;
  28268. /**
  28269. * Compiled shader to webGL program.
  28270. * @hidden
  28271. */
  28272. _program: WebGLProgram;
  28273. private _valueCache;
  28274. private static _baseCache;
  28275. /**
  28276. * Instantiates an effect.
  28277. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28278. * @param baseName Name of the effect.
  28279. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28280. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28281. * @param samplers List of sampler variables that will be passed to the shader.
  28282. * @param engine Engine to be used to render the effect
  28283. * @param defines Define statements to be added to the shader.
  28284. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28285. * @param onCompiled Callback that will be called when the shader is compiled.
  28286. * @param onError Callback that will be called if an error occurs during shader compilation.
  28287. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28288. */
  28289. 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);
  28290. /**
  28291. * Unique key for this effect
  28292. */
  28293. readonly key: string;
  28294. /**
  28295. * If the effect has been compiled and prepared.
  28296. * @returns if the effect is compiled and prepared.
  28297. */
  28298. isReady(): boolean;
  28299. /**
  28300. * The engine the effect was initialized with.
  28301. * @returns the engine.
  28302. */
  28303. getEngine(): Engine;
  28304. /**
  28305. * The compiled webGL program for the effect
  28306. * @returns the webGL program.
  28307. */
  28308. getProgram(): WebGLProgram;
  28309. /**
  28310. * The set of names of attribute variables for the shader.
  28311. * @returns An array of attribute names.
  28312. */
  28313. getAttributesNames(): string[];
  28314. /**
  28315. * Returns the attribute at the given index.
  28316. * @param index The index of the attribute.
  28317. * @returns The location of the attribute.
  28318. */
  28319. getAttributeLocation(index: number): number;
  28320. /**
  28321. * Returns the attribute based on the name of the variable.
  28322. * @param name of the attribute to look up.
  28323. * @returns the attribute location.
  28324. */
  28325. getAttributeLocationByName(name: string): number;
  28326. /**
  28327. * The number of attributes.
  28328. * @returns the numnber of attributes.
  28329. */
  28330. getAttributesCount(): number;
  28331. /**
  28332. * Gets the index of a uniform variable.
  28333. * @param uniformName of the uniform to look up.
  28334. * @returns the index.
  28335. */
  28336. getUniformIndex(uniformName: string): number;
  28337. /**
  28338. * Returns the attribute based on the name of the variable.
  28339. * @param uniformName of the uniform to look up.
  28340. * @returns the location of the uniform.
  28341. */
  28342. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28343. /**
  28344. * Returns an array of sampler variable names
  28345. * @returns The array of sampler variable neames.
  28346. */
  28347. getSamplers(): string[];
  28348. /**
  28349. * The error from the last compilation.
  28350. * @returns the error string.
  28351. */
  28352. getCompilationError(): string;
  28353. /**
  28354. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28355. * @param func The callback to be used.
  28356. */
  28357. executeWhenCompiled(func: (effect: Effect) => void): void;
  28358. private _checkIsReady;
  28359. /** @hidden */
  28360. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28361. /** @hidden */
  28362. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28363. /** @hidden */
  28364. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28365. private _processShaderConversion;
  28366. private _processIncludes;
  28367. private _processPrecision;
  28368. /**
  28369. * Recompiles the webGL program
  28370. * @param vertexSourceCode The source code for the vertex shader.
  28371. * @param fragmentSourceCode The source code for the fragment shader.
  28372. * @param onCompiled Callback called when completed.
  28373. * @param onError Callback called on error.
  28374. * @hidden
  28375. */
  28376. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28377. /**
  28378. * Gets the uniform locations of the the specified variable names
  28379. * @param names THe names of the variables to lookup.
  28380. * @returns Array of locations in the same order as variable names.
  28381. */
  28382. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28383. /**
  28384. * Prepares the effect
  28385. * @hidden
  28386. */
  28387. _prepareEffect(): void;
  28388. /**
  28389. * Checks if the effect is supported. (Must be called after compilation)
  28390. */
  28391. readonly isSupported: boolean;
  28392. /**
  28393. * Binds a texture to the engine to be used as output of the shader.
  28394. * @param channel Name of the output variable.
  28395. * @param texture Texture to bind.
  28396. * @hidden
  28397. */
  28398. _bindTexture(channel: string, texture: InternalTexture): void;
  28399. /**
  28400. * Sets a texture on the engine to be used in the shader.
  28401. * @param channel Name of the sampler variable.
  28402. * @param texture Texture to set.
  28403. */
  28404. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28405. /**
  28406. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28407. * @param channel Name of the sampler variable.
  28408. * @param texture Texture to set.
  28409. */
  28410. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28411. /**
  28412. * Sets an array of textures on the engine to be used in the shader.
  28413. * @param channel Name of the variable.
  28414. * @param textures Textures to set.
  28415. */
  28416. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28417. /**
  28418. * 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)
  28419. * @param channel Name of the sampler variable.
  28420. * @param postProcess Post process to get the input texture from.
  28421. */
  28422. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28423. /**
  28424. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28425. * 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)
  28426. * @param channel Name of the sampler variable.
  28427. * @param postProcess Post process to get the output texture from.
  28428. */
  28429. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28430. /** @hidden */
  28431. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28432. /** @hidden */
  28433. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28434. /** @hidden */
  28435. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28436. /** @hidden */
  28437. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28438. /**
  28439. * Binds a buffer to a uniform.
  28440. * @param buffer Buffer to bind.
  28441. * @param name Name of the uniform variable to bind to.
  28442. */
  28443. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28444. /**
  28445. * Binds block to a uniform.
  28446. * @param blockName Name of the block to bind.
  28447. * @param index Index to bind.
  28448. */
  28449. bindUniformBlock(blockName: string, index: number): void;
  28450. /**
  28451. * Sets an interger value on a uniform variable.
  28452. * @param uniformName Name of the variable.
  28453. * @param value Value to be set.
  28454. * @returns this effect.
  28455. */
  28456. setInt(uniformName: string, value: number): Effect;
  28457. /**
  28458. * Sets an int array on a uniform variable.
  28459. * @param uniformName Name of the variable.
  28460. * @param array array to be set.
  28461. * @returns this effect.
  28462. */
  28463. setIntArray(uniformName: string, array: Int32Array): Effect;
  28464. /**
  28465. * 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)
  28466. * @param uniformName Name of the variable.
  28467. * @param array array to be set.
  28468. * @returns this effect.
  28469. */
  28470. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28471. /**
  28472. * 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)
  28473. * @param uniformName Name of the variable.
  28474. * @param array array to be set.
  28475. * @returns this effect.
  28476. */
  28477. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28478. /**
  28479. * 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)
  28480. * @param uniformName Name of the variable.
  28481. * @param array array to be set.
  28482. * @returns this effect.
  28483. */
  28484. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28485. /**
  28486. * Sets an float array on a uniform variable.
  28487. * @param uniformName Name of the variable.
  28488. * @param array array to be set.
  28489. * @returns this effect.
  28490. */
  28491. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28492. /**
  28493. * 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)
  28494. * @param uniformName Name of the variable.
  28495. * @param array array to be set.
  28496. * @returns this effect.
  28497. */
  28498. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28499. /**
  28500. * 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)
  28501. * @param uniformName Name of the variable.
  28502. * @param array array to be set.
  28503. * @returns this effect.
  28504. */
  28505. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28506. /**
  28507. * 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)
  28508. * @param uniformName Name of the variable.
  28509. * @param array array to be set.
  28510. * @returns this effect.
  28511. */
  28512. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28513. /**
  28514. * Sets an array on a uniform variable.
  28515. * @param uniformName Name of the variable.
  28516. * @param array array to be set.
  28517. * @returns this effect.
  28518. */
  28519. setArray(uniformName: string, array: number[]): Effect;
  28520. /**
  28521. * 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)
  28522. * @param uniformName Name of the variable.
  28523. * @param array array to be set.
  28524. * @returns this effect.
  28525. */
  28526. setArray2(uniformName: string, array: number[]): Effect;
  28527. /**
  28528. * 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)
  28529. * @param uniformName Name of the variable.
  28530. * @param array array to be set.
  28531. * @returns this effect.
  28532. */
  28533. setArray3(uniformName: string, array: number[]): Effect;
  28534. /**
  28535. * 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)
  28536. * @param uniformName Name of the variable.
  28537. * @param array array to be set.
  28538. * @returns this effect.
  28539. */
  28540. setArray4(uniformName: string, array: number[]): Effect;
  28541. /**
  28542. * Sets matrices on a uniform variable.
  28543. * @param uniformName Name of the variable.
  28544. * @param matrices matrices to be set.
  28545. * @returns this effect.
  28546. */
  28547. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28548. /**
  28549. * Sets matrix on a uniform variable.
  28550. * @param uniformName Name of the variable.
  28551. * @param matrix matrix to be set.
  28552. * @returns this effect.
  28553. */
  28554. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28555. /**
  28556. * 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)
  28557. * @param uniformName Name of the variable.
  28558. * @param matrix matrix to be set.
  28559. * @returns this effect.
  28560. */
  28561. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28562. /**
  28563. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28564. * @param uniformName Name of the variable.
  28565. * @param matrix matrix to be set.
  28566. * @returns this effect.
  28567. */
  28568. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28569. /**
  28570. * Sets a float on a uniform variable.
  28571. * @param uniformName Name of the variable.
  28572. * @param value value to be set.
  28573. * @returns this effect.
  28574. */
  28575. setFloat(uniformName: string, value: number): Effect;
  28576. /**
  28577. * Sets a boolean on a uniform variable.
  28578. * @param uniformName Name of the variable.
  28579. * @param bool value to be set.
  28580. * @returns this effect.
  28581. */
  28582. setBool(uniformName: string, bool: boolean): Effect;
  28583. /**
  28584. * Sets a Vector2 on a uniform variable.
  28585. * @param uniformName Name of the variable.
  28586. * @param vector2 vector2 to be set.
  28587. * @returns this effect.
  28588. */
  28589. setVector2(uniformName: string, vector2: Vector2): Effect;
  28590. /**
  28591. * Sets a float2 on a uniform variable.
  28592. * @param uniformName Name of the variable.
  28593. * @param x First float in float2.
  28594. * @param y Second float in float2.
  28595. * @returns this effect.
  28596. */
  28597. setFloat2(uniformName: string, x: number, y: number): Effect;
  28598. /**
  28599. * Sets a Vector3 on a uniform variable.
  28600. * @param uniformName Name of the variable.
  28601. * @param vector3 Value to be set.
  28602. * @returns this effect.
  28603. */
  28604. setVector3(uniformName: string, vector3: Vector3): Effect;
  28605. /**
  28606. * Sets a float3 on a uniform variable.
  28607. * @param uniformName Name of the variable.
  28608. * @param x First float in float3.
  28609. * @param y Second float in float3.
  28610. * @param z Third float in float3.
  28611. * @returns this effect.
  28612. */
  28613. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28614. /**
  28615. * Sets a Vector4 on a uniform variable.
  28616. * @param uniformName Name of the variable.
  28617. * @param vector4 Value to be set.
  28618. * @returns this effect.
  28619. */
  28620. setVector4(uniformName: string, vector4: Vector4): Effect;
  28621. /**
  28622. * Sets a float4 on a uniform variable.
  28623. * @param uniformName Name of the variable.
  28624. * @param x First float in float4.
  28625. * @param y Second float in float4.
  28626. * @param z Third float in float4.
  28627. * @param w Fourth float in float4.
  28628. * @returns this effect.
  28629. */
  28630. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28631. /**
  28632. * Sets a Color3 on a uniform variable.
  28633. * @param uniformName Name of the variable.
  28634. * @param color3 Value to be set.
  28635. * @returns this effect.
  28636. */
  28637. setColor3(uniformName: string, color3: Color3): Effect;
  28638. /**
  28639. * Sets a Color4 on a uniform variable.
  28640. * @param uniformName Name of the variable.
  28641. * @param color3 Value to be set.
  28642. * @param alpha Alpha value to be set.
  28643. * @returns this effect.
  28644. */
  28645. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28646. /**
  28647. * Sets a Color4 on a uniform variable
  28648. * @param uniformName defines the name of the variable
  28649. * @param color4 defines the value to be set
  28650. * @returns this effect.
  28651. */
  28652. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28653. /**
  28654. * This function will add a new shader to the shader store
  28655. * @param name the name of the shader
  28656. * @param pixelShader optional pixel shader content
  28657. * @param vertexShader optional vertex shader content
  28658. */
  28659. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28660. /**
  28661. * Store of each shader (The can be looked up using effect.key)
  28662. */
  28663. static ShadersStore: {
  28664. [key: string]: string;
  28665. };
  28666. /**
  28667. * Store of each included file for a shader (The can be looked up using effect.key)
  28668. */
  28669. static IncludesShadersStore: {
  28670. [key: string]: string;
  28671. };
  28672. /**
  28673. * Resets the cache of effects.
  28674. */
  28675. static ResetCache(): void;
  28676. }
  28677. }
  28678. declare module BABYLON {
  28679. /**
  28680. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28681. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28682. * 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;
  28683. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28684. */
  28685. export class ColorCurves {
  28686. private _dirty;
  28687. private _tempColor;
  28688. private _globalCurve;
  28689. private _highlightsCurve;
  28690. private _midtonesCurve;
  28691. private _shadowsCurve;
  28692. private _positiveCurve;
  28693. private _negativeCurve;
  28694. private _globalHue;
  28695. private _globalDensity;
  28696. private _globalSaturation;
  28697. private _globalExposure;
  28698. /**
  28699. * Gets the global Hue value.
  28700. * 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).
  28701. */
  28702. /**
  28703. * Sets the global Hue value.
  28704. * 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).
  28705. */
  28706. globalHue: number;
  28707. /**
  28708. * Gets the global Density value.
  28709. * 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.
  28710. * Values less than zero provide a filter of opposite hue.
  28711. */
  28712. /**
  28713. * Sets the global Density value.
  28714. * 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.
  28715. * Values less than zero provide a filter of opposite hue.
  28716. */
  28717. globalDensity: number;
  28718. /**
  28719. * Gets the global Saturation value.
  28720. * 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.
  28721. */
  28722. /**
  28723. * Sets the global Saturation value.
  28724. * 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.
  28725. */
  28726. globalSaturation: number;
  28727. /**
  28728. * Gets the global Exposure value.
  28729. * 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.
  28730. */
  28731. /**
  28732. * Sets the global Exposure value.
  28733. * 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.
  28734. */
  28735. globalExposure: number;
  28736. private _highlightsHue;
  28737. private _highlightsDensity;
  28738. private _highlightsSaturation;
  28739. private _highlightsExposure;
  28740. /**
  28741. * Gets the highlights Hue value.
  28742. * 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).
  28743. */
  28744. /**
  28745. * Sets the highlights Hue value.
  28746. * 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).
  28747. */
  28748. highlightsHue: number;
  28749. /**
  28750. * Gets the highlights Density value.
  28751. * 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.
  28752. * Values less than zero provide a filter of opposite hue.
  28753. */
  28754. /**
  28755. * Sets the highlights Density value.
  28756. * 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.
  28757. * Values less than zero provide a filter of opposite hue.
  28758. */
  28759. highlightsDensity: number;
  28760. /**
  28761. * Gets the highlights Saturation value.
  28762. * 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.
  28763. */
  28764. /**
  28765. * Sets the highlights Saturation value.
  28766. * 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.
  28767. */
  28768. highlightsSaturation: number;
  28769. /**
  28770. * Gets the highlights Exposure value.
  28771. * 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.
  28772. */
  28773. /**
  28774. * Sets the highlights Exposure value.
  28775. * 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.
  28776. */
  28777. highlightsExposure: number;
  28778. private _midtonesHue;
  28779. private _midtonesDensity;
  28780. private _midtonesSaturation;
  28781. private _midtonesExposure;
  28782. /**
  28783. * Gets the midtones Hue value.
  28784. * 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).
  28785. */
  28786. /**
  28787. * Sets the midtones Hue value.
  28788. * 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).
  28789. */
  28790. midtonesHue: number;
  28791. /**
  28792. * Gets the midtones Density value.
  28793. * 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.
  28794. * Values less than zero provide a filter of opposite hue.
  28795. */
  28796. /**
  28797. * Sets the midtones Density value.
  28798. * 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.
  28799. * Values less than zero provide a filter of opposite hue.
  28800. */
  28801. midtonesDensity: number;
  28802. /**
  28803. * Gets the midtones Saturation value.
  28804. * 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.
  28805. */
  28806. /**
  28807. * Sets the midtones Saturation value.
  28808. * 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.
  28809. */
  28810. midtonesSaturation: number;
  28811. /**
  28812. * Gets the midtones Exposure value.
  28813. * 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.
  28814. */
  28815. /**
  28816. * Sets the midtones Exposure value.
  28817. * 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.
  28818. */
  28819. midtonesExposure: number;
  28820. private _shadowsHue;
  28821. private _shadowsDensity;
  28822. private _shadowsSaturation;
  28823. private _shadowsExposure;
  28824. /**
  28825. * Gets the shadows Hue value.
  28826. * 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).
  28827. */
  28828. /**
  28829. * Sets the shadows Hue value.
  28830. * 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).
  28831. */
  28832. shadowsHue: number;
  28833. /**
  28834. * Gets the shadows Density value.
  28835. * 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.
  28836. * Values less than zero provide a filter of opposite hue.
  28837. */
  28838. /**
  28839. * Sets the shadows Density value.
  28840. * 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.
  28841. * Values less than zero provide a filter of opposite hue.
  28842. */
  28843. shadowsDensity: number;
  28844. /**
  28845. * Gets the shadows Saturation value.
  28846. * 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.
  28847. */
  28848. /**
  28849. * Sets the shadows Saturation value.
  28850. * 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.
  28851. */
  28852. shadowsSaturation: number;
  28853. /**
  28854. * Gets the shadows Exposure value.
  28855. * 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.
  28856. */
  28857. /**
  28858. * Sets the shadows Exposure value.
  28859. * 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.
  28860. */
  28861. shadowsExposure: number;
  28862. /**
  28863. * Returns the class name
  28864. * @returns The class name
  28865. */
  28866. getClassName(): string;
  28867. /**
  28868. * Binds the color curves to the shader.
  28869. * @param colorCurves The color curve to bind
  28870. * @param effect The effect to bind to
  28871. * @param positiveUniform The positive uniform shader parameter
  28872. * @param neutralUniform The neutral uniform shader parameter
  28873. * @param negativeUniform The negative uniform shader parameter
  28874. */
  28875. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  28876. /**
  28877. * Prepare the list of uniforms associated with the ColorCurves effects.
  28878. * @param uniformsList The list of uniforms used in the effect
  28879. */
  28880. static PrepareUniforms(uniformsList: string[]): void;
  28881. /**
  28882. * Returns color grading data based on a hue, density, saturation and exposure value.
  28883. * @param filterHue The hue of the color filter.
  28884. * @param filterDensity The density of the color filter.
  28885. * @param saturation The saturation.
  28886. * @param exposure The exposure.
  28887. * @param result The result data container.
  28888. */
  28889. private getColorGradingDataToRef;
  28890. /**
  28891. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  28892. * @param value The input slider value in range [-100,100].
  28893. * @returns Adjusted value.
  28894. */
  28895. private static applyColorGradingSliderNonlinear;
  28896. /**
  28897. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  28898. * @param hue The hue (H) input.
  28899. * @param saturation The saturation (S) input.
  28900. * @param brightness The brightness (B) input.
  28901. * @result An RGBA color represented as Vector4.
  28902. */
  28903. private static fromHSBToRef;
  28904. /**
  28905. * Returns a value clamped between min and max
  28906. * @param value The value to clamp
  28907. * @param min The minimum of value
  28908. * @param max The maximum of value
  28909. * @returns The clamped value.
  28910. */
  28911. private static clamp;
  28912. /**
  28913. * Clones the current color curve instance.
  28914. * @return The cloned curves
  28915. */
  28916. clone(): ColorCurves;
  28917. /**
  28918. * Serializes the current color curve instance to a json representation.
  28919. * @return a JSON representation
  28920. */
  28921. serialize(): any;
  28922. /**
  28923. * Parses the color curve from a json representation.
  28924. * @param source the JSON source to parse
  28925. * @return The parsed curves
  28926. */
  28927. static Parse(source: any): ColorCurves;
  28928. }
  28929. }
  28930. declare module BABYLON {
  28931. /**
  28932. * Interface to follow in your material defines to integrate easily the
  28933. * Image proccessing functions.
  28934. * @hidden
  28935. */
  28936. export interface IImageProcessingConfigurationDefines {
  28937. IMAGEPROCESSING: boolean;
  28938. VIGNETTE: boolean;
  28939. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28940. VIGNETTEBLENDMODEOPAQUE: boolean;
  28941. TONEMAPPING: boolean;
  28942. TONEMAPPING_ACES: boolean;
  28943. CONTRAST: boolean;
  28944. EXPOSURE: boolean;
  28945. COLORCURVES: boolean;
  28946. COLORGRADING: boolean;
  28947. COLORGRADING3D: boolean;
  28948. SAMPLER3DGREENDEPTH: boolean;
  28949. SAMPLER3DBGRMAP: boolean;
  28950. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28951. }
  28952. /**
  28953. * @hidden
  28954. */
  28955. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  28956. IMAGEPROCESSING: boolean;
  28957. VIGNETTE: boolean;
  28958. VIGNETTEBLENDMODEMULTIPLY: boolean;
  28959. VIGNETTEBLENDMODEOPAQUE: boolean;
  28960. TONEMAPPING: boolean;
  28961. TONEMAPPING_ACES: boolean;
  28962. CONTRAST: boolean;
  28963. COLORCURVES: boolean;
  28964. COLORGRADING: boolean;
  28965. COLORGRADING3D: boolean;
  28966. SAMPLER3DGREENDEPTH: boolean;
  28967. SAMPLER3DBGRMAP: boolean;
  28968. IMAGEPROCESSINGPOSTPROCESS: boolean;
  28969. EXPOSURE: boolean;
  28970. constructor();
  28971. }
  28972. /**
  28973. * This groups together the common properties used for image processing either in direct forward pass
  28974. * or through post processing effect depending on the use of the image processing pipeline in your scene
  28975. * or not.
  28976. */
  28977. export class ImageProcessingConfiguration {
  28978. /**
  28979. * Default tone mapping applied in BabylonJS.
  28980. */
  28981. static readonly TONEMAPPING_STANDARD: number;
  28982. /**
  28983. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  28984. * to other engines rendering to increase portability.
  28985. */
  28986. static readonly TONEMAPPING_ACES: number;
  28987. /**
  28988. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  28989. */
  28990. colorCurves: Nullable<ColorCurves>;
  28991. private _colorCurvesEnabled;
  28992. /**
  28993. * Gets wether the color curves effect is enabled.
  28994. */
  28995. /**
  28996. * Sets wether the color curves effect is enabled.
  28997. */
  28998. colorCurvesEnabled: boolean;
  28999. private _colorGradingTexture;
  29000. /**
  29001. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29002. */
  29003. /**
  29004. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29005. */
  29006. colorGradingTexture: Nullable<BaseTexture>;
  29007. private _colorGradingEnabled;
  29008. /**
  29009. * Gets wether the color grading effect is enabled.
  29010. */
  29011. /**
  29012. * Sets wether the color grading effect is enabled.
  29013. */
  29014. colorGradingEnabled: boolean;
  29015. private _colorGradingWithGreenDepth;
  29016. /**
  29017. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29018. */
  29019. /**
  29020. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29021. */
  29022. colorGradingWithGreenDepth: boolean;
  29023. private _colorGradingBGR;
  29024. /**
  29025. * Gets wether the color grading texture contains BGR values.
  29026. */
  29027. /**
  29028. * Sets wether the color grading texture contains BGR values.
  29029. */
  29030. colorGradingBGR: boolean;
  29031. /** @hidden */
  29032. _exposure: number;
  29033. /**
  29034. * Gets the Exposure used in the effect.
  29035. */
  29036. /**
  29037. * Sets the Exposure used in the effect.
  29038. */
  29039. exposure: number;
  29040. private _toneMappingEnabled;
  29041. /**
  29042. * Gets wether the tone mapping effect is enabled.
  29043. */
  29044. /**
  29045. * Sets wether the tone mapping effect is enabled.
  29046. */
  29047. toneMappingEnabled: boolean;
  29048. private _toneMappingType;
  29049. /**
  29050. * Gets the type of tone mapping effect.
  29051. */
  29052. /**
  29053. * Sets the type of tone mapping effect used in BabylonJS.
  29054. */
  29055. toneMappingType: number;
  29056. protected _contrast: number;
  29057. /**
  29058. * Gets the contrast used in the effect.
  29059. */
  29060. /**
  29061. * Sets the contrast used in the effect.
  29062. */
  29063. contrast: number;
  29064. /**
  29065. * Vignette stretch size.
  29066. */
  29067. vignetteStretch: number;
  29068. /**
  29069. * Vignette centre X Offset.
  29070. */
  29071. vignetteCentreX: number;
  29072. /**
  29073. * Vignette centre Y Offset.
  29074. */
  29075. vignetteCentreY: number;
  29076. /**
  29077. * Vignette weight or intensity of the vignette effect.
  29078. */
  29079. vignetteWeight: number;
  29080. /**
  29081. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29082. * if vignetteEnabled is set to true.
  29083. */
  29084. vignetteColor: Color4;
  29085. /**
  29086. * Camera field of view used by the Vignette effect.
  29087. */
  29088. vignetteCameraFov: number;
  29089. private _vignetteBlendMode;
  29090. /**
  29091. * Gets the vignette blend mode allowing different kind of effect.
  29092. */
  29093. /**
  29094. * Sets the vignette blend mode allowing different kind of effect.
  29095. */
  29096. vignetteBlendMode: number;
  29097. private _vignetteEnabled;
  29098. /**
  29099. * Gets wether the vignette effect is enabled.
  29100. */
  29101. /**
  29102. * Sets wether the vignette effect is enabled.
  29103. */
  29104. vignetteEnabled: boolean;
  29105. private _applyByPostProcess;
  29106. /**
  29107. * Gets wether the image processing is applied through a post process or not.
  29108. */
  29109. /**
  29110. * Sets wether the image processing is applied through a post process or not.
  29111. */
  29112. applyByPostProcess: boolean;
  29113. private _isEnabled;
  29114. /**
  29115. * Gets wether the image processing is enabled or not.
  29116. */
  29117. /**
  29118. * Sets wether the image processing is enabled or not.
  29119. */
  29120. isEnabled: boolean;
  29121. /**
  29122. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29123. */
  29124. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29125. /**
  29126. * Method called each time the image processing information changes requires to recompile the effect.
  29127. */
  29128. protected _updateParameters(): void;
  29129. /**
  29130. * Gets the current class name.
  29131. * @return "ImageProcessingConfiguration"
  29132. */
  29133. getClassName(): string;
  29134. /**
  29135. * Prepare the list of uniforms associated with the Image Processing effects.
  29136. * @param uniforms The list of uniforms used in the effect
  29137. * @param defines the list of defines currently in use
  29138. */
  29139. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29140. /**
  29141. * Prepare the list of samplers associated with the Image Processing effects.
  29142. * @param samplersList The list of uniforms used in the effect
  29143. * @param defines the list of defines currently in use
  29144. */
  29145. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29146. /**
  29147. * Prepare the list of defines associated to the shader.
  29148. * @param defines the list of defines to complete
  29149. * @param forPostProcess Define if we are currently in post process mode or not
  29150. */
  29151. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29152. /**
  29153. * Returns true if all the image processing information are ready.
  29154. * @returns True if ready, otherwise, false
  29155. */
  29156. isReady(): boolean;
  29157. /**
  29158. * Binds the image processing to the shader.
  29159. * @param effect The effect to bind to
  29160. * @param aspectRatio Define the current aspect ratio of the effect
  29161. */
  29162. bind(effect: Effect, aspectRatio?: number): void;
  29163. /**
  29164. * Clones the current image processing instance.
  29165. * @return The cloned image processing
  29166. */
  29167. clone(): ImageProcessingConfiguration;
  29168. /**
  29169. * Serializes the current image processing instance to a json representation.
  29170. * @return a JSON representation
  29171. */
  29172. serialize(): any;
  29173. /**
  29174. * Parses the image processing from a json representation.
  29175. * @param source the JSON source to parse
  29176. * @return The parsed image processing
  29177. */
  29178. static Parse(source: any): ImageProcessingConfiguration;
  29179. private static _VIGNETTEMODE_MULTIPLY;
  29180. private static _VIGNETTEMODE_OPAQUE;
  29181. /**
  29182. * Used to apply the vignette as a mix with the pixel color.
  29183. */
  29184. static readonly VIGNETTEMODE_MULTIPLY: number;
  29185. /**
  29186. * Used to apply the vignette as a replacement of the pixel color.
  29187. */
  29188. static readonly VIGNETTEMODE_OPAQUE: number;
  29189. }
  29190. }
  29191. declare module BABYLON {
  29192. /**
  29193. * This represents all the required information to add a fresnel effect on a material:
  29194. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29195. */
  29196. export class FresnelParameters {
  29197. private _isEnabled;
  29198. /**
  29199. * Define if the fresnel effect is enable or not.
  29200. */
  29201. isEnabled: boolean;
  29202. /**
  29203. * Define the color used on edges (grazing angle)
  29204. */
  29205. leftColor: Color3;
  29206. /**
  29207. * Define the color used on center
  29208. */
  29209. rightColor: Color3;
  29210. /**
  29211. * Define bias applied to computed fresnel term
  29212. */
  29213. bias: number;
  29214. /**
  29215. * Defined the power exponent applied to fresnel term
  29216. */
  29217. power: number;
  29218. /**
  29219. * Clones the current fresnel and its valuues
  29220. * @returns a clone fresnel configuration
  29221. */
  29222. clone(): FresnelParameters;
  29223. /**
  29224. * Serializes the current fresnel parameters to a JSON representation.
  29225. * @return the JSON serialization
  29226. */
  29227. serialize(): any;
  29228. /**
  29229. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29230. * @param parsedFresnelParameters Define the JSON representation
  29231. * @returns the parsed parameters
  29232. */
  29233. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29234. }
  29235. }
  29236. declare module BABYLON {
  29237. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29238. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29239. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29240. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29241. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29242. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29243. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29244. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29245. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29246. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29247. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29248. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29249. /**
  29250. * Decorator used to define property that can be serialized as reference to a camera
  29251. * @param sourceName defines the name of the property to decorate
  29252. */
  29253. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29254. /**
  29255. * Class used to help serialization objects
  29256. */
  29257. export class SerializationHelper {
  29258. /** hidden */
  29259. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29260. /** hidden */
  29261. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29262. /** hidden */
  29263. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29264. /** hidden */
  29265. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29266. /**
  29267. * Appends the serialized animations from the source animations
  29268. * @param source Source containing the animations
  29269. * @param destination Target to store the animations
  29270. */
  29271. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29272. /**
  29273. * Static function used to serialized a specific entity
  29274. * @param entity defines the entity to serialize
  29275. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29276. * @returns a JSON compatible object representing the serialization of the entity
  29277. */
  29278. static Serialize<T>(entity: T, serializationObject?: any): any;
  29279. /**
  29280. * Creates a new entity from a serialization data object
  29281. * @param creationFunction defines a function used to instanciated the new entity
  29282. * @param source defines the source serialization data
  29283. * @param scene defines the hosting scene
  29284. * @param rootUrl defines the root url for resources
  29285. * @returns a new entity
  29286. */
  29287. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29288. /**
  29289. * Clones an object
  29290. * @param creationFunction defines the function used to instanciate the new object
  29291. * @param source defines the source object
  29292. * @returns the cloned object
  29293. */
  29294. static Clone<T>(creationFunction: () => T, source: T): T;
  29295. /**
  29296. * Instanciates a new object based on a source one (some data will be shared between both object)
  29297. * @param creationFunction defines the function used to instanciate the new object
  29298. * @param source defines the source object
  29299. * @returns the new object
  29300. */
  29301. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29302. }
  29303. }
  29304. declare module BABYLON {
  29305. /**
  29306. * This is the base class of all the camera used in the application.
  29307. * @see http://doc.babylonjs.com/features/cameras
  29308. */
  29309. export class Camera extends Node {
  29310. /** @hidden */
  29311. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29312. /**
  29313. * This is the default projection mode used by the cameras.
  29314. * It helps recreating a feeling of perspective and better appreciate depth.
  29315. * This is the best way to simulate real life cameras.
  29316. */
  29317. static readonly PERSPECTIVE_CAMERA: number;
  29318. /**
  29319. * This helps creating camera with an orthographic mode.
  29320. * 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.
  29321. */
  29322. static readonly ORTHOGRAPHIC_CAMERA: number;
  29323. /**
  29324. * This is the default FOV mode for perspective cameras.
  29325. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29326. */
  29327. static readonly FOVMODE_VERTICAL_FIXED: number;
  29328. /**
  29329. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29330. */
  29331. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29332. /**
  29333. * This specifies ther is no need for a camera rig.
  29334. * Basically only one eye is rendered corresponding to the camera.
  29335. */
  29336. static readonly RIG_MODE_NONE: number;
  29337. /**
  29338. * Simulates a camera Rig with one blue eye and one red eye.
  29339. * This can be use with 3d blue and red glasses.
  29340. */
  29341. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29342. /**
  29343. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29344. */
  29345. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29346. /**
  29347. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29348. */
  29349. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29350. /**
  29351. * Defines that both eyes of the camera will be rendered over under each other.
  29352. */
  29353. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29354. /**
  29355. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29356. */
  29357. static readonly RIG_MODE_VR: number;
  29358. /**
  29359. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29360. */
  29361. static readonly RIG_MODE_WEBVR: number;
  29362. /**
  29363. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29364. */
  29365. static readonly RIG_MODE_CUSTOM: number;
  29366. /**
  29367. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29368. */
  29369. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29370. /**
  29371. * @hidden
  29372. * Might be removed once multiview will be a thing
  29373. */
  29374. static UseAlternateWebVRRendering: boolean;
  29375. /**
  29376. * Define the input manager associated with the camera.
  29377. */
  29378. inputs: CameraInputsManager<Camera>;
  29379. /**
  29380. * Define the current local position of the camera in the scene
  29381. */
  29382. position: Vector3;
  29383. /**
  29384. * The vector the camera should consider as up.
  29385. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29386. */
  29387. upVector: Vector3;
  29388. /**
  29389. * Define the current limit on the left side for an orthographic camera
  29390. * In scene unit
  29391. */
  29392. orthoLeft: Nullable<number>;
  29393. /**
  29394. * Define the current limit on the right side for an orthographic camera
  29395. * In scene unit
  29396. */
  29397. orthoRight: Nullable<number>;
  29398. /**
  29399. * Define the current limit on the bottom side for an orthographic camera
  29400. * In scene unit
  29401. */
  29402. orthoBottom: Nullable<number>;
  29403. /**
  29404. * Define the current limit on the top side for an orthographic camera
  29405. * In scene unit
  29406. */
  29407. orthoTop: Nullable<number>;
  29408. /**
  29409. * Field Of View is set in Radians. (default is 0.8)
  29410. */
  29411. fov: number;
  29412. /**
  29413. * Define the minimum distance the camera can see from.
  29414. * This is important to note that the depth buffer are not infinite and the closer it starts
  29415. * the more your scene might encounter depth fighting issue.
  29416. */
  29417. minZ: number;
  29418. /**
  29419. * Define the maximum distance the camera can see to.
  29420. * This is important to note that the depth buffer are not infinite and the further it end
  29421. * the more your scene might encounter depth fighting issue.
  29422. */
  29423. maxZ: number;
  29424. /**
  29425. * Define the default inertia of the camera.
  29426. * This helps giving a smooth feeling to the camera movement.
  29427. */
  29428. inertia: number;
  29429. /**
  29430. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29431. */
  29432. mode: number;
  29433. /**
  29434. * Define wether the camera is intermediate.
  29435. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29436. */
  29437. isIntermediate: boolean;
  29438. /**
  29439. * Define the viewport of the camera.
  29440. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29441. */
  29442. viewport: Viewport;
  29443. /**
  29444. * Restricts the camera to viewing objects with the same layerMask.
  29445. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29446. */
  29447. layerMask: number;
  29448. /**
  29449. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29450. */
  29451. fovMode: number;
  29452. /**
  29453. * Rig mode of the camera.
  29454. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29455. * This is normally controlled byt the camera themselves as internal use.
  29456. */
  29457. cameraRigMode: number;
  29458. /**
  29459. * Defines the distance between both "eyes" in case of a RIG
  29460. */
  29461. interaxialDistance: number;
  29462. /**
  29463. * Defines if stereoscopic rendering is done side by side or over under.
  29464. */
  29465. isStereoscopicSideBySide: boolean;
  29466. /**
  29467. * 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
  29468. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29469. * else in the scene.
  29470. */
  29471. customRenderTargets: RenderTargetTexture[];
  29472. /**
  29473. * When set, the camera will render to this render target instead of the default canvas
  29474. */
  29475. outputRenderTarget: Nullable<RenderTargetTexture>;
  29476. /**
  29477. * Observable triggered when the camera view matrix has changed.
  29478. */
  29479. onViewMatrixChangedObservable: Observable<Camera>;
  29480. /**
  29481. * Observable triggered when the camera Projection matrix has changed.
  29482. */
  29483. onProjectionMatrixChangedObservable: Observable<Camera>;
  29484. /**
  29485. * Observable triggered when the inputs have been processed.
  29486. */
  29487. onAfterCheckInputsObservable: Observable<Camera>;
  29488. /**
  29489. * Observable triggered when reset has been called and applied to the camera.
  29490. */
  29491. onRestoreStateObservable: Observable<Camera>;
  29492. /** @hidden */
  29493. _cameraRigParams: any;
  29494. /** @hidden */
  29495. _rigCameras: Camera[];
  29496. /** @hidden */
  29497. _rigPostProcess: Nullable<PostProcess>;
  29498. protected _webvrViewMatrix: Matrix;
  29499. /** @hidden */
  29500. _skipRendering: boolean;
  29501. /** @hidden */
  29502. _alternateCamera: Camera;
  29503. /** @hidden */
  29504. _projectionMatrix: Matrix;
  29505. /** @hidden */
  29506. _postProcesses: Nullable<PostProcess>[];
  29507. /** @hidden */
  29508. _activeMeshes: SmartArray<AbstractMesh>;
  29509. protected _globalPosition: Vector3;
  29510. /** hidden */
  29511. _computedViewMatrix: Matrix;
  29512. private _doNotComputeProjectionMatrix;
  29513. private _transformMatrix;
  29514. private _frustumPlanes;
  29515. private _refreshFrustumPlanes;
  29516. private _storedFov;
  29517. private _stateStored;
  29518. /**
  29519. * Instantiates a new camera object.
  29520. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29521. * @see http://doc.babylonjs.com/features/cameras
  29522. * @param name Defines the name of the camera in the scene
  29523. * @param position Defines the position of the camera
  29524. * @param scene Defines the scene the camera belongs too
  29525. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29526. */
  29527. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29528. /**
  29529. * Store current camera state (fov, position, etc..)
  29530. * @returns the camera
  29531. */
  29532. storeState(): Camera;
  29533. /**
  29534. * Restores the camera state values if it has been stored. You must call storeState() first
  29535. */
  29536. protected _restoreStateValues(): boolean;
  29537. /**
  29538. * Restored camera state. You must call storeState() first.
  29539. * @returns true if restored and false otherwise
  29540. */
  29541. restoreState(): boolean;
  29542. /**
  29543. * Gets the class name of the camera.
  29544. * @returns the class name
  29545. */
  29546. getClassName(): string;
  29547. /** @hidden */
  29548. readonly _isCamera: boolean;
  29549. /**
  29550. * Gets a string representation of the camera useful for debug purpose.
  29551. * @param fullDetails Defines that a more verboe level of logging is required
  29552. * @returns the string representation
  29553. */
  29554. toString(fullDetails?: boolean): string;
  29555. /**
  29556. * Gets the current world space position of the camera.
  29557. */
  29558. readonly globalPosition: Vector3;
  29559. /**
  29560. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29561. * @returns the active meshe list
  29562. */
  29563. getActiveMeshes(): SmartArray<AbstractMesh>;
  29564. /**
  29565. * Check wether a mesh is part of the current active mesh list of the camera
  29566. * @param mesh Defines the mesh to check
  29567. * @returns true if active, false otherwise
  29568. */
  29569. isActiveMesh(mesh: Mesh): boolean;
  29570. /**
  29571. * Is this camera ready to be used/rendered
  29572. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29573. * @return true if the camera is ready
  29574. */
  29575. isReady(completeCheck?: boolean): boolean;
  29576. /** @hidden */
  29577. _initCache(): void;
  29578. /** @hidden */
  29579. _updateCache(ignoreParentClass?: boolean): void;
  29580. /** @hidden */
  29581. _isSynchronized(): boolean;
  29582. /** @hidden */
  29583. _isSynchronizedViewMatrix(): boolean;
  29584. /** @hidden */
  29585. _isSynchronizedProjectionMatrix(): boolean;
  29586. /**
  29587. * Attach the input controls to a specific dom element to get the input from.
  29588. * @param element Defines the element the controls should be listened from
  29589. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29590. */
  29591. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29592. /**
  29593. * Detach the current controls from the specified dom element.
  29594. * @param element Defines the element to stop listening the inputs from
  29595. */
  29596. detachControl(element: HTMLElement): void;
  29597. /**
  29598. * Update the camera state according to the different inputs gathered during the frame.
  29599. */
  29600. update(): void;
  29601. /** @hidden */
  29602. _checkInputs(): void;
  29603. /** @hidden */
  29604. readonly rigCameras: Camera[];
  29605. /**
  29606. * Gets the post process used by the rig cameras
  29607. */
  29608. readonly rigPostProcess: Nullable<PostProcess>;
  29609. /**
  29610. * Internal, gets the first post proces.
  29611. * @returns the first post process to be run on this camera.
  29612. */
  29613. _getFirstPostProcess(): Nullable<PostProcess>;
  29614. private _cascadePostProcessesToRigCams;
  29615. /**
  29616. * Attach a post process to the camera.
  29617. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29618. * @param postProcess The post process to attach to the camera
  29619. * @param insertAt The position of the post process in case several of them are in use in the scene
  29620. * @returns the position the post process has been inserted at
  29621. */
  29622. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29623. /**
  29624. * Detach a post process to the camera.
  29625. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29626. * @param postProcess The post process to detach from the camera
  29627. */
  29628. detachPostProcess(postProcess: PostProcess): void;
  29629. /**
  29630. * Gets the current world matrix of the camera
  29631. */
  29632. getWorldMatrix(): Matrix;
  29633. /** @hidden */
  29634. _getViewMatrix(): Matrix;
  29635. /**
  29636. * Gets the current view matrix of the camera.
  29637. * @param force forces the camera to recompute the matrix without looking at the cached state
  29638. * @returns the view matrix
  29639. */
  29640. getViewMatrix(force?: boolean): Matrix;
  29641. /**
  29642. * Freeze the projection matrix.
  29643. * It will prevent the cache check of the camera projection compute and can speed up perf
  29644. * if no parameter of the camera are meant to change
  29645. * @param projection Defines manually a projection if necessary
  29646. */
  29647. freezeProjectionMatrix(projection?: Matrix): void;
  29648. /**
  29649. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29650. */
  29651. unfreezeProjectionMatrix(): void;
  29652. /**
  29653. * Gets the current projection matrix of the camera.
  29654. * @param force forces the camera to recompute the matrix without looking at the cached state
  29655. * @returns the projection matrix
  29656. */
  29657. getProjectionMatrix(force?: boolean): Matrix;
  29658. /**
  29659. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29660. * @returns a Matrix
  29661. */
  29662. getTransformationMatrix(): Matrix;
  29663. private _updateFrustumPlanes;
  29664. /**
  29665. * Checks if a cullable object (mesh...) is in the camera frustum
  29666. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29667. * @param target The object to check
  29668. * @returns true if the object is in frustum otherwise false
  29669. */
  29670. isInFrustum(target: ICullable): boolean;
  29671. /**
  29672. * Checks if a cullable object (mesh...) is in the camera frustum
  29673. * Unlike isInFrustum this cheks the full bounding box
  29674. * @param target The object to check
  29675. * @returns true if the object is in frustum otherwise false
  29676. */
  29677. isCompletelyInFrustum(target: ICullable): boolean;
  29678. /**
  29679. * Gets a ray in the forward direction from the camera.
  29680. * @param length Defines the length of the ray to create
  29681. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29682. * @param origin Defines the start point of the ray which defaults to the camera position
  29683. * @returns the forward ray
  29684. */
  29685. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29686. /**
  29687. * Releases resources associated with this node.
  29688. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29689. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29690. */
  29691. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29692. /**
  29693. * Gets the left camera of a rig setup in case of Rigged Camera
  29694. */
  29695. readonly leftCamera: Nullable<FreeCamera>;
  29696. /**
  29697. * Gets the right camera of a rig setup in case of Rigged Camera
  29698. */
  29699. readonly rightCamera: Nullable<FreeCamera>;
  29700. /**
  29701. * Gets the left camera target of a rig setup in case of Rigged Camera
  29702. * @returns the target position
  29703. */
  29704. getLeftTarget(): Nullable<Vector3>;
  29705. /**
  29706. * Gets the right camera target of a rig setup in case of Rigged Camera
  29707. * @returns the target position
  29708. */
  29709. getRightTarget(): Nullable<Vector3>;
  29710. /**
  29711. * @hidden
  29712. */
  29713. setCameraRigMode(mode: number, rigParams: any): void;
  29714. /** @hidden */
  29715. static _setStereoscopicRigMode(camera: Camera): void;
  29716. /** @hidden */
  29717. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29718. /** @hidden */
  29719. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29720. /** @hidden */
  29721. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29722. /** @hidden */
  29723. _getVRProjectionMatrix(): Matrix;
  29724. protected _updateCameraRotationMatrix(): void;
  29725. protected _updateWebVRCameraRotationMatrix(): void;
  29726. /**
  29727. * This function MUST be overwritten by the different WebVR cameras available.
  29728. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29729. * @hidden
  29730. */
  29731. _getWebVRProjectionMatrix(): Matrix;
  29732. /**
  29733. * This function MUST be overwritten by the different WebVR cameras available.
  29734. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29735. * @hidden
  29736. */
  29737. _getWebVRViewMatrix(): Matrix;
  29738. /** @hidden */
  29739. setCameraRigParameter(name: string, value: any): void;
  29740. /**
  29741. * needs to be overridden by children so sub has required properties to be copied
  29742. * @hidden
  29743. */
  29744. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29745. /**
  29746. * May need to be overridden by children
  29747. * @hidden
  29748. */
  29749. _updateRigCameras(): void;
  29750. /** @hidden */
  29751. _setupInputs(): void;
  29752. /**
  29753. * Serialiaze the camera setup to a json represention
  29754. * @returns the JSON representation
  29755. */
  29756. serialize(): any;
  29757. /**
  29758. * Clones the current camera.
  29759. * @param name The cloned camera name
  29760. * @returns the cloned camera
  29761. */
  29762. clone(name: string): Camera;
  29763. /**
  29764. * Gets the direction of the camera relative to a given local axis.
  29765. * @param localAxis Defines the reference axis to provide a relative direction.
  29766. * @return the direction
  29767. */
  29768. getDirection(localAxis: Vector3): Vector3;
  29769. /**
  29770. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29771. * @param localAxis Defines the reference axis to provide a relative direction.
  29772. * @param result Defines the vector to store the result in
  29773. */
  29774. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29775. /**
  29776. * Gets a camera constructor for a given camera type
  29777. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29778. * @param name The name of the camera the result will be able to instantiate
  29779. * @param scene The scene the result will construct the camera in
  29780. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29781. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29782. * @returns a factory method to construc the camera
  29783. */
  29784. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29785. /**
  29786. * Compute the world matrix of the camera.
  29787. * @returns the camera workd matrix
  29788. */
  29789. computeWorldMatrix(): Matrix;
  29790. /**
  29791. * Parse a JSON and creates the camera from the parsed information
  29792. * @param parsedCamera The JSON to parse
  29793. * @param scene The scene to instantiate the camera in
  29794. * @returns the newly constructed camera
  29795. */
  29796. static Parse(parsedCamera: any, scene: Scene): Camera;
  29797. }
  29798. }
  29799. declare module BABYLON {
  29800. /**
  29801. * Interface for any object that can request an animation frame
  29802. */
  29803. export interface ICustomAnimationFrameRequester {
  29804. /**
  29805. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  29806. */
  29807. renderFunction?: Function;
  29808. /**
  29809. * Called to request the next frame to render to
  29810. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  29811. */
  29812. requestAnimationFrame: Function;
  29813. /**
  29814. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  29815. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  29816. */
  29817. requestID?: number;
  29818. }
  29819. /**
  29820. * Interface containing an array of animations
  29821. */
  29822. export interface IAnimatable {
  29823. /**
  29824. * Array of animations
  29825. */
  29826. animations: Array<Animation>;
  29827. }
  29828. /** Interface used by value gradients (color, factor, ...) */
  29829. export interface IValueGradient {
  29830. /**
  29831. * Gets or sets the gradient value (between 0 and 1)
  29832. */
  29833. gradient: number;
  29834. }
  29835. /** Class used to store color4 gradient */
  29836. export class ColorGradient implements IValueGradient {
  29837. /**
  29838. * Gets or sets the gradient value (between 0 and 1)
  29839. */
  29840. gradient: number;
  29841. /**
  29842. * Gets or sets first associated color
  29843. */
  29844. color1: Color4;
  29845. /**
  29846. * Gets or sets second associated color
  29847. */
  29848. color2?: Color4;
  29849. /**
  29850. * Will get a color picked randomly between color1 and color2.
  29851. * If color2 is undefined then color1 will be used
  29852. * @param result defines the target Color4 to store the result in
  29853. */
  29854. getColorToRef(result: Color4): void;
  29855. }
  29856. /** Class used to store color 3 gradient */
  29857. export class Color3Gradient implements IValueGradient {
  29858. /**
  29859. * Gets or sets the gradient value (between 0 and 1)
  29860. */
  29861. gradient: number;
  29862. /**
  29863. * Gets or sets the associated color
  29864. */
  29865. color: Color3;
  29866. }
  29867. /** Class used to store factor gradient */
  29868. export class FactorGradient implements IValueGradient {
  29869. /**
  29870. * Gets or sets the gradient value (between 0 and 1)
  29871. */
  29872. gradient: number;
  29873. /**
  29874. * Gets or sets first associated factor
  29875. */
  29876. factor1: number;
  29877. /**
  29878. * Gets or sets second associated factor
  29879. */
  29880. factor2?: number;
  29881. /**
  29882. * Will get a number picked randomly between factor1 and factor2.
  29883. * If factor2 is undefined then factor1 will be used
  29884. * @returns the picked number
  29885. */
  29886. getFactor(): number;
  29887. }
  29888. /**
  29889. * @ignore
  29890. * Application error to support additional information when loading a file
  29891. */
  29892. export class LoadFileError extends Error {
  29893. /** defines the optional XHR request */
  29894. request?: XMLHttpRequest | undefined;
  29895. private static _setPrototypeOf;
  29896. /**
  29897. * Creates a new LoadFileError
  29898. * @param message defines the message of the error
  29899. * @param request defines the optional XHR request
  29900. */
  29901. constructor(message: string,
  29902. /** defines the optional XHR request */
  29903. request?: XMLHttpRequest | undefined);
  29904. }
  29905. /**
  29906. * Class used to define a retry strategy when error happens while loading assets
  29907. */
  29908. export class RetryStrategy {
  29909. /**
  29910. * Function used to defines an exponential back off strategy
  29911. * @param maxRetries defines the maximum number of retries (3 by default)
  29912. * @param baseInterval defines the interval between retries
  29913. * @returns the strategy function to use
  29914. */
  29915. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29916. }
  29917. /**
  29918. * File request interface
  29919. */
  29920. export interface IFileRequest {
  29921. /**
  29922. * Raised when the request is complete (success or error).
  29923. */
  29924. onCompleteObservable: Observable<IFileRequest>;
  29925. /**
  29926. * Aborts the request for a file.
  29927. */
  29928. abort: () => void;
  29929. }
  29930. /**
  29931. * Class containing a set of static utilities functions
  29932. */
  29933. export class Tools {
  29934. /**
  29935. * Gets or sets the base URL to use to load assets
  29936. */
  29937. static BaseUrl: string;
  29938. /**
  29939. * Enable/Disable Custom HTTP Request Headers globally.
  29940. * default = false
  29941. * @see CustomRequestHeaders
  29942. */
  29943. static UseCustomRequestHeaders: boolean;
  29944. /**
  29945. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  29946. * i.e. when loading files, where the server/service expects an Authorization header.
  29947. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  29948. */
  29949. static CustomRequestHeaders: {
  29950. [key: string]: string;
  29951. };
  29952. /**
  29953. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  29954. */
  29955. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  29956. /**
  29957. * Default behaviour for cors in the application.
  29958. * It can be a string if the expected behavior is identical in the entire app.
  29959. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  29960. */
  29961. static CorsBehavior: string | ((url: string | string[]) => string);
  29962. /**
  29963. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  29964. * @ignorenaming
  29965. */
  29966. static UseFallbackTexture: boolean;
  29967. /**
  29968. * Use this object to register external classes like custom textures or material
  29969. * to allow the laoders to instantiate them
  29970. */
  29971. static RegisteredExternalClasses: {
  29972. [key: string]: Object;
  29973. };
  29974. /**
  29975. * Texture content used if a texture cannot loaded
  29976. * @ignorenaming
  29977. */
  29978. static fallbackTexture: string;
  29979. /**
  29980. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  29981. * @param u defines the coordinate on X axis
  29982. * @param v defines the coordinate on Y axis
  29983. * @param width defines the width of the source data
  29984. * @param height defines the height of the source data
  29985. * @param pixels defines the source byte array
  29986. * @param color defines the output color
  29987. */
  29988. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  29989. /**
  29990. * Interpolates between a and b via alpha
  29991. * @param a The lower value (returned when alpha = 0)
  29992. * @param b The upper value (returned when alpha = 1)
  29993. * @param alpha The interpolation-factor
  29994. * @return The mixed value
  29995. */
  29996. static Mix(a: number, b: number, alpha: number): number;
  29997. /**
  29998. * Tries to instantiate a new object from a given class name
  29999. * @param className defines the class name to instantiate
  30000. * @returns the new object or null if the system was not able to do the instantiation
  30001. */
  30002. static Instantiate(className: string): any;
  30003. /**
  30004. * Provides a slice function that will work even on IE
  30005. * @param data defines the array to slice
  30006. * @param start defines the start of the data (optional)
  30007. * @param end defines the end of the data (optional)
  30008. * @returns the new sliced array
  30009. */
  30010. static Slice<T>(data: T, start?: number, end?: number): T;
  30011. /**
  30012. * Polyfill for setImmediate
  30013. * @param action defines the action to execute after the current execution block
  30014. */
  30015. static SetImmediate(action: () => void): void;
  30016. /**
  30017. * Function indicating if a number is an exponent of 2
  30018. * @param value defines the value to test
  30019. * @returns true if the value is an exponent of 2
  30020. */
  30021. static IsExponentOfTwo(value: number): boolean;
  30022. private static _tmpFloatArray;
  30023. /**
  30024. * Returns the nearest 32-bit single precision float representation of a Number
  30025. * @param value A Number. If the parameter is of a different type, it will get converted
  30026. * to a number or to NaN if it cannot be converted
  30027. * @returns number
  30028. */
  30029. static FloatRound(value: number): number;
  30030. /**
  30031. * Find the next highest power of two.
  30032. * @param x Number to start search from.
  30033. * @return Next highest power of two.
  30034. */
  30035. static CeilingPOT(x: number): number;
  30036. /**
  30037. * Find the next lowest power of two.
  30038. * @param x Number to start search from.
  30039. * @return Next lowest power of two.
  30040. */
  30041. static FloorPOT(x: number): number;
  30042. /**
  30043. * Find the nearest power of two.
  30044. * @param x Number to start search from.
  30045. * @return Next nearest power of two.
  30046. */
  30047. static NearestPOT(x: number): number;
  30048. /**
  30049. * Get the closest exponent of two
  30050. * @param value defines the value to approximate
  30051. * @param max defines the maximum value to return
  30052. * @param mode defines how to define the closest value
  30053. * @returns closest exponent of two of the given value
  30054. */
  30055. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30056. /**
  30057. * Extracts the filename from a path
  30058. * @param path defines the path to use
  30059. * @returns the filename
  30060. */
  30061. static GetFilename(path: string): string;
  30062. /**
  30063. * Extracts the "folder" part of a path (everything before the filename).
  30064. * @param uri The URI to extract the info from
  30065. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30066. * @returns The "folder" part of the path
  30067. */
  30068. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30069. /**
  30070. * Extracts text content from a DOM element hierarchy
  30071. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30072. */
  30073. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30074. /**
  30075. * Convert an angle in radians to degrees
  30076. * @param angle defines the angle to convert
  30077. * @returns the angle in degrees
  30078. */
  30079. static ToDegrees(angle: number): number;
  30080. /**
  30081. * Convert an angle in degrees to radians
  30082. * @param angle defines the angle to convert
  30083. * @returns the angle in radians
  30084. */
  30085. static ToRadians(angle: number): number;
  30086. /**
  30087. * Encode a buffer to a base64 string
  30088. * @param buffer defines the buffer to encode
  30089. * @returns the encoded string
  30090. */
  30091. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30092. /**
  30093. * Extracts minimum and maximum values from a list of indexed positions
  30094. * @param positions defines the positions to use
  30095. * @param indices defines the indices to the positions
  30096. * @param indexStart defines the start index
  30097. * @param indexCount defines the end index
  30098. * @param bias defines bias value to add to the result
  30099. * @return minimum and maximum values
  30100. */
  30101. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30102. minimum: Vector3;
  30103. maximum: Vector3;
  30104. };
  30105. /**
  30106. * Extracts minimum and maximum values from a list of positions
  30107. * @param positions defines the positions to use
  30108. * @param start defines the start index in the positions array
  30109. * @param count defines the number of positions to handle
  30110. * @param bias defines bias value to add to the result
  30111. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30112. * @return minimum and maximum values
  30113. */
  30114. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30115. minimum: Vector3;
  30116. maximum: Vector3;
  30117. };
  30118. /**
  30119. * Returns an array if obj is not an array
  30120. * @param obj defines the object to evaluate as an array
  30121. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30122. * @returns either obj directly if obj is an array or a new array containing obj
  30123. */
  30124. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30125. /**
  30126. * Gets the pointer prefix to use
  30127. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30128. */
  30129. static GetPointerPrefix(): string;
  30130. /**
  30131. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30132. * @param func - the function to be called
  30133. * @param requester - the object that will request the next frame. Falls back to window.
  30134. * @returns frame number
  30135. */
  30136. static QueueNewFrame(func: () => void, requester?: any): number;
  30137. /**
  30138. * Ask the browser to promote the current element to fullscreen rendering mode
  30139. * @param element defines the DOM element to promote
  30140. */
  30141. static RequestFullscreen(element: HTMLElement): void;
  30142. /**
  30143. * Asks the browser to exit fullscreen mode
  30144. */
  30145. static ExitFullscreen(): void;
  30146. /**
  30147. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30148. * @param url define the url we are trying
  30149. * @param element define the dom element where to configure the cors policy
  30150. */
  30151. static SetCorsBehavior(url: string | string[], element: {
  30152. crossOrigin: string | null;
  30153. }): void;
  30154. /**
  30155. * Removes unwanted characters from an url
  30156. * @param url defines the url to clean
  30157. * @returns the cleaned url
  30158. */
  30159. static CleanUrl(url: string): string;
  30160. /**
  30161. * Gets or sets a function used to pre-process url before using them to load assets
  30162. */
  30163. static PreprocessUrl: (url: string) => string;
  30164. /**
  30165. * Loads an image as an HTMLImageElement.
  30166. * @param input url string, ArrayBuffer, or Blob to load
  30167. * @param onLoad callback called when the image successfully loads
  30168. * @param onError callback called when the image fails to load
  30169. * @param offlineProvider offline provider for caching
  30170. * @returns the HTMLImageElement of the loaded image
  30171. */
  30172. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30173. /**
  30174. * Loads a file
  30175. * @param url url string, ArrayBuffer, or Blob to load
  30176. * @param onSuccess callback called when the file successfully loads
  30177. * @param onProgress callback called while file is loading (if the server supports this mode)
  30178. * @param offlineProvider defines the offline provider for caching
  30179. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30180. * @param onError callback called when the file fails to load
  30181. * @returns a file request object
  30182. */
  30183. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  30184. /**
  30185. * Load a script (identified by an url). When the url returns, the
  30186. * content of this file is added into a new script element, attached to the DOM (body element)
  30187. * @param scriptUrl defines the url of the script to laod
  30188. * @param onSuccess defines the callback called when the script is loaded
  30189. * @param onError defines the callback to call if an error occurs
  30190. */
  30191. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30192. /**
  30193. * Loads a file from a blob
  30194. * @param fileToLoad defines the blob to use
  30195. * @param callback defines the callback to call when data is loaded
  30196. * @param progressCallback defines the callback to call during loading process
  30197. * @returns a file request object
  30198. */
  30199. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30200. /**
  30201. * Loads a file
  30202. * @param fileToLoad defines the file to load
  30203. * @param callback defines the callback to call when data is loaded
  30204. * @param progressCallBack defines the callback to call during loading process
  30205. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30206. * @returns a file request object
  30207. */
  30208. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30209. /**
  30210. * Creates a data url from a given string content
  30211. * @param content defines the content to convert
  30212. * @returns the new data url link
  30213. */
  30214. static FileAsURL(content: string): string;
  30215. /**
  30216. * Format the given number to a specific decimal format
  30217. * @param value defines the number to format
  30218. * @param decimals defines the number of decimals to use
  30219. * @returns the formatted string
  30220. */
  30221. static Format(value: number, decimals?: number): string;
  30222. /**
  30223. * Checks if a given vector is inside a specific range
  30224. * @param v defines the vector to test
  30225. * @param min defines the minimum range
  30226. * @param max defines the maximum range
  30227. */
  30228. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30229. /**
  30230. * Tries to copy an object by duplicating every property
  30231. * @param source defines the source object
  30232. * @param destination defines the target object
  30233. * @param doNotCopyList defines a list of properties to avoid
  30234. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30235. */
  30236. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30237. /**
  30238. * Gets a boolean indicating if the given object has no own property
  30239. * @param obj defines the object to test
  30240. * @returns true if object has no own property
  30241. */
  30242. static IsEmpty(obj: any): boolean;
  30243. /**
  30244. * Function used to register events at window level
  30245. * @param events defines the events to register
  30246. */
  30247. static RegisterTopRootEvents(events: {
  30248. name: string;
  30249. handler: Nullable<(e: FocusEvent) => any>;
  30250. }[]): void;
  30251. /**
  30252. * Function used to unregister events from window level
  30253. * @param events defines the events to unregister
  30254. */
  30255. static UnregisterTopRootEvents(events: {
  30256. name: string;
  30257. handler: Nullable<(e: FocusEvent) => any>;
  30258. }[]): void;
  30259. /**
  30260. * Dumps the current bound framebuffer
  30261. * @param width defines the rendering width
  30262. * @param height defines the rendering height
  30263. * @param engine defines the hosting engine
  30264. * @param successCallback defines the callback triggered once the data are available
  30265. * @param mimeType defines the mime type of the result
  30266. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30267. */
  30268. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30269. /**
  30270. * Converts the canvas data to blob.
  30271. * This acts as a polyfill for browsers not supporting the to blob function.
  30272. * @param canvas Defines the canvas to extract the data from
  30273. * @param successCallback Defines the callback triggered once the data are available
  30274. * @param mimeType Defines the mime type of the result
  30275. */
  30276. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30277. /**
  30278. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30279. * @param successCallback defines the callback triggered once the data are available
  30280. * @param mimeType defines the mime type of the result
  30281. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30282. */
  30283. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30284. /**
  30285. * Downloads a blob in the browser
  30286. * @param blob defines the blob to download
  30287. * @param fileName defines the name of the downloaded file
  30288. */
  30289. static Download(blob: Blob, fileName: string): void;
  30290. /**
  30291. * Captures a screenshot of the current rendering
  30292. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30293. * @param engine defines the rendering engine
  30294. * @param camera defines the source camera
  30295. * @param size This parameter can be set to a single number or to an object with the
  30296. * following (optional) properties: precision, width, height. If a single number is passed,
  30297. * it will be used for both width and height. If an object is passed, the screenshot size
  30298. * will be derived from the parameters. The precision property is a multiplier allowing
  30299. * rendering at a higher or lower resolution
  30300. * @param successCallback defines the callback receives a single parameter which contains the
  30301. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30302. * src parameter of an <img> to display it
  30303. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30304. * Check your browser for supported MIME types
  30305. */
  30306. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30307. /**
  30308. * Generates an image screenshot from the specified camera.
  30309. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30310. * @param engine The engine to use for rendering
  30311. * @param camera The camera to use for rendering
  30312. * @param size This parameter can be set to a single number or to an object with the
  30313. * following (optional) properties: precision, width, height. If a single number is passed,
  30314. * it will be used for both width and height. If an object is passed, the screenshot size
  30315. * will be derived from the parameters. The precision property is a multiplier allowing
  30316. * rendering at a higher or lower resolution
  30317. * @param successCallback The callback receives a single parameter which contains the
  30318. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30319. * src parameter of an <img> to display it
  30320. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30321. * Check your browser for supported MIME types
  30322. * @param samples Texture samples (default: 1)
  30323. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30324. * @param fileName A name for for the downloaded file.
  30325. */
  30326. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30327. /**
  30328. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30329. * Be aware Math.random() could cause collisions, but:
  30330. * "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"
  30331. * @returns a pseudo random id
  30332. */
  30333. static RandomId(): string;
  30334. /**
  30335. * Test if the given uri is a base64 string
  30336. * @param uri The uri to test
  30337. * @return True if the uri is a base64 string or false otherwise
  30338. */
  30339. static IsBase64(uri: string): boolean;
  30340. /**
  30341. * Decode the given base64 uri.
  30342. * @param uri The uri to decode
  30343. * @return The decoded base64 data.
  30344. */
  30345. static DecodeBase64(uri: string): ArrayBuffer;
  30346. /**
  30347. * No log
  30348. */
  30349. static readonly NoneLogLevel: number;
  30350. /**
  30351. * Only message logs
  30352. */
  30353. static readonly MessageLogLevel: number;
  30354. /**
  30355. * Only warning logs
  30356. */
  30357. static readonly WarningLogLevel: number;
  30358. /**
  30359. * Only error logs
  30360. */
  30361. static readonly ErrorLogLevel: number;
  30362. /**
  30363. * All logs
  30364. */
  30365. static readonly AllLogLevel: number;
  30366. /**
  30367. * Gets a value indicating the number of loading errors
  30368. * @ignorenaming
  30369. */
  30370. static readonly errorsCount: number;
  30371. /**
  30372. * Callback called when a new log is added
  30373. */
  30374. static OnNewCacheEntry: (entry: string) => void;
  30375. /**
  30376. * Log a message to the console
  30377. * @param message defines the message to log
  30378. */
  30379. static Log(message: string): void;
  30380. /**
  30381. * Write a warning message to the console
  30382. * @param message defines the message to log
  30383. */
  30384. static Warn(message: string): void;
  30385. /**
  30386. * Write an error message to the console
  30387. * @param message defines the message to log
  30388. */
  30389. static Error(message: string): void;
  30390. /**
  30391. * Gets current log cache (list of logs)
  30392. */
  30393. static readonly LogCache: string;
  30394. /**
  30395. * Clears the log cache
  30396. */
  30397. static ClearLogCache(): void;
  30398. /**
  30399. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30400. */
  30401. static LogLevels: number;
  30402. /**
  30403. * Checks if the loaded document was accessed via `file:`-Protocol.
  30404. * @returns boolean
  30405. */
  30406. static IsFileURL(): boolean;
  30407. /**
  30408. * Checks if the window object exists
  30409. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30410. */
  30411. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30412. /**
  30413. * No performance log
  30414. */
  30415. static readonly PerformanceNoneLogLevel: number;
  30416. /**
  30417. * Use user marks to log performance
  30418. */
  30419. static readonly PerformanceUserMarkLogLevel: number;
  30420. /**
  30421. * Log performance to the console
  30422. */
  30423. static readonly PerformanceConsoleLogLevel: number;
  30424. private static _performance;
  30425. /**
  30426. * Sets the current performance log level
  30427. */
  30428. static PerformanceLogLevel: number;
  30429. private static _StartPerformanceCounterDisabled;
  30430. private static _EndPerformanceCounterDisabled;
  30431. private static _StartUserMark;
  30432. private static _EndUserMark;
  30433. private static _StartPerformanceConsole;
  30434. private static _EndPerformanceConsole;
  30435. /**
  30436. * Injects the @see CustomRequestHeaders into the given request
  30437. * @param request the request that should be used for injection
  30438. */
  30439. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  30440. /**
  30441. * Starts a performance counter
  30442. */
  30443. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30444. /**
  30445. * Ends a specific performance coutner
  30446. */
  30447. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30448. /**
  30449. * Gets either window.performance.now() if supported or Date.now() else
  30450. */
  30451. static readonly Now: number;
  30452. /**
  30453. * This method will return the name of the class used to create the instance of the given object.
  30454. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30455. * @param object the object to get the class name from
  30456. * @param isType defines if the object is actually a type
  30457. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30458. */
  30459. static GetClassName(object: any, isType?: boolean): string;
  30460. /**
  30461. * Gets the first element of an array satisfying a given predicate
  30462. * @param array defines the array to browse
  30463. * @param predicate defines the predicate to use
  30464. * @returns null if not found or the element
  30465. */
  30466. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30467. /**
  30468. * This method will return the name of the full name of the class, including its owning module (if any).
  30469. * 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).
  30470. * @param object the object to get the class name from
  30471. * @param isType defines if the object is actually a type
  30472. * @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.
  30473. * @ignorenaming
  30474. */
  30475. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30476. /**
  30477. * Returns a promise that resolves after the given amount of time.
  30478. * @param delay Number of milliseconds to delay
  30479. * @returns Promise that resolves after the given amount of time
  30480. */
  30481. static DelayAsync(delay: number): Promise<void>;
  30482. /**
  30483. * Gets the current gradient from an array of IValueGradient
  30484. * @param ratio defines the current ratio to get
  30485. * @param gradients defines the array of IValueGradient
  30486. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30487. */
  30488. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30489. }
  30490. /**
  30491. * This class is used to track a performance counter which is number based.
  30492. * The user has access to many properties which give statistics of different nature.
  30493. *
  30494. * The implementer can track two kinds of Performance Counter: time and count.
  30495. * 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.
  30496. * 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.
  30497. */
  30498. export class PerfCounter {
  30499. /**
  30500. * Gets or sets a global boolean to turn on and off all the counters
  30501. */
  30502. static Enabled: boolean;
  30503. /**
  30504. * Returns the smallest value ever
  30505. */
  30506. readonly min: number;
  30507. /**
  30508. * Returns the biggest value ever
  30509. */
  30510. readonly max: number;
  30511. /**
  30512. * Returns the average value since the performance counter is running
  30513. */
  30514. readonly average: number;
  30515. /**
  30516. * Returns the average value of the last second the counter was monitored
  30517. */
  30518. readonly lastSecAverage: number;
  30519. /**
  30520. * Returns the current value
  30521. */
  30522. readonly current: number;
  30523. /**
  30524. * Gets the accumulated total
  30525. */
  30526. readonly total: number;
  30527. /**
  30528. * Gets the total value count
  30529. */
  30530. readonly count: number;
  30531. /**
  30532. * Creates a new counter
  30533. */
  30534. constructor();
  30535. /**
  30536. * Call this method to start monitoring a new frame.
  30537. * 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.
  30538. */
  30539. fetchNewFrame(): void;
  30540. /**
  30541. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30542. * @param newCount the count value to add to the monitored count
  30543. * @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.
  30544. */
  30545. addCount(newCount: number, fetchResult: boolean): void;
  30546. /**
  30547. * Start monitoring this performance counter
  30548. */
  30549. beginMonitoring(): void;
  30550. /**
  30551. * Compute the time lapsed since the previous beginMonitoring() call.
  30552. * @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
  30553. */
  30554. endMonitoring(newFrame?: boolean): void;
  30555. private _fetchResult;
  30556. private _startMonitoringTime;
  30557. private _min;
  30558. private _max;
  30559. private _average;
  30560. private _current;
  30561. private _totalValueCount;
  30562. private _totalAccumulated;
  30563. private _lastSecAverage;
  30564. private _lastSecAccumulated;
  30565. private _lastSecTime;
  30566. private _lastSecValueCount;
  30567. }
  30568. /**
  30569. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30570. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30571. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30572. * @param name The name of the class, case should be preserved
  30573. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30574. */
  30575. export function className(name: string, module?: string): (target: Object) => void;
  30576. /**
  30577. * An implementation of a loop for asynchronous functions.
  30578. */
  30579. export class AsyncLoop {
  30580. /**
  30581. * Defines the number of iterations for the loop
  30582. */
  30583. iterations: number;
  30584. /**
  30585. * Defines the current index of the loop.
  30586. */
  30587. index: number;
  30588. private _done;
  30589. private _fn;
  30590. private _successCallback;
  30591. /**
  30592. * Constructor.
  30593. * @param iterations the number of iterations.
  30594. * @param func the function to run each iteration
  30595. * @param successCallback the callback that will be called upon succesful execution
  30596. * @param offset starting offset.
  30597. */
  30598. constructor(
  30599. /**
  30600. * Defines the number of iterations for the loop
  30601. */
  30602. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30603. /**
  30604. * Execute the next iteration. Must be called after the last iteration was finished.
  30605. */
  30606. executeNext(): void;
  30607. /**
  30608. * Break the loop and run the success callback.
  30609. */
  30610. breakLoop(): void;
  30611. /**
  30612. * Create and run an async loop.
  30613. * @param iterations the number of iterations.
  30614. * @param fn the function to run each iteration
  30615. * @param successCallback the callback that will be called upon succesful execution
  30616. * @param offset starting offset.
  30617. * @returns the created async loop object
  30618. */
  30619. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30620. /**
  30621. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30622. * @param iterations total number of iterations
  30623. * @param syncedIterations number of synchronous iterations in each async iteration.
  30624. * @param fn the function to call each iteration.
  30625. * @param callback a success call back that will be called when iterating stops.
  30626. * @param breakFunction a break condition (optional)
  30627. * @param timeout timeout settings for the setTimeout function. default - 0.
  30628. * @returns the created async loop object
  30629. */
  30630. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30631. }
  30632. }
  30633. declare module BABYLON {
  30634. /** @hidden */
  30635. export interface ICollisionCoordinator {
  30636. createCollider(): Collider;
  30637. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30638. init(scene: Scene): void;
  30639. }
  30640. /** @hidden */
  30641. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30642. private _scene;
  30643. private _scaledPosition;
  30644. private _scaledVelocity;
  30645. private _finalPosition;
  30646. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30647. createCollider(): Collider;
  30648. init(scene: Scene): void;
  30649. private _collideWithWorld;
  30650. }
  30651. }
  30652. declare module BABYLON {
  30653. /**
  30654. * This class defines the direct association between an animation and a target
  30655. */
  30656. export class TargetedAnimation {
  30657. /**
  30658. * Animation to perform
  30659. */
  30660. animation: Animation;
  30661. /**
  30662. * Target to animate
  30663. */
  30664. target: any;
  30665. }
  30666. /**
  30667. * Use this class to create coordinated animations on multiple targets
  30668. */
  30669. export class AnimationGroup implements IDisposable {
  30670. /** The name of the animation group */
  30671. name: string;
  30672. private _scene;
  30673. private _targetedAnimations;
  30674. private _animatables;
  30675. private _from;
  30676. private _to;
  30677. private _isStarted;
  30678. private _isPaused;
  30679. private _speedRatio;
  30680. /**
  30681. * Gets or sets the unique id of the node
  30682. */
  30683. uniqueId: number;
  30684. /**
  30685. * This observable will notify when one animation have ended
  30686. */
  30687. onAnimationEndObservable: Observable<TargetedAnimation>;
  30688. /**
  30689. * Observer raised when one animation loops
  30690. */
  30691. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30692. /**
  30693. * This observable will notify when all animations have ended.
  30694. */
  30695. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30696. /**
  30697. * This observable will notify when all animations have paused.
  30698. */
  30699. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30700. /**
  30701. * This observable will notify when all animations are playing.
  30702. */
  30703. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30704. /**
  30705. * Gets the first frame
  30706. */
  30707. readonly from: number;
  30708. /**
  30709. * Gets the last frame
  30710. */
  30711. readonly to: number;
  30712. /**
  30713. * Define if the animations are started
  30714. */
  30715. readonly isStarted: boolean;
  30716. /**
  30717. * Gets a value indicating that the current group is playing
  30718. */
  30719. readonly isPlaying: boolean;
  30720. /**
  30721. * Gets or sets the speed ratio to use for all animations
  30722. */
  30723. /**
  30724. * Gets or sets the speed ratio to use for all animations
  30725. */
  30726. speedRatio: number;
  30727. /**
  30728. * Gets the targeted animations for this animation group
  30729. */
  30730. readonly targetedAnimations: Array<TargetedAnimation>;
  30731. /**
  30732. * returning the list of animatables controlled by this animation group.
  30733. */
  30734. readonly animatables: Array<Animatable>;
  30735. /**
  30736. * Instantiates a new Animation Group.
  30737. * This helps managing several animations at once.
  30738. * @see http://doc.babylonjs.com/how_to/group
  30739. * @param name Defines the name of the group
  30740. * @param scene Defines the scene the group belongs to
  30741. */
  30742. constructor(
  30743. /** The name of the animation group */
  30744. name: string, scene?: Nullable<Scene>);
  30745. /**
  30746. * Add an animation (with its target) in the group
  30747. * @param animation defines the animation we want to add
  30748. * @param target defines the target of the animation
  30749. * @returns the TargetedAnimation object
  30750. */
  30751. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30752. /**
  30753. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30754. * It can add constant keys at begin or end
  30755. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30756. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30757. * @returns the animation group
  30758. */
  30759. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30760. /**
  30761. * Start all animations on given targets
  30762. * @param loop defines if animations must loop
  30763. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30764. * @param from defines the from key (optional)
  30765. * @param to defines the to key (optional)
  30766. * @returns the current animation group
  30767. */
  30768. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30769. /**
  30770. * Pause all animations
  30771. * @returns the animation group
  30772. */
  30773. pause(): AnimationGroup;
  30774. /**
  30775. * Play all animations to initial state
  30776. * This function will start() the animations if they were not started or will restart() them if they were paused
  30777. * @param loop defines if animations must loop
  30778. * @returns the animation group
  30779. */
  30780. play(loop?: boolean): AnimationGroup;
  30781. /**
  30782. * Reset all animations to initial state
  30783. * @returns the animation group
  30784. */
  30785. reset(): AnimationGroup;
  30786. /**
  30787. * Restart animations from key 0
  30788. * @returns the animation group
  30789. */
  30790. restart(): AnimationGroup;
  30791. /**
  30792. * Stop all animations
  30793. * @returns the animation group
  30794. */
  30795. stop(): AnimationGroup;
  30796. /**
  30797. * Set animation weight for all animatables
  30798. * @param weight defines the weight to use
  30799. * @return the animationGroup
  30800. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30801. */
  30802. setWeightForAllAnimatables(weight: number): AnimationGroup;
  30803. /**
  30804. * Synchronize and normalize all animatables with a source animatable
  30805. * @param root defines the root animatable to synchronize with
  30806. * @return the animationGroup
  30807. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  30808. */
  30809. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  30810. /**
  30811. * Goes to a specific frame in this animation group
  30812. * @param frame the frame number to go to
  30813. * @return the animationGroup
  30814. */
  30815. goToFrame(frame: number): AnimationGroup;
  30816. /**
  30817. * Dispose all associated resources
  30818. */
  30819. dispose(): void;
  30820. private _checkAnimationGroupEnded;
  30821. /**
  30822. * Clone the current animation group and returns a copy
  30823. * @param newName defines the name of the new group
  30824. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  30825. * @returns the new aniamtion group
  30826. */
  30827. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  30828. /**
  30829. * Returns a new AnimationGroup object parsed from the source provided.
  30830. * @param parsedAnimationGroup defines the source
  30831. * @param scene defines the scene that will receive the animationGroup
  30832. * @returns a new AnimationGroup
  30833. */
  30834. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  30835. /**
  30836. * Returns the string "AnimationGroup"
  30837. * @returns "AnimationGroup"
  30838. */
  30839. getClassName(): string;
  30840. /**
  30841. * Creates a detailled string about the object
  30842. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  30843. * @returns a string representing the object
  30844. */
  30845. toString(fullDetails?: boolean): string;
  30846. }
  30847. }
  30848. declare module BABYLON {
  30849. /**
  30850. * Define an interface for all classes that will hold resources
  30851. */
  30852. export interface IDisposable {
  30853. /**
  30854. * Releases all held resources
  30855. */
  30856. dispose(): void;
  30857. }
  30858. /** Interface defining initialization parameters for Scene class */
  30859. export interface SceneOptions {
  30860. /**
  30861. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  30862. * It will improve performance when the number of geometries becomes important.
  30863. */
  30864. useGeometryUniqueIdsMap?: boolean;
  30865. /**
  30866. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  30867. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30868. */
  30869. useMaterialMeshMap?: boolean;
  30870. /**
  30871. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  30872. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  30873. */
  30874. useClonedMeshhMap?: boolean;
  30875. }
  30876. /**
  30877. * Represents a scene to be rendered by the engine.
  30878. * @see http://doc.babylonjs.com/features/scene
  30879. */
  30880. export class Scene extends AbstractScene implements IAnimatable {
  30881. private static _uniqueIdCounter;
  30882. /** The fog is deactivated */
  30883. static readonly FOGMODE_NONE: number;
  30884. /** The fog density is following an exponential function */
  30885. static readonly FOGMODE_EXP: number;
  30886. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  30887. static readonly FOGMODE_EXP2: number;
  30888. /** The fog density is following a linear function. */
  30889. static readonly FOGMODE_LINEAR: number;
  30890. /**
  30891. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  30892. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30893. */
  30894. static MinDeltaTime: number;
  30895. /**
  30896. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  30897. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30898. */
  30899. static MaxDeltaTime: number;
  30900. /**
  30901. * Factory used to create the default material.
  30902. * @param name The name of the material to create
  30903. * @param scene The scene to create the material for
  30904. * @returns The default material
  30905. */
  30906. static DefaultMaterialFactory(scene: Scene): Material;
  30907. /**
  30908. * Factory used to create the a collision coordinator.
  30909. * @returns The collision coordinator
  30910. */
  30911. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  30912. /** @hidden */
  30913. readonly _isScene: boolean;
  30914. /**
  30915. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  30916. */
  30917. autoClear: boolean;
  30918. /**
  30919. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  30920. */
  30921. autoClearDepthAndStencil: boolean;
  30922. /**
  30923. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  30924. */
  30925. clearColor: Color4;
  30926. /**
  30927. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  30928. */
  30929. ambientColor: Color3;
  30930. /** @hidden */
  30931. _environmentBRDFTexture: BaseTexture;
  30932. /** @hidden */
  30933. protected _environmentTexture: Nullable<BaseTexture>;
  30934. /**
  30935. * Texture used in all pbr material as the reflection texture.
  30936. * As in the majority of the scene they are the same (exception for multi room and so on),
  30937. * this is easier to reference from here than from all the materials.
  30938. */
  30939. /**
  30940. * Texture used in all pbr material as the reflection texture.
  30941. * As in the majority of the scene they are the same (exception for multi room and so on),
  30942. * this is easier to set here than in all the materials.
  30943. */
  30944. environmentTexture: Nullable<BaseTexture>;
  30945. /** @hidden */
  30946. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30947. /**
  30948. * Default image processing configuration used either in the rendering
  30949. * Forward main pass or through the imageProcessingPostProcess if present.
  30950. * As in the majority of the scene they are the same (exception for multi camera),
  30951. * this is easier to reference from here than from all the materials and post process.
  30952. *
  30953. * No setter as we it is a shared configuration, you can set the values instead.
  30954. */
  30955. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  30956. private _forceWireframe;
  30957. /**
  30958. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  30959. */
  30960. forceWireframe: boolean;
  30961. private _forcePointsCloud;
  30962. /**
  30963. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  30964. */
  30965. forcePointsCloud: boolean;
  30966. /**
  30967. * Gets or sets the active clipplane 1
  30968. */
  30969. clipPlane: Nullable<Plane>;
  30970. /**
  30971. * Gets or sets the active clipplane 2
  30972. */
  30973. clipPlane2: Nullable<Plane>;
  30974. /**
  30975. * Gets or sets the active clipplane 3
  30976. */
  30977. clipPlane3: Nullable<Plane>;
  30978. /**
  30979. * Gets or sets the active clipplane 4
  30980. */
  30981. clipPlane4: Nullable<Plane>;
  30982. /**
  30983. * Gets or sets a boolean indicating if animations are enabled
  30984. */
  30985. animationsEnabled: boolean;
  30986. private _animationPropertiesOverride;
  30987. /**
  30988. * Gets or sets the animation properties override
  30989. */
  30990. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  30991. /**
  30992. * Gets or sets a boolean indicating if a constant deltatime has to be used
  30993. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  30994. */
  30995. useConstantAnimationDeltaTime: boolean;
  30996. /**
  30997. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  30998. * Please note that it requires to run a ray cast through the scene on every frame
  30999. */
  31000. constantlyUpdateMeshUnderPointer: boolean;
  31001. /**
  31002. * Defines the HTML cursor to use when hovering over interactive elements
  31003. */
  31004. hoverCursor: string;
  31005. /**
  31006. * Defines the HTML default cursor to use (empty by default)
  31007. */
  31008. defaultCursor: string;
  31009. /**
  31010. * This is used to call preventDefault() on pointer down
  31011. * in order to block unwanted artifacts like system double clicks
  31012. */
  31013. preventDefaultOnPointerDown: boolean;
  31014. /**
  31015. * This is used to call preventDefault() on pointer up
  31016. * in order to block unwanted artifacts like system double clicks
  31017. */
  31018. preventDefaultOnPointerUp: boolean;
  31019. /**
  31020. * Gets or sets user defined metadata
  31021. */
  31022. metadata: any;
  31023. /**
  31024. * For internal use only. Please do not use.
  31025. */
  31026. reservedDataStore: any;
  31027. /**
  31028. * Gets the name of the plugin used to load this scene (null by default)
  31029. */
  31030. loadingPluginName: string;
  31031. /**
  31032. * Use this array to add regular expressions used to disable offline support for specific urls
  31033. */
  31034. disableOfflineSupportExceptionRules: RegExp[];
  31035. /**
  31036. * An event triggered when the scene is disposed.
  31037. */
  31038. onDisposeObservable: Observable<Scene>;
  31039. private _onDisposeObserver;
  31040. /** Sets a function to be executed when this scene is disposed. */
  31041. onDispose: () => void;
  31042. /**
  31043. * An event triggered before rendering the scene (right after animations and physics)
  31044. */
  31045. onBeforeRenderObservable: Observable<Scene>;
  31046. private _onBeforeRenderObserver;
  31047. /** Sets a function to be executed before rendering this scene */
  31048. beforeRender: Nullable<() => void>;
  31049. /**
  31050. * An event triggered after rendering the scene
  31051. */
  31052. onAfterRenderObservable: Observable<Scene>;
  31053. private _onAfterRenderObserver;
  31054. /** Sets a function to be executed after rendering this scene */
  31055. afterRender: Nullable<() => void>;
  31056. /**
  31057. * An event triggered before animating the scene
  31058. */
  31059. onBeforeAnimationsObservable: Observable<Scene>;
  31060. /**
  31061. * An event triggered after animations processing
  31062. */
  31063. onAfterAnimationsObservable: Observable<Scene>;
  31064. /**
  31065. * An event triggered before draw calls are ready to be sent
  31066. */
  31067. onBeforeDrawPhaseObservable: Observable<Scene>;
  31068. /**
  31069. * An event triggered after draw calls have been sent
  31070. */
  31071. onAfterDrawPhaseObservable: Observable<Scene>;
  31072. /**
  31073. * An event triggered when the scene is ready
  31074. */
  31075. onReadyObservable: Observable<Scene>;
  31076. /**
  31077. * An event triggered before rendering a camera
  31078. */
  31079. onBeforeCameraRenderObservable: Observable<Camera>;
  31080. private _onBeforeCameraRenderObserver;
  31081. /** Sets a function to be executed before rendering a camera*/
  31082. beforeCameraRender: () => void;
  31083. /**
  31084. * An event triggered after rendering a camera
  31085. */
  31086. onAfterCameraRenderObservable: Observable<Camera>;
  31087. private _onAfterCameraRenderObserver;
  31088. /** Sets a function to be executed after rendering a camera*/
  31089. afterCameraRender: () => void;
  31090. /**
  31091. * An event triggered when active meshes evaluation is about to start
  31092. */
  31093. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31094. /**
  31095. * An event triggered when active meshes evaluation is done
  31096. */
  31097. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31098. /**
  31099. * An event triggered when particles rendering is about to start
  31100. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31101. */
  31102. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31103. /**
  31104. * An event triggered when particles rendering is done
  31105. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31106. */
  31107. onAfterParticlesRenderingObservable: Observable<Scene>;
  31108. /**
  31109. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31110. */
  31111. onDataLoadedObservable: Observable<Scene>;
  31112. /**
  31113. * An event triggered when a camera is created
  31114. */
  31115. onNewCameraAddedObservable: Observable<Camera>;
  31116. /**
  31117. * An event triggered when a camera is removed
  31118. */
  31119. onCameraRemovedObservable: Observable<Camera>;
  31120. /**
  31121. * An event triggered when a light is created
  31122. */
  31123. onNewLightAddedObservable: Observable<Light>;
  31124. /**
  31125. * An event triggered when a light is removed
  31126. */
  31127. onLightRemovedObservable: Observable<Light>;
  31128. /**
  31129. * An event triggered when a geometry is created
  31130. */
  31131. onNewGeometryAddedObservable: Observable<Geometry>;
  31132. /**
  31133. * An event triggered when a geometry is removed
  31134. */
  31135. onGeometryRemovedObservable: Observable<Geometry>;
  31136. /**
  31137. * An event triggered when a transform node is created
  31138. */
  31139. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31140. /**
  31141. * An event triggered when a transform node is removed
  31142. */
  31143. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31144. /**
  31145. * An event triggered when a mesh is created
  31146. */
  31147. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31148. /**
  31149. * An event triggered when a mesh is removed
  31150. */
  31151. onMeshRemovedObservable: Observable<AbstractMesh>;
  31152. /**
  31153. * An event triggered when a material is created
  31154. */
  31155. onNewMaterialAddedObservable: Observable<Material>;
  31156. /**
  31157. * An event triggered when a material is removed
  31158. */
  31159. onMaterialRemovedObservable: Observable<Material>;
  31160. /**
  31161. * An event triggered when a texture is created
  31162. */
  31163. onNewTextureAddedObservable: Observable<BaseTexture>;
  31164. /**
  31165. * An event triggered when a texture is removed
  31166. */
  31167. onTextureRemovedObservable: Observable<BaseTexture>;
  31168. /**
  31169. * An event triggered when render targets are about to be rendered
  31170. * Can happen multiple times per frame.
  31171. */
  31172. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31173. /**
  31174. * An event triggered when render targets were rendered.
  31175. * Can happen multiple times per frame.
  31176. */
  31177. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31178. /**
  31179. * An event triggered before calculating deterministic simulation step
  31180. */
  31181. onBeforeStepObservable: Observable<Scene>;
  31182. /**
  31183. * An event triggered after calculating deterministic simulation step
  31184. */
  31185. onAfterStepObservable: Observable<Scene>;
  31186. /**
  31187. * An event triggered when the activeCamera property is updated
  31188. */
  31189. onActiveCameraChanged: Observable<Scene>;
  31190. /**
  31191. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31192. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31193. * 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)
  31194. */
  31195. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31196. /**
  31197. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31198. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31199. * 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)
  31200. */
  31201. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31202. /**
  31203. * This Observable will when a mesh has been imported into the scene.
  31204. */
  31205. onMeshImportedObservable: Observable<AbstractMesh>;
  31206. /** @hidden */
  31207. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31208. /**
  31209. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31210. */
  31211. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31212. /**
  31213. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31214. */
  31215. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31216. /**
  31217. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31218. */
  31219. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31220. private _onPointerMove;
  31221. private _onPointerDown;
  31222. private _onPointerUp;
  31223. /** Callback called when a pointer move is detected */
  31224. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31225. /** Callback called when a pointer down is detected */
  31226. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31227. /** Callback called when a pointer up is detected */
  31228. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31229. /** Callback called when a pointer pick is detected */
  31230. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31231. /**
  31232. * 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).
  31233. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31234. */
  31235. onPrePointerObservable: Observable<PointerInfoPre>;
  31236. /**
  31237. * Observable event triggered each time an input event is received from the rendering canvas
  31238. */
  31239. onPointerObservable: Observable<PointerInfo>;
  31240. /**
  31241. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31242. */
  31243. readonly unTranslatedPointer: Vector2;
  31244. /** The distance in pixel that you have to move to prevent some events */
  31245. static DragMovementThreshold: number;
  31246. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31247. static LongPressDelay: number;
  31248. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31249. static DoubleClickDelay: number;
  31250. /** If you need to check double click without raising a single click at first click, enable this flag */
  31251. static ExclusiveDoubleClickMode: boolean;
  31252. private _initClickEvent;
  31253. private _initActionManager;
  31254. private _delayedSimpleClick;
  31255. private _delayedSimpleClickTimeout;
  31256. private _previousDelayedSimpleClickTimeout;
  31257. private _meshPickProceed;
  31258. private _previousButtonPressed;
  31259. private _currentPickResult;
  31260. private _previousPickResult;
  31261. private _totalPointersPressed;
  31262. private _doubleClickOccured;
  31263. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31264. cameraToUseForPointers: Nullable<Camera>;
  31265. private _pointerX;
  31266. private _pointerY;
  31267. private _unTranslatedPointerX;
  31268. private _unTranslatedPointerY;
  31269. private _startingPointerPosition;
  31270. private _previousStartingPointerPosition;
  31271. private _startingPointerTime;
  31272. private _previousStartingPointerTime;
  31273. private _pointerCaptures;
  31274. private _timeAccumulator;
  31275. private _currentStepId;
  31276. private _currentInternalStep;
  31277. /** @hidden */
  31278. _mirroredCameraPosition: Nullable<Vector3>;
  31279. /**
  31280. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31281. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31282. */
  31283. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31284. /**
  31285. * Observable event triggered each time an keyboard event is received from the hosting window
  31286. */
  31287. onKeyboardObservable: Observable<KeyboardInfo>;
  31288. private _onKeyDown;
  31289. private _onKeyUp;
  31290. private _onCanvasFocusObserver;
  31291. private _onCanvasBlurObserver;
  31292. private _useRightHandedSystem;
  31293. /**
  31294. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31295. */
  31296. useRightHandedSystem: boolean;
  31297. /**
  31298. * Sets the step Id used by deterministic lock step
  31299. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31300. * @param newStepId defines the step Id
  31301. */
  31302. setStepId(newStepId: number): void;
  31303. /**
  31304. * Gets the step Id used by deterministic lock step
  31305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31306. * @returns the step Id
  31307. */
  31308. getStepId(): number;
  31309. /**
  31310. * Gets the internal step used by deterministic lock step
  31311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31312. * @returns the internal step
  31313. */
  31314. getInternalStep(): number;
  31315. private _fogEnabled;
  31316. /**
  31317. * Gets or sets a boolean indicating if fog is enabled on this scene
  31318. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31319. * (Default is true)
  31320. */
  31321. fogEnabled: boolean;
  31322. private _fogMode;
  31323. /**
  31324. * Gets or sets the fog mode to use
  31325. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31326. * | mode | value |
  31327. * | --- | --- |
  31328. * | FOGMODE_NONE | 0 |
  31329. * | FOGMODE_EXP | 1 |
  31330. * | FOGMODE_EXP2 | 2 |
  31331. * | FOGMODE_LINEAR | 3 |
  31332. */
  31333. fogMode: number;
  31334. /**
  31335. * Gets or sets the fog color to use
  31336. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31337. * (Default is Color3(0.2, 0.2, 0.3))
  31338. */
  31339. fogColor: Color3;
  31340. /**
  31341. * Gets or sets the fog density to use
  31342. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31343. * (Default is 0.1)
  31344. */
  31345. fogDensity: number;
  31346. /**
  31347. * Gets or sets the fog start distance to use
  31348. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31349. * (Default is 0)
  31350. */
  31351. fogStart: number;
  31352. /**
  31353. * Gets or sets the fog end distance to use
  31354. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31355. * (Default is 1000)
  31356. */
  31357. fogEnd: number;
  31358. private _shadowsEnabled;
  31359. /**
  31360. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31361. */
  31362. shadowsEnabled: boolean;
  31363. private _lightsEnabled;
  31364. /**
  31365. * Gets or sets a boolean indicating if lights are enabled on this scene
  31366. */
  31367. lightsEnabled: boolean;
  31368. /** All of the active cameras added to this scene. */
  31369. activeCameras: Camera[];
  31370. private _activeCamera;
  31371. /** Gets or sets the current active camera */
  31372. activeCamera: Nullable<Camera>;
  31373. private _defaultMaterial;
  31374. /** The default material used on meshes when no material is affected */
  31375. /** The default material used on meshes when no material is affected */
  31376. defaultMaterial: Material;
  31377. private _texturesEnabled;
  31378. /**
  31379. * Gets or sets a boolean indicating if textures are enabled on this scene
  31380. */
  31381. texturesEnabled: boolean;
  31382. /**
  31383. * Gets or sets a boolean indicating if particles are enabled on this scene
  31384. */
  31385. particlesEnabled: boolean;
  31386. /**
  31387. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31388. */
  31389. spritesEnabled: boolean;
  31390. private _skeletonsEnabled;
  31391. /**
  31392. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31393. */
  31394. skeletonsEnabled: boolean;
  31395. /**
  31396. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31397. */
  31398. lensFlaresEnabled: boolean;
  31399. /**
  31400. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31401. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31402. */
  31403. collisionsEnabled: boolean;
  31404. private _collisionCoordinator;
  31405. /** @hidden */
  31406. readonly collisionCoordinator: ICollisionCoordinator;
  31407. /**
  31408. * Defines the gravity applied to this scene (used only for collisions)
  31409. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31410. */
  31411. gravity: Vector3;
  31412. /**
  31413. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31414. */
  31415. postProcessesEnabled: boolean;
  31416. /**
  31417. * The list of postprocesses added to the scene
  31418. */
  31419. postProcesses: PostProcess[];
  31420. /**
  31421. * Gets the current postprocess manager
  31422. */
  31423. postProcessManager: PostProcessManager;
  31424. /**
  31425. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31426. */
  31427. renderTargetsEnabled: boolean;
  31428. /**
  31429. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31430. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31431. */
  31432. dumpNextRenderTargets: boolean;
  31433. /**
  31434. * The list of user defined render targets added to the scene
  31435. */
  31436. customRenderTargets: RenderTargetTexture[];
  31437. /**
  31438. * Defines if texture loading must be delayed
  31439. * If true, textures will only be loaded when they need to be rendered
  31440. */
  31441. useDelayedTextureLoading: boolean;
  31442. /**
  31443. * Gets the list of meshes imported to the scene through SceneLoader
  31444. */
  31445. importedMeshesFiles: String[];
  31446. /**
  31447. * Gets or sets a boolean indicating if probes are enabled on this scene
  31448. */
  31449. probesEnabled: boolean;
  31450. /**
  31451. * Gets or sets the current offline provider to use to store scene data
  31452. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31453. */
  31454. offlineProvider: IOfflineProvider;
  31455. /**
  31456. * Gets or sets the action manager associated with the scene
  31457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31458. */
  31459. actionManager: AbstractActionManager;
  31460. private _meshesForIntersections;
  31461. /**
  31462. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31463. */
  31464. proceduralTexturesEnabled: boolean;
  31465. private _engine;
  31466. private _totalVertices;
  31467. /** @hidden */
  31468. _activeIndices: PerfCounter;
  31469. /** @hidden */
  31470. _activeParticles: PerfCounter;
  31471. /** @hidden */
  31472. _activeBones: PerfCounter;
  31473. private _animationRatio;
  31474. /** @hidden */
  31475. _animationTimeLast: number;
  31476. /** @hidden */
  31477. _animationTime: number;
  31478. /**
  31479. * Gets or sets a general scale for animation speed
  31480. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31481. */
  31482. animationTimeScale: number;
  31483. /** @hidden */
  31484. _cachedMaterial: Nullable<Material>;
  31485. /** @hidden */
  31486. _cachedEffect: Nullable<Effect>;
  31487. /** @hidden */
  31488. _cachedVisibility: Nullable<number>;
  31489. private _renderId;
  31490. private _frameId;
  31491. private _executeWhenReadyTimeoutId;
  31492. private _intermediateRendering;
  31493. private _viewUpdateFlag;
  31494. private _projectionUpdateFlag;
  31495. private _alternateViewUpdateFlag;
  31496. private _alternateProjectionUpdateFlag;
  31497. /** @hidden */
  31498. _toBeDisposed: Nullable<IDisposable>[];
  31499. private _activeRequests;
  31500. /** @hidden */
  31501. _pendingData: any[];
  31502. private _isDisposed;
  31503. /**
  31504. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31505. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31506. */
  31507. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31508. private _activeMeshes;
  31509. private _processedMaterials;
  31510. private _renderTargets;
  31511. /** @hidden */
  31512. _activeParticleSystems: SmartArray<IParticleSystem>;
  31513. private _activeSkeletons;
  31514. private _softwareSkinnedMeshes;
  31515. private _renderingManager;
  31516. /** @hidden */
  31517. _activeAnimatables: Animatable[];
  31518. private _transformMatrix;
  31519. private _sceneUbo;
  31520. private _alternateSceneUbo;
  31521. private _viewMatrix;
  31522. private _projectionMatrix;
  31523. private _alternateViewMatrix;
  31524. private _alternateProjectionMatrix;
  31525. private _alternateTransformMatrix;
  31526. private _useAlternateCameraConfiguration;
  31527. private _alternateRendering;
  31528. private _wheelEventName;
  31529. /** @hidden */
  31530. _forcedViewPosition: Nullable<Vector3>;
  31531. /** @hidden */
  31532. readonly _isAlternateRenderingEnabled: boolean;
  31533. private _frustumPlanes;
  31534. /**
  31535. * Gets the list of frustum planes (built from the active camera)
  31536. */
  31537. readonly frustumPlanes: Plane[];
  31538. /**
  31539. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31540. * This is useful if there are more lights that the maximum simulteanous authorized
  31541. */
  31542. requireLightSorting: boolean;
  31543. /** @hidden */
  31544. readonly useMaterialMeshMap: boolean;
  31545. /** @hidden */
  31546. readonly useClonedMeshhMap: boolean;
  31547. private _pointerOverMesh;
  31548. private _pickedDownMesh;
  31549. private _pickedUpMesh;
  31550. private _externalData;
  31551. private _uid;
  31552. /**
  31553. * @hidden
  31554. * Backing store of defined scene components.
  31555. */
  31556. _components: ISceneComponent[];
  31557. /**
  31558. * @hidden
  31559. * Backing store of defined scene components.
  31560. */
  31561. _serializableComponents: ISceneSerializableComponent[];
  31562. /**
  31563. * List of components to register on the next registration step.
  31564. */
  31565. private _transientComponents;
  31566. /**
  31567. * Registers the transient components if needed.
  31568. */
  31569. private _registerTransientComponents;
  31570. /**
  31571. * @hidden
  31572. * Add a component to the scene.
  31573. * Note that the ccomponent could be registered on th next frame if this is called after
  31574. * the register component stage.
  31575. * @param component Defines the component to add to the scene
  31576. */
  31577. _addComponent(component: ISceneComponent): void;
  31578. /**
  31579. * @hidden
  31580. * Gets a component from the scene.
  31581. * @param name defines the name of the component to retrieve
  31582. * @returns the component or null if not present
  31583. */
  31584. _getComponent(name: string): Nullable<ISceneComponent>;
  31585. /**
  31586. * @hidden
  31587. * Defines the actions happening before camera updates.
  31588. */
  31589. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31590. /**
  31591. * @hidden
  31592. * Defines the actions happening before clear the canvas.
  31593. */
  31594. _beforeClearStage: Stage<SimpleStageAction>;
  31595. /**
  31596. * @hidden
  31597. * Defines the actions when collecting render targets for the frame.
  31598. */
  31599. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31600. /**
  31601. * @hidden
  31602. * Defines the actions happening for one camera in the frame.
  31603. */
  31604. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31605. /**
  31606. * @hidden
  31607. * Defines the actions happening during the per mesh ready checks.
  31608. */
  31609. _isReadyForMeshStage: Stage<MeshStageAction>;
  31610. /**
  31611. * @hidden
  31612. * Defines the actions happening before evaluate active mesh checks.
  31613. */
  31614. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31615. /**
  31616. * @hidden
  31617. * Defines the actions happening during the evaluate sub mesh checks.
  31618. */
  31619. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31620. /**
  31621. * @hidden
  31622. * Defines the actions happening during the active mesh stage.
  31623. */
  31624. _activeMeshStage: Stage<ActiveMeshStageAction>;
  31625. /**
  31626. * @hidden
  31627. * Defines the actions happening during the per camera render target step.
  31628. */
  31629. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31630. /**
  31631. * @hidden
  31632. * Defines the actions happening just before the active camera is drawing.
  31633. */
  31634. _beforeCameraDrawStage: Stage<CameraStageAction>;
  31635. /**
  31636. * @hidden
  31637. * Defines the actions happening just before a render target is drawing.
  31638. */
  31639. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31640. /**
  31641. * @hidden
  31642. * Defines the actions happening just before a rendering group is drawing.
  31643. */
  31644. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31645. /**
  31646. * @hidden
  31647. * Defines the actions happening just before a mesh is drawing.
  31648. */
  31649. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31650. /**
  31651. * @hidden
  31652. * Defines the actions happening just after a mesh has been drawn.
  31653. */
  31654. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31655. /**
  31656. * @hidden
  31657. * Defines the actions happening just after a rendering group has been drawn.
  31658. */
  31659. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31660. /**
  31661. * @hidden
  31662. * Defines the actions happening just after the active camera has been drawn.
  31663. */
  31664. _afterCameraDrawStage: Stage<CameraStageAction>;
  31665. /**
  31666. * @hidden
  31667. * Defines the actions happening just after a render target has been drawn.
  31668. */
  31669. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31670. /**
  31671. * @hidden
  31672. * Defines the actions happening just after rendering all cameras and computing intersections.
  31673. */
  31674. _afterRenderStage: Stage<SimpleStageAction>;
  31675. /**
  31676. * @hidden
  31677. * Defines the actions happening when a pointer move event happens.
  31678. */
  31679. _pointerMoveStage: Stage<PointerMoveStageAction>;
  31680. /**
  31681. * @hidden
  31682. * Defines the actions happening when a pointer down event happens.
  31683. */
  31684. _pointerDownStage: Stage<PointerUpDownStageAction>;
  31685. /**
  31686. * @hidden
  31687. * Defines the actions happening when a pointer up event happens.
  31688. */
  31689. _pointerUpStage: Stage<PointerUpDownStageAction>;
  31690. /**
  31691. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31692. */
  31693. private geometriesByUniqueId;
  31694. /**
  31695. * Creates a new Scene
  31696. * @param engine defines the engine to use to render this scene
  31697. * @param options defines the scene options
  31698. */
  31699. constructor(engine: Engine, options?: SceneOptions);
  31700. private _defaultMeshCandidates;
  31701. /**
  31702. * @hidden
  31703. */
  31704. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31705. private _defaultSubMeshCandidates;
  31706. /**
  31707. * @hidden
  31708. */
  31709. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31710. /**
  31711. * Sets the default candidate providers for the scene.
  31712. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31713. * and getCollidingSubMeshCandidates to their default function
  31714. */
  31715. setDefaultCandidateProviders(): void;
  31716. /**
  31717. * Gets the mesh that is currently under the pointer
  31718. */
  31719. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31720. /**
  31721. * Gets or sets the current on-screen X position of the pointer
  31722. */
  31723. pointerX: number;
  31724. /**
  31725. * Gets or sets the current on-screen Y position of the pointer
  31726. */
  31727. pointerY: number;
  31728. /**
  31729. * Gets the cached material (ie. the latest rendered one)
  31730. * @returns the cached material
  31731. */
  31732. getCachedMaterial(): Nullable<Material>;
  31733. /**
  31734. * Gets the cached effect (ie. the latest rendered one)
  31735. * @returns the cached effect
  31736. */
  31737. getCachedEffect(): Nullable<Effect>;
  31738. /**
  31739. * Gets the cached visibility state (ie. the latest rendered one)
  31740. * @returns the cached visibility state
  31741. */
  31742. getCachedVisibility(): Nullable<number>;
  31743. /**
  31744. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31745. * @param material defines the current material
  31746. * @param effect defines the current effect
  31747. * @param visibility defines the current visibility state
  31748. * @returns true if one parameter is not cached
  31749. */
  31750. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31751. /**
  31752. * Gets the engine associated with the scene
  31753. * @returns an Engine
  31754. */
  31755. getEngine(): Engine;
  31756. /**
  31757. * Gets the total number of vertices rendered per frame
  31758. * @returns the total number of vertices rendered per frame
  31759. */
  31760. getTotalVertices(): number;
  31761. /**
  31762. * Gets the performance counter for total vertices
  31763. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31764. */
  31765. readonly totalVerticesPerfCounter: PerfCounter;
  31766. /**
  31767. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31768. * @returns the total number of active indices rendered per frame
  31769. */
  31770. getActiveIndices(): number;
  31771. /**
  31772. * Gets the performance counter for active indices
  31773. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31774. */
  31775. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31776. /**
  31777. * Gets the total number of active particles rendered per frame
  31778. * @returns the total number of active particles rendered per frame
  31779. */
  31780. getActiveParticles(): number;
  31781. /**
  31782. * Gets the performance counter for active particles
  31783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31784. */
  31785. readonly activeParticlesPerfCounter: PerfCounter;
  31786. /**
  31787. * Gets the total number of active bones rendered per frame
  31788. * @returns the total number of active bones rendered per frame
  31789. */
  31790. getActiveBones(): number;
  31791. /**
  31792. * Gets the performance counter for active bones
  31793. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31794. */
  31795. readonly activeBonesPerfCounter: PerfCounter;
  31796. /**
  31797. * Gets the array of active meshes
  31798. * @returns an array of AbstractMesh
  31799. */
  31800. getActiveMeshes(): SmartArray<AbstractMesh>;
  31801. /**
  31802. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31803. * @returns a number
  31804. */
  31805. getAnimationRatio(): number;
  31806. /**
  31807. * Gets an unique Id for the current render phase
  31808. * @returns a number
  31809. */
  31810. getRenderId(): number;
  31811. /**
  31812. * Gets an unique Id for the current frame
  31813. * @returns a number
  31814. */
  31815. getFrameId(): number;
  31816. /** Call this function if you want to manually increment the render Id*/
  31817. incrementRenderId(): void;
  31818. private _updatePointerPosition;
  31819. private _createUbo;
  31820. private _createAlternateUbo;
  31821. private _setRayOnPointerInfo;
  31822. /**
  31823. * Use this method to simulate a pointer move on a mesh
  31824. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31825. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31826. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31827. * @returns the current scene
  31828. */
  31829. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31830. private _processPointerMove;
  31831. private _checkPrePointerObservable;
  31832. /**
  31833. * Use this method to simulate a pointer down on a mesh
  31834. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31835. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31836. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31837. * @returns the current scene
  31838. */
  31839. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  31840. private _processPointerDown;
  31841. /**
  31842. * Use this method to simulate a pointer up on a mesh
  31843. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31844. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31845. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31846. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31847. * @returns the current scene
  31848. */
  31849. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  31850. private _processPointerUp;
  31851. /**
  31852. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31853. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31854. * @returns true if the pointer was captured
  31855. */
  31856. isPointerCaptured(pointerId?: number): boolean;
  31857. /** @hidden */
  31858. _isPointerSwiping(): boolean;
  31859. /**
  31860. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31861. * @param attachUp defines if you want to attach events to pointerup
  31862. * @param attachDown defines if you want to attach events to pointerdown
  31863. * @param attachMove defines if you want to attach events to pointermove
  31864. */
  31865. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31866. /** Detaches all event handlers*/
  31867. detachControl(): void;
  31868. /**
  31869. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  31870. * Delay loaded resources are not taking in account
  31871. * @return true if all required resources are ready
  31872. */
  31873. isReady(): boolean;
  31874. /** Resets all cached information relative to material (including effect and visibility) */
  31875. resetCachedMaterial(): void;
  31876. /**
  31877. * Registers a function to be called before every frame render
  31878. * @param func defines the function to register
  31879. */
  31880. registerBeforeRender(func: () => void): void;
  31881. /**
  31882. * Unregisters a function called before every frame render
  31883. * @param func defines the function to unregister
  31884. */
  31885. unregisterBeforeRender(func: () => void): void;
  31886. /**
  31887. * Registers a function to be called after every frame render
  31888. * @param func defines the function to register
  31889. */
  31890. registerAfterRender(func: () => void): void;
  31891. /**
  31892. * Unregisters a function called after every frame render
  31893. * @param func defines the function to unregister
  31894. */
  31895. unregisterAfterRender(func: () => void): void;
  31896. private _executeOnceBeforeRender;
  31897. /**
  31898. * The provided function will run before render once and will be disposed afterwards.
  31899. * A timeout delay can be provided so that the function will be executed in N ms.
  31900. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  31901. * @param func The function to be executed.
  31902. * @param timeout optional delay in ms
  31903. */
  31904. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  31905. /** @hidden */
  31906. _addPendingData(data: any): void;
  31907. /** @hidden */
  31908. _removePendingData(data: any): void;
  31909. /**
  31910. * Returns the number of items waiting to be loaded
  31911. * @returns the number of items waiting to be loaded
  31912. */
  31913. getWaitingItemsCount(): number;
  31914. /**
  31915. * Returns a boolean indicating if the scene is still loading data
  31916. */
  31917. readonly isLoading: boolean;
  31918. /**
  31919. * Registers a function to be executed when the scene is ready
  31920. * @param {Function} func - the function to be executed
  31921. */
  31922. executeWhenReady(func: () => void): void;
  31923. /**
  31924. * Returns a promise that resolves when the scene is ready
  31925. * @returns A promise that resolves when the scene is ready
  31926. */
  31927. whenReadyAsync(): Promise<void>;
  31928. /** @hidden */
  31929. _checkIsReady(): void;
  31930. /**
  31931. * Gets all animatable attached to the scene
  31932. */
  31933. readonly animatables: Animatable[];
  31934. /**
  31935. * Resets the last animation time frame.
  31936. * Useful to override when animations start running when loading a scene for the first time.
  31937. */
  31938. resetLastAnimationTimeFrame(): void;
  31939. /** @hidden */
  31940. _switchToAlternateCameraConfiguration(active: boolean): void;
  31941. /**
  31942. * Gets the current view matrix
  31943. * @returns a Matrix
  31944. */
  31945. getViewMatrix(): Matrix;
  31946. /**
  31947. * Gets the current projection matrix
  31948. * @returns a Matrix
  31949. */
  31950. getProjectionMatrix(): Matrix;
  31951. /**
  31952. * Gets the current transform matrix
  31953. * @returns a Matrix made of View * Projection
  31954. */
  31955. getTransformMatrix(): Matrix;
  31956. /**
  31957. * Sets the current transform matrix
  31958. * @param view defines the View matrix to use
  31959. * @param projection defines the Projection matrix to use
  31960. */
  31961. setTransformMatrix(view: Matrix, projection: Matrix): void;
  31962. /** @hidden */
  31963. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  31964. /**
  31965. * Gets the uniform buffer used to store scene data
  31966. * @returns a UniformBuffer
  31967. */
  31968. getSceneUniformBuffer(): UniformBuffer;
  31969. /**
  31970. * Gets an unique (relatively to the current scene) Id
  31971. * @returns an unique number for the scene
  31972. */
  31973. getUniqueId(): number;
  31974. /**
  31975. * Add a mesh to the list of scene's meshes
  31976. * @param newMesh defines the mesh to add
  31977. * @param recursive if all child meshes should also be added to the scene
  31978. */
  31979. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  31980. /**
  31981. * Remove a mesh for the list of scene's meshes
  31982. * @param toRemove defines the mesh to remove
  31983. * @param recursive if all child meshes should also be removed from the scene
  31984. * @returns the index where the mesh was in the mesh list
  31985. */
  31986. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  31987. /**
  31988. * Add a transform node to the list of scene's transform nodes
  31989. * @param newTransformNode defines the transform node to add
  31990. */
  31991. addTransformNode(newTransformNode: TransformNode): void;
  31992. /**
  31993. * Remove a transform node for the list of scene's transform nodes
  31994. * @param toRemove defines the transform node to remove
  31995. * @returns the index where the transform node was in the transform node list
  31996. */
  31997. removeTransformNode(toRemove: TransformNode): number;
  31998. /**
  31999. * Remove a skeleton for the list of scene's skeletons
  32000. * @param toRemove defines the skeleton to remove
  32001. * @returns the index where the skeleton was in the skeleton list
  32002. */
  32003. removeSkeleton(toRemove: Skeleton): number;
  32004. /**
  32005. * Remove a morph target for the list of scene's morph targets
  32006. * @param toRemove defines the morph target to remove
  32007. * @returns the index where the morph target was in the morph target list
  32008. */
  32009. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32010. /**
  32011. * Remove a light for the list of scene's lights
  32012. * @param toRemove defines the light to remove
  32013. * @returns the index where the light was in the light list
  32014. */
  32015. removeLight(toRemove: Light): number;
  32016. /**
  32017. * Remove a camera for the list of scene's cameras
  32018. * @param toRemove defines the camera to remove
  32019. * @returns the index where the camera was in the camera list
  32020. */
  32021. removeCamera(toRemove: Camera): number;
  32022. /**
  32023. * Remove a particle system for the list of scene's particle systems
  32024. * @param toRemove defines the particle system to remove
  32025. * @returns the index where the particle system was in the particle system list
  32026. */
  32027. removeParticleSystem(toRemove: IParticleSystem): number;
  32028. /**
  32029. * Remove a animation for the list of scene's animations
  32030. * @param toRemove defines the animation to remove
  32031. * @returns the index where the animation was in the animation list
  32032. */
  32033. removeAnimation(toRemove: Animation): number;
  32034. /**
  32035. * Removes the given animation group from this scene.
  32036. * @param toRemove The animation group to remove
  32037. * @returns The index of the removed animation group
  32038. */
  32039. removeAnimationGroup(toRemove: AnimationGroup): number;
  32040. /**
  32041. * Removes the given multi-material from this scene.
  32042. * @param toRemove The multi-material to remove
  32043. * @returns The index of the removed multi-material
  32044. */
  32045. removeMultiMaterial(toRemove: MultiMaterial): number;
  32046. /**
  32047. * Removes the given material from this scene.
  32048. * @param toRemove The material to remove
  32049. * @returns The index of the removed material
  32050. */
  32051. removeMaterial(toRemove: Material): number;
  32052. /**
  32053. * Removes the given action manager from this scene.
  32054. * @param toRemove The action manager to remove
  32055. * @returns The index of the removed action manager
  32056. */
  32057. removeActionManager(toRemove: AbstractActionManager): number;
  32058. /**
  32059. * Removes the given texture from this scene.
  32060. * @param toRemove The texture to remove
  32061. * @returns The index of the removed texture
  32062. */
  32063. removeTexture(toRemove: BaseTexture): number;
  32064. /**
  32065. * Adds the given light to this scene
  32066. * @param newLight The light to add
  32067. */
  32068. addLight(newLight: Light): void;
  32069. /**
  32070. * Sorts the list list based on light priorities
  32071. */
  32072. sortLightsByPriority(): void;
  32073. /**
  32074. * Adds the given camera to this scene
  32075. * @param newCamera The camera to add
  32076. */
  32077. addCamera(newCamera: Camera): void;
  32078. /**
  32079. * Adds the given skeleton to this scene
  32080. * @param newSkeleton The skeleton to add
  32081. */
  32082. addSkeleton(newSkeleton: Skeleton): void;
  32083. /**
  32084. * Adds the given particle system to this scene
  32085. * @param newParticleSystem The particle system to add
  32086. */
  32087. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32088. /**
  32089. * Adds the given animation to this scene
  32090. * @param newAnimation The animation to add
  32091. */
  32092. addAnimation(newAnimation: Animation): void;
  32093. /**
  32094. * Adds the given animation group to this scene.
  32095. * @param newAnimationGroup The animation group to add
  32096. */
  32097. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32098. /**
  32099. * Adds the given multi-material to this scene
  32100. * @param newMultiMaterial The multi-material to add
  32101. */
  32102. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32103. /**
  32104. * Adds the given material to this scene
  32105. * @param newMaterial The material to add
  32106. */
  32107. addMaterial(newMaterial: Material): void;
  32108. /**
  32109. * Adds the given morph target to this scene
  32110. * @param newMorphTargetManager The morph target to add
  32111. */
  32112. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32113. /**
  32114. * Adds the given geometry to this scene
  32115. * @param newGeometry The geometry to add
  32116. */
  32117. addGeometry(newGeometry: Geometry): void;
  32118. /**
  32119. * Adds the given action manager to this scene
  32120. * @param newActionManager The action manager to add
  32121. */
  32122. addActionManager(newActionManager: AbstractActionManager): void;
  32123. /**
  32124. * Adds the given texture to this scene.
  32125. * @param newTexture The texture to add
  32126. */
  32127. addTexture(newTexture: BaseTexture): void;
  32128. /**
  32129. * Switch active camera
  32130. * @param newCamera defines the new active camera
  32131. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32132. */
  32133. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32134. /**
  32135. * sets the active camera of the scene using its ID
  32136. * @param id defines the camera's ID
  32137. * @return the new active camera or null if none found.
  32138. */
  32139. setActiveCameraByID(id: string): Nullable<Camera>;
  32140. /**
  32141. * sets the active camera of the scene using its name
  32142. * @param name defines the camera's name
  32143. * @returns the new active camera or null if none found.
  32144. */
  32145. setActiveCameraByName(name: string): Nullable<Camera>;
  32146. /**
  32147. * get an animation group using its name
  32148. * @param name defines the material's name
  32149. * @return the animation group or null if none found.
  32150. */
  32151. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32152. /**
  32153. * get a material using its id
  32154. * @param id defines the material's ID
  32155. * @return the material or null if none found.
  32156. */
  32157. getMaterialByID(id: string): Nullable<Material>;
  32158. /**
  32159. * Gets a material using its name
  32160. * @param name defines the material's name
  32161. * @return the material or null if none found.
  32162. */
  32163. getMaterialByName(name: string): Nullable<Material>;
  32164. /**
  32165. * Gets a camera using its id
  32166. * @param id defines the id to look for
  32167. * @returns the camera or null if not found
  32168. */
  32169. getCameraByID(id: string): Nullable<Camera>;
  32170. /**
  32171. * Gets a camera using its unique id
  32172. * @param uniqueId defines the unique id to look for
  32173. * @returns the camera or null if not found
  32174. */
  32175. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32176. /**
  32177. * Gets a camera using its name
  32178. * @param name defines the camera's name
  32179. * @return the camera or null if none found.
  32180. */
  32181. getCameraByName(name: string): Nullable<Camera>;
  32182. /**
  32183. * Gets a bone using its id
  32184. * @param id defines the bone's id
  32185. * @return the bone or null if not found
  32186. */
  32187. getBoneByID(id: string): Nullable<Bone>;
  32188. /**
  32189. * Gets a bone using its id
  32190. * @param name defines the bone's name
  32191. * @return the bone or null if not found
  32192. */
  32193. getBoneByName(name: string): Nullable<Bone>;
  32194. /**
  32195. * Gets a light node using its name
  32196. * @param name defines the the light's name
  32197. * @return the light or null if none found.
  32198. */
  32199. getLightByName(name: string): Nullable<Light>;
  32200. /**
  32201. * Gets a light node using its id
  32202. * @param id defines the light's id
  32203. * @return the light or null if none found.
  32204. */
  32205. getLightByID(id: string): Nullable<Light>;
  32206. /**
  32207. * Gets a light node using its scene-generated unique ID
  32208. * @param uniqueId defines the light's unique id
  32209. * @return the light or null if none found.
  32210. */
  32211. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32212. /**
  32213. * Gets a particle system by id
  32214. * @param id defines the particle system id
  32215. * @return the corresponding system or null if none found
  32216. */
  32217. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32218. /**
  32219. * Gets a geometry using its ID
  32220. * @param id defines the geometry's id
  32221. * @return the geometry or null if none found.
  32222. */
  32223. getGeometryByID(id: string): Nullable<Geometry>;
  32224. private _getGeometryByUniqueID;
  32225. /**
  32226. * Add a new geometry to this scene
  32227. * @param geometry defines the geometry to be added to the scene.
  32228. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32229. * @return a boolean defining if the geometry was added or not
  32230. */
  32231. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32232. /**
  32233. * Removes an existing geometry
  32234. * @param geometry defines the geometry to be removed from the scene
  32235. * @return a boolean defining if the geometry was removed or not
  32236. */
  32237. removeGeometry(geometry: Geometry): boolean;
  32238. /**
  32239. * Gets the list of geometries attached to the scene
  32240. * @returns an array of Geometry
  32241. */
  32242. getGeometries(): Geometry[];
  32243. /**
  32244. * Gets the first added mesh found of a given ID
  32245. * @param id defines the id to search for
  32246. * @return the mesh found or null if not found at all
  32247. */
  32248. getMeshByID(id: string): Nullable<AbstractMesh>;
  32249. /**
  32250. * Gets a list of meshes using their id
  32251. * @param id defines the id to search for
  32252. * @returns a list of meshes
  32253. */
  32254. getMeshesByID(id: string): Array<AbstractMesh>;
  32255. /**
  32256. * Gets the first added transform node found of a given ID
  32257. * @param id defines the id to search for
  32258. * @return the found transform node or null if not found at all.
  32259. */
  32260. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32261. /**
  32262. * Gets a list of transform nodes using their id
  32263. * @param id defines the id to search for
  32264. * @returns a list of transform nodes
  32265. */
  32266. getTransformNodesByID(id: string): Array<TransformNode>;
  32267. /**
  32268. * Gets a mesh with its auto-generated unique id
  32269. * @param uniqueId defines the unique id to search for
  32270. * @return the found mesh or null if not found at all.
  32271. */
  32272. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32273. /**
  32274. * Gets a the last added mesh using a given id
  32275. * @param id defines the id to search for
  32276. * @return the found mesh or null if not found at all.
  32277. */
  32278. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32279. /**
  32280. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32281. * @param id defines the id to search for
  32282. * @return the found node or null if not found at all
  32283. */
  32284. getLastEntryByID(id: string): Nullable<Node>;
  32285. /**
  32286. * Gets a node (Mesh, Camera, Light) using a given id
  32287. * @param id defines the id to search for
  32288. * @return the found node or null if not found at all
  32289. */
  32290. getNodeByID(id: string): Nullable<Node>;
  32291. /**
  32292. * Gets a node (Mesh, Camera, Light) using a given name
  32293. * @param name defines the name to search for
  32294. * @return the found node or null if not found at all.
  32295. */
  32296. getNodeByName(name: string): Nullable<Node>;
  32297. /**
  32298. * Gets a mesh using a given name
  32299. * @param name defines the name to search for
  32300. * @return the found mesh or null if not found at all.
  32301. */
  32302. getMeshByName(name: string): Nullable<AbstractMesh>;
  32303. /**
  32304. * Gets a transform node using a given name
  32305. * @param name defines the name to search for
  32306. * @return the found transform node or null if not found at all.
  32307. */
  32308. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32309. /**
  32310. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32311. * @param id defines the id to search for
  32312. * @return the found skeleton or null if not found at all.
  32313. */
  32314. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32315. /**
  32316. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32317. * @param id defines the id to search for
  32318. * @return the found skeleton or null if not found at all.
  32319. */
  32320. getSkeletonById(id: string): Nullable<Skeleton>;
  32321. /**
  32322. * Gets a skeleton using a given name
  32323. * @param name defines the name to search for
  32324. * @return the found skeleton or null if not found at all.
  32325. */
  32326. getSkeletonByName(name: string): Nullable<Skeleton>;
  32327. /**
  32328. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32329. * @param id defines the id to search for
  32330. * @return the found morph target manager or null if not found at all.
  32331. */
  32332. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32333. /**
  32334. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32335. * @param id defines the id to search for
  32336. * @return the found morph target or null if not found at all.
  32337. */
  32338. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32339. /**
  32340. * Gets a boolean indicating if the given mesh is active
  32341. * @param mesh defines the mesh to look for
  32342. * @returns true if the mesh is in the active list
  32343. */
  32344. isActiveMesh(mesh: AbstractMesh): boolean;
  32345. /**
  32346. * Return a unique id as a string which can serve as an identifier for the scene
  32347. */
  32348. readonly uid: string;
  32349. /**
  32350. * Add an externaly attached data from its key.
  32351. * This method call will fail and return false, if such key already exists.
  32352. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32353. * @param key the unique key that identifies the data
  32354. * @param data the data object to associate to the key for this Engine instance
  32355. * @return true if no such key were already present and the data was added successfully, false otherwise
  32356. */
  32357. addExternalData<T>(key: string, data: T): boolean;
  32358. /**
  32359. * Get an externaly attached data from its key
  32360. * @param key the unique key that identifies the data
  32361. * @return the associated data, if present (can be null), or undefined if not present
  32362. */
  32363. getExternalData<T>(key: string): Nullable<T>;
  32364. /**
  32365. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32366. * @param key the unique key that identifies the data
  32367. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32368. * @return the associated data, can be null if the factory returned null.
  32369. */
  32370. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32371. /**
  32372. * Remove an externaly attached data from the Engine instance
  32373. * @param key the unique key that identifies the data
  32374. * @return true if the data was successfully removed, false if it doesn't exist
  32375. */
  32376. removeExternalData(key: string): boolean;
  32377. private _evaluateSubMesh;
  32378. /**
  32379. * Clear the processed materials smart array preventing retention point in material dispose.
  32380. */
  32381. freeProcessedMaterials(): void;
  32382. private _preventFreeActiveMeshesAndRenderingGroups;
  32383. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32384. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32385. * when disposing several meshes in a row or a hierarchy of meshes.
  32386. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32387. */
  32388. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32389. /**
  32390. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32391. */
  32392. freeActiveMeshes(): void;
  32393. /**
  32394. * Clear the info related to rendering groups preventing retention points during dispose.
  32395. */
  32396. freeRenderingGroups(): void;
  32397. /** @hidden */
  32398. _isInIntermediateRendering(): boolean;
  32399. /**
  32400. * Lambda returning the list of potentially active meshes.
  32401. */
  32402. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32403. /**
  32404. * Lambda returning the list of potentially active sub meshes.
  32405. */
  32406. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32407. /**
  32408. * Lambda returning the list of potentially intersecting sub meshes.
  32409. */
  32410. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32411. /**
  32412. * Lambda returning the list of potentially colliding sub meshes.
  32413. */
  32414. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32415. private _activeMeshesFrozen;
  32416. /**
  32417. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32418. * @returns the current scene
  32419. */
  32420. freezeActiveMeshes(): Scene;
  32421. /**
  32422. * Use this function to restart evaluating active meshes on every frame
  32423. * @returns the current scene
  32424. */
  32425. unfreezeActiveMeshes(): Scene;
  32426. private _evaluateActiveMeshes;
  32427. private _activeMesh;
  32428. /**
  32429. * Update the transform matrix to update from the current active camera
  32430. * @param force defines a boolean used to force the update even if cache is up to date
  32431. */
  32432. updateTransformMatrix(force?: boolean): void;
  32433. /**
  32434. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  32435. * @param alternateCamera defines the camera to use
  32436. */
  32437. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  32438. /** @hidden */
  32439. _allowPostProcessClearColor: boolean;
  32440. private _renderForCamera;
  32441. private _processSubCameras;
  32442. private _checkIntersections;
  32443. /** @hidden */
  32444. _advancePhysicsEngineStep(step: number): void;
  32445. /**
  32446. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32447. */
  32448. getDeterministicFrameTime: () => number;
  32449. /** @hidden */
  32450. _animate(): void;
  32451. /**
  32452. * Render the scene
  32453. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32454. */
  32455. render(updateCameras?: boolean): void;
  32456. /**
  32457. * Freeze all materials
  32458. * A frozen material will not be updatable but should be faster to render
  32459. */
  32460. freezeMaterials(): void;
  32461. /**
  32462. * Unfreeze all materials
  32463. * A frozen material will not be updatable but should be faster to render
  32464. */
  32465. unfreezeMaterials(): void;
  32466. /**
  32467. * Releases all held ressources
  32468. */
  32469. dispose(): void;
  32470. /**
  32471. * Gets if the scene is already disposed
  32472. */
  32473. readonly isDisposed: boolean;
  32474. /**
  32475. * Call this function to reduce memory footprint of the scene.
  32476. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32477. */
  32478. clearCachedVertexData(): void;
  32479. /**
  32480. * This function will remove the local cached buffer data from texture.
  32481. * It will save memory but will prevent the texture from being rebuilt
  32482. */
  32483. cleanCachedTextureBuffer(): void;
  32484. /**
  32485. * Get the world extend vectors with an optional filter
  32486. *
  32487. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32488. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32489. */
  32490. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32491. min: Vector3;
  32492. max: Vector3;
  32493. };
  32494. /**
  32495. * Creates a ray that can be used to pick in the scene
  32496. * @param x defines the x coordinate of the origin (on-screen)
  32497. * @param y defines the y coordinate of the origin (on-screen)
  32498. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32499. * @param camera defines the camera to use for the picking
  32500. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32501. * @returns a Ray
  32502. */
  32503. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32504. /**
  32505. * Creates a ray that can be used to pick in the scene
  32506. * @param x defines the x coordinate of the origin (on-screen)
  32507. * @param y defines the y coordinate of the origin (on-screen)
  32508. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32509. * @param result defines the ray where to store the picking ray
  32510. * @param camera defines the camera to use for the picking
  32511. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32512. * @returns the current scene
  32513. */
  32514. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32515. /**
  32516. * Creates a ray that can be used to pick in the scene
  32517. * @param x defines the x coordinate of the origin (on-screen)
  32518. * @param y defines the y coordinate of the origin (on-screen)
  32519. * @param camera defines the camera to use for the picking
  32520. * @returns a Ray
  32521. */
  32522. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32523. /**
  32524. * Creates a ray that can be used to pick in the scene
  32525. * @param x defines the x coordinate of the origin (on-screen)
  32526. * @param y defines the y coordinate of the origin (on-screen)
  32527. * @param result defines the ray where to store the picking ray
  32528. * @param camera defines the camera to use for the picking
  32529. * @returns the current scene
  32530. */
  32531. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32532. /** Launch a ray to try to pick a mesh in the scene
  32533. * @param x position on screen
  32534. * @param y position on screen
  32535. * @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
  32536. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32537. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32538. * @returns a PickingInfo
  32539. */
  32540. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  32541. /** Use the given ray to pick a mesh in the scene
  32542. * @param ray The ray to use to pick meshes
  32543. * @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
  32544. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32545. * @returns a PickingInfo
  32546. */
  32547. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  32548. /**
  32549. * Launch a ray to try to pick a mesh in the scene
  32550. * @param x X position on screen
  32551. * @param y Y position on screen
  32552. * @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
  32553. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32554. * @returns an array of PickingInfo
  32555. */
  32556. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  32557. /**
  32558. * Launch a ray to try to pick a mesh in the scene
  32559. * @param ray Ray to use
  32560. * @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
  32561. * @returns an array of PickingInfo
  32562. */
  32563. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  32564. /**
  32565. * Force the value of meshUnderPointer
  32566. * @param mesh defines the mesh to use
  32567. */
  32568. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32569. /**
  32570. * Gets the mesh under the pointer
  32571. * @returns a Mesh or null if no mesh is under the pointer
  32572. */
  32573. getPointerOverMesh(): Nullable<AbstractMesh>;
  32574. /** @hidden */
  32575. _rebuildGeometries(): void;
  32576. /** @hidden */
  32577. _rebuildTextures(): void;
  32578. private _getByTags;
  32579. /**
  32580. * Get a list of meshes by tags
  32581. * @param tagsQuery defines the tags query to use
  32582. * @param forEach defines a predicate used to filter results
  32583. * @returns an array of Mesh
  32584. */
  32585. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32586. /**
  32587. * Get a list of cameras by tags
  32588. * @param tagsQuery defines the tags query to use
  32589. * @param forEach defines a predicate used to filter results
  32590. * @returns an array of Camera
  32591. */
  32592. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32593. /**
  32594. * Get a list of lights by tags
  32595. * @param tagsQuery defines the tags query to use
  32596. * @param forEach defines a predicate used to filter results
  32597. * @returns an array of Light
  32598. */
  32599. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32600. /**
  32601. * Get a list of materials by tags
  32602. * @param tagsQuery defines the tags query to use
  32603. * @param forEach defines a predicate used to filter results
  32604. * @returns an array of Material
  32605. */
  32606. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32607. /**
  32608. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32609. * This allowed control for front to back rendering or reversly depending of the special needs.
  32610. *
  32611. * @param renderingGroupId The rendering group id corresponding to its index
  32612. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32613. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32614. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32615. */
  32616. 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;
  32617. /**
  32618. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32619. *
  32620. * @param renderingGroupId The rendering group id corresponding to its index
  32621. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32622. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32623. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32624. */
  32625. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32626. /**
  32627. * Gets the current auto clear configuration for one rendering group of the rendering
  32628. * manager.
  32629. * @param index the rendering group index to get the information for
  32630. * @returns The auto clear setup for the requested rendering group
  32631. */
  32632. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32633. private _blockMaterialDirtyMechanism;
  32634. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32635. blockMaterialDirtyMechanism: boolean;
  32636. /**
  32637. * Will flag all materials as dirty to trigger new shader compilation
  32638. * @param flag defines the flag used to specify which material part must be marked as dirty
  32639. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32640. */
  32641. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32642. /** @hidden */
  32643. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  32644. /** @hidden */
  32645. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32646. }
  32647. }
  32648. declare module BABYLON {
  32649. /**
  32650. * Set of assets to keep when moving a scene into an asset container.
  32651. */
  32652. export class KeepAssets extends AbstractScene {
  32653. }
  32654. /**
  32655. * Container with a set of assets that can be added or removed from a scene.
  32656. */
  32657. export class AssetContainer extends AbstractScene {
  32658. /**
  32659. * The scene the AssetContainer belongs to.
  32660. */
  32661. scene: Scene;
  32662. /**
  32663. * Instantiates an AssetContainer.
  32664. * @param scene The scene the AssetContainer belongs to.
  32665. */
  32666. constructor(scene: Scene);
  32667. /**
  32668. * Adds all the assets from the container to the scene.
  32669. */
  32670. addAllToScene(): void;
  32671. /**
  32672. * Removes all the assets in the container from the scene
  32673. */
  32674. removeAllFromScene(): void;
  32675. /**
  32676. * Disposes all the assets in the container
  32677. */
  32678. dispose(): void;
  32679. private _moveAssets;
  32680. /**
  32681. * Removes all the assets contained in the scene and adds them to the container.
  32682. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32683. */
  32684. moveAllFromScene(keepAssets?: KeepAssets): void;
  32685. /**
  32686. * 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.
  32687. * @returns the root mesh
  32688. */
  32689. createRootMesh(): Mesh;
  32690. }
  32691. }
  32692. declare module BABYLON {
  32693. /**
  32694. * Defines how the parser contract is defined.
  32695. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32696. */
  32697. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32698. /**
  32699. * Defines how the individual parser contract is defined.
  32700. * These parser can parse an individual asset
  32701. */
  32702. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32703. /**
  32704. * Base class of the scene acting as a container for the different elements composing a scene.
  32705. * This class is dynamically extended by the different components of the scene increasing
  32706. * flexibility and reducing coupling
  32707. */
  32708. export abstract class AbstractScene {
  32709. /**
  32710. * Stores the list of available parsers in the application.
  32711. */
  32712. private static _BabylonFileParsers;
  32713. /**
  32714. * Stores the list of available individual parsers in the application.
  32715. */
  32716. private static _IndividualBabylonFileParsers;
  32717. /**
  32718. * Adds a parser in the list of available ones
  32719. * @param name Defines the name of the parser
  32720. * @param parser Defines the parser to add
  32721. */
  32722. static AddParser(name: string, parser: BabylonFileParser): void;
  32723. /**
  32724. * Gets a general parser from the list of avaialble ones
  32725. * @param name Defines the name of the parser
  32726. * @returns the requested parser or null
  32727. */
  32728. static GetParser(name: string): Nullable<BabylonFileParser>;
  32729. /**
  32730. * Adds n individual parser in the list of available ones
  32731. * @param name Defines the name of the parser
  32732. * @param parser Defines the parser to add
  32733. */
  32734. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32735. /**
  32736. * Gets an individual parser from the list of avaialble ones
  32737. * @param name Defines the name of the parser
  32738. * @returns the requested parser or null
  32739. */
  32740. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32741. /**
  32742. * Parser json data and populate both a scene and its associated container object
  32743. * @param jsonData Defines the data to parse
  32744. * @param scene Defines the scene to parse the data for
  32745. * @param container Defines the container attached to the parsing sequence
  32746. * @param rootUrl Defines the root url of the data
  32747. */
  32748. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32749. /**
  32750. * Gets the list of root nodes (ie. nodes with no parent)
  32751. */
  32752. rootNodes: Node[];
  32753. /** All of the cameras added to this scene
  32754. * @see http://doc.babylonjs.com/babylon101/cameras
  32755. */
  32756. cameras: Camera[];
  32757. /**
  32758. * All of the lights added to this scene
  32759. * @see http://doc.babylonjs.com/babylon101/lights
  32760. */
  32761. lights: Light[];
  32762. /**
  32763. * All of the (abstract) meshes added to this scene
  32764. */
  32765. meshes: AbstractMesh[];
  32766. /**
  32767. * The list of skeletons added to the scene
  32768. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32769. */
  32770. skeletons: Skeleton[];
  32771. /**
  32772. * All of the particle systems added to this scene
  32773. * @see http://doc.babylonjs.com/babylon101/particles
  32774. */
  32775. particleSystems: IParticleSystem[];
  32776. /**
  32777. * Gets a list of Animations associated with the scene
  32778. */
  32779. animations: Animation[];
  32780. /**
  32781. * All of the animation groups added to this scene
  32782. * @see http://doc.babylonjs.com/how_to/group
  32783. */
  32784. animationGroups: AnimationGroup[];
  32785. /**
  32786. * All of the multi-materials added to this scene
  32787. * @see http://doc.babylonjs.com/how_to/multi_materials
  32788. */
  32789. multiMaterials: MultiMaterial[];
  32790. /**
  32791. * All of the materials added to this scene
  32792. * In the context of a Scene, it is not supposed to be modified manually.
  32793. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32794. * Note also that the order of the Material wihin the array is not significant and might change.
  32795. * @see http://doc.babylonjs.com/babylon101/materials
  32796. */
  32797. materials: Material[];
  32798. /**
  32799. * The list of morph target managers added to the scene
  32800. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32801. */
  32802. morphTargetManagers: MorphTargetManager[];
  32803. /**
  32804. * The list of geometries used in the scene.
  32805. */
  32806. geometries: Geometry[];
  32807. /**
  32808. * All of the tranform nodes added to this scene
  32809. * In the context of a Scene, it is not supposed to be modified manually.
  32810. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  32811. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  32812. * @see http://doc.babylonjs.com/how_to/transformnode
  32813. */
  32814. transformNodes: TransformNode[];
  32815. /**
  32816. * ActionManagers available on the scene.
  32817. */
  32818. actionManagers: AbstractActionManager[];
  32819. /**
  32820. * Textures to keep.
  32821. */
  32822. textures: BaseTexture[];
  32823. }
  32824. }
  32825. declare module BABYLON {
  32826. /**
  32827. * Defines a sound that can be played in the application.
  32828. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  32829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32830. */
  32831. export class Sound {
  32832. /**
  32833. * The name of the sound in the scene.
  32834. */
  32835. name: string;
  32836. /**
  32837. * Does the sound autoplay once loaded.
  32838. */
  32839. autoplay: boolean;
  32840. /**
  32841. * Does the sound loop after it finishes playing once.
  32842. */
  32843. loop: boolean;
  32844. /**
  32845. * Does the sound use a custom attenuation curve to simulate the falloff
  32846. * happening when the source gets further away from the camera.
  32847. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  32848. */
  32849. useCustomAttenuation: boolean;
  32850. /**
  32851. * The sound track id this sound belongs to.
  32852. */
  32853. soundTrackId: number;
  32854. /**
  32855. * Is this sound currently played.
  32856. */
  32857. isPlaying: boolean;
  32858. /**
  32859. * Is this sound currently paused.
  32860. */
  32861. isPaused: boolean;
  32862. /**
  32863. * Does this sound enables spatial sound.
  32864. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32865. */
  32866. spatialSound: boolean;
  32867. /**
  32868. * Define the reference distance the sound should be heard perfectly.
  32869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32870. */
  32871. refDistance: number;
  32872. /**
  32873. * Define the roll off factor of spatial sounds.
  32874. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32875. */
  32876. rolloffFactor: number;
  32877. /**
  32878. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  32879. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32880. */
  32881. maxDistance: number;
  32882. /**
  32883. * Define the distance attenuation model the sound will follow.
  32884. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32885. */
  32886. distanceModel: string;
  32887. /**
  32888. * @hidden
  32889. * Back Compat
  32890. **/
  32891. onended: () => any;
  32892. /**
  32893. * Observable event when the current playing sound finishes.
  32894. */
  32895. onEndedObservable: Observable<Sound>;
  32896. private _panningModel;
  32897. private _playbackRate;
  32898. private _streaming;
  32899. private _startTime;
  32900. private _startOffset;
  32901. private _position;
  32902. /** @hidden */
  32903. _positionInEmitterSpace: boolean;
  32904. private _localDirection;
  32905. private _volume;
  32906. private _isReadyToPlay;
  32907. private _isDirectional;
  32908. private _readyToPlayCallback;
  32909. private _audioBuffer;
  32910. private _soundSource;
  32911. private _streamingSource;
  32912. private _soundPanner;
  32913. private _soundGain;
  32914. private _inputAudioNode;
  32915. private _outputAudioNode;
  32916. private _coneInnerAngle;
  32917. private _coneOuterAngle;
  32918. private _coneOuterGain;
  32919. private _scene;
  32920. private _connectedTransformNode;
  32921. private _customAttenuationFunction;
  32922. private _registerFunc;
  32923. private _isOutputConnected;
  32924. private _htmlAudioElement;
  32925. private _urlType;
  32926. /** @hidden */
  32927. static _SceneComponentInitialization: (scene: Scene) => void;
  32928. /**
  32929. * Create a sound and attach it to a scene
  32930. * @param name Name of your sound
  32931. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  32932. * @param scene defines the scene the sound belongs to
  32933. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  32934. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  32935. */
  32936. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  32937. /**
  32938. * Release the sound and its associated resources
  32939. */
  32940. dispose(): void;
  32941. /**
  32942. * Gets if the sounds is ready to be played or not.
  32943. * @returns true if ready, otherwise false
  32944. */
  32945. isReady(): boolean;
  32946. private _soundLoaded;
  32947. /**
  32948. * Sets the data of the sound from an audiobuffer
  32949. * @param audioBuffer The audioBuffer containing the data
  32950. */
  32951. setAudioBuffer(audioBuffer: AudioBuffer): void;
  32952. /**
  32953. * Updates the current sounds options such as maxdistance, loop...
  32954. * @param options A JSON object containing values named as the object properties
  32955. */
  32956. updateOptions(options: any): void;
  32957. private _createSpatialParameters;
  32958. private _updateSpatialParameters;
  32959. /**
  32960. * Switch the panning model to HRTF:
  32961. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  32962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32963. */
  32964. switchPanningModelToHRTF(): void;
  32965. /**
  32966. * Switch the panning model to Equal Power:
  32967. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  32968. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  32969. */
  32970. switchPanningModelToEqualPower(): void;
  32971. private _switchPanningModel;
  32972. /**
  32973. * Connect this sound to a sound track audio node like gain...
  32974. * @param soundTrackAudioNode the sound track audio node to connect to
  32975. */
  32976. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  32977. /**
  32978. * Transform this sound into a directional source
  32979. * @param coneInnerAngle Size of the inner cone in degree
  32980. * @param coneOuterAngle Size of the outer cone in degree
  32981. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  32982. */
  32983. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  32984. /**
  32985. * Gets or sets the inner angle for the directional cone.
  32986. */
  32987. /**
  32988. * Gets or sets the inner angle for the directional cone.
  32989. */
  32990. directionalConeInnerAngle: number;
  32991. /**
  32992. * Gets or sets the outer angle for the directional cone.
  32993. */
  32994. /**
  32995. * Gets or sets the outer angle for the directional cone.
  32996. */
  32997. directionalConeOuterAngle: number;
  32998. /**
  32999. * Sets the position of the emitter if spatial sound is enabled
  33000. * @param newPosition Defines the new posisiton
  33001. */
  33002. setPosition(newPosition: Vector3): void;
  33003. /**
  33004. * Sets the local direction of the emitter if spatial sound is enabled
  33005. * @param newLocalDirection Defines the new local direction
  33006. */
  33007. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33008. private _updateDirection;
  33009. /** @hidden */
  33010. updateDistanceFromListener(): void;
  33011. /**
  33012. * Sets a new custom attenuation function for the sound.
  33013. * @param callback Defines the function used for the attenuation
  33014. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33015. */
  33016. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33017. /**
  33018. * Play the sound
  33019. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33020. * @param offset (optional) Start the sound setting it at a specific time
  33021. */
  33022. play(time?: number, offset?: number): void;
  33023. private _onended;
  33024. /**
  33025. * Stop the sound
  33026. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33027. */
  33028. stop(time?: number): void;
  33029. /**
  33030. * Put the sound in pause
  33031. */
  33032. pause(): void;
  33033. /**
  33034. * Sets a dedicated volume for this sounds
  33035. * @param newVolume Define the new volume of the sound
  33036. * @param time Define in how long the sound should be at this value
  33037. */
  33038. setVolume(newVolume: number, time?: number): void;
  33039. /**
  33040. * Set the sound play back rate
  33041. * @param newPlaybackRate Define the playback rate the sound should be played at
  33042. */
  33043. setPlaybackRate(newPlaybackRate: number): void;
  33044. /**
  33045. * Gets the volume of the sound.
  33046. * @returns the volume of the sound
  33047. */
  33048. getVolume(): number;
  33049. /**
  33050. * Attach the sound to a dedicated mesh
  33051. * @param transformNode The transform node to connect the sound with
  33052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33053. */
  33054. attachToMesh(transformNode: TransformNode): void;
  33055. /**
  33056. * Detach the sound from the previously attached mesh
  33057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33058. */
  33059. detachFromMesh(): void;
  33060. private _onRegisterAfterWorldMatrixUpdate;
  33061. /**
  33062. * Clone the current sound in the scene.
  33063. * @returns the new sound clone
  33064. */
  33065. clone(): Nullable<Sound>;
  33066. /**
  33067. * Gets the current underlying audio buffer containing the data
  33068. * @returns the audio buffer
  33069. */
  33070. getAudioBuffer(): Nullable<AudioBuffer>;
  33071. /**
  33072. * Serializes the Sound in a JSON representation
  33073. * @returns the JSON representation of the sound
  33074. */
  33075. serialize(): any;
  33076. /**
  33077. * Parse a JSON representation of a sound to innstantiate in a given scene
  33078. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33079. * @param scene Define the scene the new parsed sound should be created in
  33080. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33081. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33082. * @returns the newly parsed sound
  33083. */
  33084. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33085. }
  33086. }
  33087. declare module BABYLON {
  33088. /**
  33089. * This defines an action helpful to play a defined sound on a triggered action.
  33090. */
  33091. export class PlaySoundAction extends Action {
  33092. private _sound;
  33093. /**
  33094. * Instantiate the action
  33095. * @param triggerOptions defines the trigger options
  33096. * @param sound defines the sound to play
  33097. * @param condition defines the trigger related conditions
  33098. */
  33099. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33100. /** @hidden */
  33101. _prepare(): void;
  33102. /**
  33103. * Execute the action and play the sound.
  33104. */
  33105. execute(): void;
  33106. /**
  33107. * Serializes the actions and its related information.
  33108. * @param parent defines the object to serialize in
  33109. * @returns the serialized object
  33110. */
  33111. serialize(parent: any): any;
  33112. }
  33113. /**
  33114. * This defines an action helpful to stop a defined sound on a triggered action.
  33115. */
  33116. export class StopSoundAction extends Action {
  33117. private _sound;
  33118. /**
  33119. * Instantiate the action
  33120. * @param triggerOptions defines the trigger options
  33121. * @param sound defines the sound to stop
  33122. * @param condition defines the trigger related conditions
  33123. */
  33124. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33125. /** @hidden */
  33126. _prepare(): void;
  33127. /**
  33128. * Execute the action and stop the sound.
  33129. */
  33130. execute(): void;
  33131. /**
  33132. * Serializes the actions and its related information.
  33133. * @param parent defines the object to serialize in
  33134. * @returns the serialized object
  33135. */
  33136. serialize(parent: any): any;
  33137. }
  33138. }
  33139. declare module BABYLON {
  33140. /**
  33141. * This defines an action responsible to change the value of a property
  33142. * by interpolating between its current value and the newly set one once triggered.
  33143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33144. */
  33145. export class InterpolateValueAction extends Action {
  33146. /**
  33147. * Defines the path of the property where the value should be interpolated
  33148. */
  33149. propertyPath: string;
  33150. /**
  33151. * Defines the target value at the end of the interpolation.
  33152. */
  33153. value: any;
  33154. /**
  33155. * Defines the time it will take for the property to interpolate to the value.
  33156. */
  33157. duration: number;
  33158. /**
  33159. * Defines if the other scene animations should be stopped when the action has been triggered
  33160. */
  33161. stopOtherAnimations?: boolean;
  33162. /**
  33163. * Defines a callback raised once the interpolation animation has been done.
  33164. */
  33165. onInterpolationDone?: () => void;
  33166. /**
  33167. * Observable triggered once the interpolation animation has been done.
  33168. */
  33169. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33170. private _target;
  33171. private _effectiveTarget;
  33172. private _property;
  33173. /**
  33174. * Instantiate the action
  33175. * @param triggerOptions defines the trigger options
  33176. * @param target defines the object containing the value to interpolate
  33177. * @param propertyPath defines the path to the property in the target object
  33178. * @param value defines the target value at the end of the interpolation
  33179. * @param duration deines the time it will take for the property to interpolate to the value.
  33180. * @param condition defines the trigger related conditions
  33181. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33182. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33183. */
  33184. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33185. /** @hidden */
  33186. _prepare(): void;
  33187. /**
  33188. * Execute the action starts the value interpolation.
  33189. */
  33190. execute(): void;
  33191. /**
  33192. * Serializes the actions and its related information.
  33193. * @param parent defines the object to serialize in
  33194. * @returns the serialized object
  33195. */
  33196. serialize(parent: any): any;
  33197. }
  33198. }
  33199. declare module BABYLON {
  33200. /**
  33201. * Options allowed during the creation of a sound track.
  33202. */
  33203. export interface ISoundTrackOptions {
  33204. /**
  33205. * The volume the sound track should take during creation
  33206. */
  33207. volume?: number;
  33208. /**
  33209. * Define if the sound track is the main sound track of the scene
  33210. */
  33211. mainTrack?: boolean;
  33212. }
  33213. /**
  33214. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33215. * It will be also used in a future release to apply effects on a specific track.
  33216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33217. */
  33218. export class SoundTrack {
  33219. /**
  33220. * The unique identifier of the sound track in the scene.
  33221. */
  33222. id: number;
  33223. /**
  33224. * The list of sounds included in the sound track.
  33225. */
  33226. soundCollection: Array<Sound>;
  33227. private _outputAudioNode;
  33228. private _scene;
  33229. private _isMainTrack;
  33230. private _connectedAnalyser;
  33231. private _options;
  33232. private _isInitialized;
  33233. /**
  33234. * Creates a new sound track.
  33235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33236. * @param scene Define the scene the sound track belongs to
  33237. * @param options
  33238. */
  33239. constructor(scene: Scene, options?: ISoundTrackOptions);
  33240. private _initializeSoundTrackAudioGraph;
  33241. /**
  33242. * Release the sound track and its associated resources
  33243. */
  33244. dispose(): void;
  33245. /**
  33246. * Adds a sound to this sound track
  33247. * @param sound define the cound to add
  33248. * @ignoreNaming
  33249. */
  33250. AddSound(sound: Sound): void;
  33251. /**
  33252. * Removes a sound to this sound track
  33253. * @param sound define the cound to remove
  33254. * @ignoreNaming
  33255. */
  33256. RemoveSound(sound: Sound): void;
  33257. /**
  33258. * Set a global volume for the full sound track.
  33259. * @param newVolume Define the new volume of the sound track
  33260. */
  33261. setVolume(newVolume: number): void;
  33262. /**
  33263. * Switch the panning model to HRTF:
  33264. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33266. */
  33267. switchPanningModelToHRTF(): void;
  33268. /**
  33269. * Switch the panning model to Equal Power:
  33270. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33271. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33272. */
  33273. switchPanningModelToEqualPower(): void;
  33274. /**
  33275. * Connect the sound track to an audio analyser allowing some amazing
  33276. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33278. * @param analyser The analyser to connect to the engine
  33279. */
  33280. connectToAnalyser(analyser: Analyser): void;
  33281. }
  33282. }
  33283. declare module BABYLON {
  33284. interface AbstractScene {
  33285. /**
  33286. * The list of sounds used in the scene.
  33287. */
  33288. sounds: Nullable<Array<Sound>>;
  33289. }
  33290. interface Scene {
  33291. /**
  33292. * @hidden
  33293. * Backing field
  33294. */
  33295. _mainSoundTrack: SoundTrack;
  33296. /**
  33297. * The main sound track played by the scene.
  33298. * It cotains your primary collection of sounds.
  33299. */
  33300. mainSoundTrack: SoundTrack;
  33301. /**
  33302. * The list of sound tracks added to the scene
  33303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33304. */
  33305. soundTracks: Nullable<Array<SoundTrack>>;
  33306. /**
  33307. * Gets a sound using a given name
  33308. * @param name defines the name to search for
  33309. * @return the found sound or null if not found at all.
  33310. */
  33311. getSoundByName(name: string): Nullable<Sound>;
  33312. /**
  33313. * Gets or sets if audio support is enabled
  33314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33315. */
  33316. audioEnabled: boolean;
  33317. /**
  33318. * Gets or sets if audio will be output to headphones
  33319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33320. */
  33321. headphone: boolean;
  33322. }
  33323. /**
  33324. * Defines the sound scene component responsible to manage any sounds
  33325. * in a given scene.
  33326. */
  33327. export class AudioSceneComponent implements ISceneSerializableComponent {
  33328. /**
  33329. * The component name helpfull to identify the component in the list of scene components.
  33330. */
  33331. readonly name: string;
  33332. /**
  33333. * The scene the component belongs to.
  33334. */
  33335. scene: Scene;
  33336. private _audioEnabled;
  33337. /**
  33338. * Gets whether audio is enabled or not.
  33339. * Please use related enable/disable method to switch state.
  33340. */
  33341. readonly audioEnabled: boolean;
  33342. private _headphone;
  33343. /**
  33344. * Gets whether audio is outputing to headphone or not.
  33345. * Please use the according Switch methods to change output.
  33346. */
  33347. readonly headphone: boolean;
  33348. /**
  33349. * Creates a new instance of the component for the given scene
  33350. * @param scene Defines the scene to register the component in
  33351. */
  33352. constructor(scene: Scene);
  33353. /**
  33354. * Registers the component in a given scene
  33355. */
  33356. register(): void;
  33357. /**
  33358. * Rebuilds the elements related to this component in case of
  33359. * context lost for instance.
  33360. */
  33361. rebuild(): void;
  33362. /**
  33363. * Serializes the component data to the specified json object
  33364. * @param serializationObject The object to serialize to
  33365. */
  33366. serialize(serializationObject: any): void;
  33367. /**
  33368. * Adds all the element from the container to the scene
  33369. * @param container the container holding the elements
  33370. */
  33371. addFromContainer(container: AbstractScene): void;
  33372. /**
  33373. * Removes all the elements in the container from the scene
  33374. * @param container contains the elements to remove
  33375. */
  33376. removeFromContainer(container: AbstractScene): void;
  33377. /**
  33378. * Disposes the component and the associated ressources.
  33379. */
  33380. dispose(): void;
  33381. /**
  33382. * Disables audio in the associated scene.
  33383. */
  33384. disableAudio(): void;
  33385. /**
  33386. * Enables audio in the associated scene.
  33387. */
  33388. enableAudio(): void;
  33389. /**
  33390. * Switch audio to headphone output.
  33391. */
  33392. switchAudioModeForHeadphones(): void;
  33393. /**
  33394. * Switch audio to normal speakers.
  33395. */
  33396. switchAudioModeForNormalSpeakers(): void;
  33397. private _afterRender;
  33398. }
  33399. }
  33400. declare module BABYLON {
  33401. /**
  33402. * Wraps one or more Sound objects and selects one with random weight for playback.
  33403. */
  33404. export class WeightedSound {
  33405. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33406. loop: boolean;
  33407. private _coneInnerAngle;
  33408. private _coneOuterAngle;
  33409. private _volume;
  33410. /** A Sound is currently playing. */
  33411. isPlaying: boolean;
  33412. /** A Sound is currently paused. */
  33413. isPaused: boolean;
  33414. private _sounds;
  33415. private _weights;
  33416. private _currentIndex?;
  33417. /**
  33418. * Creates a new WeightedSound from the list of sounds given.
  33419. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33420. * @param sounds Array of Sounds that will be selected from.
  33421. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33422. */
  33423. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33424. /**
  33425. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33426. */
  33427. /**
  33428. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33429. */
  33430. directionalConeInnerAngle: number;
  33431. /**
  33432. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33433. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33434. */
  33435. /**
  33436. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33437. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33438. */
  33439. directionalConeOuterAngle: number;
  33440. /**
  33441. * Playback volume.
  33442. */
  33443. /**
  33444. * Playback volume.
  33445. */
  33446. volume: number;
  33447. private _onended;
  33448. /**
  33449. * Suspend playback
  33450. */
  33451. pause(): void;
  33452. /**
  33453. * Stop playback
  33454. */
  33455. stop(): void;
  33456. /**
  33457. * Start playback.
  33458. * @param startOffset Position the clip head at a specific time in seconds.
  33459. */
  33460. play(startOffset?: number): void;
  33461. }
  33462. }
  33463. declare module BABYLON {
  33464. /**
  33465. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33466. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33467. */
  33468. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33469. /**
  33470. * Gets the name of the behavior.
  33471. */
  33472. readonly name: string;
  33473. /**
  33474. * The easing function used by animations
  33475. */
  33476. static EasingFunction: BackEase;
  33477. /**
  33478. * The easing mode used by animations
  33479. */
  33480. static EasingMode: number;
  33481. /**
  33482. * The duration of the animation, in milliseconds
  33483. */
  33484. transitionDuration: number;
  33485. /**
  33486. * Length of the distance animated by the transition when lower radius is reached
  33487. */
  33488. lowerRadiusTransitionRange: number;
  33489. /**
  33490. * Length of the distance animated by the transition when upper radius is reached
  33491. */
  33492. upperRadiusTransitionRange: number;
  33493. private _autoTransitionRange;
  33494. /**
  33495. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33496. */
  33497. /**
  33498. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33499. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33500. */
  33501. autoTransitionRange: boolean;
  33502. private _attachedCamera;
  33503. private _onAfterCheckInputsObserver;
  33504. private _onMeshTargetChangedObserver;
  33505. /**
  33506. * Initializes the behavior.
  33507. */
  33508. init(): void;
  33509. /**
  33510. * Attaches the behavior to its arc rotate camera.
  33511. * @param camera Defines the camera to attach the behavior to
  33512. */
  33513. attach(camera: ArcRotateCamera): void;
  33514. /**
  33515. * Detaches the behavior from its current arc rotate camera.
  33516. */
  33517. detach(): void;
  33518. private _radiusIsAnimating;
  33519. private _radiusBounceTransition;
  33520. private _animatables;
  33521. private _cachedWheelPrecision;
  33522. /**
  33523. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33524. * @param radiusLimit The limit to check against.
  33525. * @return Bool to indicate if at limit.
  33526. */
  33527. private _isRadiusAtLimit;
  33528. /**
  33529. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33530. * @param radiusDelta The delta by which to animate to. Can be negative.
  33531. */
  33532. private _applyBoundRadiusAnimation;
  33533. /**
  33534. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33535. */
  33536. protected _clearAnimationLocks(): void;
  33537. /**
  33538. * Stops and removes all animations that have been applied to the camera
  33539. */
  33540. stopAllAnimations(): void;
  33541. }
  33542. }
  33543. declare module BABYLON {
  33544. /**
  33545. * 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.
  33546. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33547. */
  33548. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33549. /**
  33550. * Gets the name of the behavior.
  33551. */
  33552. readonly name: string;
  33553. private _mode;
  33554. private _radiusScale;
  33555. private _positionScale;
  33556. private _defaultElevation;
  33557. private _elevationReturnTime;
  33558. private _elevationReturnWaitTime;
  33559. private _zoomStopsAnimation;
  33560. private _framingTime;
  33561. /**
  33562. * The easing function used by animations
  33563. */
  33564. static EasingFunction: ExponentialEase;
  33565. /**
  33566. * The easing mode used by animations
  33567. */
  33568. static EasingMode: number;
  33569. /**
  33570. * Sets the current mode used by the behavior
  33571. */
  33572. /**
  33573. * Gets current mode used by the behavior.
  33574. */
  33575. mode: number;
  33576. /**
  33577. * Sets the scale applied to the radius (1 by default)
  33578. */
  33579. /**
  33580. * Gets the scale applied to the radius
  33581. */
  33582. radiusScale: number;
  33583. /**
  33584. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33585. */
  33586. /**
  33587. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33588. */
  33589. positionScale: number;
  33590. /**
  33591. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33592. * behaviour is triggered, in radians.
  33593. */
  33594. /**
  33595. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33596. * behaviour is triggered, in radians.
  33597. */
  33598. defaultElevation: number;
  33599. /**
  33600. * Sets the time (in milliseconds) taken to return to the default beta position.
  33601. * Negative value indicates camera should not return to default.
  33602. */
  33603. /**
  33604. * Gets the time (in milliseconds) taken to return to the default beta position.
  33605. * Negative value indicates camera should not return to default.
  33606. */
  33607. elevationReturnTime: number;
  33608. /**
  33609. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33610. */
  33611. /**
  33612. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33613. */
  33614. elevationReturnWaitTime: number;
  33615. /**
  33616. * Sets the flag that indicates if user zooming should stop animation.
  33617. */
  33618. /**
  33619. * Gets the flag that indicates if user zooming should stop animation.
  33620. */
  33621. zoomStopsAnimation: boolean;
  33622. /**
  33623. * Sets the transition time when framing the mesh, in milliseconds
  33624. */
  33625. /**
  33626. * Gets the transition time when framing the mesh, in milliseconds
  33627. */
  33628. framingTime: number;
  33629. /**
  33630. * Define if the behavior should automatically change the configured
  33631. * camera limits and sensibilities.
  33632. */
  33633. autoCorrectCameraLimitsAndSensibility: boolean;
  33634. private _onPrePointerObservableObserver;
  33635. private _onAfterCheckInputsObserver;
  33636. private _onMeshTargetChangedObserver;
  33637. private _attachedCamera;
  33638. private _isPointerDown;
  33639. private _lastInteractionTime;
  33640. /**
  33641. * Initializes the behavior.
  33642. */
  33643. init(): void;
  33644. /**
  33645. * Attaches the behavior to its arc rotate camera.
  33646. * @param camera Defines the camera to attach the behavior to
  33647. */
  33648. attach(camera: ArcRotateCamera): void;
  33649. /**
  33650. * Detaches the behavior from its current arc rotate camera.
  33651. */
  33652. detach(): void;
  33653. private _animatables;
  33654. private _betaIsAnimating;
  33655. private _betaTransition;
  33656. private _radiusTransition;
  33657. private _vectorTransition;
  33658. /**
  33659. * Targets the given mesh and updates zoom level accordingly.
  33660. * @param mesh The mesh to target.
  33661. * @param radius Optional. If a cached radius position already exists, overrides default.
  33662. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33663. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33664. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33665. */
  33666. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33667. /**
  33668. * Targets the given mesh with its children and updates zoom level accordingly.
  33669. * @param mesh The mesh to target.
  33670. * @param radius Optional. If a cached radius position already exists, overrides default.
  33671. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33672. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33673. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33674. */
  33675. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33676. /**
  33677. * Targets the given meshes with their children and updates zoom level accordingly.
  33678. * @param meshes The mesh to target.
  33679. * @param radius Optional. If a cached radius position already exists, overrides default.
  33680. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33681. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33682. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33683. */
  33684. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33685. /**
  33686. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33687. * @param minimumWorld Determines the smaller position of the bounding box extend
  33688. * @param maximumWorld Determines the bigger position of the bounding box extend
  33689. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33690. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33691. */
  33692. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33693. /**
  33694. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33695. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33696. * frustum width.
  33697. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33698. * to fully enclose the mesh in the viewing frustum.
  33699. */
  33700. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33701. /**
  33702. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33703. * is automatically returned to its default position (expected to be above ground plane).
  33704. */
  33705. private _maintainCameraAboveGround;
  33706. /**
  33707. * Returns the frustum slope based on the canvas ratio and camera FOV
  33708. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33709. */
  33710. private _getFrustumSlope;
  33711. /**
  33712. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33713. */
  33714. private _clearAnimationLocks;
  33715. /**
  33716. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33717. */
  33718. private _applyUserInteraction;
  33719. /**
  33720. * Stops and removes all animations that have been applied to the camera
  33721. */
  33722. stopAllAnimations(): void;
  33723. /**
  33724. * Gets a value indicating if the user is moving the camera
  33725. */
  33726. readonly isUserIsMoving: boolean;
  33727. /**
  33728. * The camera can move all the way towards the mesh.
  33729. */
  33730. static IgnoreBoundsSizeMode: number;
  33731. /**
  33732. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33733. */
  33734. static FitFrustumSidesMode: number;
  33735. }
  33736. }
  33737. declare module BABYLON {
  33738. /**
  33739. * Manage the pointers inputs to control an arc rotate camera.
  33740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33741. */
  33742. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  33743. /**
  33744. * Defines the camera the input is attached to.
  33745. */
  33746. camera: ArcRotateCamera;
  33747. /**
  33748. * Defines the buttons associated with the input to handle camera move.
  33749. */
  33750. buttons: number[];
  33751. /**
  33752. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  33753. */
  33754. angularSensibilityX: number;
  33755. /**
  33756. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  33757. */
  33758. angularSensibilityY: number;
  33759. /**
  33760. * Defines the pointer pinch precision or how fast is the camera zooming.
  33761. */
  33762. pinchPrecision: number;
  33763. /**
  33764. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  33765. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  33766. */
  33767. pinchDeltaPercentage: number;
  33768. /**
  33769. * Defines the pointer panning sensibility or how fast is the camera moving.
  33770. */
  33771. panningSensibility: number;
  33772. /**
  33773. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  33774. */
  33775. multiTouchPanning: boolean;
  33776. /**
  33777. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  33778. */
  33779. multiTouchPanAndZoom: boolean;
  33780. /**
  33781. * Revers pinch action direction.
  33782. */
  33783. pinchInwards: boolean;
  33784. private _isPanClick;
  33785. private _pointerInput;
  33786. private _observer;
  33787. private _onMouseMove;
  33788. private _onGestureStart;
  33789. private _onGesture;
  33790. private _MSGestureHandler;
  33791. private _onLostFocus;
  33792. private _onContextMenu;
  33793. /**
  33794. * Attach the input controls to a specific dom element to get the input from.
  33795. * @param element Defines the element the controls should be listened from
  33796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33797. */
  33798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33799. /**
  33800. * Detach the current controls from the specified dom element.
  33801. * @param element Defines the element to stop listening the inputs from
  33802. */
  33803. detachControl(element: Nullable<HTMLElement>): void;
  33804. /**
  33805. * Gets the class name of the current intput.
  33806. * @returns the class name
  33807. */
  33808. getClassName(): string;
  33809. /**
  33810. * Get the friendly name associated with the input class.
  33811. * @returns the input friendly name
  33812. */
  33813. getSimpleName(): string;
  33814. }
  33815. }
  33816. declare module BABYLON {
  33817. /**
  33818. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  33819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33820. */
  33821. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  33822. /**
  33823. * Defines the camera the input is attached to.
  33824. */
  33825. camera: ArcRotateCamera;
  33826. /**
  33827. * Defines the list of key codes associated with the up action (increase alpha)
  33828. */
  33829. keysUp: number[];
  33830. /**
  33831. * Defines the list of key codes associated with the down action (decrease alpha)
  33832. */
  33833. keysDown: number[];
  33834. /**
  33835. * Defines the list of key codes associated with the left action (increase beta)
  33836. */
  33837. keysLeft: number[];
  33838. /**
  33839. * Defines the list of key codes associated with the right action (decrease beta)
  33840. */
  33841. keysRight: number[];
  33842. /**
  33843. * Defines the list of key codes associated with the reset action.
  33844. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  33845. */
  33846. keysReset: number[];
  33847. /**
  33848. * Defines the panning sensibility of the inputs.
  33849. * (How fast is the camera paning)
  33850. */
  33851. panningSensibility: number;
  33852. /**
  33853. * Defines the zooming sensibility of the inputs.
  33854. * (How fast is the camera zooming)
  33855. */
  33856. zoomingSensibility: number;
  33857. /**
  33858. * Defines wether maintaining the alt key down switch the movement mode from
  33859. * orientation to zoom.
  33860. */
  33861. useAltToZoom: boolean;
  33862. /**
  33863. * Rotation speed of the camera
  33864. */
  33865. angularSpeed: number;
  33866. private _keys;
  33867. private _ctrlPressed;
  33868. private _altPressed;
  33869. private _onCanvasBlurObserver;
  33870. private _onKeyboardObserver;
  33871. private _engine;
  33872. private _scene;
  33873. /**
  33874. * Attach the input controls to a specific dom element to get the input from.
  33875. * @param element Defines the element the controls should be listened from
  33876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33877. */
  33878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33879. /**
  33880. * Detach the current controls from the specified dom element.
  33881. * @param element Defines the element to stop listening the inputs from
  33882. */
  33883. detachControl(element: Nullable<HTMLElement>): void;
  33884. /**
  33885. * Update the current camera state depending on the inputs that have been used this frame.
  33886. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  33887. */
  33888. checkInputs(): void;
  33889. /**
  33890. * Gets the class name of the current intput.
  33891. * @returns the class name
  33892. */
  33893. getClassName(): string;
  33894. /**
  33895. * Get the friendly name associated with the input class.
  33896. * @returns the input friendly name
  33897. */
  33898. getSimpleName(): string;
  33899. }
  33900. }
  33901. declare module BABYLON {
  33902. /**
  33903. * Manage the mouse wheel inputs to control an arc rotate camera.
  33904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33905. */
  33906. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  33907. /**
  33908. * Defines the camera the input is attached to.
  33909. */
  33910. camera: ArcRotateCamera;
  33911. /**
  33912. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  33913. */
  33914. wheelPrecision: number;
  33915. /**
  33916. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  33917. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  33918. */
  33919. wheelDeltaPercentage: number;
  33920. private _wheel;
  33921. private _observer;
  33922. /**
  33923. * Attach the input controls to a specific dom element to get the input from.
  33924. * @param element Defines the element the controls should be listened from
  33925. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33926. */
  33927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33928. /**
  33929. * Detach the current controls from the specified dom element.
  33930. * @param element Defines the element to stop listening the inputs from
  33931. */
  33932. detachControl(element: Nullable<HTMLElement>): void;
  33933. /**
  33934. * Gets the class name of the current intput.
  33935. * @returns the class name
  33936. */
  33937. getClassName(): string;
  33938. /**
  33939. * Get the friendly name associated with the input class.
  33940. * @returns the input friendly name
  33941. */
  33942. getSimpleName(): string;
  33943. }
  33944. }
  33945. declare module BABYLON {
  33946. /**
  33947. * Default Inputs manager for the ArcRotateCamera.
  33948. * It groups all the default supported inputs for ease of use.
  33949. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  33950. */
  33951. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  33952. /**
  33953. * Instantiates a new ArcRotateCameraInputsManager.
  33954. * @param camera Defines the camera the inputs belong to
  33955. */
  33956. constructor(camera: ArcRotateCamera);
  33957. /**
  33958. * Add mouse wheel input support to the input manager.
  33959. * @returns the current input manager
  33960. */
  33961. addMouseWheel(): ArcRotateCameraInputsManager;
  33962. /**
  33963. * Add pointers input support to the input manager.
  33964. * @returns the current input manager
  33965. */
  33966. addPointers(): ArcRotateCameraInputsManager;
  33967. /**
  33968. * Add keyboard input support to the input manager.
  33969. * @returns the current input manager
  33970. */
  33971. addKeyboard(): ArcRotateCameraInputsManager;
  33972. }
  33973. }
  33974. declare module BABYLON {
  33975. /**
  33976. * This represents an orbital type of camera.
  33977. *
  33978. * 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.
  33979. * 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.
  33980. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  33981. */
  33982. export class ArcRotateCamera extends TargetCamera {
  33983. /**
  33984. * Defines the rotation angle of the camera along the longitudinal axis.
  33985. */
  33986. alpha: number;
  33987. /**
  33988. * Defines the rotation angle of the camera along the latitudinal axis.
  33989. */
  33990. beta: number;
  33991. /**
  33992. * Defines the radius of the camera from it s target point.
  33993. */
  33994. radius: number;
  33995. protected _target: Vector3;
  33996. protected _targetHost: Nullable<AbstractMesh>;
  33997. /**
  33998. * Defines the target point of the camera.
  33999. * The camera looks towards it form the radius distance.
  34000. */
  34001. target: Vector3;
  34002. /**
  34003. * Current inertia value on the longitudinal axis.
  34004. * The bigger this number the longer it will take for the camera to stop.
  34005. */
  34006. inertialAlphaOffset: number;
  34007. /**
  34008. * Current inertia value on the latitudinal axis.
  34009. * The bigger this number the longer it will take for the camera to stop.
  34010. */
  34011. inertialBetaOffset: number;
  34012. /**
  34013. * Current inertia value on the radius axis.
  34014. * The bigger this number the longer it will take for the camera to stop.
  34015. */
  34016. inertialRadiusOffset: number;
  34017. /**
  34018. * Minimum allowed angle on the longitudinal axis.
  34019. * This can help limiting how the Camera is able to move in the scene.
  34020. */
  34021. lowerAlphaLimit: Nullable<number>;
  34022. /**
  34023. * Maximum allowed angle on the longitudinal axis.
  34024. * This can help limiting how the Camera is able to move in the scene.
  34025. */
  34026. upperAlphaLimit: Nullable<number>;
  34027. /**
  34028. * Minimum allowed angle on the latitudinal axis.
  34029. * This can help limiting how the Camera is able to move in the scene.
  34030. */
  34031. lowerBetaLimit: number;
  34032. /**
  34033. * Maximum allowed angle on the latitudinal axis.
  34034. * This can help limiting how the Camera is able to move in the scene.
  34035. */
  34036. upperBetaLimit: number;
  34037. /**
  34038. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34039. * This can help limiting how the Camera is able to move in the scene.
  34040. */
  34041. lowerRadiusLimit: Nullable<number>;
  34042. /**
  34043. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34044. * This can help limiting how the Camera is able to move in the scene.
  34045. */
  34046. upperRadiusLimit: Nullable<number>;
  34047. /**
  34048. * Defines the current inertia value used during panning of the camera along the X axis.
  34049. */
  34050. inertialPanningX: number;
  34051. /**
  34052. * Defines the current inertia value used during panning of the camera along the Y axis.
  34053. */
  34054. inertialPanningY: number;
  34055. /**
  34056. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34057. * Basically if your fingers moves away from more than this distance you will be considered
  34058. * in pinch mode.
  34059. */
  34060. pinchToPanMaxDistance: number;
  34061. /**
  34062. * Defines the maximum distance the camera can pan.
  34063. * This could help keeping the cammera always in your scene.
  34064. */
  34065. panningDistanceLimit: Nullable<number>;
  34066. /**
  34067. * Defines the target of the camera before paning.
  34068. */
  34069. panningOriginTarget: Vector3;
  34070. /**
  34071. * Defines the value of the inertia used during panning.
  34072. * 0 would mean stop inertia and one would mean no decelleration at all.
  34073. */
  34074. panningInertia: number;
  34075. /**
  34076. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34077. */
  34078. angularSensibilityX: number;
  34079. /**
  34080. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34081. */
  34082. angularSensibilityY: number;
  34083. /**
  34084. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34085. */
  34086. pinchPrecision: number;
  34087. /**
  34088. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34089. * It will be used instead of pinchDeltaPrecision if different from 0.
  34090. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34091. */
  34092. pinchDeltaPercentage: number;
  34093. /**
  34094. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34095. */
  34096. panningSensibility: number;
  34097. /**
  34098. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34099. */
  34100. keysUp: number[];
  34101. /**
  34102. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34103. */
  34104. keysDown: number[];
  34105. /**
  34106. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34107. */
  34108. keysLeft: number[];
  34109. /**
  34110. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34111. */
  34112. keysRight: number[];
  34113. /**
  34114. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34115. */
  34116. wheelPrecision: number;
  34117. /**
  34118. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34119. * It will be used instead of pinchDeltaPrecision if different from 0.
  34120. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34121. */
  34122. wheelDeltaPercentage: number;
  34123. /**
  34124. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34125. */
  34126. zoomOnFactor: number;
  34127. /**
  34128. * Defines a screen offset for the camera position.
  34129. */
  34130. targetScreenOffset: Vector2;
  34131. /**
  34132. * Allows the camera to be completely reversed.
  34133. * If false the camera can not arrive upside down.
  34134. */
  34135. allowUpsideDown: boolean;
  34136. /**
  34137. * Define if double tap/click is used to restore the previously saved state of the camera.
  34138. */
  34139. useInputToRestoreState: boolean;
  34140. /** @hidden */
  34141. _viewMatrix: Matrix;
  34142. /** @hidden */
  34143. _useCtrlForPanning: boolean;
  34144. /** @hidden */
  34145. _panningMouseButton: number;
  34146. /**
  34147. * Defines the input associated to the camera.
  34148. */
  34149. inputs: ArcRotateCameraInputsManager;
  34150. /** @hidden */
  34151. _reset: () => void;
  34152. /**
  34153. * Defines the allowed panning axis.
  34154. */
  34155. panningAxis: Vector3;
  34156. protected _localDirection: Vector3;
  34157. protected _transformedDirection: Vector3;
  34158. private _bouncingBehavior;
  34159. /**
  34160. * Gets the bouncing behavior of the camera if it has been enabled.
  34161. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34162. */
  34163. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34164. /**
  34165. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34166. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34167. */
  34168. useBouncingBehavior: boolean;
  34169. private _framingBehavior;
  34170. /**
  34171. * Gets the framing behavior of the camera if it has been enabled.
  34172. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34173. */
  34174. readonly framingBehavior: Nullable<FramingBehavior>;
  34175. /**
  34176. * Defines if the framing behavior of the camera is enabled on the camera.
  34177. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34178. */
  34179. useFramingBehavior: boolean;
  34180. private _autoRotationBehavior;
  34181. /**
  34182. * Gets the auto rotation behavior of the camera if it has been enabled.
  34183. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34184. */
  34185. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34186. /**
  34187. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34188. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34189. */
  34190. useAutoRotationBehavior: boolean;
  34191. /**
  34192. * Observable triggered when the mesh target has been changed on the camera.
  34193. */
  34194. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34195. /**
  34196. * Event raised when the camera is colliding with a mesh.
  34197. */
  34198. onCollide: (collidedMesh: AbstractMesh) => void;
  34199. /**
  34200. * Defines whether the camera should check collision with the objects oh the scene.
  34201. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34202. */
  34203. checkCollisions: boolean;
  34204. /**
  34205. * Defines the collision radius of the camera.
  34206. * This simulates a sphere around the camera.
  34207. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34208. */
  34209. collisionRadius: Vector3;
  34210. protected _collider: Collider;
  34211. protected _previousPosition: Vector3;
  34212. protected _collisionVelocity: Vector3;
  34213. protected _newPosition: Vector3;
  34214. protected _previousAlpha: number;
  34215. protected _previousBeta: number;
  34216. protected _previousRadius: number;
  34217. protected _collisionTriggered: boolean;
  34218. protected _targetBoundingCenter: Nullable<Vector3>;
  34219. private _computationVector;
  34220. private _tempAxisVector;
  34221. private _tempAxisRotationMatrix;
  34222. /**
  34223. * Instantiates a new ArcRotateCamera in a given scene
  34224. * @param name Defines the name of the camera
  34225. * @param alpha Defines the camera rotation along the logitudinal axis
  34226. * @param beta Defines the camera rotation along the latitudinal axis
  34227. * @param radius Defines the camera distance from its target
  34228. * @param target Defines the camera target
  34229. * @param scene Defines the scene the camera belongs to
  34230. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34231. */
  34232. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34233. /** @hidden */
  34234. _initCache(): void;
  34235. /** @hidden */
  34236. _updateCache(ignoreParentClass?: boolean): void;
  34237. protected _getTargetPosition(): Vector3;
  34238. private _storedAlpha;
  34239. private _storedBeta;
  34240. private _storedRadius;
  34241. private _storedTarget;
  34242. /**
  34243. * Stores the current state of the camera (alpha, beta, radius and target)
  34244. * @returns the camera itself
  34245. */
  34246. storeState(): Camera;
  34247. /**
  34248. * @hidden
  34249. * Restored camera state. You must call storeState() first
  34250. */
  34251. _restoreStateValues(): boolean;
  34252. /** @hidden */
  34253. _isSynchronizedViewMatrix(): boolean;
  34254. /**
  34255. * Attached controls to the current camera.
  34256. * @param element Defines the element the controls should be listened from
  34257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34258. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34259. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34260. */
  34261. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34262. /**
  34263. * Detach the current controls from the camera.
  34264. * The camera will stop reacting to inputs.
  34265. * @param element Defines the element to stop listening the inputs from
  34266. */
  34267. detachControl(element: HTMLElement): void;
  34268. /** @hidden */
  34269. _checkInputs(): void;
  34270. protected _checkLimits(): void;
  34271. /**
  34272. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  34273. */
  34274. rebuildAnglesAndRadius(): void;
  34275. /**
  34276. * Use a position to define the current camera related information like aplha, beta and radius
  34277. * @param position Defines the position to set the camera at
  34278. */
  34279. setPosition(position: Vector3): void;
  34280. /**
  34281. * Defines the target the camera should look at.
  34282. * This will automatically adapt alpha beta and radius to fit within the new target.
  34283. * @param target Defines the new target as a Vector or a mesh
  34284. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34285. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34286. */
  34287. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34288. /** @hidden */
  34289. _getViewMatrix(): Matrix;
  34290. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34291. /**
  34292. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34293. * @param meshes Defines the mesh to zoom on
  34294. * @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)
  34295. */
  34296. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34297. /**
  34298. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34299. * The target will be changed but the radius
  34300. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34301. * @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)
  34302. */
  34303. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34304. min: Vector3;
  34305. max: Vector3;
  34306. distance: number;
  34307. }, doNotUpdateMaxZ?: boolean): void;
  34308. /**
  34309. * @override
  34310. * Override Camera.createRigCamera
  34311. */
  34312. createRigCamera(name: string, cameraIndex: number): Camera;
  34313. /**
  34314. * @hidden
  34315. * @override
  34316. * Override Camera._updateRigCameras
  34317. */
  34318. _updateRigCameras(): void;
  34319. /**
  34320. * Destroy the camera and release the current resources hold by it.
  34321. */
  34322. dispose(): void;
  34323. /**
  34324. * Gets the current object class name.
  34325. * @return the class name
  34326. */
  34327. getClassName(): string;
  34328. }
  34329. }
  34330. declare module BABYLON {
  34331. /**
  34332. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34333. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34334. */
  34335. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34336. /**
  34337. * Gets the name of the behavior.
  34338. */
  34339. readonly name: string;
  34340. private _zoomStopsAnimation;
  34341. private _idleRotationSpeed;
  34342. private _idleRotationWaitTime;
  34343. private _idleRotationSpinupTime;
  34344. /**
  34345. * Sets the flag that indicates if user zooming should stop animation.
  34346. */
  34347. /**
  34348. * Gets the flag that indicates if user zooming should stop animation.
  34349. */
  34350. zoomStopsAnimation: boolean;
  34351. /**
  34352. * Sets the default speed at which the camera rotates around the model.
  34353. */
  34354. /**
  34355. * Gets the default speed at which the camera rotates around the model.
  34356. */
  34357. idleRotationSpeed: number;
  34358. /**
  34359. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34360. */
  34361. /**
  34362. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34363. */
  34364. idleRotationWaitTime: number;
  34365. /**
  34366. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34367. */
  34368. /**
  34369. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34370. */
  34371. idleRotationSpinupTime: number;
  34372. /**
  34373. * Gets a value indicating if the camera is currently rotating because of this behavior
  34374. */
  34375. readonly rotationInProgress: boolean;
  34376. private _onPrePointerObservableObserver;
  34377. private _onAfterCheckInputsObserver;
  34378. private _attachedCamera;
  34379. private _isPointerDown;
  34380. private _lastFrameTime;
  34381. private _lastInteractionTime;
  34382. private _cameraRotationSpeed;
  34383. /**
  34384. * Initializes the behavior.
  34385. */
  34386. init(): void;
  34387. /**
  34388. * Attaches the behavior to its arc rotate camera.
  34389. * @param camera Defines the camera to attach the behavior to
  34390. */
  34391. attach(camera: ArcRotateCamera): void;
  34392. /**
  34393. * Detaches the behavior from its current arc rotate camera.
  34394. */
  34395. detach(): void;
  34396. /**
  34397. * Returns true if user is scrolling.
  34398. * @return true if user is scrolling.
  34399. */
  34400. private _userIsZooming;
  34401. private _lastFrameRadius;
  34402. private _shouldAnimationStopForInteraction;
  34403. /**
  34404. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34405. */
  34406. private _applyUserInteraction;
  34407. private _userIsMoving;
  34408. }
  34409. }
  34410. declare module BABYLON {
  34411. /**
  34412. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34413. */
  34414. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34415. private ui;
  34416. /**
  34417. * The name of the behavior
  34418. */
  34419. name: string;
  34420. /**
  34421. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34422. */
  34423. distanceAwayFromFace: number;
  34424. /**
  34425. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34426. */
  34427. distanceAwayFromBottomOfFace: number;
  34428. private _faceVectors;
  34429. private _target;
  34430. private _scene;
  34431. private _onRenderObserver;
  34432. private _tmpMatrix;
  34433. private _tmpVector;
  34434. /**
  34435. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34436. * @param ui The transform node that should be attched to the mesh
  34437. */
  34438. constructor(ui: TransformNode);
  34439. /**
  34440. * Initializes the behavior
  34441. */
  34442. init(): void;
  34443. private _closestFace;
  34444. private _zeroVector;
  34445. private _lookAtTmpMatrix;
  34446. private _lookAtToRef;
  34447. /**
  34448. * Attaches the AttachToBoxBehavior to the passed in mesh
  34449. * @param target The mesh that the specified node will be attached to
  34450. */
  34451. attach(target: Mesh): void;
  34452. /**
  34453. * Detaches the behavior from the mesh
  34454. */
  34455. detach(): void;
  34456. }
  34457. }
  34458. declare module BABYLON {
  34459. /**
  34460. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34461. */
  34462. export class FadeInOutBehavior implements Behavior<Mesh> {
  34463. /**
  34464. * Time in milliseconds to delay before fading in (Default: 0)
  34465. */
  34466. delay: number;
  34467. /**
  34468. * Time in milliseconds for the mesh to fade in (Default: 300)
  34469. */
  34470. fadeInTime: number;
  34471. private _millisecondsPerFrame;
  34472. private _hovered;
  34473. private _hoverValue;
  34474. private _ownerNode;
  34475. /**
  34476. * Instatiates the FadeInOutBehavior
  34477. */
  34478. constructor();
  34479. /**
  34480. * The name of the behavior
  34481. */
  34482. readonly name: string;
  34483. /**
  34484. * Initializes the behavior
  34485. */
  34486. init(): void;
  34487. /**
  34488. * Attaches the fade behavior on the passed in mesh
  34489. * @param ownerNode The mesh that will be faded in/out once attached
  34490. */
  34491. attach(ownerNode: Mesh): void;
  34492. /**
  34493. * Detaches the behavior from the mesh
  34494. */
  34495. detach(): void;
  34496. /**
  34497. * Triggers the mesh to begin fading in or out
  34498. * @param value if the object should fade in or out (true to fade in)
  34499. */
  34500. fadeIn(value: boolean): void;
  34501. private _update;
  34502. private _setAllVisibility;
  34503. }
  34504. }
  34505. declare module BABYLON {
  34506. /**
  34507. * Class containing a set of static utilities functions for managing Pivots
  34508. * @hidden
  34509. */
  34510. export class PivotTools {
  34511. private static _PivotCached;
  34512. private static _OldPivotPoint;
  34513. private static _PivotTranslation;
  34514. private static _PivotTmpVector;
  34515. /** @hidden */
  34516. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34517. /** @hidden */
  34518. static _RestorePivotPoint(mesh: AbstractMesh): void;
  34519. }
  34520. }
  34521. declare module BABYLON {
  34522. /**
  34523. * Class containing static functions to help procedurally build meshes
  34524. */
  34525. export class PlaneBuilder {
  34526. /**
  34527. * Creates a plane mesh
  34528. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34529. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34530. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34532. * * 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
  34533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34534. * @param name defines the name of the mesh
  34535. * @param options defines the options used to create the mesh
  34536. * @param scene defines the hosting scene
  34537. * @returns the plane mesh
  34538. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34539. */
  34540. static CreatePlane(name: string, options: {
  34541. size?: number;
  34542. width?: number;
  34543. height?: number;
  34544. sideOrientation?: number;
  34545. frontUVs?: Vector4;
  34546. backUVs?: Vector4;
  34547. updatable?: boolean;
  34548. sourcePlane?: Plane;
  34549. }, scene: Scene): Mesh;
  34550. }
  34551. }
  34552. declare module BABYLON {
  34553. /**
  34554. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34555. */
  34556. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34557. private static _AnyMouseID;
  34558. private _attachedNode;
  34559. private _dragPlane;
  34560. private _scene;
  34561. private _pointerObserver;
  34562. private _beforeRenderObserver;
  34563. private static _planeScene;
  34564. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34565. /**
  34566. * 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)
  34567. */
  34568. maxDragAngle: number;
  34569. /**
  34570. * @hidden
  34571. */
  34572. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  34573. /**
  34574. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34575. */
  34576. currentDraggingPointerID: number;
  34577. /**
  34578. * The last position where the pointer hit the drag plane in world space
  34579. */
  34580. lastDragPosition: Vector3;
  34581. /**
  34582. * If the behavior is currently in a dragging state
  34583. */
  34584. dragging: boolean;
  34585. /**
  34586. * 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)
  34587. */
  34588. dragDeltaRatio: number;
  34589. /**
  34590. * If the drag plane orientation should be updated during the dragging (Default: true)
  34591. */
  34592. updateDragPlane: boolean;
  34593. private _debugMode;
  34594. private _moving;
  34595. /**
  34596. * Fires each time the attached mesh is dragged with the pointer
  34597. * * delta between last drag position and current drag position in world space
  34598. * * dragDistance along the drag axis
  34599. * * dragPlaneNormal normal of the current drag plane used during the drag
  34600. * * dragPlanePoint in world space where the drag intersects the drag plane
  34601. */
  34602. onDragObservable: Observable<{
  34603. delta: Vector3;
  34604. dragPlanePoint: Vector3;
  34605. dragPlaneNormal: Vector3;
  34606. dragDistance: number;
  34607. pointerId: number;
  34608. }>;
  34609. /**
  34610. * Fires each time a drag begins (eg. mouse down on mesh)
  34611. */
  34612. onDragStartObservable: Observable<{
  34613. dragPlanePoint: Vector3;
  34614. pointerId: number;
  34615. }>;
  34616. /**
  34617. * Fires each time a drag ends (eg. mouse release after drag)
  34618. */
  34619. onDragEndObservable: Observable<{
  34620. dragPlanePoint: Vector3;
  34621. pointerId: number;
  34622. }>;
  34623. /**
  34624. * If the attached mesh should be moved when dragged
  34625. */
  34626. moveAttached: boolean;
  34627. /**
  34628. * If the drag behavior will react to drag events (Default: true)
  34629. */
  34630. enabled: boolean;
  34631. /**
  34632. * If camera controls should be detached during the drag
  34633. */
  34634. detachCameraControls: boolean;
  34635. /**
  34636. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34637. */
  34638. useObjectOrienationForDragging: boolean;
  34639. private _options;
  34640. /**
  34641. * Creates a pointer drag behavior that can be attached to a mesh
  34642. * @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)
  34643. */
  34644. constructor(options?: {
  34645. dragAxis?: Vector3;
  34646. dragPlaneNormal?: Vector3;
  34647. });
  34648. /**
  34649. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34650. */
  34651. validateDrag: (targetPosition: Vector3) => boolean;
  34652. /**
  34653. * The name of the behavior
  34654. */
  34655. readonly name: string;
  34656. /**
  34657. * Initializes the behavior
  34658. */
  34659. init(): void;
  34660. private _tmpVector;
  34661. private _alternatePickedPoint;
  34662. private _worldDragAxis;
  34663. private _targetPosition;
  34664. private _attachedElement;
  34665. /**
  34666. * Attaches the drag behavior the passed in mesh
  34667. * @param ownerNode The mesh that will be dragged around once attached
  34668. */
  34669. attach(ownerNode: AbstractMesh): void;
  34670. /**
  34671. * Force relase the drag action by code.
  34672. */
  34673. releaseDrag(): void;
  34674. private _startDragRay;
  34675. private _lastPointerRay;
  34676. /**
  34677. * Simulates the start of a pointer drag event on the behavior
  34678. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34679. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34680. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34681. */
  34682. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34683. private _startDrag;
  34684. private _dragDelta;
  34685. private _moveDrag;
  34686. private _pickWithRayOnDragPlane;
  34687. private _pointA;
  34688. private _pointB;
  34689. private _pointC;
  34690. private _lineA;
  34691. private _lineB;
  34692. private _localAxis;
  34693. private _lookAt;
  34694. private _updateDragPlanePosition;
  34695. /**
  34696. * Detaches the behavior from the mesh
  34697. */
  34698. detach(): void;
  34699. }
  34700. }
  34701. declare module BABYLON {
  34702. /**
  34703. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34704. */
  34705. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34706. private _dragBehaviorA;
  34707. private _dragBehaviorB;
  34708. private _startDistance;
  34709. private _initialScale;
  34710. private _targetScale;
  34711. private _ownerNode;
  34712. private _sceneRenderObserver;
  34713. /**
  34714. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  34715. */
  34716. constructor();
  34717. /**
  34718. * The name of the behavior
  34719. */
  34720. readonly name: string;
  34721. /**
  34722. * Initializes the behavior
  34723. */
  34724. init(): void;
  34725. private _getCurrentDistance;
  34726. /**
  34727. * Attaches the scale behavior the passed in mesh
  34728. * @param ownerNode The mesh that will be scaled around once attached
  34729. */
  34730. attach(ownerNode: Mesh): void;
  34731. /**
  34732. * Detaches the behavior from the mesh
  34733. */
  34734. detach(): void;
  34735. }
  34736. }
  34737. declare module BABYLON {
  34738. /**
  34739. * 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
  34740. */
  34741. export class SixDofDragBehavior implements Behavior<Mesh> {
  34742. private static _virtualScene;
  34743. private _ownerNode;
  34744. private _sceneRenderObserver;
  34745. private _scene;
  34746. private _targetPosition;
  34747. private _virtualOriginMesh;
  34748. private _virtualDragMesh;
  34749. private _pointerObserver;
  34750. private _moving;
  34751. private _startingOrientation;
  34752. /**
  34753. * 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)
  34754. */
  34755. private zDragFactor;
  34756. /**
  34757. * If the object should rotate to face the drag origin
  34758. */
  34759. rotateDraggedObject: boolean;
  34760. /**
  34761. * If the behavior is currently in a dragging state
  34762. */
  34763. dragging: boolean;
  34764. /**
  34765. * 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)
  34766. */
  34767. dragDeltaRatio: number;
  34768. /**
  34769. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34770. */
  34771. currentDraggingPointerID: number;
  34772. /**
  34773. * If camera controls should be detached during the drag
  34774. */
  34775. detachCameraControls: boolean;
  34776. /**
  34777. * Fires each time a drag starts
  34778. */
  34779. onDragStartObservable: Observable<{}>;
  34780. /**
  34781. * Fires each time a drag ends (eg. mouse release after drag)
  34782. */
  34783. onDragEndObservable: Observable<{}>;
  34784. /**
  34785. * 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
  34786. */
  34787. constructor();
  34788. /**
  34789. * The name of the behavior
  34790. */
  34791. readonly name: string;
  34792. /**
  34793. * Initializes the behavior
  34794. */
  34795. init(): void;
  34796. /**
  34797. * Attaches the scale behavior the passed in mesh
  34798. * @param ownerNode The mesh that will be scaled around once attached
  34799. */
  34800. attach(ownerNode: Mesh): void;
  34801. /**
  34802. * Detaches the behavior from the mesh
  34803. */
  34804. detach(): void;
  34805. }
  34806. }
  34807. declare module BABYLON {
  34808. /**
  34809. * Class used to apply inverse kinematics to bones
  34810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  34811. */
  34812. export class BoneIKController {
  34813. private static _tmpVecs;
  34814. private static _tmpQuat;
  34815. private static _tmpMats;
  34816. /**
  34817. * Gets or sets the target mesh
  34818. */
  34819. targetMesh: AbstractMesh;
  34820. /** Gets or sets the mesh used as pole */
  34821. poleTargetMesh: AbstractMesh;
  34822. /**
  34823. * Gets or sets the bone used as pole
  34824. */
  34825. poleTargetBone: Nullable<Bone>;
  34826. /**
  34827. * Gets or sets the target position
  34828. */
  34829. targetPosition: Vector3;
  34830. /**
  34831. * Gets or sets the pole target position
  34832. */
  34833. poleTargetPosition: Vector3;
  34834. /**
  34835. * Gets or sets the pole target local offset
  34836. */
  34837. poleTargetLocalOffset: Vector3;
  34838. /**
  34839. * Gets or sets the pole angle
  34840. */
  34841. poleAngle: number;
  34842. /**
  34843. * Gets or sets the mesh associated with the controller
  34844. */
  34845. mesh: AbstractMesh;
  34846. /**
  34847. * 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)
  34848. */
  34849. slerpAmount: number;
  34850. private _bone1Quat;
  34851. private _bone1Mat;
  34852. private _bone2Ang;
  34853. private _bone1;
  34854. private _bone2;
  34855. private _bone1Length;
  34856. private _bone2Length;
  34857. private _maxAngle;
  34858. private _maxReach;
  34859. private _rightHandedSystem;
  34860. private _bendAxis;
  34861. private _slerping;
  34862. private _adjustRoll;
  34863. /**
  34864. * Gets or sets maximum allowed angle
  34865. */
  34866. maxAngle: number;
  34867. /**
  34868. * Creates a new BoneIKController
  34869. * @param mesh defines the mesh to control
  34870. * @param bone defines the bone to control
  34871. * @param options defines options to set up the controller
  34872. */
  34873. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  34874. targetMesh?: AbstractMesh;
  34875. poleTargetMesh?: AbstractMesh;
  34876. poleTargetBone?: Bone;
  34877. poleTargetLocalOffset?: Vector3;
  34878. poleAngle?: number;
  34879. bendAxis?: Vector3;
  34880. maxAngle?: number;
  34881. slerpAmount?: number;
  34882. });
  34883. private _setMaxAngle;
  34884. /**
  34885. * Force the controller to update the bones
  34886. */
  34887. update(): void;
  34888. }
  34889. }
  34890. declare module BABYLON {
  34891. /**
  34892. * Class used to make a bone look toward a point in space
  34893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  34894. */
  34895. export class BoneLookController {
  34896. private static _tmpVecs;
  34897. private static _tmpQuat;
  34898. private static _tmpMats;
  34899. /**
  34900. * The target Vector3 that the bone will look at
  34901. */
  34902. target: Vector3;
  34903. /**
  34904. * The mesh that the bone is attached to
  34905. */
  34906. mesh: AbstractMesh;
  34907. /**
  34908. * The bone that will be looking to the target
  34909. */
  34910. bone: Bone;
  34911. /**
  34912. * The up axis of the coordinate system that is used when the bone is rotated
  34913. */
  34914. upAxis: Vector3;
  34915. /**
  34916. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  34917. */
  34918. upAxisSpace: Space;
  34919. /**
  34920. * Used to make an adjustment to the yaw of the bone
  34921. */
  34922. adjustYaw: number;
  34923. /**
  34924. * Used to make an adjustment to the pitch of the bone
  34925. */
  34926. adjustPitch: number;
  34927. /**
  34928. * Used to make an adjustment to the roll of the bone
  34929. */
  34930. adjustRoll: number;
  34931. /**
  34932. * 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)
  34933. */
  34934. slerpAmount: number;
  34935. private _minYaw;
  34936. private _maxYaw;
  34937. private _minPitch;
  34938. private _maxPitch;
  34939. private _minYawSin;
  34940. private _minYawCos;
  34941. private _maxYawSin;
  34942. private _maxYawCos;
  34943. private _midYawConstraint;
  34944. private _minPitchTan;
  34945. private _maxPitchTan;
  34946. private _boneQuat;
  34947. private _slerping;
  34948. private _transformYawPitch;
  34949. private _transformYawPitchInv;
  34950. private _firstFrameSkipped;
  34951. private _yawRange;
  34952. private _fowardAxis;
  34953. /**
  34954. * Gets or sets the minimum yaw angle that the bone can look to
  34955. */
  34956. minYaw: number;
  34957. /**
  34958. * Gets or sets the maximum yaw angle that the bone can look to
  34959. */
  34960. maxYaw: number;
  34961. /**
  34962. * Gets or sets the minimum pitch angle that the bone can look to
  34963. */
  34964. minPitch: number;
  34965. /**
  34966. * Gets or sets the maximum pitch angle that the bone can look to
  34967. */
  34968. maxPitch: number;
  34969. /**
  34970. * Create a BoneLookController
  34971. * @param mesh the mesh that the bone belongs to
  34972. * @param bone the bone that will be looking to the target
  34973. * @param target the target Vector3 to look at
  34974. * @param options optional settings:
  34975. * * maxYaw: the maximum angle the bone will yaw to
  34976. * * minYaw: the minimum angle the bone will yaw to
  34977. * * maxPitch: the maximum angle the bone will pitch to
  34978. * * minPitch: the minimum angle the bone will yaw to
  34979. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  34980. * * upAxis: the up axis of the coordinate system
  34981. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  34982. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  34983. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  34984. * * adjustYaw: used to make an adjustment to the yaw of the bone
  34985. * * adjustPitch: used to make an adjustment to the pitch of the bone
  34986. * * adjustRoll: used to make an adjustment to the roll of the bone
  34987. **/
  34988. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  34989. maxYaw?: number;
  34990. minYaw?: number;
  34991. maxPitch?: number;
  34992. minPitch?: number;
  34993. slerpAmount?: number;
  34994. upAxis?: Vector3;
  34995. upAxisSpace?: Space;
  34996. yawAxis?: Vector3;
  34997. pitchAxis?: Vector3;
  34998. adjustYaw?: number;
  34999. adjustPitch?: number;
  35000. adjustRoll?: number;
  35001. });
  35002. /**
  35003. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35004. */
  35005. update(): void;
  35006. private _getAngleDiff;
  35007. private _getAngleBetween;
  35008. private _isAngleBetween;
  35009. }
  35010. }
  35011. declare module BABYLON {
  35012. /**
  35013. * Manage the gamepad inputs to control an arc rotate camera.
  35014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35015. */
  35016. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35017. /**
  35018. * Defines the camera the input is attached to.
  35019. */
  35020. camera: ArcRotateCamera;
  35021. /**
  35022. * Defines the gamepad the input is gathering event from.
  35023. */
  35024. gamepad: Nullable<Gamepad>;
  35025. /**
  35026. * Defines the gamepad rotation sensiblity.
  35027. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35028. */
  35029. gamepadRotationSensibility: number;
  35030. /**
  35031. * Defines the gamepad move sensiblity.
  35032. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35033. */
  35034. gamepadMoveSensibility: number;
  35035. private _onGamepadConnectedObserver;
  35036. private _onGamepadDisconnectedObserver;
  35037. /**
  35038. * Attach the input controls to a specific dom element to get the input from.
  35039. * @param element Defines the element the controls should be listened from
  35040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35041. */
  35042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35043. /**
  35044. * Detach the current controls from the specified dom element.
  35045. * @param element Defines the element to stop listening the inputs from
  35046. */
  35047. detachControl(element: Nullable<HTMLElement>): void;
  35048. /**
  35049. * Update the current camera state depending on the inputs that have been used this frame.
  35050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35051. */
  35052. checkInputs(): void;
  35053. /**
  35054. * Gets the class name of the current intput.
  35055. * @returns the class name
  35056. */
  35057. getClassName(): string;
  35058. /**
  35059. * Get the friendly name associated with the input class.
  35060. * @returns the input friendly name
  35061. */
  35062. getSimpleName(): string;
  35063. }
  35064. }
  35065. declare module BABYLON {
  35066. interface ArcRotateCameraInputsManager {
  35067. /**
  35068. * Add orientation input support to the input manager.
  35069. * @returns the current input manager
  35070. */
  35071. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35072. }
  35073. /**
  35074. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35076. */
  35077. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35078. /**
  35079. * Defines the camera the input is attached to.
  35080. */
  35081. camera: ArcRotateCamera;
  35082. /**
  35083. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35084. */
  35085. alphaCorrection: number;
  35086. /**
  35087. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35088. */
  35089. gammaCorrection: number;
  35090. private _alpha;
  35091. private _gamma;
  35092. private _dirty;
  35093. private _deviceOrientationHandler;
  35094. /**
  35095. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35096. */
  35097. constructor();
  35098. /**
  35099. * Attach the input controls to a specific dom element to get the input from.
  35100. * @param element Defines the element the controls should be listened from
  35101. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35102. */
  35103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35104. /** @hidden */
  35105. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35106. /**
  35107. * Update the current camera state depending on the inputs that have been used this frame.
  35108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35109. */
  35110. checkInputs(): void;
  35111. /**
  35112. * Detach the current controls from the specified dom element.
  35113. * @param element Defines the element to stop listening the inputs from
  35114. */
  35115. detachControl(element: Nullable<HTMLElement>): void;
  35116. /**
  35117. * Gets the class name of the current intput.
  35118. * @returns the class name
  35119. */
  35120. getClassName(): string;
  35121. /**
  35122. * Get the friendly name associated with the input class.
  35123. * @returns the input friendly name
  35124. */
  35125. getSimpleName(): string;
  35126. }
  35127. }
  35128. declare module BABYLON {
  35129. /**
  35130. * Listen to mouse events to control the camera.
  35131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35132. */
  35133. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35134. /**
  35135. * Defines the camera the input is attached to.
  35136. */
  35137. camera: FlyCamera;
  35138. /**
  35139. * Defines if touch is enabled. (Default is true.)
  35140. */
  35141. touchEnabled: boolean;
  35142. /**
  35143. * Defines the buttons associated with the input to handle camera rotation.
  35144. */
  35145. buttons: number[];
  35146. /**
  35147. * Assign buttons for Yaw control.
  35148. */
  35149. buttonsYaw: number[];
  35150. /**
  35151. * Assign buttons for Pitch control.
  35152. */
  35153. buttonsPitch: number[];
  35154. /**
  35155. * Assign buttons for Roll control.
  35156. */
  35157. buttonsRoll: number[];
  35158. /**
  35159. * Detect if any button is being pressed while mouse is moved.
  35160. * -1 = Mouse locked.
  35161. * 0 = Left button.
  35162. * 1 = Middle Button.
  35163. * 2 = Right Button.
  35164. */
  35165. activeButton: number;
  35166. /**
  35167. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35168. * Higher values reduce its sensitivity.
  35169. */
  35170. angularSensibility: number;
  35171. private _mousemoveCallback;
  35172. private _observer;
  35173. private _rollObserver;
  35174. private previousPosition;
  35175. private noPreventDefault;
  35176. private element;
  35177. /**
  35178. * Listen to mouse events to control the camera.
  35179. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35181. */
  35182. constructor(touchEnabled?: boolean);
  35183. /**
  35184. * Attach the mouse control to the HTML DOM element.
  35185. * @param element Defines the element that listens to the input events.
  35186. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35187. */
  35188. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35189. /**
  35190. * Detach the current controls from the specified dom element.
  35191. * @param element Defines the element to stop listening the inputs from
  35192. */
  35193. detachControl(element: Nullable<HTMLElement>): void;
  35194. /**
  35195. * Gets the class name of the current input.
  35196. * @returns the class name.
  35197. */
  35198. getClassName(): string;
  35199. /**
  35200. * Get the friendly name associated with the input class.
  35201. * @returns the input's friendly name.
  35202. */
  35203. getSimpleName(): string;
  35204. private _pointerInput;
  35205. private _onMouseMove;
  35206. /**
  35207. * Rotate camera by mouse offset.
  35208. */
  35209. private rotateCamera;
  35210. }
  35211. }
  35212. declare module BABYLON {
  35213. /**
  35214. * Default Inputs manager for the FlyCamera.
  35215. * It groups all the default supported inputs for ease of use.
  35216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35217. */
  35218. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35219. /**
  35220. * Instantiates a new FlyCameraInputsManager.
  35221. * @param camera Defines the camera the inputs belong to.
  35222. */
  35223. constructor(camera: FlyCamera);
  35224. /**
  35225. * Add keyboard input support to the input manager.
  35226. * @returns the new FlyCameraKeyboardMoveInput().
  35227. */
  35228. addKeyboard(): FlyCameraInputsManager;
  35229. /**
  35230. * Add mouse input support to the input manager.
  35231. * @param touchEnabled Enable touch screen support.
  35232. * @returns the new FlyCameraMouseInput().
  35233. */
  35234. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35235. }
  35236. }
  35237. declare module BABYLON {
  35238. /**
  35239. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35240. * such as in a 3D Space Shooter or a Flight Simulator.
  35241. */
  35242. export class FlyCamera extends TargetCamera {
  35243. /**
  35244. * Define the collision ellipsoid of the camera.
  35245. * This is helpful for simulating a camera body, like a player's body.
  35246. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35247. */
  35248. ellipsoid: Vector3;
  35249. /**
  35250. * Define an offset for the position of the ellipsoid around the camera.
  35251. * This can be helpful if the camera is attached away from the player's body center,
  35252. * such as at its head.
  35253. */
  35254. ellipsoidOffset: Vector3;
  35255. /**
  35256. * Enable or disable collisions of the camera with the rest of the scene objects.
  35257. */
  35258. checkCollisions: boolean;
  35259. /**
  35260. * Enable or disable gravity on the camera.
  35261. */
  35262. applyGravity: boolean;
  35263. /**
  35264. * Define the current direction the camera is moving to.
  35265. */
  35266. cameraDirection: Vector3;
  35267. /**
  35268. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35269. * This overrides and empties cameraRotation.
  35270. */
  35271. rotationQuaternion: Quaternion;
  35272. /**
  35273. * Track Roll to maintain the wanted Rolling when looking around.
  35274. */
  35275. _trackRoll: number;
  35276. /**
  35277. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35278. */
  35279. rollCorrect: number;
  35280. /**
  35281. * Mimic a banked turn, Rolling the camera when Yawing.
  35282. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35283. */
  35284. bankedTurn: boolean;
  35285. /**
  35286. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35287. */
  35288. bankedTurnLimit: number;
  35289. /**
  35290. * Value of 0 disables the banked Roll.
  35291. * Value of 1 is equal to the Yaw angle in radians.
  35292. */
  35293. bankedTurnMultiplier: number;
  35294. /**
  35295. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35296. */
  35297. inputs: FlyCameraInputsManager;
  35298. /**
  35299. * Gets the input sensibility for mouse input.
  35300. * Higher values reduce sensitivity.
  35301. */
  35302. /**
  35303. * Sets the input sensibility for a mouse input.
  35304. * Higher values reduce sensitivity.
  35305. */
  35306. angularSensibility: number;
  35307. /**
  35308. * Get the keys for camera movement forward.
  35309. */
  35310. /**
  35311. * Set the keys for camera movement forward.
  35312. */
  35313. keysForward: number[];
  35314. /**
  35315. * Get the keys for camera movement backward.
  35316. */
  35317. keysBackward: number[];
  35318. /**
  35319. * Get the keys for camera movement up.
  35320. */
  35321. /**
  35322. * Set the keys for camera movement up.
  35323. */
  35324. keysUp: number[];
  35325. /**
  35326. * Get the keys for camera movement down.
  35327. */
  35328. /**
  35329. * Set the keys for camera movement down.
  35330. */
  35331. keysDown: number[];
  35332. /**
  35333. * Get the keys for camera movement left.
  35334. */
  35335. /**
  35336. * Set the keys for camera movement left.
  35337. */
  35338. keysLeft: number[];
  35339. /**
  35340. * Set the keys for camera movement right.
  35341. */
  35342. /**
  35343. * Set the keys for camera movement right.
  35344. */
  35345. keysRight: number[];
  35346. /**
  35347. * Event raised when the camera collides with a mesh in the scene.
  35348. */
  35349. onCollide: (collidedMesh: AbstractMesh) => void;
  35350. private _collider;
  35351. private _needMoveForGravity;
  35352. private _oldPosition;
  35353. private _diffPosition;
  35354. private _newPosition;
  35355. /** @hidden */
  35356. _localDirection: Vector3;
  35357. /** @hidden */
  35358. _transformedDirection: Vector3;
  35359. /**
  35360. * Instantiates a FlyCamera.
  35361. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35362. * such as in a 3D Space Shooter or a Flight Simulator.
  35363. * @param name Define the name of the camera in the scene.
  35364. * @param position Define the starting position of the camera in the scene.
  35365. * @param scene Define the scene the camera belongs to.
  35366. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35367. */
  35368. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35369. /**
  35370. * Attach a control to the HTML DOM element.
  35371. * @param element Defines the element that listens to the input events.
  35372. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35373. */
  35374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35375. /**
  35376. * Detach a control from the HTML DOM element.
  35377. * The camera will stop reacting to that input.
  35378. * @param element Defines the element that listens to the input events.
  35379. */
  35380. detachControl(element: HTMLElement): void;
  35381. private _collisionMask;
  35382. /**
  35383. * Get the mask that the camera ignores in collision events.
  35384. */
  35385. /**
  35386. * Set the mask that the camera ignores in collision events.
  35387. */
  35388. collisionMask: number;
  35389. /** @hidden */
  35390. _collideWithWorld(displacement: Vector3): void;
  35391. /** @hidden */
  35392. private _onCollisionPositionChange;
  35393. /** @hidden */
  35394. _checkInputs(): void;
  35395. /** @hidden */
  35396. _decideIfNeedsToMove(): boolean;
  35397. /** @hidden */
  35398. _updatePosition(): void;
  35399. /**
  35400. * Restore the Roll to its target value at the rate specified.
  35401. * @param rate - Higher means slower restoring.
  35402. * @hidden
  35403. */
  35404. restoreRoll(rate: number): void;
  35405. /**
  35406. * Destroy the camera and release the current resources held by it.
  35407. */
  35408. dispose(): void;
  35409. /**
  35410. * Get the current object class name.
  35411. * @returns the class name.
  35412. */
  35413. getClassName(): string;
  35414. }
  35415. }
  35416. declare module BABYLON {
  35417. /**
  35418. * Listen to keyboard events to control the camera.
  35419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35420. */
  35421. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35422. /**
  35423. * Defines the camera the input is attached to.
  35424. */
  35425. camera: FlyCamera;
  35426. /**
  35427. * The list of keyboard keys used to control the forward move of the camera.
  35428. */
  35429. keysForward: number[];
  35430. /**
  35431. * The list of keyboard keys used to control the backward move of the camera.
  35432. */
  35433. keysBackward: number[];
  35434. /**
  35435. * The list of keyboard keys used to control the forward move of the camera.
  35436. */
  35437. keysUp: number[];
  35438. /**
  35439. * The list of keyboard keys used to control the backward move of the camera.
  35440. */
  35441. keysDown: number[];
  35442. /**
  35443. * The list of keyboard keys used to control the right strafe move of the camera.
  35444. */
  35445. keysRight: number[];
  35446. /**
  35447. * The list of keyboard keys used to control the left strafe move of the camera.
  35448. */
  35449. keysLeft: number[];
  35450. private _keys;
  35451. private _onCanvasBlurObserver;
  35452. private _onKeyboardObserver;
  35453. private _engine;
  35454. private _scene;
  35455. /**
  35456. * Attach the input controls to a specific dom element to get the input from.
  35457. * @param element Defines the element the controls should be listened from
  35458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35459. */
  35460. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35461. /**
  35462. * Detach the current controls from the specified dom element.
  35463. * @param element Defines the element to stop listening the inputs from
  35464. */
  35465. detachControl(element: Nullable<HTMLElement>): void;
  35466. /**
  35467. * Gets the class name of the current intput.
  35468. * @returns the class name
  35469. */
  35470. getClassName(): string;
  35471. /** @hidden */
  35472. _onLostFocus(e: FocusEvent): void;
  35473. /**
  35474. * Get the friendly name associated with the input class.
  35475. * @returns the input friendly name
  35476. */
  35477. getSimpleName(): string;
  35478. /**
  35479. * Update the current camera state depending on the inputs that have been used this frame.
  35480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35481. */
  35482. checkInputs(): void;
  35483. }
  35484. }
  35485. declare module BABYLON {
  35486. interface FreeCameraInputsManager {
  35487. /**
  35488. * Add orientation input support to the input manager.
  35489. * @returns the current input manager
  35490. */
  35491. addDeviceOrientation(): FreeCameraInputsManager;
  35492. }
  35493. /**
  35494. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  35495. * Screen rotation is taken into account.
  35496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35497. */
  35498. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  35499. private _camera;
  35500. private _screenOrientationAngle;
  35501. private _constantTranform;
  35502. private _screenQuaternion;
  35503. private _alpha;
  35504. private _beta;
  35505. private _gamma;
  35506. /**
  35507. * Instantiates a new input
  35508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35509. */
  35510. constructor();
  35511. /**
  35512. * Define the camera controlled by the input.
  35513. */
  35514. camera: FreeCamera;
  35515. /**
  35516. * Attach the input controls to a specific dom element to get the input from.
  35517. * @param element Defines the element the controls should be listened from
  35518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35519. */
  35520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35521. private _orientationChanged;
  35522. private _deviceOrientation;
  35523. /**
  35524. * Detach the current controls from the specified dom element.
  35525. * @param element Defines the element to stop listening the inputs from
  35526. */
  35527. detachControl(element: Nullable<HTMLElement>): void;
  35528. /**
  35529. * Update the current camera state depending on the inputs that have been used this frame.
  35530. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35531. */
  35532. checkInputs(): void;
  35533. /**
  35534. * Gets the class name of the current intput.
  35535. * @returns the class name
  35536. */
  35537. getClassName(): string;
  35538. /**
  35539. * Get the friendly name associated with the input class.
  35540. * @returns the input friendly name
  35541. */
  35542. getSimpleName(): string;
  35543. }
  35544. }
  35545. declare module BABYLON {
  35546. /**
  35547. * Manage the gamepad inputs to control a free camera.
  35548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35549. */
  35550. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  35551. /**
  35552. * Define the camera the input is attached to.
  35553. */
  35554. camera: FreeCamera;
  35555. /**
  35556. * Define the Gamepad controlling the input
  35557. */
  35558. gamepad: Nullable<Gamepad>;
  35559. /**
  35560. * Defines the gamepad rotation sensiblity.
  35561. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35562. */
  35563. gamepadAngularSensibility: number;
  35564. /**
  35565. * Defines the gamepad move sensiblity.
  35566. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35567. */
  35568. gamepadMoveSensibility: number;
  35569. private _onGamepadConnectedObserver;
  35570. private _onGamepadDisconnectedObserver;
  35571. private _cameraTransform;
  35572. private _deltaTransform;
  35573. private _vector3;
  35574. private _vector2;
  35575. /**
  35576. * Attach the input controls to a specific dom element to get the input from.
  35577. * @param element Defines the element the controls should be listened from
  35578. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35579. */
  35580. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35581. /**
  35582. * Detach the current controls from the specified dom element.
  35583. * @param element Defines the element to stop listening the inputs from
  35584. */
  35585. detachControl(element: Nullable<HTMLElement>): void;
  35586. /**
  35587. * Update the current camera state depending on the inputs that have been used this frame.
  35588. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35589. */
  35590. checkInputs(): void;
  35591. /**
  35592. * Gets the class name of the current intput.
  35593. * @returns the class name
  35594. */
  35595. getClassName(): string;
  35596. /**
  35597. * Get the friendly name associated with the input class.
  35598. * @returns the input friendly name
  35599. */
  35600. getSimpleName(): string;
  35601. }
  35602. }
  35603. declare module BABYLON {
  35604. /**
  35605. * Defines the potential axis of a Joystick
  35606. */
  35607. export enum JoystickAxis {
  35608. /** X axis */
  35609. X = 0,
  35610. /** Y axis */
  35611. Y = 1,
  35612. /** Z axis */
  35613. Z = 2
  35614. }
  35615. /**
  35616. * Class used to define virtual joystick (used in touch mode)
  35617. */
  35618. export class VirtualJoystick {
  35619. /**
  35620. * Gets or sets a boolean indicating that left and right values must be inverted
  35621. */
  35622. reverseLeftRight: boolean;
  35623. /**
  35624. * Gets or sets a boolean indicating that up and down values must be inverted
  35625. */
  35626. reverseUpDown: boolean;
  35627. /**
  35628. * Gets the offset value for the position (ie. the change of the position value)
  35629. */
  35630. deltaPosition: Vector3;
  35631. /**
  35632. * Gets a boolean indicating if the virtual joystick was pressed
  35633. */
  35634. pressed: boolean;
  35635. /**
  35636. * Canvas the virtual joystick will render onto, default z-index of this is 5
  35637. */
  35638. static Canvas: Nullable<HTMLCanvasElement>;
  35639. private static _globalJoystickIndex;
  35640. private static vjCanvasContext;
  35641. private static vjCanvasWidth;
  35642. private static vjCanvasHeight;
  35643. private static halfWidth;
  35644. private _action;
  35645. private _axisTargetedByLeftAndRight;
  35646. private _axisTargetedByUpAndDown;
  35647. private _joystickSensibility;
  35648. private _inversedSensibility;
  35649. private _joystickPointerID;
  35650. private _joystickColor;
  35651. private _joystickPointerPos;
  35652. private _joystickPreviousPointerPos;
  35653. private _joystickPointerStartPos;
  35654. private _deltaJoystickVector;
  35655. private _leftJoystick;
  35656. private _touches;
  35657. private _onPointerDownHandlerRef;
  35658. private _onPointerMoveHandlerRef;
  35659. private _onPointerUpHandlerRef;
  35660. private _onResize;
  35661. /**
  35662. * Creates a new virtual joystick
  35663. * @param leftJoystick defines that the joystick is for left hand (false by default)
  35664. */
  35665. constructor(leftJoystick?: boolean);
  35666. /**
  35667. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  35668. * @param newJoystickSensibility defines the new sensibility
  35669. */
  35670. setJoystickSensibility(newJoystickSensibility: number): void;
  35671. private _onPointerDown;
  35672. private _onPointerMove;
  35673. private _onPointerUp;
  35674. /**
  35675. * Change the color of the virtual joystick
  35676. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  35677. */
  35678. setJoystickColor(newColor: string): void;
  35679. /**
  35680. * Defines a callback to call when the joystick is touched
  35681. * @param action defines the callback
  35682. */
  35683. setActionOnTouch(action: () => any): void;
  35684. /**
  35685. * Defines which axis you'd like to control for left & right
  35686. * @param axis defines the axis to use
  35687. */
  35688. setAxisForLeftRight(axis: JoystickAxis): void;
  35689. /**
  35690. * Defines which axis you'd like to control for up & down
  35691. * @param axis defines the axis to use
  35692. */
  35693. setAxisForUpDown(axis: JoystickAxis): void;
  35694. private _drawVirtualJoystick;
  35695. /**
  35696. * Release internal HTML canvas
  35697. */
  35698. releaseCanvas(): void;
  35699. }
  35700. }
  35701. declare module BABYLON {
  35702. interface FreeCameraInputsManager {
  35703. /**
  35704. * Add virtual joystick input support to the input manager.
  35705. * @returns the current input manager
  35706. */
  35707. addVirtualJoystick(): FreeCameraInputsManager;
  35708. }
  35709. /**
  35710. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  35711. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35712. */
  35713. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  35714. /**
  35715. * Defines the camera the input is attached to.
  35716. */
  35717. camera: FreeCamera;
  35718. private _leftjoystick;
  35719. private _rightjoystick;
  35720. /**
  35721. * Gets the left stick of the virtual joystick.
  35722. * @returns The virtual Joystick
  35723. */
  35724. getLeftJoystick(): VirtualJoystick;
  35725. /**
  35726. * Gets the right stick of the virtual joystick.
  35727. * @returns The virtual Joystick
  35728. */
  35729. getRightJoystick(): VirtualJoystick;
  35730. /**
  35731. * Update the current camera state depending on the inputs that have been used this frame.
  35732. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35733. */
  35734. checkInputs(): void;
  35735. /**
  35736. * Attach the input controls to a specific dom element to get the input from.
  35737. * @param element Defines the element the controls should be listened from
  35738. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35739. */
  35740. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35741. /**
  35742. * Detach the current controls from the specified dom element.
  35743. * @param element Defines the element to stop listening the inputs from
  35744. */
  35745. detachControl(element: Nullable<HTMLElement>): void;
  35746. /**
  35747. * Gets the class name of the current intput.
  35748. * @returns the class name
  35749. */
  35750. getClassName(): string;
  35751. /**
  35752. * Get the friendly name associated with the input class.
  35753. * @returns the input friendly name
  35754. */
  35755. getSimpleName(): string;
  35756. }
  35757. }
  35758. declare module BABYLON {
  35759. /**
  35760. * This represents a FPS type of camera controlled by touch.
  35761. * This is like a universal camera minus the Gamepad controls.
  35762. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35763. */
  35764. export class TouchCamera extends FreeCamera {
  35765. /**
  35766. * Defines the touch sensibility for rotation.
  35767. * The higher the faster.
  35768. */
  35769. touchAngularSensibility: number;
  35770. /**
  35771. * Defines the touch sensibility for move.
  35772. * The higher the faster.
  35773. */
  35774. touchMoveSensibility: number;
  35775. /**
  35776. * Instantiates a new touch camera.
  35777. * This represents a FPS type of camera controlled by touch.
  35778. * This is like a universal camera minus the Gamepad controls.
  35779. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  35780. * @param name Define the name of the camera in the scene
  35781. * @param position Define the start position of the camera in the scene
  35782. * @param scene Define the scene the camera belongs to
  35783. */
  35784. constructor(name: string, position: Vector3, scene: Scene);
  35785. /**
  35786. * Gets the current object class name.
  35787. * @return the class name
  35788. */
  35789. getClassName(): string;
  35790. /** @hidden */
  35791. _setupInputs(): void;
  35792. }
  35793. }
  35794. declare module BABYLON {
  35795. /**
  35796. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  35797. * being tilted forward or back and left or right.
  35798. */
  35799. export class DeviceOrientationCamera extends FreeCamera {
  35800. private _initialQuaternion;
  35801. private _quaternionCache;
  35802. /**
  35803. * Creates a new device orientation camera
  35804. * @param name The name of the camera
  35805. * @param position The start position camera
  35806. * @param scene The scene the camera belongs to
  35807. */
  35808. constructor(name: string, position: Vector3, scene: Scene);
  35809. /**
  35810. * Gets the current instance class name ("DeviceOrientationCamera").
  35811. * This helps avoiding instanceof at run time.
  35812. * @returns the class name
  35813. */
  35814. getClassName(): string;
  35815. /**
  35816. * @hidden
  35817. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  35818. */
  35819. _checkInputs(): void;
  35820. /**
  35821. * Reset the camera to its default orientation on the specified axis only.
  35822. * @param axis The axis to reset
  35823. */
  35824. resetToCurrentRotation(axis?: Axis): void;
  35825. }
  35826. }
  35827. declare module BABYLON {
  35828. /**
  35829. * Manage the keyboard inputs to control the movement of a follow camera.
  35830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35831. */
  35832. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  35833. /**
  35834. * Defines the camera the input is attached to.
  35835. */
  35836. camera: FollowCamera;
  35837. /**
  35838. * Defines the list of key codes associated with the up action (increase heightOffset)
  35839. */
  35840. keysHeightOffsetIncr: number[];
  35841. /**
  35842. * Defines the list of key codes associated with the down action (decrease heightOffset)
  35843. */
  35844. keysHeightOffsetDecr: number[];
  35845. /**
  35846. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  35847. */
  35848. keysHeightOffsetModifierAlt: boolean;
  35849. /**
  35850. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  35851. */
  35852. keysHeightOffsetModifierCtrl: boolean;
  35853. /**
  35854. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  35855. */
  35856. keysHeightOffsetModifierShift: boolean;
  35857. /**
  35858. * Defines the list of key codes associated with the left action (increase rotationOffset)
  35859. */
  35860. keysRotationOffsetIncr: number[];
  35861. /**
  35862. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  35863. */
  35864. keysRotationOffsetDecr: number[];
  35865. /**
  35866. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  35867. */
  35868. keysRotationOffsetModifierAlt: boolean;
  35869. /**
  35870. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  35871. */
  35872. keysRotationOffsetModifierCtrl: boolean;
  35873. /**
  35874. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  35875. */
  35876. keysRotationOffsetModifierShift: boolean;
  35877. /**
  35878. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  35879. */
  35880. keysRadiusIncr: number[];
  35881. /**
  35882. * Defines the list of key codes associated with the zoom-out action (increase radius)
  35883. */
  35884. keysRadiusDecr: number[];
  35885. /**
  35886. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  35887. */
  35888. keysRadiusModifierAlt: boolean;
  35889. /**
  35890. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  35891. */
  35892. keysRadiusModifierCtrl: boolean;
  35893. /**
  35894. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  35895. */
  35896. keysRadiusModifierShift: boolean;
  35897. /**
  35898. * Defines the rate of change of heightOffset.
  35899. */
  35900. heightSensibility: number;
  35901. /**
  35902. * Defines the rate of change of rotationOffset.
  35903. */
  35904. rotationSensibility: number;
  35905. /**
  35906. * Defines the rate of change of radius.
  35907. */
  35908. radiusSensibility: number;
  35909. private _keys;
  35910. private _ctrlPressed;
  35911. private _altPressed;
  35912. private _shiftPressed;
  35913. private _onCanvasBlurObserver;
  35914. private _onKeyboardObserver;
  35915. private _engine;
  35916. private _scene;
  35917. /**
  35918. * Attach the input controls to a specific dom element to get the input from.
  35919. * @param element Defines the element the controls should be listened from
  35920. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35921. */
  35922. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35923. /**
  35924. * Detach the current controls from the specified dom element.
  35925. * @param element Defines the element to stop listening the inputs from
  35926. */
  35927. detachControl(element: Nullable<HTMLElement>): void;
  35928. /**
  35929. * Update the current camera state depending on the inputs that have been used this frame.
  35930. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35931. */
  35932. checkInputs(): void;
  35933. /**
  35934. * Gets the class name of the current input.
  35935. * @returns the class name
  35936. */
  35937. getClassName(): string;
  35938. /**
  35939. * Get the friendly name associated with the input class.
  35940. * @returns the input friendly name
  35941. */
  35942. getSimpleName(): string;
  35943. /**
  35944. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35945. * allow modification of the heightOffset value.
  35946. */
  35947. private _modifierHeightOffset;
  35948. /**
  35949. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35950. * allow modification of the rotationOffset value.
  35951. */
  35952. private _modifierRotationOffset;
  35953. /**
  35954. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  35955. * allow modification of the radius value.
  35956. */
  35957. private _modifierRadius;
  35958. }
  35959. }
  35960. declare module BABYLON {
  35961. /**
  35962. * Manage the mouse wheel inputs to control a follow camera.
  35963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35964. */
  35965. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35966. /**
  35967. * Defines the camera the input is attached to.
  35968. */
  35969. camera: FollowCamera;
  35970. /**
  35971. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  35972. */
  35973. axisControlRadius: boolean;
  35974. /**
  35975. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  35976. */
  35977. axisControlHeight: boolean;
  35978. /**
  35979. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  35980. */
  35981. axisControlRotation: boolean;
  35982. /**
  35983. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35984. * relation to mouseWheel events.
  35985. */
  35986. wheelPrecision: number;
  35987. /**
  35988. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35989. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35990. */
  35991. wheelDeltaPercentage: number;
  35992. private _wheel;
  35993. private _observer;
  35994. /**
  35995. * Attach the input controls to a specific dom element to get the input from.
  35996. * @param element Defines the element the controls should be listened from
  35997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35998. */
  35999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36000. /**
  36001. * Detach the current controls from the specified dom element.
  36002. * @param element Defines the element to stop listening the inputs from
  36003. */
  36004. detachControl(element: Nullable<HTMLElement>): void;
  36005. /**
  36006. * Gets the class name of the current intput.
  36007. * @returns the class name
  36008. */
  36009. getClassName(): string;
  36010. /**
  36011. * Get the friendly name associated with the input class.
  36012. * @returns the input friendly name
  36013. */
  36014. getSimpleName(): string;
  36015. }
  36016. }
  36017. declare module BABYLON {
  36018. /**
  36019. * Default Inputs manager for the FollowCamera.
  36020. * It groups all the default supported inputs for ease of use.
  36021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36022. */
  36023. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36024. /**
  36025. * Instantiates a new FollowCameraInputsManager.
  36026. * @param camera Defines the camera the inputs belong to
  36027. */
  36028. constructor(camera: FollowCamera);
  36029. /**
  36030. * Add keyboard input support to the input manager.
  36031. * @returns the current input manager
  36032. */
  36033. addKeyboard(): FollowCameraInputsManager;
  36034. /**
  36035. * Add mouse wheel input support to the input manager.
  36036. * @returns the current input manager
  36037. */
  36038. addMouseWheel(): FollowCameraInputsManager;
  36039. /**
  36040. * Add pointers input support to the input manager.
  36041. * @returns the current input manager
  36042. */
  36043. addPointers(): FollowCameraInputsManager;
  36044. /**
  36045. * Add orientation input support to the input manager.
  36046. * @returns the current input manager
  36047. */
  36048. addVRDeviceOrientation(): FollowCameraInputsManager;
  36049. }
  36050. }
  36051. declare module BABYLON {
  36052. /**
  36053. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36054. * an arc rotate version arcFollowCamera are available.
  36055. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36056. */
  36057. export class FollowCamera extends TargetCamera {
  36058. /**
  36059. * Distance the follow camera should follow an object at
  36060. */
  36061. radius: number;
  36062. /**
  36063. * Minimum allowed distance of the camera to the axis of rotation
  36064. * (The camera can not get closer).
  36065. * This can help limiting how the Camera is able to move in the scene.
  36066. */
  36067. lowerRadiusLimit: Nullable<number>;
  36068. /**
  36069. * Maximum allowed distance of the camera to the axis of rotation
  36070. * (The camera can not get further).
  36071. * This can help limiting how the Camera is able to move in the scene.
  36072. */
  36073. upperRadiusLimit: Nullable<number>;
  36074. /**
  36075. * Define a rotation offset between the camera and the object it follows
  36076. */
  36077. rotationOffset: number;
  36078. /**
  36079. * Minimum allowed angle to camera position relative to target object.
  36080. * This can help limiting how the Camera is able to move in the scene.
  36081. */
  36082. lowerRotationOffsetLimit: Nullable<number>;
  36083. /**
  36084. * Maximum allowed angle to camera position relative to target object.
  36085. * This can help limiting how the Camera is able to move in the scene.
  36086. */
  36087. upperRotationOffsetLimit: Nullable<number>;
  36088. /**
  36089. * Define a height offset between the camera and the object it follows.
  36090. * It can help following an object from the top (like a car chaing a plane)
  36091. */
  36092. heightOffset: number;
  36093. /**
  36094. * Minimum allowed height of camera position relative to target object.
  36095. * This can help limiting how the Camera is able to move in the scene.
  36096. */
  36097. lowerHeightOffsetLimit: Nullable<number>;
  36098. /**
  36099. * Maximum allowed height of camera position relative to target object.
  36100. * This can help limiting how the Camera is able to move in the scene.
  36101. */
  36102. upperHeightOffsetLimit: Nullable<number>;
  36103. /**
  36104. * Define how fast the camera can accelerate to follow it s target.
  36105. */
  36106. cameraAcceleration: number;
  36107. /**
  36108. * Define the speed limit of the camera following an object.
  36109. */
  36110. maxCameraSpeed: number;
  36111. /**
  36112. * Define the target of the camera.
  36113. */
  36114. lockedTarget: Nullable<AbstractMesh>;
  36115. /**
  36116. * Defines the input associated with the camera.
  36117. */
  36118. inputs: FollowCameraInputsManager;
  36119. /**
  36120. * Instantiates the follow camera.
  36121. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36122. * @param name Define the name of the camera in the scene
  36123. * @param position Define the position of the camera
  36124. * @param scene Define the scene the camera belong to
  36125. * @param lockedTarget Define the target of the camera
  36126. */
  36127. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36128. private _follow;
  36129. /**
  36130. * Attached controls to the current camera.
  36131. * @param element Defines the element the controls should be listened from
  36132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36133. */
  36134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36135. /**
  36136. * Detach the current controls from the camera.
  36137. * The camera will stop reacting to inputs.
  36138. * @param element Defines the element to stop listening the inputs from
  36139. */
  36140. detachControl(element: HTMLElement): void;
  36141. /** @hidden */
  36142. _checkInputs(): void;
  36143. private _checkLimits;
  36144. /**
  36145. * Gets the camera class name.
  36146. * @returns the class name
  36147. */
  36148. getClassName(): string;
  36149. }
  36150. /**
  36151. * Arc Rotate version of the follow camera.
  36152. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36153. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36154. */
  36155. export class ArcFollowCamera extends TargetCamera {
  36156. /** The longitudinal angle of the camera */
  36157. alpha: number;
  36158. /** The latitudinal angle of the camera */
  36159. beta: number;
  36160. /** The radius of the camera from its target */
  36161. radius: number;
  36162. /** Define the camera target (the messh it should follow) */
  36163. target: Nullable<AbstractMesh>;
  36164. private _cartesianCoordinates;
  36165. /**
  36166. * Instantiates a new ArcFollowCamera
  36167. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36168. * @param name Define the name of the camera
  36169. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36170. * @param beta Define the rotation angle of the camera around the elevation axis
  36171. * @param radius Define the radius of the camera from its target point
  36172. * @param target Define the target of the camera
  36173. * @param scene Define the scene the camera belongs to
  36174. */
  36175. constructor(name: string,
  36176. /** The longitudinal angle of the camera */
  36177. alpha: number,
  36178. /** The latitudinal angle of the camera */
  36179. beta: number,
  36180. /** The radius of the camera from its target */
  36181. radius: number,
  36182. /** Define the camera target (the messh it should follow) */
  36183. target: Nullable<AbstractMesh>, scene: Scene);
  36184. private _follow;
  36185. /** @hidden */
  36186. _checkInputs(): void;
  36187. /**
  36188. * Returns the class name of the object.
  36189. * It is mostly used internally for serialization purposes.
  36190. */
  36191. getClassName(): string;
  36192. }
  36193. }
  36194. declare module BABYLON {
  36195. /**
  36196. * 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,
  36197. * which still works and will still be found in many Playgrounds.
  36198. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36199. */
  36200. export class UniversalCamera extends TouchCamera {
  36201. /**
  36202. * Defines the gamepad rotation sensiblity.
  36203. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36204. */
  36205. gamepadAngularSensibility: number;
  36206. /**
  36207. * Defines the gamepad move sensiblity.
  36208. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36209. */
  36210. gamepadMoveSensibility: number;
  36211. /**
  36212. * 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,
  36213. * which still works and will still be found in many Playgrounds.
  36214. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36215. * @param name Define the name of the camera in the scene
  36216. * @param position Define the start position of the camera in the scene
  36217. * @param scene Define the scene the camera belongs to
  36218. */
  36219. constructor(name: string, position: Vector3, scene: Scene);
  36220. /**
  36221. * Gets the current object class name.
  36222. * @return the class name
  36223. */
  36224. getClassName(): string;
  36225. }
  36226. }
  36227. declare module BABYLON {
  36228. /**
  36229. * This represents a FPS type of camera. This is only here for back compat purpose.
  36230. * Please use the UniversalCamera instead as both are identical.
  36231. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36232. */
  36233. export class GamepadCamera extends UniversalCamera {
  36234. /**
  36235. * Instantiates a new Gamepad Camera
  36236. * This represents a FPS type of camera. This is only here for back compat purpose.
  36237. * Please use the UniversalCamera instead as both are identical.
  36238. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36239. * @param name Define the name of the camera in the scene
  36240. * @param position Define the start position of the camera in the scene
  36241. * @param scene Define the scene the camera belongs to
  36242. */
  36243. constructor(name: string, position: Vector3, scene: Scene);
  36244. /**
  36245. * Gets the current object class name.
  36246. * @return the class name
  36247. */
  36248. getClassName(): string;
  36249. }
  36250. }
  36251. declare module BABYLON {
  36252. /** @hidden */
  36253. export var passPixelShader: {
  36254. name: string;
  36255. shader: string;
  36256. };
  36257. }
  36258. declare module BABYLON {
  36259. /** @hidden */
  36260. export var passCubePixelShader: {
  36261. name: string;
  36262. shader: string;
  36263. };
  36264. }
  36265. declare module BABYLON {
  36266. /**
  36267. * PassPostProcess which produces an output the same as it's input
  36268. */
  36269. export class PassPostProcess extends PostProcess {
  36270. /**
  36271. * Creates the PassPostProcess
  36272. * @param name The name of the effect.
  36273. * @param options The required width/height ratio to downsize to before computing the render pass.
  36274. * @param camera The camera to apply the render pass to.
  36275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36276. * @param engine The engine which the post process will be applied. (default: current engine)
  36277. * @param reusable If the post process can be reused on the same frame. (default: false)
  36278. * @param textureType The type of texture to be used when performing the post processing.
  36279. * @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)
  36280. */
  36281. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36282. }
  36283. /**
  36284. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36285. */
  36286. export class PassCubePostProcess extends PostProcess {
  36287. private _face;
  36288. /**
  36289. * Gets or sets the cube face to display.
  36290. * * 0 is +X
  36291. * * 1 is -X
  36292. * * 2 is +Y
  36293. * * 3 is -Y
  36294. * * 4 is +Z
  36295. * * 5 is -Z
  36296. */
  36297. face: number;
  36298. /**
  36299. * Creates the PassCubePostProcess
  36300. * @param name The name of the effect.
  36301. * @param options The required width/height ratio to downsize to before computing the render pass.
  36302. * @param camera The camera to apply the render pass to.
  36303. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36304. * @param engine The engine which the post process will be applied. (default: current engine)
  36305. * @param reusable If the post process can be reused on the same frame. (default: false)
  36306. * @param textureType The type of texture to be used when performing the post processing.
  36307. * @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)
  36308. */
  36309. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36310. }
  36311. }
  36312. declare module BABYLON {
  36313. /** @hidden */
  36314. export var anaglyphPixelShader: {
  36315. name: string;
  36316. shader: string;
  36317. };
  36318. }
  36319. declare module BABYLON {
  36320. /**
  36321. * Postprocess used to generate anaglyphic rendering
  36322. */
  36323. export class AnaglyphPostProcess extends PostProcess {
  36324. private _passedProcess;
  36325. /**
  36326. * Creates a new AnaglyphPostProcess
  36327. * @param name defines postprocess name
  36328. * @param options defines creation options or target ratio scale
  36329. * @param rigCameras defines cameras using this postprocess
  36330. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36331. * @param engine defines hosting engine
  36332. * @param reusable defines if the postprocess will be reused multiple times per frame
  36333. */
  36334. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36335. }
  36336. }
  36337. declare module BABYLON {
  36338. /**
  36339. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36340. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36341. */
  36342. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36343. /**
  36344. * Creates a new AnaglyphArcRotateCamera
  36345. * @param name defines camera name
  36346. * @param alpha defines alpha angle (in radians)
  36347. * @param beta defines beta angle (in radians)
  36348. * @param radius defines radius
  36349. * @param target defines camera target
  36350. * @param interaxialDistance defines distance between each color axis
  36351. * @param scene defines the hosting scene
  36352. */
  36353. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36354. /**
  36355. * Gets camera class name
  36356. * @returns AnaglyphArcRotateCamera
  36357. */
  36358. getClassName(): string;
  36359. }
  36360. }
  36361. declare module BABYLON {
  36362. /**
  36363. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36364. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36365. */
  36366. export class AnaglyphFreeCamera extends FreeCamera {
  36367. /**
  36368. * Creates a new AnaglyphFreeCamera
  36369. * @param name defines camera name
  36370. * @param position defines initial position
  36371. * @param interaxialDistance defines distance between each color axis
  36372. * @param scene defines the hosting scene
  36373. */
  36374. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36375. /**
  36376. * Gets camera class name
  36377. * @returns AnaglyphFreeCamera
  36378. */
  36379. getClassName(): string;
  36380. }
  36381. }
  36382. declare module BABYLON {
  36383. /**
  36384. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36385. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36386. */
  36387. export class AnaglyphGamepadCamera extends GamepadCamera {
  36388. /**
  36389. * Creates a new AnaglyphGamepadCamera
  36390. * @param name defines camera name
  36391. * @param position defines initial position
  36392. * @param interaxialDistance defines distance between each color axis
  36393. * @param scene defines the hosting scene
  36394. */
  36395. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36396. /**
  36397. * Gets camera class name
  36398. * @returns AnaglyphGamepadCamera
  36399. */
  36400. getClassName(): string;
  36401. }
  36402. }
  36403. declare module BABYLON {
  36404. /**
  36405. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36406. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36407. */
  36408. export class AnaglyphUniversalCamera extends UniversalCamera {
  36409. /**
  36410. * Creates a new AnaglyphUniversalCamera
  36411. * @param name defines camera name
  36412. * @param position defines initial position
  36413. * @param interaxialDistance defines distance between each color axis
  36414. * @param scene defines the hosting scene
  36415. */
  36416. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36417. /**
  36418. * Gets camera class name
  36419. * @returns AnaglyphUniversalCamera
  36420. */
  36421. getClassName(): string;
  36422. }
  36423. }
  36424. declare module BABYLON {
  36425. /** @hidden */
  36426. export var stereoscopicInterlacePixelShader: {
  36427. name: string;
  36428. shader: string;
  36429. };
  36430. }
  36431. declare module BABYLON {
  36432. /**
  36433. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36434. */
  36435. export class StereoscopicInterlacePostProcess extends PostProcess {
  36436. private _stepSize;
  36437. private _passedProcess;
  36438. /**
  36439. * Initializes a StereoscopicInterlacePostProcess
  36440. * @param name The name of the effect.
  36441. * @param rigCameras The rig cameras to be appled to the post process
  36442. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36443. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36444. * @param engine The engine which the post process will be applied. (default: current engine)
  36445. * @param reusable If the post process can be reused on the same frame. (default: false)
  36446. */
  36447. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36448. }
  36449. }
  36450. declare module BABYLON {
  36451. /**
  36452. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36453. * @see http://doc.babylonjs.com/features/cameras
  36454. */
  36455. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36456. /**
  36457. * Creates a new StereoscopicArcRotateCamera
  36458. * @param name defines camera name
  36459. * @param alpha defines alpha angle (in radians)
  36460. * @param beta defines beta angle (in radians)
  36461. * @param radius defines radius
  36462. * @param target defines camera target
  36463. * @param interaxialDistance defines distance between each color axis
  36464. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36465. * @param scene defines the hosting scene
  36466. */
  36467. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36468. /**
  36469. * Gets camera class name
  36470. * @returns StereoscopicArcRotateCamera
  36471. */
  36472. getClassName(): string;
  36473. }
  36474. }
  36475. declare module BABYLON {
  36476. /**
  36477. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36478. * @see http://doc.babylonjs.com/features/cameras
  36479. */
  36480. export class StereoscopicFreeCamera extends FreeCamera {
  36481. /**
  36482. * Creates a new StereoscopicFreeCamera
  36483. * @param name defines camera name
  36484. * @param position defines initial position
  36485. * @param interaxialDistance defines distance between each color axis
  36486. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36487. * @param scene defines the hosting scene
  36488. */
  36489. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36490. /**
  36491. * Gets camera class name
  36492. * @returns StereoscopicFreeCamera
  36493. */
  36494. getClassName(): string;
  36495. }
  36496. }
  36497. declare module BABYLON {
  36498. /**
  36499. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36500. * @see http://doc.babylonjs.com/features/cameras
  36501. */
  36502. export class StereoscopicGamepadCamera extends GamepadCamera {
  36503. /**
  36504. * Creates a new StereoscopicGamepadCamera
  36505. * @param name defines camera name
  36506. * @param position defines initial position
  36507. * @param interaxialDistance defines distance between each color axis
  36508. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36509. * @param scene defines the hosting scene
  36510. */
  36511. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36512. /**
  36513. * Gets camera class name
  36514. * @returns StereoscopicGamepadCamera
  36515. */
  36516. getClassName(): string;
  36517. }
  36518. }
  36519. declare module BABYLON {
  36520. /**
  36521. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36522. * @see http://doc.babylonjs.com/features/cameras
  36523. */
  36524. export class StereoscopicUniversalCamera extends UniversalCamera {
  36525. /**
  36526. * Creates a new StereoscopicUniversalCamera
  36527. * @param name defines camera name
  36528. * @param position defines initial position
  36529. * @param interaxialDistance defines distance between each color axis
  36530. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36531. * @param scene defines the hosting scene
  36532. */
  36533. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36534. /**
  36535. * Gets camera class name
  36536. * @returns StereoscopicUniversalCamera
  36537. */
  36538. getClassName(): string;
  36539. }
  36540. }
  36541. declare module BABYLON {
  36542. /**
  36543. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36544. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36545. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36546. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36547. */
  36548. export class VirtualJoysticksCamera extends FreeCamera {
  36549. /**
  36550. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36551. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36552. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36553. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36554. * @param name Define the name of the camera in the scene
  36555. * @param position Define the start position of the camera in the scene
  36556. * @param scene Define the scene the camera belongs to
  36557. */
  36558. constructor(name: string, position: Vector3, scene: Scene);
  36559. /**
  36560. * Gets the current object class name.
  36561. * @return the class name
  36562. */
  36563. getClassName(): string;
  36564. }
  36565. }
  36566. declare module BABYLON {
  36567. /**
  36568. * This represents all the required metrics to create a VR camera.
  36569. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36570. */
  36571. export class VRCameraMetrics {
  36572. /**
  36573. * Define the horizontal resolution off the screen.
  36574. */
  36575. hResolution: number;
  36576. /**
  36577. * Define the vertical resolution off the screen.
  36578. */
  36579. vResolution: number;
  36580. /**
  36581. * Define the horizontal screen size.
  36582. */
  36583. hScreenSize: number;
  36584. /**
  36585. * Define the vertical screen size.
  36586. */
  36587. vScreenSize: number;
  36588. /**
  36589. * Define the vertical screen center position.
  36590. */
  36591. vScreenCenter: number;
  36592. /**
  36593. * Define the distance of the eyes to the screen.
  36594. */
  36595. eyeToScreenDistance: number;
  36596. /**
  36597. * Define the distance between both lenses
  36598. */
  36599. lensSeparationDistance: number;
  36600. /**
  36601. * Define the distance between both viewer's eyes.
  36602. */
  36603. interpupillaryDistance: number;
  36604. /**
  36605. * Define the distortion factor of the VR postprocess.
  36606. * Please, touch with care.
  36607. */
  36608. distortionK: number[];
  36609. /**
  36610. * Define the chromatic aberration correction factors for the VR post process.
  36611. */
  36612. chromaAbCorrection: number[];
  36613. /**
  36614. * Define the scale factor of the post process.
  36615. * The smaller the better but the slower.
  36616. */
  36617. postProcessScaleFactor: number;
  36618. /**
  36619. * Define an offset for the lens center.
  36620. */
  36621. lensCenterOffset: number;
  36622. /**
  36623. * Define if the current vr camera should compensate the distortion of the lense or not.
  36624. */
  36625. compensateDistortion: boolean;
  36626. /**
  36627. * Gets the rendering aspect ratio based on the provided resolutions.
  36628. */
  36629. readonly aspectRatio: number;
  36630. /**
  36631. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  36632. */
  36633. readonly aspectRatioFov: number;
  36634. /**
  36635. * @hidden
  36636. */
  36637. readonly leftHMatrix: Matrix;
  36638. /**
  36639. * @hidden
  36640. */
  36641. readonly rightHMatrix: Matrix;
  36642. /**
  36643. * @hidden
  36644. */
  36645. readonly leftPreViewMatrix: Matrix;
  36646. /**
  36647. * @hidden
  36648. */
  36649. readonly rightPreViewMatrix: Matrix;
  36650. /**
  36651. * Get the default VRMetrics based on the most generic setup.
  36652. * @returns the default vr metrics
  36653. */
  36654. static GetDefault(): VRCameraMetrics;
  36655. }
  36656. }
  36657. declare module BABYLON {
  36658. /** @hidden */
  36659. export var vrDistortionCorrectionPixelShader: {
  36660. name: string;
  36661. shader: string;
  36662. };
  36663. }
  36664. declare module BABYLON {
  36665. /**
  36666. * VRDistortionCorrectionPostProcess used for mobile VR
  36667. */
  36668. export class VRDistortionCorrectionPostProcess extends PostProcess {
  36669. private _isRightEye;
  36670. private _distortionFactors;
  36671. private _postProcessScaleFactor;
  36672. private _lensCenterOffset;
  36673. private _scaleIn;
  36674. private _scaleFactor;
  36675. private _lensCenter;
  36676. /**
  36677. * Initializes the VRDistortionCorrectionPostProcess
  36678. * @param name The name of the effect.
  36679. * @param camera The camera to apply the render pass to.
  36680. * @param isRightEye If this is for the right eye distortion
  36681. * @param vrMetrics All the required metrics for the VR camera
  36682. */
  36683. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36684. }
  36685. }
  36686. declare module BABYLON {
  36687. /**
  36688. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  36689. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36690. */
  36691. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  36692. /**
  36693. * Creates a new VRDeviceOrientationArcRotateCamera
  36694. * @param name defines camera name
  36695. * @param alpha defines the camera rotation along the logitudinal axis
  36696. * @param beta defines the camera rotation along the latitudinal axis
  36697. * @param radius defines the camera distance from its target
  36698. * @param target defines the camera target
  36699. * @param scene defines the scene the camera belongs to
  36700. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36701. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36702. */
  36703. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36704. /**
  36705. * Gets camera class name
  36706. * @returns VRDeviceOrientationArcRotateCamera
  36707. */
  36708. getClassName(): string;
  36709. }
  36710. }
  36711. declare module BABYLON {
  36712. /**
  36713. * Camera used to simulate VR rendering (based on FreeCamera)
  36714. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36715. */
  36716. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  36717. /**
  36718. * Creates a new VRDeviceOrientationFreeCamera
  36719. * @param name defines camera name
  36720. * @param position defines the start position of the camera
  36721. * @param scene defines the scene the camera belongs to
  36722. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36723. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36724. */
  36725. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36726. /**
  36727. * Gets camera class name
  36728. * @returns VRDeviceOrientationFreeCamera
  36729. */
  36730. getClassName(): string;
  36731. }
  36732. }
  36733. declare module BABYLON {
  36734. /**
  36735. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  36736. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  36737. */
  36738. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  36739. /**
  36740. * Creates a new VRDeviceOrientationGamepadCamera
  36741. * @param name defines camera name
  36742. * @param position defines the start position of the camera
  36743. * @param scene defines the scene the camera belongs to
  36744. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  36745. * @param vrCameraMetrics defines the vr metrics associated to the camera
  36746. */
  36747. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  36748. /**
  36749. * Gets camera class name
  36750. * @returns VRDeviceOrientationGamepadCamera
  36751. */
  36752. getClassName(): string;
  36753. }
  36754. }
  36755. declare module BABYLON {
  36756. /**
  36757. * Defines supported buttons for XBox360 compatible gamepads
  36758. */
  36759. export enum Xbox360Button {
  36760. /** A */
  36761. A = 0,
  36762. /** B */
  36763. B = 1,
  36764. /** X */
  36765. X = 2,
  36766. /** Y */
  36767. Y = 3,
  36768. /** Start */
  36769. Start = 4,
  36770. /** Back */
  36771. Back = 5,
  36772. /** Left button */
  36773. LB = 6,
  36774. /** Right button */
  36775. RB = 7,
  36776. /** Left stick */
  36777. LeftStick = 8,
  36778. /** Right stick */
  36779. RightStick = 9
  36780. }
  36781. /** Defines values for XBox360 DPad */
  36782. export enum Xbox360Dpad {
  36783. /** Up */
  36784. Up = 0,
  36785. /** Down */
  36786. Down = 1,
  36787. /** Left */
  36788. Left = 2,
  36789. /** Right */
  36790. Right = 3
  36791. }
  36792. /**
  36793. * Defines a XBox360 gamepad
  36794. */
  36795. export class Xbox360Pad extends Gamepad {
  36796. private _leftTrigger;
  36797. private _rightTrigger;
  36798. private _onlefttriggerchanged;
  36799. private _onrighttriggerchanged;
  36800. private _onbuttondown;
  36801. private _onbuttonup;
  36802. private _ondpaddown;
  36803. private _ondpadup;
  36804. /** Observable raised when a button is pressed */
  36805. onButtonDownObservable: Observable<Xbox360Button>;
  36806. /** Observable raised when a button is released */
  36807. onButtonUpObservable: Observable<Xbox360Button>;
  36808. /** Observable raised when a pad is pressed */
  36809. onPadDownObservable: Observable<Xbox360Dpad>;
  36810. /** Observable raised when a pad is released */
  36811. onPadUpObservable: Observable<Xbox360Dpad>;
  36812. private _buttonA;
  36813. private _buttonB;
  36814. private _buttonX;
  36815. private _buttonY;
  36816. private _buttonBack;
  36817. private _buttonStart;
  36818. private _buttonLB;
  36819. private _buttonRB;
  36820. private _buttonLeftStick;
  36821. private _buttonRightStick;
  36822. private _dPadUp;
  36823. private _dPadDown;
  36824. private _dPadLeft;
  36825. private _dPadRight;
  36826. private _isXboxOnePad;
  36827. /**
  36828. * Creates a new XBox360 gamepad object
  36829. * @param id defines the id of this gamepad
  36830. * @param index defines its index
  36831. * @param gamepad defines the internal HTML gamepad object
  36832. * @param xboxOne defines if it is a XBox One gamepad
  36833. */
  36834. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36835. /**
  36836. * Defines the callback to call when left trigger is pressed
  36837. * @param callback defines the callback to use
  36838. */
  36839. onlefttriggerchanged(callback: (value: number) => void): void;
  36840. /**
  36841. * Defines the callback to call when right trigger is pressed
  36842. * @param callback defines the callback to use
  36843. */
  36844. onrighttriggerchanged(callback: (value: number) => void): void;
  36845. /**
  36846. * Gets the left trigger value
  36847. */
  36848. /**
  36849. * Sets the left trigger value
  36850. */
  36851. leftTrigger: number;
  36852. /**
  36853. * Gets the right trigger value
  36854. */
  36855. /**
  36856. * Sets the right trigger value
  36857. */
  36858. rightTrigger: number;
  36859. /**
  36860. * Defines the callback to call when a button is pressed
  36861. * @param callback defines the callback to use
  36862. */
  36863. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36864. /**
  36865. * Defines the callback to call when a button is released
  36866. * @param callback defines the callback to use
  36867. */
  36868. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36869. /**
  36870. * Defines the callback to call when a pad is pressed
  36871. * @param callback defines the callback to use
  36872. */
  36873. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36874. /**
  36875. * Defines the callback to call when a pad is released
  36876. * @param callback defines the callback to use
  36877. */
  36878. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36879. private _setButtonValue;
  36880. private _setDPadValue;
  36881. /**
  36882. * Gets the value of the `A` button
  36883. */
  36884. /**
  36885. * Sets the value of the `A` button
  36886. */
  36887. buttonA: number;
  36888. /**
  36889. * Gets the value of the `B` button
  36890. */
  36891. /**
  36892. * Sets the value of the `B` button
  36893. */
  36894. buttonB: number;
  36895. /**
  36896. * Gets the value of the `X` button
  36897. */
  36898. /**
  36899. * Sets the value of the `X` button
  36900. */
  36901. buttonX: number;
  36902. /**
  36903. * Gets the value of the `Y` button
  36904. */
  36905. /**
  36906. * Sets the value of the `Y` button
  36907. */
  36908. buttonY: number;
  36909. /**
  36910. * Gets the value of the `Start` button
  36911. */
  36912. /**
  36913. * Sets the value of the `Start` button
  36914. */
  36915. buttonStart: number;
  36916. /**
  36917. * Gets the value of the `Back` button
  36918. */
  36919. /**
  36920. * Sets the value of the `Back` button
  36921. */
  36922. buttonBack: number;
  36923. /**
  36924. * Gets the value of the `Left` button
  36925. */
  36926. /**
  36927. * Sets the value of the `Left` button
  36928. */
  36929. buttonLB: number;
  36930. /**
  36931. * Gets the value of the `Right` button
  36932. */
  36933. /**
  36934. * Sets the value of the `Right` button
  36935. */
  36936. buttonRB: number;
  36937. /**
  36938. * Gets the value of the Left joystick
  36939. */
  36940. /**
  36941. * Sets the value of the Left joystick
  36942. */
  36943. buttonLeftStick: number;
  36944. /**
  36945. * Gets the value of the Right joystick
  36946. */
  36947. /**
  36948. * Sets the value of the Right joystick
  36949. */
  36950. buttonRightStick: number;
  36951. /**
  36952. * Gets the value of D-pad up
  36953. */
  36954. /**
  36955. * Sets the value of D-pad up
  36956. */
  36957. dPadUp: number;
  36958. /**
  36959. * Gets the value of D-pad down
  36960. */
  36961. /**
  36962. * Sets the value of D-pad down
  36963. */
  36964. dPadDown: number;
  36965. /**
  36966. * Gets the value of D-pad left
  36967. */
  36968. /**
  36969. * Sets the value of D-pad left
  36970. */
  36971. dPadLeft: number;
  36972. /**
  36973. * Gets the value of D-pad right
  36974. */
  36975. /**
  36976. * Sets the value of D-pad right
  36977. */
  36978. dPadRight: number;
  36979. /**
  36980. * Force the gamepad to synchronize with device values
  36981. */
  36982. update(): void;
  36983. /**
  36984. * Disposes the gamepad
  36985. */
  36986. dispose(): void;
  36987. }
  36988. }
  36989. declare module BABYLON {
  36990. /**
  36991. * Base class of materials working in push mode in babylon JS
  36992. * @hidden
  36993. */
  36994. export class PushMaterial extends Material {
  36995. protected _activeEffect: Effect;
  36996. protected _normalMatrix: Matrix;
  36997. /**
  36998. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  36999. * This means that the material can keep using a previous shader while a new one is being compiled.
  37000. * This is mostly used when shader parallel compilation is supported (true by default)
  37001. */
  37002. allowShaderHotSwapping: boolean;
  37003. constructor(name: string, scene: Scene);
  37004. getEffect(): Effect;
  37005. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37006. /**
  37007. * Binds the given world matrix to the active effect
  37008. *
  37009. * @param world the matrix to bind
  37010. */
  37011. bindOnlyWorldMatrix(world: Matrix): void;
  37012. /**
  37013. * Binds the given normal matrix to the active effect
  37014. *
  37015. * @param normalMatrix the matrix to bind
  37016. */
  37017. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37018. bind(world: Matrix, mesh?: Mesh): void;
  37019. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37020. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37021. }
  37022. }
  37023. declare module BABYLON {
  37024. /**
  37025. * This groups all the flags used to control the materials channel.
  37026. */
  37027. export class MaterialFlags {
  37028. private static _DiffuseTextureEnabled;
  37029. /**
  37030. * Are diffuse textures enabled in the application.
  37031. */
  37032. static DiffuseTextureEnabled: boolean;
  37033. private static _AmbientTextureEnabled;
  37034. /**
  37035. * Are ambient textures enabled in the application.
  37036. */
  37037. static AmbientTextureEnabled: boolean;
  37038. private static _OpacityTextureEnabled;
  37039. /**
  37040. * Are opacity textures enabled in the application.
  37041. */
  37042. static OpacityTextureEnabled: boolean;
  37043. private static _ReflectionTextureEnabled;
  37044. /**
  37045. * Are reflection textures enabled in the application.
  37046. */
  37047. static ReflectionTextureEnabled: boolean;
  37048. private static _EmissiveTextureEnabled;
  37049. /**
  37050. * Are emissive textures enabled in the application.
  37051. */
  37052. static EmissiveTextureEnabled: boolean;
  37053. private static _SpecularTextureEnabled;
  37054. /**
  37055. * Are specular textures enabled in the application.
  37056. */
  37057. static SpecularTextureEnabled: boolean;
  37058. private static _BumpTextureEnabled;
  37059. /**
  37060. * Are bump textures enabled in the application.
  37061. */
  37062. static BumpTextureEnabled: boolean;
  37063. private static _LightmapTextureEnabled;
  37064. /**
  37065. * Are lightmap textures enabled in the application.
  37066. */
  37067. static LightmapTextureEnabled: boolean;
  37068. private static _RefractionTextureEnabled;
  37069. /**
  37070. * Are refraction textures enabled in the application.
  37071. */
  37072. static RefractionTextureEnabled: boolean;
  37073. private static _ColorGradingTextureEnabled;
  37074. /**
  37075. * Are color grading textures enabled in the application.
  37076. */
  37077. static ColorGradingTextureEnabled: boolean;
  37078. private static _FresnelEnabled;
  37079. /**
  37080. * Are fresnels enabled in the application.
  37081. */
  37082. static FresnelEnabled: boolean;
  37083. }
  37084. }
  37085. declare module BABYLON {
  37086. /** @hidden */
  37087. export var defaultFragmentDeclaration: {
  37088. name: string;
  37089. shader: string;
  37090. };
  37091. }
  37092. declare module BABYLON {
  37093. /** @hidden */
  37094. export var defaultUboDeclaration: {
  37095. name: string;
  37096. shader: string;
  37097. };
  37098. }
  37099. declare module BABYLON {
  37100. /** @hidden */
  37101. export var lightFragmentDeclaration: {
  37102. name: string;
  37103. shader: string;
  37104. };
  37105. }
  37106. declare module BABYLON {
  37107. /** @hidden */
  37108. export var lightUboDeclaration: {
  37109. name: string;
  37110. shader: string;
  37111. };
  37112. }
  37113. declare module BABYLON {
  37114. /** @hidden */
  37115. export var lightsFragmentFunctions: {
  37116. name: string;
  37117. shader: string;
  37118. };
  37119. }
  37120. declare module BABYLON {
  37121. /** @hidden */
  37122. export var shadowsFragmentFunctions: {
  37123. name: string;
  37124. shader: string;
  37125. };
  37126. }
  37127. declare module BABYLON {
  37128. /** @hidden */
  37129. export var fresnelFunction: {
  37130. name: string;
  37131. shader: string;
  37132. };
  37133. }
  37134. declare module BABYLON {
  37135. /** @hidden */
  37136. export var reflectionFunction: {
  37137. name: string;
  37138. shader: string;
  37139. };
  37140. }
  37141. declare module BABYLON {
  37142. /** @hidden */
  37143. export var bumpFragmentFunctions: {
  37144. name: string;
  37145. shader: string;
  37146. };
  37147. }
  37148. declare module BABYLON {
  37149. /** @hidden */
  37150. export var logDepthDeclaration: {
  37151. name: string;
  37152. shader: string;
  37153. };
  37154. }
  37155. declare module BABYLON {
  37156. /** @hidden */
  37157. export var bumpFragment: {
  37158. name: string;
  37159. shader: string;
  37160. };
  37161. }
  37162. declare module BABYLON {
  37163. /** @hidden */
  37164. export var depthPrePass: {
  37165. name: string;
  37166. shader: string;
  37167. };
  37168. }
  37169. declare module BABYLON {
  37170. /** @hidden */
  37171. export var lightFragment: {
  37172. name: string;
  37173. shader: string;
  37174. };
  37175. }
  37176. declare module BABYLON {
  37177. /** @hidden */
  37178. export var logDepthFragment: {
  37179. name: string;
  37180. shader: string;
  37181. };
  37182. }
  37183. declare module BABYLON {
  37184. /** @hidden */
  37185. export var defaultPixelShader: {
  37186. name: string;
  37187. shader: string;
  37188. };
  37189. }
  37190. declare module BABYLON {
  37191. /** @hidden */
  37192. export var defaultVertexDeclaration: {
  37193. name: string;
  37194. shader: string;
  37195. };
  37196. }
  37197. declare module BABYLON {
  37198. /** @hidden */
  37199. export var bumpVertexDeclaration: {
  37200. name: string;
  37201. shader: string;
  37202. };
  37203. }
  37204. declare module BABYLON {
  37205. /** @hidden */
  37206. export var bumpVertex: {
  37207. name: string;
  37208. shader: string;
  37209. };
  37210. }
  37211. declare module BABYLON {
  37212. /** @hidden */
  37213. export var fogVertex: {
  37214. name: string;
  37215. shader: string;
  37216. };
  37217. }
  37218. declare module BABYLON {
  37219. /** @hidden */
  37220. export var shadowsVertex: {
  37221. name: string;
  37222. shader: string;
  37223. };
  37224. }
  37225. declare module BABYLON {
  37226. /** @hidden */
  37227. export var pointCloudVertex: {
  37228. name: string;
  37229. shader: string;
  37230. };
  37231. }
  37232. declare module BABYLON {
  37233. /** @hidden */
  37234. export var logDepthVertex: {
  37235. name: string;
  37236. shader: string;
  37237. };
  37238. }
  37239. declare module BABYLON {
  37240. /** @hidden */
  37241. export var defaultVertexShader: {
  37242. name: string;
  37243. shader: string;
  37244. };
  37245. }
  37246. declare module BABYLON {
  37247. /** @hidden */
  37248. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37249. MAINUV1: boolean;
  37250. MAINUV2: boolean;
  37251. DIFFUSE: boolean;
  37252. DIFFUSEDIRECTUV: number;
  37253. AMBIENT: boolean;
  37254. AMBIENTDIRECTUV: number;
  37255. OPACITY: boolean;
  37256. OPACITYDIRECTUV: number;
  37257. OPACITYRGB: boolean;
  37258. REFLECTION: boolean;
  37259. EMISSIVE: boolean;
  37260. EMISSIVEDIRECTUV: number;
  37261. SPECULAR: boolean;
  37262. SPECULARDIRECTUV: number;
  37263. BUMP: boolean;
  37264. BUMPDIRECTUV: number;
  37265. PARALLAX: boolean;
  37266. PARALLAXOCCLUSION: boolean;
  37267. SPECULAROVERALPHA: boolean;
  37268. CLIPPLANE: boolean;
  37269. CLIPPLANE2: boolean;
  37270. CLIPPLANE3: boolean;
  37271. CLIPPLANE4: boolean;
  37272. ALPHATEST: boolean;
  37273. DEPTHPREPASS: boolean;
  37274. ALPHAFROMDIFFUSE: boolean;
  37275. POINTSIZE: boolean;
  37276. FOG: boolean;
  37277. SPECULARTERM: boolean;
  37278. DIFFUSEFRESNEL: boolean;
  37279. OPACITYFRESNEL: boolean;
  37280. REFLECTIONFRESNEL: boolean;
  37281. REFRACTIONFRESNEL: boolean;
  37282. EMISSIVEFRESNEL: boolean;
  37283. FRESNEL: boolean;
  37284. NORMAL: boolean;
  37285. UV1: boolean;
  37286. UV2: boolean;
  37287. VERTEXCOLOR: boolean;
  37288. VERTEXALPHA: boolean;
  37289. NUM_BONE_INFLUENCERS: number;
  37290. BonesPerMesh: number;
  37291. BONETEXTURE: boolean;
  37292. INSTANCES: boolean;
  37293. GLOSSINESS: boolean;
  37294. ROUGHNESS: boolean;
  37295. EMISSIVEASILLUMINATION: boolean;
  37296. LINKEMISSIVEWITHDIFFUSE: boolean;
  37297. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37298. LIGHTMAP: boolean;
  37299. LIGHTMAPDIRECTUV: number;
  37300. OBJECTSPACE_NORMALMAP: boolean;
  37301. USELIGHTMAPASSHADOWMAP: boolean;
  37302. REFLECTIONMAP_3D: boolean;
  37303. REFLECTIONMAP_SPHERICAL: boolean;
  37304. REFLECTIONMAP_PLANAR: boolean;
  37305. REFLECTIONMAP_CUBIC: boolean;
  37306. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37307. REFLECTIONMAP_PROJECTION: boolean;
  37308. REFLECTIONMAP_SKYBOX: boolean;
  37309. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37310. REFLECTIONMAP_EXPLICIT: boolean;
  37311. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37312. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37313. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37314. INVERTCUBICMAP: boolean;
  37315. LOGARITHMICDEPTH: boolean;
  37316. REFRACTION: boolean;
  37317. REFRACTIONMAP_3D: boolean;
  37318. REFLECTIONOVERALPHA: boolean;
  37319. TWOSIDEDLIGHTING: boolean;
  37320. SHADOWFLOAT: boolean;
  37321. MORPHTARGETS: boolean;
  37322. MORPHTARGETS_NORMAL: boolean;
  37323. MORPHTARGETS_TANGENT: boolean;
  37324. NUM_MORPH_INFLUENCERS: number;
  37325. NONUNIFORMSCALING: boolean;
  37326. PREMULTIPLYALPHA: boolean;
  37327. IMAGEPROCESSING: boolean;
  37328. VIGNETTE: boolean;
  37329. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37330. VIGNETTEBLENDMODEOPAQUE: boolean;
  37331. TONEMAPPING: boolean;
  37332. TONEMAPPING_ACES: boolean;
  37333. CONTRAST: boolean;
  37334. COLORCURVES: boolean;
  37335. COLORGRADING: boolean;
  37336. COLORGRADING3D: boolean;
  37337. SAMPLER3DGREENDEPTH: boolean;
  37338. SAMPLER3DBGRMAP: boolean;
  37339. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37340. /**
  37341. * If the reflection texture on this material is in linear color space
  37342. * @hidden
  37343. */
  37344. IS_REFLECTION_LINEAR: boolean;
  37345. /**
  37346. * If the refraction texture on this material is in linear color space
  37347. * @hidden
  37348. */
  37349. IS_REFRACTION_LINEAR: boolean;
  37350. EXPOSURE: boolean;
  37351. constructor();
  37352. setReflectionMode(modeToEnable: string): void;
  37353. }
  37354. /**
  37355. * This is the default material used in Babylon. It is the best trade off between quality
  37356. * and performances.
  37357. * @see http://doc.babylonjs.com/babylon101/materials
  37358. */
  37359. export class StandardMaterial extends PushMaterial {
  37360. private _diffuseTexture;
  37361. /**
  37362. * The basic texture of the material as viewed under a light.
  37363. */
  37364. diffuseTexture: Nullable<BaseTexture>;
  37365. private _ambientTexture;
  37366. /**
  37367. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37368. */
  37369. ambientTexture: Nullable<BaseTexture>;
  37370. private _opacityTexture;
  37371. /**
  37372. * Define the transparency of the material from a texture.
  37373. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37374. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37375. */
  37376. opacityTexture: Nullable<BaseTexture>;
  37377. private _reflectionTexture;
  37378. /**
  37379. * Define the texture used to display the reflection.
  37380. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37381. */
  37382. reflectionTexture: Nullable<BaseTexture>;
  37383. private _emissiveTexture;
  37384. /**
  37385. * Define texture of the material as if self lit.
  37386. * This will be mixed in the final result even in the absence of light.
  37387. */
  37388. emissiveTexture: Nullable<BaseTexture>;
  37389. private _specularTexture;
  37390. /**
  37391. * Define how the color and intensity of the highlight given by the light in the material.
  37392. */
  37393. specularTexture: Nullable<BaseTexture>;
  37394. private _bumpTexture;
  37395. /**
  37396. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37397. * 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.
  37398. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37399. */
  37400. bumpTexture: Nullable<BaseTexture>;
  37401. private _lightmapTexture;
  37402. /**
  37403. * Complex lighting can be computationally expensive to compute at runtime.
  37404. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37405. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37406. */
  37407. lightmapTexture: Nullable<BaseTexture>;
  37408. private _refractionTexture;
  37409. /**
  37410. * Define the texture used to display the refraction.
  37411. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37412. */
  37413. refractionTexture: Nullable<BaseTexture>;
  37414. /**
  37415. * The color of the material lit by the environmental background lighting.
  37416. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37417. */
  37418. ambientColor: Color3;
  37419. /**
  37420. * The basic color of the material as viewed under a light.
  37421. */
  37422. diffuseColor: Color3;
  37423. /**
  37424. * Define how the color and intensity of the highlight given by the light in the material.
  37425. */
  37426. specularColor: Color3;
  37427. /**
  37428. * Define the color of the material as if self lit.
  37429. * This will be mixed in the final result even in the absence of light.
  37430. */
  37431. emissiveColor: Color3;
  37432. /**
  37433. * Defines how sharp are the highlights in the material.
  37434. * The bigger the value the sharper giving a more glossy feeling to the result.
  37435. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37436. */
  37437. specularPower: number;
  37438. private _useAlphaFromDiffuseTexture;
  37439. /**
  37440. * Does the transparency come from the diffuse texture alpha channel.
  37441. */
  37442. useAlphaFromDiffuseTexture: boolean;
  37443. private _useEmissiveAsIllumination;
  37444. /**
  37445. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37446. */
  37447. useEmissiveAsIllumination: boolean;
  37448. private _linkEmissiveWithDiffuse;
  37449. /**
  37450. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37451. * the emissive level when the final color is close to one.
  37452. */
  37453. linkEmissiveWithDiffuse: boolean;
  37454. private _useSpecularOverAlpha;
  37455. /**
  37456. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37457. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37458. */
  37459. useSpecularOverAlpha: boolean;
  37460. private _useReflectionOverAlpha;
  37461. /**
  37462. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37463. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37464. */
  37465. useReflectionOverAlpha: boolean;
  37466. private _disableLighting;
  37467. /**
  37468. * Does lights from the scene impacts this material.
  37469. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37470. */
  37471. disableLighting: boolean;
  37472. private _useObjectSpaceNormalMap;
  37473. /**
  37474. * Allows using an object space normal map (instead of tangent space).
  37475. */
  37476. useObjectSpaceNormalMap: boolean;
  37477. private _useParallax;
  37478. /**
  37479. * Is parallax enabled or not.
  37480. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37481. */
  37482. useParallax: boolean;
  37483. private _useParallaxOcclusion;
  37484. /**
  37485. * Is parallax occlusion enabled or not.
  37486. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37487. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37488. */
  37489. useParallaxOcclusion: boolean;
  37490. /**
  37491. * 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.
  37492. */
  37493. parallaxScaleBias: number;
  37494. private _roughness;
  37495. /**
  37496. * Helps to define how blurry the reflections should appears in the material.
  37497. */
  37498. roughness: number;
  37499. /**
  37500. * In case of refraction, define the value of the indice of refraction.
  37501. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37502. */
  37503. indexOfRefraction: number;
  37504. /**
  37505. * Invert the refraction texture alongside the y axis.
  37506. * It can be useful with procedural textures or probe for instance.
  37507. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37508. */
  37509. invertRefractionY: boolean;
  37510. /**
  37511. * Defines the alpha limits in alpha test mode.
  37512. */
  37513. alphaCutOff: number;
  37514. private _useLightmapAsShadowmap;
  37515. /**
  37516. * In case of light mapping, define whether the map contains light or shadow informations.
  37517. */
  37518. useLightmapAsShadowmap: boolean;
  37519. private _diffuseFresnelParameters;
  37520. /**
  37521. * Define the diffuse fresnel parameters of the material.
  37522. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37523. */
  37524. diffuseFresnelParameters: FresnelParameters;
  37525. private _opacityFresnelParameters;
  37526. /**
  37527. * Define the opacity fresnel parameters of the material.
  37528. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37529. */
  37530. opacityFresnelParameters: FresnelParameters;
  37531. private _reflectionFresnelParameters;
  37532. /**
  37533. * Define the reflection fresnel parameters of the material.
  37534. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37535. */
  37536. reflectionFresnelParameters: FresnelParameters;
  37537. private _refractionFresnelParameters;
  37538. /**
  37539. * Define the refraction fresnel parameters of the material.
  37540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37541. */
  37542. refractionFresnelParameters: FresnelParameters;
  37543. private _emissiveFresnelParameters;
  37544. /**
  37545. * Define the emissive fresnel parameters of the material.
  37546. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37547. */
  37548. emissiveFresnelParameters: FresnelParameters;
  37549. private _useReflectionFresnelFromSpecular;
  37550. /**
  37551. * If true automatically deducts the fresnels values from the material specularity.
  37552. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37553. */
  37554. useReflectionFresnelFromSpecular: boolean;
  37555. private _useGlossinessFromSpecularMapAlpha;
  37556. /**
  37557. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  37558. */
  37559. useGlossinessFromSpecularMapAlpha: boolean;
  37560. private _maxSimultaneousLights;
  37561. /**
  37562. * Defines the maximum number of lights that can be used in the material
  37563. */
  37564. maxSimultaneousLights: number;
  37565. private _invertNormalMapX;
  37566. /**
  37567. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37568. */
  37569. invertNormalMapX: boolean;
  37570. private _invertNormalMapY;
  37571. /**
  37572. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37573. */
  37574. invertNormalMapY: boolean;
  37575. private _twoSidedLighting;
  37576. /**
  37577. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37578. */
  37579. twoSidedLighting: boolean;
  37580. /**
  37581. * Default configuration related to image processing available in the standard Material.
  37582. */
  37583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37584. /**
  37585. * Gets the image processing configuration used either in this material.
  37586. */
  37587. /**
  37588. * Sets the Default image processing configuration used either in the this material.
  37589. *
  37590. * If sets to null, the scene one is in use.
  37591. */
  37592. imageProcessingConfiguration: ImageProcessingConfiguration;
  37593. /**
  37594. * Keep track of the image processing observer to allow dispose and replace.
  37595. */
  37596. private _imageProcessingObserver;
  37597. /**
  37598. * Attaches a new image processing configuration to the Standard Material.
  37599. * @param configuration
  37600. */
  37601. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  37602. /**
  37603. * Gets wether the color curves effect is enabled.
  37604. */
  37605. /**
  37606. * Sets wether the color curves effect is enabled.
  37607. */
  37608. cameraColorCurvesEnabled: boolean;
  37609. /**
  37610. * Gets wether the color grading effect is enabled.
  37611. */
  37612. /**
  37613. * Gets wether the color grading effect is enabled.
  37614. */
  37615. cameraColorGradingEnabled: boolean;
  37616. /**
  37617. * Gets wether tonemapping is enabled or not.
  37618. */
  37619. /**
  37620. * Sets wether tonemapping is enabled or not
  37621. */
  37622. cameraToneMappingEnabled: boolean;
  37623. /**
  37624. * The camera exposure used on this material.
  37625. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37626. * This corresponds to a photographic exposure.
  37627. */
  37628. /**
  37629. * The camera exposure used on this material.
  37630. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  37631. * This corresponds to a photographic exposure.
  37632. */
  37633. cameraExposure: number;
  37634. /**
  37635. * Gets The camera contrast used on this material.
  37636. */
  37637. /**
  37638. * Sets The camera contrast used on this material.
  37639. */
  37640. cameraContrast: number;
  37641. /**
  37642. * Gets the Color Grading 2D Lookup Texture.
  37643. */
  37644. /**
  37645. * Sets the Color Grading 2D Lookup Texture.
  37646. */
  37647. cameraColorGradingTexture: Nullable<BaseTexture>;
  37648. /**
  37649. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37650. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37651. * 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;
  37652. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37653. */
  37654. /**
  37655. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  37656. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  37657. * 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;
  37658. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  37659. */
  37660. cameraColorCurves: Nullable<ColorCurves>;
  37661. /**
  37662. * Custom callback helping to override the default shader used in the material.
  37663. */
  37664. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  37665. protected _renderTargets: SmartArray<RenderTargetTexture>;
  37666. protected _worldViewProjectionMatrix: Matrix;
  37667. protected _globalAmbientColor: Color3;
  37668. protected _useLogarithmicDepth: boolean;
  37669. /**
  37670. * Instantiates a new standard material.
  37671. * This is the default material used in Babylon. It is the best trade off between quality
  37672. * and performances.
  37673. * @see http://doc.babylonjs.com/babylon101/materials
  37674. * @param name Define the name of the material in the scene
  37675. * @param scene Define the scene the material belong to
  37676. */
  37677. constructor(name: string, scene: Scene);
  37678. /**
  37679. * Gets a boolean indicating that current material needs to register RTT
  37680. */
  37681. readonly hasRenderTargetTextures: boolean;
  37682. /**
  37683. * Gets the current class name of the material e.g. "StandardMaterial"
  37684. * Mainly use in serialization.
  37685. * @returns the class name
  37686. */
  37687. getClassName(): string;
  37688. /**
  37689. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  37690. * You can try switching to logarithmic depth.
  37691. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  37692. */
  37693. useLogarithmicDepth: boolean;
  37694. /**
  37695. * Specifies if the material will require alpha blending
  37696. * @returns a boolean specifying if alpha blending is needed
  37697. */
  37698. needAlphaBlending(): boolean;
  37699. /**
  37700. * Specifies if this material should be rendered in alpha test mode
  37701. * @returns a boolean specifying if an alpha test is needed.
  37702. */
  37703. needAlphaTesting(): boolean;
  37704. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  37705. /**
  37706. * Get the texture used for alpha test purpose.
  37707. * @returns the diffuse texture in case of the standard material.
  37708. */
  37709. getAlphaTestTexture(): Nullable<BaseTexture>;
  37710. /**
  37711. * Get if the submesh is ready to be used and all its information available.
  37712. * Child classes can use it to update shaders
  37713. * @param mesh defines the mesh to check
  37714. * @param subMesh defines which submesh to check
  37715. * @param useInstances specifies that instances should be used
  37716. * @returns a boolean indicating that the submesh is ready or not
  37717. */
  37718. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  37719. /**
  37720. * Builds the material UBO layouts.
  37721. * Used internally during the effect preparation.
  37722. */
  37723. buildUniformLayout(): void;
  37724. /**
  37725. * Unbinds the material from the mesh
  37726. */
  37727. unbind(): void;
  37728. /**
  37729. * Binds the submesh to this material by preparing the effect and shader to draw
  37730. * @param world defines the world transformation matrix
  37731. * @param mesh defines the mesh containing the submesh
  37732. * @param subMesh defines the submesh to bind the material to
  37733. */
  37734. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  37735. /**
  37736. * Get the list of animatables in the material.
  37737. * @returns the list of animatables object used in the material
  37738. */
  37739. getAnimatables(): IAnimatable[];
  37740. /**
  37741. * Gets the active textures from the material
  37742. * @returns an array of textures
  37743. */
  37744. getActiveTextures(): BaseTexture[];
  37745. /**
  37746. * Specifies if the material uses a texture
  37747. * @param texture defines the texture to check against the material
  37748. * @returns a boolean specifying if the material uses the texture
  37749. */
  37750. hasTexture(texture: BaseTexture): boolean;
  37751. /**
  37752. * Disposes the material
  37753. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  37754. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  37755. */
  37756. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  37757. /**
  37758. * Makes a duplicate of the material, and gives it a new name
  37759. * @param name defines the new name for the duplicated material
  37760. * @returns the cloned material
  37761. */
  37762. clone(name: string): StandardMaterial;
  37763. /**
  37764. * Serializes this material in a JSON representation
  37765. * @returns the serialized material object
  37766. */
  37767. serialize(): any;
  37768. /**
  37769. * Creates a standard material from parsed material data
  37770. * @param source defines the JSON representation of the material
  37771. * @param scene defines the hosting scene
  37772. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  37773. * @returns a new standard material
  37774. */
  37775. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  37776. /**
  37777. * Are diffuse textures enabled in the application.
  37778. */
  37779. static DiffuseTextureEnabled: boolean;
  37780. /**
  37781. * Are ambient textures enabled in the application.
  37782. */
  37783. static AmbientTextureEnabled: boolean;
  37784. /**
  37785. * Are opacity textures enabled in the application.
  37786. */
  37787. static OpacityTextureEnabled: boolean;
  37788. /**
  37789. * Are reflection textures enabled in the application.
  37790. */
  37791. static ReflectionTextureEnabled: boolean;
  37792. /**
  37793. * Are emissive textures enabled in the application.
  37794. */
  37795. static EmissiveTextureEnabled: boolean;
  37796. /**
  37797. * Are specular textures enabled in the application.
  37798. */
  37799. static SpecularTextureEnabled: boolean;
  37800. /**
  37801. * Are bump textures enabled in the application.
  37802. */
  37803. static BumpTextureEnabled: boolean;
  37804. /**
  37805. * Are lightmap textures enabled in the application.
  37806. */
  37807. static LightmapTextureEnabled: boolean;
  37808. /**
  37809. * Are refraction textures enabled in the application.
  37810. */
  37811. static RefractionTextureEnabled: boolean;
  37812. /**
  37813. * Are color grading textures enabled in the application.
  37814. */
  37815. static ColorGradingTextureEnabled: boolean;
  37816. /**
  37817. * Are fresnels enabled in the application.
  37818. */
  37819. static FresnelEnabled: boolean;
  37820. }
  37821. }
  37822. declare module BABYLON {
  37823. /**
  37824. * A class extending Texture allowing drawing on a texture
  37825. * @see http://doc.babylonjs.com/how_to/dynamictexture
  37826. */
  37827. export class DynamicTexture extends Texture {
  37828. private _generateMipMaps;
  37829. private _canvas;
  37830. private _context;
  37831. private _engine;
  37832. /**
  37833. * Creates a DynamicTexture
  37834. * @param name defines the name of the texture
  37835. * @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
  37836. * @param scene defines the scene where you want the texture
  37837. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  37838. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  37839. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  37840. */
  37841. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  37842. /**
  37843. * Get the current class name of the texture useful for serialization or dynamic coding.
  37844. * @returns "DynamicTexture"
  37845. */
  37846. getClassName(): string;
  37847. /**
  37848. * Gets the current state of canRescale
  37849. */
  37850. readonly canRescale: boolean;
  37851. private _recreate;
  37852. /**
  37853. * Scales the texture
  37854. * @param ratio the scale factor to apply to both width and height
  37855. */
  37856. scale(ratio: number): void;
  37857. /**
  37858. * Resizes the texture
  37859. * @param width the new width
  37860. * @param height the new height
  37861. */
  37862. scaleTo(width: number, height: number): void;
  37863. /**
  37864. * Gets the context of the canvas used by the texture
  37865. * @returns the canvas context of the dynamic texture
  37866. */
  37867. getContext(): CanvasRenderingContext2D;
  37868. /**
  37869. * Clears the texture
  37870. */
  37871. clear(): void;
  37872. /**
  37873. * Updates the texture
  37874. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37875. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  37876. */
  37877. update(invertY?: boolean, premulAlpha?: boolean): void;
  37878. /**
  37879. * Draws text onto the texture
  37880. * @param text defines the text to be drawn
  37881. * @param x defines the placement of the text from the left
  37882. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  37883. * @param font defines the font to be used with font-style, font-size, font-name
  37884. * @param color defines the color used for the text
  37885. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  37886. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  37887. * @param update defines whether texture is immediately update (default is true)
  37888. */
  37889. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  37890. /**
  37891. * Clones the texture
  37892. * @returns the clone of the texture.
  37893. */
  37894. clone(): DynamicTexture;
  37895. /**
  37896. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  37897. * @returns a serialized dynamic texture object
  37898. */
  37899. serialize(): any;
  37900. /** @hidden */
  37901. _rebuild(): void;
  37902. }
  37903. }
  37904. declare module BABYLON {
  37905. /** @hidden */
  37906. export var imageProcessingPixelShader: {
  37907. name: string;
  37908. shader: string;
  37909. };
  37910. }
  37911. declare module BABYLON {
  37912. /**
  37913. * ImageProcessingPostProcess
  37914. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  37915. */
  37916. export class ImageProcessingPostProcess extends PostProcess {
  37917. /**
  37918. * Default configuration related to image processing available in the PBR Material.
  37919. */
  37920. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37921. /**
  37922. * Gets the image processing configuration used either in this material.
  37923. */
  37924. /**
  37925. * Sets the Default image processing configuration used either in the this material.
  37926. *
  37927. * If sets to null, the scene one is in use.
  37928. */
  37929. imageProcessingConfiguration: ImageProcessingConfiguration;
  37930. /**
  37931. * Keep track of the image processing observer to allow dispose and replace.
  37932. */
  37933. private _imageProcessingObserver;
  37934. /**
  37935. * Attaches a new image processing configuration to the PBR Material.
  37936. * @param configuration
  37937. */
  37938. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  37939. /**
  37940. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37941. */
  37942. /**
  37943. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  37944. */
  37945. colorCurves: Nullable<ColorCurves>;
  37946. /**
  37947. * Gets wether the color curves effect is enabled.
  37948. */
  37949. /**
  37950. * Sets wether the color curves effect is enabled.
  37951. */
  37952. colorCurvesEnabled: boolean;
  37953. /**
  37954. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37955. */
  37956. /**
  37957. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  37958. */
  37959. colorGradingTexture: Nullable<BaseTexture>;
  37960. /**
  37961. * Gets wether the color grading effect is enabled.
  37962. */
  37963. /**
  37964. * Gets wether the color grading effect is enabled.
  37965. */
  37966. colorGradingEnabled: boolean;
  37967. /**
  37968. * Gets exposure used in the effect.
  37969. */
  37970. /**
  37971. * Sets exposure used in the effect.
  37972. */
  37973. exposure: number;
  37974. /**
  37975. * Gets wether tonemapping is enabled or not.
  37976. */
  37977. /**
  37978. * Sets wether tonemapping is enabled or not
  37979. */
  37980. toneMappingEnabled: boolean;
  37981. /**
  37982. * Gets contrast used in the effect.
  37983. */
  37984. /**
  37985. * Sets contrast used in the effect.
  37986. */
  37987. contrast: number;
  37988. /**
  37989. * Gets Vignette stretch size.
  37990. */
  37991. /**
  37992. * Sets Vignette stretch size.
  37993. */
  37994. vignetteStretch: number;
  37995. /**
  37996. * Gets Vignette centre X Offset.
  37997. */
  37998. /**
  37999. * Sets Vignette centre X Offset.
  38000. */
  38001. vignetteCentreX: number;
  38002. /**
  38003. * Gets Vignette centre Y Offset.
  38004. */
  38005. /**
  38006. * Sets Vignette centre Y Offset.
  38007. */
  38008. vignetteCentreY: number;
  38009. /**
  38010. * Gets Vignette weight or intensity of the vignette effect.
  38011. */
  38012. /**
  38013. * Sets Vignette weight or intensity of the vignette effect.
  38014. */
  38015. vignetteWeight: number;
  38016. /**
  38017. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38018. * if vignetteEnabled is set to true.
  38019. */
  38020. /**
  38021. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38022. * if vignetteEnabled is set to true.
  38023. */
  38024. vignetteColor: Color4;
  38025. /**
  38026. * Gets Camera field of view used by the Vignette effect.
  38027. */
  38028. /**
  38029. * Sets Camera field of view used by the Vignette effect.
  38030. */
  38031. vignetteCameraFov: number;
  38032. /**
  38033. * Gets the vignette blend mode allowing different kind of effect.
  38034. */
  38035. /**
  38036. * Sets the vignette blend mode allowing different kind of effect.
  38037. */
  38038. vignetteBlendMode: number;
  38039. /**
  38040. * Gets wether the vignette effect is enabled.
  38041. */
  38042. /**
  38043. * Sets wether the vignette effect is enabled.
  38044. */
  38045. vignetteEnabled: boolean;
  38046. private _fromLinearSpace;
  38047. /**
  38048. * Gets wether the input of the processing is in Gamma or Linear Space.
  38049. */
  38050. /**
  38051. * Sets wether the input of the processing is in Gamma or Linear Space.
  38052. */
  38053. fromLinearSpace: boolean;
  38054. /**
  38055. * Defines cache preventing GC.
  38056. */
  38057. private _defines;
  38058. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38059. /**
  38060. * "ImageProcessingPostProcess"
  38061. * @returns "ImageProcessingPostProcess"
  38062. */
  38063. getClassName(): string;
  38064. protected _updateParameters(): void;
  38065. dispose(camera?: Camera): void;
  38066. }
  38067. }
  38068. declare module BABYLON {
  38069. /**
  38070. * Class containing static functions to help procedurally build meshes
  38071. */
  38072. export class GroundBuilder {
  38073. /**
  38074. * Creates a ground mesh
  38075. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38076. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38078. * @param name defines the name of the mesh
  38079. * @param options defines the options used to create the mesh
  38080. * @param scene defines the hosting scene
  38081. * @returns the ground mesh
  38082. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38083. */
  38084. static CreateGround(name: string, options: {
  38085. width?: number;
  38086. height?: number;
  38087. subdivisions?: number;
  38088. subdivisionsX?: number;
  38089. subdivisionsY?: number;
  38090. updatable?: boolean;
  38091. }, scene: any): Mesh;
  38092. /**
  38093. * Creates a tiled ground mesh
  38094. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38095. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38096. * * 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
  38097. * * 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
  38098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38099. * @param name defines the name of the mesh
  38100. * @param options defines the options used to create the mesh
  38101. * @param scene defines the hosting scene
  38102. * @returns the tiled ground mesh
  38103. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38104. */
  38105. static CreateTiledGround(name: string, options: {
  38106. xmin: number;
  38107. zmin: number;
  38108. xmax: number;
  38109. zmax: number;
  38110. subdivisions?: {
  38111. w: number;
  38112. h: number;
  38113. };
  38114. precision?: {
  38115. w: number;
  38116. h: number;
  38117. };
  38118. updatable?: boolean;
  38119. }, scene: Scene): Mesh;
  38120. /**
  38121. * Creates a ground mesh from a height map
  38122. * * The parameter `url` sets the URL of the height map image resource.
  38123. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38124. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38125. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38126. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38127. * * 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.
  38128. * * 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).
  38129. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38131. * @param name defines the name of the mesh
  38132. * @param url defines the url to the height map
  38133. * @param options defines the options used to create the mesh
  38134. * @param scene defines the hosting scene
  38135. * @returns the ground mesh
  38136. * @see https://doc.babylonjs.com/babylon101/height_map
  38137. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38138. */
  38139. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38140. width?: number;
  38141. height?: number;
  38142. subdivisions?: number;
  38143. minHeight?: number;
  38144. maxHeight?: number;
  38145. colorFilter?: Color3;
  38146. alphaFilter?: number;
  38147. updatable?: boolean;
  38148. onReady?: (mesh: GroundMesh) => void;
  38149. }, scene: Scene): GroundMesh;
  38150. }
  38151. }
  38152. declare module BABYLON {
  38153. /**
  38154. * Class containing static functions to help procedurally build meshes
  38155. */
  38156. export class TorusBuilder {
  38157. /**
  38158. * Creates a torus mesh
  38159. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38160. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38161. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38162. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38163. * * 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
  38164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38165. * @param name defines the name of the mesh
  38166. * @param options defines the options used to create the mesh
  38167. * @param scene defines the hosting scene
  38168. * @returns the torus mesh
  38169. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38170. */
  38171. static CreateTorus(name: string, options: {
  38172. diameter?: number;
  38173. thickness?: number;
  38174. tessellation?: number;
  38175. updatable?: boolean;
  38176. sideOrientation?: number;
  38177. frontUVs?: Vector4;
  38178. backUVs?: Vector4;
  38179. }, scene: any): Mesh;
  38180. }
  38181. }
  38182. declare module BABYLON {
  38183. /**
  38184. * Class containing static functions to help procedurally build meshes
  38185. */
  38186. export class CylinderBuilder {
  38187. /**
  38188. * Creates a cylinder or a cone mesh
  38189. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38190. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38191. * * 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.
  38192. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38193. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38194. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38195. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38196. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38197. * * 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).
  38198. * * 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
  38199. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38200. * * 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
  38201. * * 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.
  38202. * * If `enclose` is false, a ring surface is one element.
  38203. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38204. * * 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
  38205. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38206. * * 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
  38207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38208. * @param name defines the name of the mesh
  38209. * @param options defines the options used to create the mesh
  38210. * @param scene defines the hosting scene
  38211. * @returns the cylinder mesh
  38212. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38213. */
  38214. static CreateCylinder(name: string, options: {
  38215. height?: number;
  38216. diameterTop?: number;
  38217. diameterBottom?: number;
  38218. diameter?: number;
  38219. tessellation?: number;
  38220. subdivisions?: number;
  38221. arc?: number;
  38222. faceColors?: Color4[];
  38223. faceUV?: Vector4[];
  38224. updatable?: boolean;
  38225. hasRings?: boolean;
  38226. enclose?: boolean;
  38227. sideOrientation?: number;
  38228. frontUVs?: Vector4;
  38229. backUVs?: Vector4;
  38230. }, scene: any): Mesh;
  38231. }
  38232. }
  38233. declare module BABYLON {
  38234. /**
  38235. * Manager for handling gamepads
  38236. */
  38237. export class GamepadManager {
  38238. private _scene?;
  38239. private _babylonGamepads;
  38240. private _oneGamepadConnected;
  38241. /** @hidden */
  38242. _isMonitoring: boolean;
  38243. private _gamepadEventSupported;
  38244. private _gamepadSupport;
  38245. /**
  38246. * observable to be triggered when the gamepad controller has been connected
  38247. */
  38248. onGamepadConnectedObservable: Observable<Gamepad>;
  38249. /**
  38250. * observable to be triggered when the gamepad controller has been disconnected
  38251. */
  38252. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38253. private _onGamepadConnectedEvent;
  38254. private _onGamepadDisconnectedEvent;
  38255. /**
  38256. * Initializes the gamepad manager
  38257. * @param _scene BabylonJS scene
  38258. */
  38259. constructor(_scene?: Scene | undefined);
  38260. /**
  38261. * The gamepads in the game pad manager
  38262. */
  38263. readonly gamepads: Gamepad[];
  38264. /**
  38265. * Get the gamepad controllers based on type
  38266. * @param type The type of gamepad controller
  38267. * @returns Nullable gamepad
  38268. */
  38269. getGamepadByType(type?: number): Nullable<Gamepad>;
  38270. /**
  38271. * Disposes the gamepad manager
  38272. */
  38273. dispose(): void;
  38274. private _addNewGamepad;
  38275. private _startMonitoringGamepads;
  38276. private _stopMonitoringGamepads;
  38277. /** @hidden */
  38278. _checkGamepadsStatus(): void;
  38279. private _updateGamepadObjects;
  38280. }
  38281. }
  38282. declare module BABYLON {
  38283. interface Scene {
  38284. /** @hidden */
  38285. _gamepadManager: Nullable<GamepadManager>;
  38286. /**
  38287. * Gets the gamepad manager associated with the scene
  38288. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38289. */
  38290. gamepadManager: GamepadManager;
  38291. }
  38292. /**
  38293. * Interface representing a free camera inputs manager
  38294. */
  38295. interface FreeCameraInputsManager {
  38296. /**
  38297. * Adds gamepad input support to the FreeCameraInputsManager.
  38298. * @returns the FreeCameraInputsManager
  38299. */
  38300. addGamepad(): FreeCameraInputsManager;
  38301. }
  38302. /**
  38303. * Interface representing an arc rotate camera inputs manager
  38304. */
  38305. interface ArcRotateCameraInputsManager {
  38306. /**
  38307. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38308. * @returns the camera inputs manager
  38309. */
  38310. addGamepad(): ArcRotateCameraInputsManager;
  38311. }
  38312. /**
  38313. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38314. */
  38315. export class GamepadSystemSceneComponent implements ISceneComponent {
  38316. /**
  38317. * The component name helpfull to identify the component in the list of scene components.
  38318. */
  38319. readonly name: string;
  38320. /**
  38321. * The scene the component belongs to.
  38322. */
  38323. scene: Scene;
  38324. /**
  38325. * Creates a new instance of the component for the given scene
  38326. * @param scene Defines the scene to register the component in
  38327. */
  38328. constructor(scene: Scene);
  38329. /**
  38330. * Registers the component in a given scene
  38331. */
  38332. register(): void;
  38333. /**
  38334. * Rebuilds the elements related to this component in case of
  38335. * context lost for instance.
  38336. */
  38337. rebuild(): void;
  38338. /**
  38339. * Disposes the component and the associated ressources
  38340. */
  38341. dispose(): void;
  38342. private _beforeCameraUpdate;
  38343. }
  38344. }
  38345. declare module BABYLON {
  38346. /**
  38347. * Options to modify the vr teleportation behavior.
  38348. */
  38349. export interface VRTeleportationOptions {
  38350. /**
  38351. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38352. */
  38353. floorMeshName?: string;
  38354. /**
  38355. * A list of meshes to be used as the teleportation floor. (default: empty)
  38356. */
  38357. floorMeshes?: Mesh[];
  38358. }
  38359. /**
  38360. * Options to modify the vr experience helper's behavior.
  38361. */
  38362. export interface VRExperienceHelperOptions extends WebVROptions {
  38363. /**
  38364. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38365. */
  38366. createDeviceOrientationCamera?: boolean;
  38367. /**
  38368. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38369. */
  38370. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38371. /**
  38372. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38373. */
  38374. laserToggle?: boolean;
  38375. /**
  38376. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38377. */
  38378. floorMeshes?: Mesh[];
  38379. /**
  38380. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38381. */
  38382. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38383. }
  38384. /**
  38385. * Helps to quickly add VR support to an existing scene.
  38386. * See http://doc.babylonjs.com/how_to/webvr_helper
  38387. */
  38388. export class VRExperienceHelper {
  38389. /** Options to modify the vr experience helper's behavior. */
  38390. webVROptions: VRExperienceHelperOptions;
  38391. private _scene;
  38392. private _position;
  38393. private _btnVR;
  38394. private _btnVRDisplayed;
  38395. private _webVRsupported;
  38396. private _webVRready;
  38397. private _webVRrequesting;
  38398. private _webVRpresenting;
  38399. private _hasEnteredVR;
  38400. private _fullscreenVRpresenting;
  38401. private _canvas;
  38402. private _webVRCamera;
  38403. private _vrDeviceOrientationCamera;
  38404. private _deviceOrientationCamera;
  38405. private _existingCamera;
  38406. private _onKeyDown;
  38407. private _onVrDisplayPresentChange;
  38408. private _onVRDisplayChanged;
  38409. private _onVRRequestPresentStart;
  38410. private _onVRRequestPresentComplete;
  38411. /**
  38412. * Observable raised when entering VR.
  38413. */
  38414. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38415. /**
  38416. * Observable raised when exiting VR.
  38417. */
  38418. onExitingVRObservable: Observable<VRExperienceHelper>;
  38419. /**
  38420. * Observable raised when controller mesh is loaded.
  38421. */
  38422. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38423. /** Return this.onEnteringVRObservable
  38424. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38425. */
  38426. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38427. /** Return this.onExitingVRObservable
  38428. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38429. */
  38430. readonly onExitingVR: Observable<VRExperienceHelper>;
  38431. /** Return this.onControllerMeshLoadedObservable
  38432. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38433. */
  38434. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38435. private _rayLength;
  38436. private _useCustomVRButton;
  38437. private _teleportationRequested;
  38438. private _teleportActive;
  38439. private _floorMeshName;
  38440. private _floorMeshesCollection;
  38441. private _rotationAllowed;
  38442. private _teleportBackwardsVector;
  38443. private _teleportationTarget;
  38444. private _isDefaultTeleportationTarget;
  38445. private _postProcessMove;
  38446. private _teleportationFillColor;
  38447. private _teleportationBorderColor;
  38448. private _rotationAngle;
  38449. private _haloCenter;
  38450. private _cameraGazer;
  38451. private _padSensibilityUp;
  38452. private _padSensibilityDown;
  38453. private _leftController;
  38454. private _rightController;
  38455. /**
  38456. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38457. */
  38458. onNewMeshSelected: Observable<AbstractMesh>;
  38459. /**
  38460. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38461. */
  38462. onNewMeshPicked: Observable<PickingInfo>;
  38463. private _circleEase;
  38464. /**
  38465. * Observable raised before camera teleportation
  38466. */
  38467. onBeforeCameraTeleport: Observable<Vector3>;
  38468. /**
  38469. * Observable raised after camera teleportation
  38470. */
  38471. onAfterCameraTeleport: Observable<Vector3>;
  38472. /**
  38473. * Observable raised when current selected mesh gets unselected
  38474. */
  38475. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38476. private _raySelectionPredicate;
  38477. /**
  38478. * To be optionaly changed by user to define custom ray selection
  38479. */
  38480. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38481. /**
  38482. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38483. */
  38484. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38485. /**
  38486. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38487. */
  38488. teleportationEnabled: boolean;
  38489. private _defaultHeight;
  38490. private _teleportationInitialized;
  38491. private _interactionsEnabled;
  38492. private _interactionsRequested;
  38493. private _displayGaze;
  38494. private _displayLaserPointer;
  38495. /**
  38496. * The mesh used to display where the user is going to teleport.
  38497. */
  38498. /**
  38499. * Sets the mesh to be used to display where the user is going to teleport.
  38500. */
  38501. teleportationTarget: Mesh;
  38502. /**
  38503. * 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
  38504. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38505. * See http://doc.babylonjs.com/resources/baking_transformations
  38506. */
  38507. gazeTrackerMesh: Mesh;
  38508. /**
  38509. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38510. */
  38511. updateGazeTrackerScale: boolean;
  38512. /**
  38513. * If the gaze trackers color should be updated when selecting meshes
  38514. */
  38515. updateGazeTrackerColor: boolean;
  38516. /**
  38517. * The gaze tracking mesh corresponding to the left controller
  38518. */
  38519. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38520. /**
  38521. * The gaze tracking mesh corresponding to the right controller
  38522. */
  38523. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38524. /**
  38525. * If the ray of the gaze should be displayed.
  38526. */
  38527. /**
  38528. * Sets if the ray of the gaze should be displayed.
  38529. */
  38530. displayGaze: boolean;
  38531. /**
  38532. * If the ray of the LaserPointer should be displayed.
  38533. */
  38534. /**
  38535. * Sets if the ray of the LaserPointer should be displayed.
  38536. */
  38537. displayLaserPointer: boolean;
  38538. /**
  38539. * The deviceOrientationCamera used as the camera when not in VR.
  38540. */
  38541. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38542. /**
  38543. * Based on the current WebVR support, returns the current VR camera used.
  38544. */
  38545. readonly currentVRCamera: Nullable<Camera>;
  38546. /**
  38547. * The webVRCamera which is used when in VR.
  38548. */
  38549. readonly webVRCamera: WebVRFreeCamera;
  38550. /**
  38551. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38552. */
  38553. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38554. private readonly _teleportationRequestInitiated;
  38555. /**
  38556. * Defines wether or not Pointer lock should be requested when switching to
  38557. * full screen.
  38558. */
  38559. requestPointerLockOnFullScreen: boolean;
  38560. /**
  38561. * Instantiates a VRExperienceHelper.
  38562. * Helps to quickly add VR support to an existing scene.
  38563. * @param scene The scene the VRExperienceHelper belongs to.
  38564. * @param webVROptions Options to modify the vr experience helper's behavior.
  38565. */
  38566. constructor(scene: Scene,
  38567. /** Options to modify the vr experience helper's behavior. */
  38568. webVROptions?: VRExperienceHelperOptions);
  38569. private _onDefaultMeshLoaded;
  38570. private _onResize;
  38571. private _onFullscreenChange;
  38572. /**
  38573. * Gets a value indicating if we are currently in VR mode.
  38574. */
  38575. readonly isInVRMode: boolean;
  38576. private onVrDisplayPresentChange;
  38577. private onVRDisplayChanged;
  38578. private moveButtonToBottomRight;
  38579. private displayVRButton;
  38580. private updateButtonVisibility;
  38581. private _cachedAngularSensibility;
  38582. /**
  38583. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  38584. * Otherwise, will use the fullscreen API.
  38585. */
  38586. enterVR(): void;
  38587. /**
  38588. * Attempt to exit VR, or fullscreen.
  38589. */
  38590. exitVR(): void;
  38591. /**
  38592. * The position of the vr experience helper.
  38593. */
  38594. /**
  38595. * Sets the position of the vr experience helper.
  38596. */
  38597. position: Vector3;
  38598. /**
  38599. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  38600. */
  38601. enableInteractions(): void;
  38602. private readonly _noControllerIsActive;
  38603. private beforeRender;
  38604. private _isTeleportationFloor;
  38605. /**
  38606. * Adds a floor mesh to be used for teleportation.
  38607. * @param floorMesh the mesh to be used for teleportation.
  38608. */
  38609. addFloorMesh(floorMesh: Mesh): void;
  38610. /**
  38611. * Removes a floor mesh from being used for teleportation.
  38612. * @param floorMesh the mesh to be removed.
  38613. */
  38614. removeFloorMesh(floorMesh: Mesh): void;
  38615. /**
  38616. * Enables interactions and teleportation using the VR controllers and gaze.
  38617. * @param vrTeleportationOptions options to modify teleportation behavior.
  38618. */
  38619. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  38620. private _onNewGamepadConnected;
  38621. private _tryEnableInteractionOnController;
  38622. private _onNewGamepadDisconnected;
  38623. private _enableInteractionOnController;
  38624. private _checkTeleportWithRay;
  38625. private _checkRotate;
  38626. private _checkTeleportBackwards;
  38627. private _enableTeleportationOnController;
  38628. private _createTeleportationCircles;
  38629. private _displayTeleportationTarget;
  38630. private _hideTeleportationTarget;
  38631. private _rotateCamera;
  38632. private _moveTeleportationSelectorTo;
  38633. private _workingVector;
  38634. private _workingQuaternion;
  38635. private _workingMatrix;
  38636. /**
  38637. * Teleports the users feet to the desired location
  38638. * @param location The location where the user's feet should be placed
  38639. */
  38640. teleportCamera(location: Vector3): void;
  38641. private _convertNormalToDirectionOfRay;
  38642. private _castRayAndSelectObject;
  38643. private _notifySelectedMeshUnselected;
  38644. /**
  38645. * Sets the color of the laser ray from the vr controllers.
  38646. * @param color new color for the ray.
  38647. */
  38648. changeLaserColor(color: Color3): void;
  38649. /**
  38650. * Sets the color of the ray from the vr headsets gaze.
  38651. * @param color new color for the ray.
  38652. */
  38653. changeGazeColor(color: Color3): void;
  38654. /**
  38655. * Exits VR and disposes of the vr experience helper
  38656. */
  38657. dispose(): void;
  38658. /**
  38659. * Gets the name of the VRExperienceHelper class
  38660. * @returns "VRExperienceHelper"
  38661. */
  38662. getClassName(): string;
  38663. }
  38664. }
  38665. declare module BABYLON {
  38666. /**
  38667. * Manages an XRSession
  38668. * @see https://doc.babylonjs.com/how_to/webxr
  38669. */
  38670. export class WebXRSessionManager implements IDisposable {
  38671. private scene;
  38672. /**
  38673. * Fires every time a new xrFrame arrives which can be used to update the camera
  38674. */
  38675. onXRFrameObservable: Observable<any>;
  38676. /**
  38677. * Fires when the xr session is ended either by the device or manually done
  38678. */
  38679. onXRSessionEnded: Observable<any>;
  38680. /** @hidden */
  38681. _xrSession: XRSession;
  38682. /** @hidden */
  38683. _frameOfReference: XRFrameOfReference;
  38684. /** @hidden */
  38685. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  38686. /** @hidden */
  38687. _currentXRFrame: Nullable<XRFrame>;
  38688. private _xrNavigator;
  38689. private _xrDevice;
  38690. private _tmpMatrix;
  38691. /**
  38692. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  38693. * @param scene The scene which the session should be created for
  38694. */
  38695. constructor(scene: Scene);
  38696. /**
  38697. * Initializes the manager
  38698. * After initialization enterXR can be called to start an XR session
  38699. * @returns Promise which resolves after it is initialized
  38700. */
  38701. initializeAsync(): Promise<void>;
  38702. /**
  38703. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  38704. * @param sessionCreationOptions xr options to create the session with
  38705. * @param frameOfReferenceType option to configure how the xr pose is expressed
  38706. * @returns Promise which resolves after it enters XR
  38707. */
  38708. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  38709. /**
  38710. * Stops the xrSession and restores the renderloop
  38711. * @returns Promise which resolves after it exits XR
  38712. */
  38713. exitXRAsync(): Promise<void>;
  38714. /**
  38715. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38716. * @param ray ray to cast into the environment
  38717. * @returns Promise which resolves with a collision point in the environment if it exists
  38718. */
  38719. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38720. /**
  38721. * Checks if a session would be supported for the creation options specified
  38722. * @param options creation options to check if they are supported
  38723. * @returns true if supported
  38724. */
  38725. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38726. /**
  38727. * @hidden
  38728. * Converts the render layer of xrSession to a render target
  38729. * @param session session to create render target for
  38730. * @param scene scene the new render target should be created for
  38731. */
  38732. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  38733. /**
  38734. * Disposes of the session manager
  38735. */
  38736. dispose(): void;
  38737. }
  38738. }
  38739. declare module BABYLON {
  38740. /**
  38741. * WebXR Camera which holds the views for the xrSession
  38742. * @see https://doc.babylonjs.com/how_to/webxr
  38743. */
  38744. export class WebXRCamera extends FreeCamera {
  38745. private static _TmpMatrix;
  38746. /**
  38747. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  38748. * @param name the name of the camera
  38749. * @param scene the scene to add the camera to
  38750. */
  38751. constructor(name: string, scene: Scene);
  38752. private _updateNumberOfRigCameras;
  38753. /** @hidden */
  38754. _updateForDualEyeDebugging(pupilDistance?: number): void;
  38755. /**
  38756. * Updates the cameras position from the current pose information of the XR session
  38757. * @param xrSessionManager the session containing pose information
  38758. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  38759. */
  38760. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  38761. }
  38762. }
  38763. declare module BABYLON {
  38764. /**
  38765. * States of the webXR experience
  38766. */
  38767. export enum WebXRState {
  38768. /**
  38769. * Transitioning to being in XR mode
  38770. */
  38771. ENTERING_XR = 0,
  38772. /**
  38773. * Transitioning to non XR mode
  38774. */
  38775. EXITING_XR = 1,
  38776. /**
  38777. * In XR mode and presenting
  38778. */
  38779. IN_XR = 2,
  38780. /**
  38781. * Not entered XR mode
  38782. */
  38783. NOT_IN_XR = 3
  38784. }
  38785. /**
  38786. * Helper class used to enable XR
  38787. * @see https://doc.babylonjs.com/how_to/webxr
  38788. */
  38789. export class WebXRExperienceHelper implements IDisposable {
  38790. private scene;
  38791. /**
  38792. * 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
  38793. */
  38794. container: AbstractMesh;
  38795. /**
  38796. * Camera used to render xr content
  38797. */
  38798. camera: WebXRCamera;
  38799. /**
  38800. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  38801. */
  38802. state: WebXRState;
  38803. private _setState;
  38804. private static _TmpVector;
  38805. /**
  38806. * Fires when the state of the experience helper has changed
  38807. */
  38808. onStateChangedObservable: Observable<WebXRState>;
  38809. /** @hidden */
  38810. _sessionManager: WebXRSessionManager;
  38811. private _nonVRCamera;
  38812. private _originalSceneAutoClear;
  38813. private _supported;
  38814. /**
  38815. * Creates the experience helper
  38816. * @param scene the scene to attach the experience helper to
  38817. * @returns a promise for the experience helper
  38818. */
  38819. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  38820. /**
  38821. * Creates a WebXRExperienceHelper
  38822. * @param scene The scene the helper should be created in
  38823. */
  38824. private constructor();
  38825. /**
  38826. * Exits XR mode and returns the scene to its original state
  38827. * @returns promise that resolves after xr mode has exited
  38828. */
  38829. exitXRAsync(): Promise<void>;
  38830. /**
  38831. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  38832. * @param sessionCreationOptions options for the XR session
  38833. * @param frameOfReference frame of reference of the XR session
  38834. * @returns promise that resolves after xr mode has entered
  38835. */
  38836. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  38837. /**
  38838. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  38839. * @param ray ray to cast into the environment
  38840. * @returns Promise which resolves with a collision point in the environment if it exists
  38841. */
  38842. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  38843. /**
  38844. * Updates the global position of the camera by moving the camera's container
  38845. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  38846. * @param position The desired global position of the camera
  38847. */
  38848. setPositionOfCameraUsingContainer(position: Vector3): void;
  38849. /**
  38850. * Rotates the xr camera by rotating the camera's container around the camera's position
  38851. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  38852. * @param rotation the desired quaternion rotation to apply to the camera
  38853. */
  38854. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  38855. /**
  38856. * Checks if the creation options are supported by the xr session
  38857. * @param options creation options
  38858. * @returns true if supported
  38859. */
  38860. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  38861. /**
  38862. * Disposes of the experience helper
  38863. */
  38864. dispose(): void;
  38865. }
  38866. }
  38867. declare module BABYLON {
  38868. /**
  38869. * Button which can be used to enter a different mode of XR
  38870. */
  38871. export class WebXREnterExitUIButton {
  38872. /** button element */
  38873. element: HTMLElement;
  38874. /** XR initialization options for the button */
  38875. initializationOptions: XRSessionCreationOptions;
  38876. /**
  38877. * Creates a WebXREnterExitUIButton
  38878. * @param element button element
  38879. * @param initializationOptions XR initialization options for the button
  38880. */
  38881. constructor(
  38882. /** button element */
  38883. element: HTMLElement,
  38884. /** XR initialization options for the button */
  38885. initializationOptions: XRSessionCreationOptions);
  38886. /**
  38887. * Overwritable function which can be used to update the button's visuals when the state changes
  38888. * @param activeButton the current active button in the UI
  38889. */
  38890. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  38891. }
  38892. /**
  38893. * Options to create the webXR UI
  38894. */
  38895. export class WebXREnterExitUIOptions {
  38896. /**
  38897. * Context to enter xr with
  38898. */
  38899. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  38900. /**
  38901. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  38902. */
  38903. customButtons?: Array<WebXREnterExitUIButton>;
  38904. }
  38905. /**
  38906. * UI to allow the user to enter/exit XR mode
  38907. */
  38908. export class WebXREnterExitUI implements IDisposable {
  38909. private scene;
  38910. private _overlay;
  38911. private _buttons;
  38912. private _activeButton;
  38913. /**
  38914. * Fired every time the active button is changed.
  38915. *
  38916. * When xr is entered via a button that launches xr that button will be the callback parameter
  38917. *
  38918. * When exiting xr the callback parameter will be null)
  38919. */
  38920. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  38921. /**
  38922. * Creates UI to allow the user to enter/exit XR mode
  38923. * @param scene the scene to add the ui to
  38924. * @param helper the xr experience helper to enter/exit xr with
  38925. * @param options options to configure the UI
  38926. * @returns the created ui
  38927. */
  38928. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  38929. private constructor();
  38930. private _updateButtons;
  38931. /**
  38932. * Disposes of the object
  38933. */
  38934. dispose(): void;
  38935. }
  38936. }
  38937. declare module BABYLON {
  38938. /**
  38939. * Represents an XR input
  38940. */
  38941. export class WebXRController {
  38942. /**
  38943. * 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
  38944. */
  38945. grip?: AbstractMesh;
  38946. /**
  38947. * Pointer which can be used to select objects or attach a visible laser to
  38948. */
  38949. pointer: AbstractMesh;
  38950. /**
  38951. * Creates the controller
  38952. * @see https://doc.babylonjs.com/how_to/webxr
  38953. * @param scene the scene which the controller should be associated to
  38954. */
  38955. constructor(scene: Scene);
  38956. /**
  38957. * Disposes of the object
  38958. */
  38959. dispose(): void;
  38960. }
  38961. /**
  38962. * XR input used to track XR inputs such as controllers/rays
  38963. */
  38964. export class WebXRInput implements IDisposable {
  38965. private helper;
  38966. /**
  38967. * XR controllers being tracked
  38968. */
  38969. controllers: Array<WebXRController>;
  38970. private _tmpMatrix;
  38971. private _frameObserver;
  38972. /**
  38973. * Initializes the WebXRInput
  38974. * @param helper experience helper which the input should be created for
  38975. */
  38976. constructor(helper: WebXRExperienceHelper);
  38977. /**
  38978. * Disposes of the object
  38979. */
  38980. dispose(): void;
  38981. }
  38982. }
  38983. declare module BABYLON {
  38984. /**
  38985. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  38986. */
  38987. export class WebXRManagedOutputCanvas implements IDisposable {
  38988. private _canvas;
  38989. /**
  38990. * xrpresent context of the canvas which can be used to display/mirror xr content
  38991. */
  38992. canvasContext: Nullable<WebGLRenderingContext>;
  38993. /**
  38994. * Initializes the canvas to be added/removed upon entering/exiting xr
  38995. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  38996. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  38997. */
  38998. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  38999. /**
  39000. * Disposes of the object
  39001. */
  39002. dispose(): void;
  39003. private _setManagedOutputCanvas;
  39004. private _addCanvas;
  39005. private _removeCanvas;
  39006. }
  39007. }
  39008. declare module BABYLON {
  39009. /**
  39010. * Contains an array of blocks representing the octree
  39011. */
  39012. export interface IOctreeContainer<T> {
  39013. /**
  39014. * Blocks within the octree
  39015. */
  39016. blocks: Array<OctreeBlock<T>>;
  39017. }
  39018. /**
  39019. * Class used to store a cell in an octree
  39020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39021. */
  39022. export class OctreeBlock<T> {
  39023. /**
  39024. * Gets the content of the current block
  39025. */
  39026. entries: T[];
  39027. /**
  39028. * Gets the list of block children
  39029. */
  39030. blocks: Array<OctreeBlock<T>>;
  39031. private _depth;
  39032. private _maxDepth;
  39033. private _capacity;
  39034. private _minPoint;
  39035. private _maxPoint;
  39036. private _boundingVectors;
  39037. private _creationFunc;
  39038. /**
  39039. * Creates a new block
  39040. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39041. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39042. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39043. * @param depth defines the current depth of this block in the octree
  39044. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39045. * @param creationFunc defines a callback to call when an element is added to the block
  39046. */
  39047. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39048. /**
  39049. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39050. */
  39051. readonly capacity: number;
  39052. /**
  39053. * Gets the minimum vector (in world space) of the block's bounding box
  39054. */
  39055. readonly minPoint: Vector3;
  39056. /**
  39057. * Gets the maximum vector (in world space) of the block's bounding box
  39058. */
  39059. readonly maxPoint: Vector3;
  39060. /**
  39061. * Add a new element to this block
  39062. * @param entry defines the element to add
  39063. */
  39064. addEntry(entry: T): void;
  39065. /**
  39066. * Remove an element from this block
  39067. * @param entry defines the element to remove
  39068. */
  39069. removeEntry(entry: T): void;
  39070. /**
  39071. * Add an array of elements to this block
  39072. * @param entries defines the array of elements to add
  39073. */
  39074. addEntries(entries: T[]): void;
  39075. /**
  39076. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39077. * @param frustumPlanes defines the frustum planes to test
  39078. * @param selection defines the array to store current content if selection is positive
  39079. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39080. */
  39081. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39082. /**
  39083. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39084. * @param sphereCenter defines the bounding sphere center
  39085. * @param sphereRadius defines the bounding sphere radius
  39086. * @param selection defines the array to store current content if selection is positive
  39087. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39088. */
  39089. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39090. /**
  39091. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39092. * @param ray defines the ray to test with
  39093. * @param selection defines the array to store current content if selection is positive
  39094. */
  39095. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39096. /**
  39097. * Subdivide the content into child blocks (this block will then be empty)
  39098. */
  39099. createInnerBlocks(): void;
  39100. /**
  39101. * @hidden
  39102. */
  39103. 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;
  39104. }
  39105. }
  39106. declare module BABYLON {
  39107. /**
  39108. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39109. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39110. */
  39111. export class Octree<T> {
  39112. /** 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.) */
  39113. maxDepth: number;
  39114. /**
  39115. * Blocks within the octree containing objects
  39116. */
  39117. blocks: Array<OctreeBlock<T>>;
  39118. /**
  39119. * Content stored in the octree
  39120. */
  39121. dynamicContent: T[];
  39122. private _maxBlockCapacity;
  39123. private _selectionContent;
  39124. private _creationFunc;
  39125. /**
  39126. * Creates a octree
  39127. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39128. * @param creationFunc function to be used to instatiate the octree
  39129. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39130. * @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.)
  39131. */
  39132. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39133. /** 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.) */
  39134. maxDepth?: number);
  39135. /**
  39136. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39137. * @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);
  39138. * @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);
  39139. * @param entries meshes to be added to the octree blocks
  39140. */
  39141. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39142. /**
  39143. * Adds a mesh to the octree
  39144. * @param entry Mesh to add to the octree
  39145. */
  39146. addMesh(entry: T): void;
  39147. /**
  39148. * Remove an element from the octree
  39149. * @param entry defines the element to remove
  39150. */
  39151. removeMesh(entry: T): void;
  39152. /**
  39153. * Selects an array of meshes within the frustum
  39154. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39155. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39156. * @returns array of meshes within the frustum
  39157. */
  39158. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39159. /**
  39160. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39161. * @param sphereCenter defines the bounding sphere center
  39162. * @param sphereRadius defines the bounding sphere radius
  39163. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39164. * @returns an array of objects that intersect the sphere
  39165. */
  39166. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39167. /**
  39168. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39169. * @param ray defines the ray to test with
  39170. * @returns array of intersected objects
  39171. */
  39172. intersectsRay(ray: Ray): SmartArray<T>;
  39173. /**
  39174. * Adds a mesh into the octree block if it intersects the block
  39175. */
  39176. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39177. /**
  39178. * Adds a submesh into the octree block if it intersects the block
  39179. */
  39180. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39181. }
  39182. }
  39183. declare module BABYLON {
  39184. interface Scene {
  39185. /**
  39186. * @hidden
  39187. * Backing Filed
  39188. */
  39189. _selectionOctree: Octree<AbstractMesh>;
  39190. /**
  39191. * Gets the octree used to boost mesh selection (picking)
  39192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39193. */
  39194. selectionOctree: Octree<AbstractMesh>;
  39195. /**
  39196. * Creates or updates the octree used to boost selection (picking)
  39197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39198. * @param maxCapacity defines the maximum capacity per leaf
  39199. * @param maxDepth defines the maximum depth of the octree
  39200. * @returns an octree of AbstractMesh
  39201. */
  39202. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39203. }
  39204. interface AbstractMesh {
  39205. /**
  39206. * @hidden
  39207. * Backing Field
  39208. */
  39209. _submeshesOctree: Octree<SubMesh>;
  39210. /**
  39211. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39212. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39213. * @param maxCapacity defines the maximum size of each block (64 by default)
  39214. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39215. * @returns the new octree
  39216. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39217. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39218. */
  39219. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39220. }
  39221. /**
  39222. * Defines the octree scene component responsible to manage any octrees
  39223. * in a given scene.
  39224. */
  39225. export class OctreeSceneComponent {
  39226. /**
  39227. * The component name helpfull to identify the component in the list of scene components.
  39228. */
  39229. readonly name: string;
  39230. /**
  39231. * The scene the component belongs to.
  39232. */
  39233. scene: Scene;
  39234. /**
  39235. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39236. */
  39237. readonly checksIsEnabled: boolean;
  39238. /**
  39239. * Creates a new instance of the component for the given scene
  39240. * @param scene Defines the scene to register the component in
  39241. */
  39242. constructor(scene: Scene);
  39243. /**
  39244. * Registers the component in a given scene
  39245. */
  39246. register(): void;
  39247. /**
  39248. * Return the list of active meshes
  39249. * @returns the list of active meshes
  39250. */
  39251. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39252. /**
  39253. * Return the list of active sub meshes
  39254. * @param mesh The mesh to get the candidates sub meshes from
  39255. * @returns the list of active sub meshes
  39256. */
  39257. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39258. private _tempRay;
  39259. /**
  39260. * Return the list of sub meshes intersecting with a given local ray
  39261. * @param mesh defines the mesh to find the submesh for
  39262. * @param localRay defines the ray in local space
  39263. * @returns the list of intersecting sub meshes
  39264. */
  39265. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39266. /**
  39267. * Return the list of sub meshes colliding with a collider
  39268. * @param mesh defines the mesh to find the submesh for
  39269. * @param collider defines the collider to evaluate the collision against
  39270. * @returns the list of colliding sub meshes
  39271. */
  39272. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39273. /**
  39274. * Rebuilds the elements related to this component in case of
  39275. * context lost for instance.
  39276. */
  39277. rebuild(): void;
  39278. /**
  39279. * Disposes the component and the associated ressources.
  39280. */
  39281. dispose(): void;
  39282. }
  39283. }
  39284. declare module BABYLON {
  39285. /**
  39286. * Class containing static functions to help procedurally build meshes
  39287. */
  39288. export class LinesBuilder {
  39289. /**
  39290. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  39291. * * 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
  39292. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  39293. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  39294. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  39295. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  39296. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  39297. * * 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
  39298. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  39299. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39300. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  39301. * @param name defines the name of the new line system
  39302. * @param options defines the options used to create the line system
  39303. * @param scene defines the hosting scene
  39304. * @returns a new line system mesh
  39305. */
  39306. static CreateLineSystem(name: string, options: {
  39307. lines: Vector3[][];
  39308. updatable?: boolean;
  39309. instance?: Nullable<LinesMesh>;
  39310. colors?: Nullable<Color4[][]>;
  39311. useVertexAlpha?: boolean;
  39312. }, scene: Nullable<Scene>): LinesMesh;
  39313. /**
  39314. * Creates a line mesh
  39315. * 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
  39316. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39317. * * The parameter `points` is an array successive Vector3
  39318. * * 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
  39319. * * The optional parameter `colors` is an array of successive Color4, one per line point
  39320. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  39321. * * When updating an instance, remember that only point positions can change, not the number of points
  39322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  39324. * @param name defines the name of the new line system
  39325. * @param options defines the options used to create the line system
  39326. * @param scene defines the hosting scene
  39327. * @returns a new line mesh
  39328. */
  39329. static CreateLines(name: string, options: {
  39330. points: Vector3[];
  39331. updatable?: boolean;
  39332. instance?: Nullable<LinesMesh>;
  39333. colors?: Color4[];
  39334. useVertexAlpha?: boolean;
  39335. }, scene?: Nullable<Scene>): LinesMesh;
  39336. /**
  39337. * Creates a dashed line mesh
  39338. * * 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
  39339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  39340. * * The parameter `points` is an array successive Vector3
  39341. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  39342. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  39343. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  39344. * * 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
  39345. * * When updating an instance, remember that only point positions can change, not the number of points
  39346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39347. * @param name defines the name of the mesh
  39348. * @param options defines the options used to create the mesh
  39349. * @param scene defines the hosting scene
  39350. * @returns the dashed line mesh
  39351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  39352. */
  39353. static CreateDashedLines(name: string, options: {
  39354. points: Vector3[];
  39355. dashSize?: number;
  39356. gapSize?: number;
  39357. dashNb?: number;
  39358. updatable?: boolean;
  39359. instance?: LinesMesh;
  39360. }, scene?: Nullable<Scene>): LinesMesh;
  39361. }
  39362. }
  39363. declare module BABYLON {
  39364. /**
  39365. * Renders a layer on top of an existing scene
  39366. */
  39367. export class UtilityLayerRenderer implements IDisposable {
  39368. /** the original scene that will be rendered on top of */
  39369. originalScene: Scene;
  39370. private _pointerCaptures;
  39371. private _lastPointerEvents;
  39372. private static _DefaultUtilityLayer;
  39373. private static _DefaultKeepDepthUtilityLayer;
  39374. /**
  39375. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39376. */
  39377. pickUtilitySceneFirst: boolean;
  39378. /**
  39379. * 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)
  39380. */
  39381. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39382. /**
  39383. * 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)
  39384. */
  39385. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39386. /**
  39387. * The scene that is rendered on top of the original scene
  39388. */
  39389. utilityLayerScene: Scene;
  39390. /**
  39391. * If the utility layer should automatically be rendered on top of existing scene
  39392. */
  39393. shouldRender: boolean;
  39394. /**
  39395. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39396. */
  39397. onlyCheckPointerDownEvents: boolean;
  39398. /**
  39399. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39400. */
  39401. processAllEvents: boolean;
  39402. /**
  39403. * Observable raised when the pointer move from the utility layer scene to the main scene
  39404. */
  39405. onPointerOutObservable: Observable<number>;
  39406. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39407. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39408. private _afterRenderObserver;
  39409. private _sceneDisposeObserver;
  39410. private _originalPointerObserver;
  39411. /**
  39412. * Instantiates a UtilityLayerRenderer
  39413. * @param originalScene the original scene that will be rendered on top of
  39414. * @param handleEvents boolean indicating if the utility layer should handle events
  39415. */
  39416. constructor(
  39417. /** the original scene that will be rendered on top of */
  39418. originalScene: Scene, handleEvents?: boolean);
  39419. private _notifyObservers;
  39420. /**
  39421. * Renders the utility layers scene on top of the original scene
  39422. */
  39423. render(): void;
  39424. /**
  39425. * Disposes of the renderer
  39426. */
  39427. dispose(): void;
  39428. private _updateCamera;
  39429. }
  39430. }
  39431. declare module BABYLON {
  39432. /**
  39433. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39434. */
  39435. export class Gizmo implements IDisposable {
  39436. /** The utility layer the gizmo will be added to */
  39437. gizmoLayer: UtilityLayerRenderer;
  39438. /**
  39439. * The root mesh of the gizmo
  39440. */
  39441. _rootMesh: Mesh;
  39442. private _attachedMesh;
  39443. /**
  39444. * Ratio for the scale of the gizmo (Default: 1)
  39445. */
  39446. scaleRatio: number;
  39447. private _tmpMatrix;
  39448. /**
  39449. * If a custom mesh has been set (Default: false)
  39450. */
  39451. protected _customMeshSet: boolean;
  39452. /**
  39453. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39454. * * When set, interactions will be enabled
  39455. */
  39456. attachedMesh: Nullable<AbstractMesh>;
  39457. /**
  39458. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39459. * @param mesh The mesh to replace the default mesh of the gizmo
  39460. */
  39461. setCustomMesh(mesh: Mesh): void;
  39462. /**
  39463. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39464. */
  39465. updateGizmoRotationToMatchAttachedMesh: boolean;
  39466. /**
  39467. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39468. */
  39469. updateGizmoPositionToMatchAttachedMesh: boolean;
  39470. /**
  39471. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39472. */
  39473. protected _updateScale: boolean;
  39474. protected _interactionsEnabled: boolean;
  39475. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39476. private _beforeRenderObserver;
  39477. /**
  39478. * Creates a gizmo
  39479. * @param gizmoLayer The utility layer the gizmo will be added to
  39480. */
  39481. constructor(
  39482. /** The utility layer the gizmo will be added to */
  39483. gizmoLayer?: UtilityLayerRenderer);
  39484. private _tempVector;
  39485. /**
  39486. * @hidden
  39487. * Updates the gizmo to match the attached mesh's position/rotation
  39488. */
  39489. protected _update(): void;
  39490. /**
  39491. * Disposes of the gizmo
  39492. */
  39493. dispose(): void;
  39494. }
  39495. }
  39496. declare module BABYLON {
  39497. /**
  39498. * Single axis drag gizmo
  39499. */
  39500. export class AxisDragGizmo extends Gizmo {
  39501. /**
  39502. * Drag behavior responsible for the gizmos dragging interactions
  39503. */
  39504. dragBehavior: PointerDragBehavior;
  39505. private _pointerObserver;
  39506. /**
  39507. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39508. */
  39509. snapDistance: number;
  39510. /**
  39511. * Event that fires each time the gizmo snaps to a new location.
  39512. * * snapDistance is the the change in distance
  39513. */
  39514. onSnapObservable: Observable<{
  39515. snapDistance: number;
  39516. }>;
  39517. /** @hidden */
  39518. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39519. /** @hidden */
  39520. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39521. /**
  39522. * Creates an AxisDragGizmo
  39523. * @param gizmoLayer The utility layer the gizmo will be added to
  39524. * @param dragAxis The axis which the gizmo will be able to drag on
  39525. * @param color The color of the gizmo
  39526. */
  39527. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39528. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39529. /**
  39530. * Disposes of the gizmo
  39531. */
  39532. dispose(): void;
  39533. }
  39534. }
  39535. declare module BABYLON.Debug {
  39536. /**
  39537. * The Axes viewer will show 3 axes in a specific point in space
  39538. */
  39539. export class AxesViewer {
  39540. private _xAxis;
  39541. private _yAxis;
  39542. private _zAxis;
  39543. private _scaleLinesFactor;
  39544. private _instanced;
  39545. /**
  39546. * Gets the hosting scene
  39547. */
  39548. scene: Scene;
  39549. /**
  39550. * Gets or sets a number used to scale line length
  39551. */
  39552. scaleLines: number;
  39553. /** Gets the node hierarchy used to render x-axis */
  39554. readonly xAxis: TransformNode;
  39555. /** Gets the node hierarchy used to render y-axis */
  39556. readonly yAxis: TransformNode;
  39557. /** Gets the node hierarchy used to render z-axis */
  39558. readonly zAxis: TransformNode;
  39559. /**
  39560. * Creates a new AxesViewer
  39561. * @param scene defines the hosting scene
  39562. * @param scaleLines defines a number used to scale line length (1 by default)
  39563. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39564. * @param xAxis defines the node hierarchy used to render the x-axis
  39565. * @param yAxis defines the node hierarchy used to render the y-axis
  39566. * @param zAxis defines the node hierarchy used to render the z-axis
  39567. */
  39568. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39569. /**
  39570. * Force the viewer to update
  39571. * @param position defines the position of the viewer
  39572. * @param xaxis defines the x axis of the viewer
  39573. * @param yaxis defines the y axis of the viewer
  39574. * @param zaxis defines the z axis of the viewer
  39575. */
  39576. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39577. /**
  39578. * Creates an instance of this axes viewer.
  39579. * @returns a new axes viewer with instanced meshes
  39580. */
  39581. createInstance(): AxesViewer;
  39582. /** Releases resources */
  39583. dispose(): void;
  39584. private static _SetRenderingGroupId;
  39585. }
  39586. }
  39587. declare module BABYLON.Debug {
  39588. /**
  39589. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39590. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39591. */
  39592. export class BoneAxesViewer extends AxesViewer {
  39593. /**
  39594. * Gets or sets the target mesh where to display the axes viewer
  39595. */
  39596. mesh: Nullable<Mesh>;
  39597. /**
  39598. * Gets or sets the target bone where to display the axes viewer
  39599. */
  39600. bone: Nullable<Bone>;
  39601. /** Gets current position */
  39602. pos: Vector3;
  39603. /** Gets direction of X axis */
  39604. xaxis: Vector3;
  39605. /** Gets direction of Y axis */
  39606. yaxis: Vector3;
  39607. /** Gets direction of Z axis */
  39608. zaxis: Vector3;
  39609. /**
  39610. * Creates a new BoneAxesViewer
  39611. * @param scene defines the hosting scene
  39612. * @param bone defines the target bone
  39613. * @param mesh defines the target mesh
  39614. * @param scaleLines defines a scaling factor for line length (1 by default)
  39615. */
  39616. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39617. /**
  39618. * Force the viewer to update
  39619. */
  39620. update(): void;
  39621. /** Releases resources */
  39622. dispose(): void;
  39623. }
  39624. }
  39625. declare module BABYLON {
  39626. /**
  39627. * Interface used to define scene explorer extensibility option
  39628. */
  39629. export interface IExplorerExtensibilityOption {
  39630. /**
  39631. * Define the option label
  39632. */
  39633. label: string;
  39634. /**
  39635. * Defines the action to execute on click
  39636. */
  39637. action: (entity: any) => void;
  39638. }
  39639. /**
  39640. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39641. */
  39642. export interface IExplorerExtensibilityGroup {
  39643. /**
  39644. * Defines a predicate to test if a given type mut be extended
  39645. */
  39646. predicate: (entity: any) => boolean;
  39647. /**
  39648. * Gets the list of options added to a type
  39649. */
  39650. entries: IExplorerExtensibilityOption[];
  39651. }
  39652. /**
  39653. * Interface used to define the options to use to create the Inspector
  39654. */
  39655. export interface IInspectorOptions {
  39656. /**
  39657. * Display in overlay mode (default: false)
  39658. */
  39659. overlay?: boolean;
  39660. /**
  39661. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39662. */
  39663. globalRoot?: HTMLElement;
  39664. /**
  39665. * Display the Scene explorer
  39666. */
  39667. showExplorer?: boolean;
  39668. /**
  39669. * Display the property inspector
  39670. */
  39671. showInspector?: boolean;
  39672. /**
  39673. * Display in embed mode (both panes on the right)
  39674. */
  39675. embedMode?: boolean;
  39676. /**
  39677. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  39678. */
  39679. handleResize?: boolean;
  39680. /**
  39681. * Allow the panes to popup (default: true)
  39682. */
  39683. enablePopup?: boolean;
  39684. /**
  39685. * Allow the panes to be closed by users (default: true)
  39686. */
  39687. enableClose?: boolean;
  39688. /**
  39689. * Optional list of extensibility entries
  39690. */
  39691. explorerExtensibility?: IExplorerExtensibilityGroup[];
  39692. }
  39693. interface Scene {
  39694. /**
  39695. * @hidden
  39696. * Backing field
  39697. */
  39698. _debugLayer: DebugLayer;
  39699. /**
  39700. * Gets the debug layer (aka Inspector) associated with the scene
  39701. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39702. */
  39703. debugLayer: DebugLayer;
  39704. }
  39705. /**
  39706. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39707. * what is happening in your scene
  39708. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39709. */
  39710. export class DebugLayer {
  39711. /**
  39712. * Define the url to get the inspector script from.
  39713. * By default it uses the babylonjs CDN.
  39714. * @ignoreNaming
  39715. */
  39716. static InspectorURL: string;
  39717. private _scene;
  39718. private BJSINSPECTOR;
  39719. /**
  39720. * Observable triggered when a property is changed through the inspector.
  39721. */
  39722. onPropertyChangedObservable: Observable<{
  39723. object: any;
  39724. property: string;
  39725. value: any;
  39726. initialValue: any;
  39727. }>;
  39728. /**
  39729. * Instantiates a new debug layer.
  39730. * The debug layer (aka Inspector) is the go to tool in order to better understand
  39731. * what is happening in your scene
  39732. * @see http://doc.babylonjs.com/features/playground_debuglayer
  39733. * @param scene Defines the scene to inspect
  39734. */
  39735. constructor(scene: Scene);
  39736. /** Creates the inspector window. */
  39737. private _createInspector;
  39738. /** Get the inspector from bundle or global */
  39739. private _getGlobalInspector;
  39740. /**
  39741. * Get if the inspector is visible or not.
  39742. * @returns true if visible otherwise, false
  39743. */
  39744. isVisible(): boolean;
  39745. /**
  39746. * Hide the inspector and close its window.
  39747. */
  39748. hide(): void;
  39749. /**
  39750. * Launch the debugLayer.
  39751. * @param config Define the configuration of the inspector
  39752. */
  39753. show(config?: IInspectorOptions): void;
  39754. }
  39755. }
  39756. declare module BABYLON {
  39757. /**
  39758. * Class containing static functions to help procedurally build meshes
  39759. */
  39760. export class BoxBuilder {
  39761. /**
  39762. * Creates a box mesh
  39763. * * The parameter `size` sets the size (float) of each box side (default 1)
  39764. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  39765. * * 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)
  39766. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  39767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39768. * * 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
  39769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39770. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  39771. * @param name defines the name of the mesh
  39772. * @param options defines the options used to create the mesh
  39773. * @param scene defines the hosting scene
  39774. * @returns the box mesh
  39775. */
  39776. static CreateBox(name: string, options: {
  39777. size?: number;
  39778. width?: number;
  39779. height?: number;
  39780. depth?: number;
  39781. faceUV?: Vector4[];
  39782. faceColors?: Color4[];
  39783. sideOrientation?: number;
  39784. frontUVs?: Vector4;
  39785. backUVs?: Vector4;
  39786. updatable?: boolean;
  39787. }, scene?: Nullable<Scene>): Mesh;
  39788. }
  39789. }
  39790. declare module BABYLON {
  39791. /**
  39792. * Class containing static functions to help procedurally build meshes
  39793. */
  39794. export class SphereBuilder {
  39795. /**
  39796. * Creates a sphere mesh
  39797. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  39798. * * 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`)
  39799. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  39800. * * 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
  39801. * * 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)
  39802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39803. * * 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
  39804. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39805. * @param name defines the name of the mesh
  39806. * @param options defines the options used to create the mesh
  39807. * @param scene defines the hosting scene
  39808. * @returns the sphere mesh
  39809. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  39810. */
  39811. static CreateSphere(name: string, options: {
  39812. segments?: number;
  39813. diameter?: number;
  39814. diameterX?: number;
  39815. diameterY?: number;
  39816. diameterZ?: number;
  39817. arc?: number;
  39818. slice?: number;
  39819. sideOrientation?: number;
  39820. frontUVs?: Vector4;
  39821. backUVs?: Vector4;
  39822. updatable?: boolean;
  39823. }, scene: any): Mesh;
  39824. }
  39825. }
  39826. declare module BABYLON.Debug {
  39827. /**
  39828. * Used to show the physics impostor around the specific mesh
  39829. */
  39830. export class PhysicsViewer {
  39831. /** @hidden */
  39832. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  39833. /** @hidden */
  39834. protected _meshes: Array<Nullable<AbstractMesh>>;
  39835. /** @hidden */
  39836. protected _scene: Nullable<Scene>;
  39837. /** @hidden */
  39838. protected _numMeshes: number;
  39839. /** @hidden */
  39840. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  39841. private _renderFunction;
  39842. private _utilityLayer;
  39843. private _debugBoxMesh;
  39844. private _debugSphereMesh;
  39845. private _debugMaterial;
  39846. /**
  39847. * Creates a new PhysicsViewer
  39848. * @param scene defines the hosting scene
  39849. */
  39850. constructor(scene: Scene);
  39851. /** @hidden */
  39852. protected _updateDebugMeshes(): void;
  39853. /**
  39854. * Renders a specified physic impostor
  39855. * @param impostor defines the impostor to render
  39856. * @returns the new debug mesh used to render the impostor
  39857. */
  39858. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  39859. /**
  39860. * Hides a specified physic impostor
  39861. * @param impostor defines the impostor to hide
  39862. */
  39863. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  39864. private _getDebugMaterial;
  39865. private _getDebugBoxMesh;
  39866. private _getDebugSphereMesh;
  39867. private _getDebugMesh;
  39868. /** Releases all resources */
  39869. dispose(): void;
  39870. }
  39871. }
  39872. declare module BABYLON {
  39873. /**
  39874. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39875. * in order to better appreciate the issue one might have.
  39876. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39877. */
  39878. export class RayHelper {
  39879. /**
  39880. * Defines the ray we are currently tryin to visualize.
  39881. */
  39882. ray: Nullable<Ray>;
  39883. private _renderPoints;
  39884. private _renderLine;
  39885. private _renderFunction;
  39886. private _scene;
  39887. private _updateToMeshFunction;
  39888. private _attachedToMesh;
  39889. private _meshSpaceDirection;
  39890. private _meshSpaceOrigin;
  39891. /**
  39892. * Helper function to create a colored helper in a scene in one line.
  39893. * @param ray Defines the ray we are currently tryin to visualize
  39894. * @param scene Defines the scene the ray is used in
  39895. * @param color Defines the color we want to see the ray in
  39896. * @returns The newly created ray helper.
  39897. */
  39898. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  39899. /**
  39900. * Instantiate a new ray helper.
  39901. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  39902. * in order to better appreciate the issue one might have.
  39903. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  39904. * @param ray Defines the ray we are currently tryin to visualize
  39905. */
  39906. constructor(ray: Ray);
  39907. /**
  39908. * Shows the ray we are willing to debug.
  39909. * @param scene Defines the scene the ray needs to be rendered in
  39910. * @param color Defines the color the ray needs to be rendered in
  39911. */
  39912. show(scene: Scene, color?: Color3): void;
  39913. /**
  39914. * Hides the ray we are debugging.
  39915. */
  39916. hide(): void;
  39917. private _render;
  39918. /**
  39919. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  39920. * @param mesh Defines the mesh we want the helper attached to
  39921. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  39922. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  39923. * @param length Defines the length of the ray
  39924. */
  39925. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  39926. /**
  39927. * Detach the ray helper from the mesh it has previously been attached to.
  39928. */
  39929. detachFromMesh(): void;
  39930. private _updateToMesh;
  39931. /**
  39932. * Dispose the helper and release its associated resources.
  39933. */
  39934. dispose(): void;
  39935. }
  39936. }
  39937. declare module BABYLON.Debug {
  39938. /**
  39939. * Class used to render a debug view of a given skeleton
  39940. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  39941. */
  39942. export class SkeletonViewer {
  39943. /** defines the skeleton to render */
  39944. skeleton: Skeleton;
  39945. /** defines the mesh attached to the skeleton */
  39946. mesh: AbstractMesh;
  39947. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39948. autoUpdateBonesMatrices: boolean;
  39949. /** defines the rendering group id to use with the viewer */
  39950. renderingGroupId: number;
  39951. /** Gets or sets the color used to render the skeleton */
  39952. color: Color3;
  39953. private _scene;
  39954. private _debugLines;
  39955. private _debugMesh;
  39956. private _isEnabled;
  39957. private _renderFunction;
  39958. private _utilityLayer;
  39959. /**
  39960. * Returns the mesh used to render the bones
  39961. */
  39962. readonly debugMesh: Nullable<LinesMesh>;
  39963. /**
  39964. * Creates a new SkeletonViewer
  39965. * @param skeleton defines the skeleton to render
  39966. * @param mesh defines the mesh attached to the skeleton
  39967. * @param scene defines the hosting scene
  39968. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  39969. * @param renderingGroupId defines the rendering group id to use with the viewer
  39970. */
  39971. constructor(
  39972. /** defines the skeleton to render */
  39973. skeleton: Skeleton,
  39974. /** defines the mesh attached to the skeleton */
  39975. mesh: AbstractMesh, scene: Scene,
  39976. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  39977. autoUpdateBonesMatrices?: boolean,
  39978. /** defines the rendering group id to use with the viewer */
  39979. renderingGroupId?: number);
  39980. /** Gets or sets a boolean indicating if the viewer is enabled */
  39981. isEnabled: boolean;
  39982. private _getBonePosition;
  39983. private _getLinesForBonesWithLength;
  39984. private _getLinesForBonesNoLength;
  39985. /** Update the viewer to sync with current skeleton state */
  39986. update(): void;
  39987. /** Release associated resources */
  39988. dispose(): void;
  39989. }
  39990. }
  39991. declare module BABYLON {
  39992. /**
  39993. * Options to create the null engine
  39994. */
  39995. export class NullEngineOptions {
  39996. /**
  39997. * Render width (Default: 512)
  39998. */
  39999. renderWidth: number;
  40000. /**
  40001. * Render height (Default: 256)
  40002. */
  40003. renderHeight: number;
  40004. /**
  40005. * Texture size (Default: 512)
  40006. */
  40007. textureSize: number;
  40008. /**
  40009. * If delta time between frames should be constant
  40010. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40011. */
  40012. deterministicLockstep: boolean;
  40013. /**
  40014. * Maximum about of steps between frames (Default: 4)
  40015. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40016. */
  40017. lockstepMaxSteps: number;
  40018. }
  40019. /**
  40020. * The null engine class provides support for headless version of babylon.js.
  40021. * This can be used in server side scenario or for testing purposes
  40022. */
  40023. export class NullEngine extends Engine {
  40024. private _options;
  40025. /**
  40026. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40027. */
  40028. isDeterministicLockStep(): boolean;
  40029. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40030. getLockstepMaxSteps(): number;
  40031. /**
  40032. * Sets hardware scaling, used to save performance if needed
  40033. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40034. */
  40035. getHardwareScalingLevel(): number;
  40036. constructor(options?: NullEngineOptions);
  40037. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40038. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40039. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40040. getRenderWidth(useScreen?: boolean): number;
  40041. getRenderHeight(useScreen?: boolean): number;
  40042. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40043. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40044. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40045. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40046. bindSamplers(effect: Effect): void;
  40047. enableEffect(effect: Effect): void;
  40048. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40049. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40050. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40051. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40052. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40053. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40054. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40055. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40056. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40057. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40058. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40059. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40060. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40061. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40062. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40063. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40064. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40065. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40066. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40067. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40068. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40069. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40070. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40071. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40072. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40073. bindBuffers(vertexBuffers: {
  40074. [key: string]: VertexBuffer;
  40075. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40076. wipeCaches(bruteForce?: boolean): void;
  40077. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40078. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40079. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40080. /** @hidden */
  40081. _createTexture(): WebGLTexture;
  40082. /** @hidden */
  40083. _releaseTexture(texture: InternalTexture): void;
  40084. 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;
  40085. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40086. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40087. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40088. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40089. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40090. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40091. areAllEffectsReady(): boolean;
  40092. /**
  40093. * @hidden
  40094. * Get the current error code of the webGL context
  40095. * @returns the error code
  40096. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40097. */
  40098. getError(): number;
  40099. /** @hidden */
  40100. _getUnpackAlignement(): number;
  40101. /** @hidden */
  40102. _unpackFlipY(value: boolean): void;
  40103. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40104. /**
  40105. * Updates a dynamic vertex buffer.
  40106. * @param vertexBuffer the vertex buffer to update
  40107. * @param data the data used to update the vertex buffer
  40108. * @param byteOffset the byte offset of the data (optional)
  40109. * @param byteLength the byte length of the data (optional)
  40110. */
  40111. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  40112. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40113. /** @hidden */
  40114. _bindTexture(channel: number, texture: InternalTexture): void;
  40115. /** @hidden */
  40116. _releaseBuffer(buffer: WebGLBuffer): boolean;
  40117. releaseEffects(): void;
  40118. displayLoadingUI(): void;
  40119. hideLoadingUI(): void;
  40120. /** @hidden */
  40121. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40122. /** @hidden */
  40123. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40124. /** @hidden */
  40125. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40126. /** @hidden */
  40127. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40128. }
  40129. }
  40130. declare module BABYLON {
  40131. /** @hidden */
  40132. export class _OcclusionDataStorage {
  40133. /** @hidden */
  40134. occlusionInternalRetryCounter: number;
  40135. /** @hidden */
  40136. isOcclusionQueryInProgress: boolean;
  40137. /** @hidden */
  40138. isOccluded: boolean;
  40139. /** @hidden */
  40140. occlusionRetryCount: number;
  40141. /** @hidden */
  40142. occlusionType: number;
  40143. /** @hidden */
  40144. occlusionQueryAlgorithmType: number;
  40145. }
  40146. interface Engine {
  40147. /**
  40148. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40149. * @return the new query
  40150. */
  40151. createQuery(): WebGLQuery;
  40152. /**
  40153. * Delete and release a webGL query
  40154. * @param query defines the query to delete
  40155. * @return the current engine
  40156. */
  40157. deleteQuery(query: WebGLQuery): Engine;
  40158. /**
  40159. * Check if a given query has resolved and got its value
  40160. * @param query defines the query to check
  40161. * @returns true if the query got its value
  40162. */
  40163. isQueryResultAvailable(query: WebGLQuery): boolean;
  40164. /**
  40165. * Gets the value of a given query
  40166. * @param query defines the query to check
  40167. * @returns the value of the query
  40168. */
  40169. getQueryResult(query: WebGLQuery): number;
  40170. /**
  40171. * Initiates an occlusion query
  40172. * @param algorithmType defines the algorithm to use
  40173. * @param query defines the query to use
  40174. * @returns the current engine
  40175. * @see http://doc.babylonjs.com/features/occlusionquery
  40176. */
  40177. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40178. /**
  40179. * Ends an occlusion query
  40180. * @see http://doc.babylonjs.com/features/occlusionquery
  40181. * @param algorithmType defines the algorithm to use
  40182. * @returns the current engine
  40183. */
  40184. endOcclusionQuery(algorithmType: number): Engine;
  40185. /**
  40186. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40187. * Please note that only one query can be issued at a time
  40188. * @returns a time token used to track the time span
  40189. */
  40190. startTimeQuery(): Nullable<_TimeToken>;
  40191. /**
  40192. * Ends a time query
  40193. * @param token defines the token used to measure the time span
  40194. * @returns the time spent (in ns)
  40195. */
  40196. endTimeQuery(token: _TimeToken): int;
  40197. /** @hidden */
  40198. _currentNonTimestampToken: Nullable<_TimeToken>;
  40199. /** @hidden */
  40200. _createTimeQuery(): WebGLQuery;
  40201. /** @hidden */
  40202. _deleteTimeQuery(query: WebGLQuery): void;
  40203. /** @hidden */
  40204. _getGlAlgorithmType(algorithmType: number): number;
  40205. /** @hidden */
  40206. _getTimeQueryResult(query: WebGLQuery): any;
  40207. /** @hidden */
  40208. _getTimeQueryAvailability(query: WebGLQuery): any;
  40209. }
  40210. interface AbstractMesh {
  40211. /**
  40212. * Backing filed
  40213. * @hidden
  40214. */
  40215. __occlusionDataStorage: _OcclusionDataStorage;
  40216. /**
  40217. * Access property
  40218. * @hidden
  40219. */
  40220. _occlusionDataStorage: _OcclusionDataStorage;
  40221. /**
  40222. * 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.
  40223. * The default value is -1 which means don't break the query and wait till the result
  40224. * @see http://doc.babylonjs.com/features/occlusionquery
  40225. */
  40226. occlusionRetryCount: number;
  40227. /**
  40228. * 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:
  40229. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40230. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40231. * * 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.
  40232. * @see http://doc.babylonjs.com/features/occlusionquery
  40233. */
  40234. occlusionType: number;
  40235. /**
  40236. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40237. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40238. * * 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.
  40239. * @see http://doc.babylonjs.com/features/occlusionquery
  40240. */
  40241. occlusionQueryAlgorithmType: number;
  40242. /**
  40243. * 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
  40244. * @see http://doc.babylonjs.com/features/occlusionquery
  40245. */
  40246. isOccluded: boolean;
  40247. /**
  40248. * Flag to check the progress status of the query
  40249. * @see http://doc.babylonjs.com/features/occlusionquery
  40250. */
  40251. isOcclusionQueryInProgress: boolean;
  40252. }
  40253. }
  40254. declare module BABYLON {
  40255. /** @hidden */
  40256. export var _forceTransformFeedbackToBundle: boolean;
  40257. interface Engine {
  40258. /**
  40259. * Creates a webGL transform feedback object
  40260. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40261. * @returns the webGL transform feedback object
  40262. */
  40263. createTransformFeedback(): WebGLTransformFeedback;
  40264. /**
  40265. * Delete a webGL transform feedback object
  40266. * @param value defines the webGL transform feedback object to delete
  40267. */
  40268. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40269. /**
  40270. * Bind a webGL transform feedback object to the webgl context
  40271. * @param value defines the webGL transform feedback object to bind
  40272. */
  40273. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40274. /**
  40275. * Begins a transform feedback operation
  40276. * @param usePoints defines if points or triangles must be used
  40277. */
  40278. beginTransformFeedback(usePoints: boolean): void;
  40279. /**
  40280. * Ends a transform feedback operation
  40281. */
  40282. endTransformFeedback(): void;
  40283. /**
  40284. * Specify the varyings to use with transform feedback
  40285. * @param program defines the associated webGL program
  40286. * @param value defines the list of strings representing the varying names
  40287. */
  40288. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40289. /**
  40290. * Bind a webGL buffer for a transform feedback operation
  40291. * @param value defines the webGL buffer to bind
  40292. */
  40293. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40294. }
  40295. }
  40296. declare module BABYLON {
  40297. /**
  40298. * Gather the list of clipboard event types as constants.
  40299. */
  40300. export class ClipboardEventTypes {
  40301. /**
  40302. * The clipboard event is fired when a copy command is active (pressed).
  40303. */
  40304. static readonly COPY: number;
  40305. /**
  40306. * The clipboard event is fired when a cut command is active (pressed).
  40307. */
  40308. static readonly CUT: number;
  40309. /**
  40310. * The clipboard event is fired when a paste command is active (pressed).
  40311. */
  40312. static readonly PASTE: number;
  40313. }
  40314. /**
  40315. * This class is used to store clipboard related info for the onClipboardObservable event.
  40316. */
  40317. export class ClipboardInfo {
  40318. /**
  40319. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40320. */
  40321. type: number;
  40322. /**
  40323. * Defines the related dom event
  40324. */
  40325. event: ClipboardEvent;
  40326. /**
  40327. *Creates an instance of ClipboardInfo.
  40328. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40329. * @param event Defines the related dom event
  40330. */
  40331. constructor(
  40332. /**
  40333. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40334. */
  40335. type: number,
  40336. /**
  40337. * Defines the related dom event
  40338. */
  40339. event: ClipboardEvent);
  40340. /**
  40341. * Get the clipboard event's type from the keycode.
  40342. * @param keyCode Defines the keyCode for the current keyboard event.
  40343. * @return {number}
  40344. */
  40345. static GetTypeFromCharacter(keyCode: number): number;
  40346. }
  40347. }
  40348. declare module BABYLON {
  40349. /**
  40350. * Class used to represent data loading progression
  40351. */
  40352. export class SceneLoaderProgressEvent {
  40353. /** defines if data length to load can be evaluated */
  40354. readonly lengthComputable: boolean;
  40355. /** defines the loaded data length */
  40356. readonly loaded: number;
  40357. /** defines the data length to load */
  40358. readonly total: number;
  40359. /**
  40360. * Create a new progress event
  40361. * @param lengthComputable defines if data length to load can be evaluated
  40362. * @param loaded defines the loaded data length
  40363. * @param total defines the data length to load
  40364. */
  40365. constructor(
  40366. /** defines if data length to load can be evaluated */
  40367. lengthComputable: boolean,
  40368. /** defines the loaded data length */
  40369. loaded: number,
  40370. /** defines the data length to load */
  40371. total: number);
  40372. /**
  40373. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40374. * @param event defines the source event
  40375. * @returns a new SceneLoaderProgressEvent
  40376. */
  40377. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40378. }
  40379. /**
  40380. * Interface used by SceneLoader plugins to define supported file extensions
  40381. */
  40382. export interface ISceneLoaderPluginExtensions {
  40383. /**
  40384. * Defines the list of supported extensions
  40385. */
  40386. [extension: string]: {
  40387. isBinary: boolean;
  40388. };
  40389. }
  40390. /**
  40391. * Interface used by SceneLoader plugin factory
  40392. */
  40393. export interface ISceneLoaderPluginFactory {
  40394. /**
  40395. * Defines the name of the factory
  40396. */
  40397. name: string;
  40398. /**
  40399. * Function called to create a new plugin
  40400. * @return the new plugin
  40401. */
  40402. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40403. /**
  40404. * Boolean indicating if the plugin can direct load specific data
  40405. */
  40406. canDirectLoad?: (data: string) => boolean;
  40407. }
  40408. /**
  40409. * Interface used to define a SceneLoader plugin
  40410. */
  40411. export interface ISceneLoaderPlugin {
  40412. /**
  40413. * The friendly name of this plugin.
  40414. */
  40415. name: string;
  40416. /**
  40417. * The file extensions supported by this plugin.
  40418. */
  40419. extensions: string | ISceneLoaderPluginExtensions;
  40420. /**
  40421. * Import meshes into a scene.
  40422. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40423. * @param scene The scene to import into
  40424. * @param data The data to import
  40425. * @param rootUrl The root url for scene and resources
  40426. * @param meshes The meshes array to import into
  40427. * @param particleSystems The particle systems array to import into
  40428. * @param skeletons The skeletons array to import into
  40429. * @param onError The callback when import fails
  40430. * @returns True if successful or false otherwise
  40431. */
  40432. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40433. /**
  40434. * Load into a scene.
  40435. * @param scene The scene to load into
  40436. * @param data The data to import
  40437. * @param rootUrl The root url for scene and resources
  40438. * @param onError The callback when import fails
  40439. * @returns true if successful or false otherwise
  40440. */
  40441. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40442. /**
  40443. * The callback that returns true if the data can be directly loaded.
  40444. */
  40445. canDirectLoad?: (data: string) => boolean;
  40446. /**
  40447. * The callback that allows custom handling of the root url based on the response url.
  40448. */
  40449. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40450. /**
  40451. * Load into an asset container.
  40452. * @param scene The scene to load into
  40453. * @param data The data to import
  40454. * @param rootUrl The root url for scene and resources
  40455. * @param onError The callback when import fails
  40456. * @returns The loaded asset container
  40457. */
  40458. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40459. }
  40460. /**
  40461. * Interface used to define an async SceneLoader plugin
  40462. */
  40463. export interface ISceneLoaderPluginAsync {
  40464. /**
  40465. * The friendly name of this plugin.
  40466. */
  40467. name: string;
  40468. /**
  40469. * The file extensions supported by this plugin.
  40470. */
  40471. extensions: string | ISceneLoaderPluginExtensions;
  40472. /**
  40473. * Import meshes into a scene.
  40474. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40475. * @param scene The scene to import into
  40476. * @param data The data to import
  40477. * @param rootUrl The root url for scene and resources
  40478. * @param onProgress The callback when the load progresses
  40479. * @param fileName Defines the name of the file to load
  40480. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40481. */
  40482. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40483. meshes: AbstractMesh[];
  40484. particleSystems: IParticleSystem[];
  40485. skeletons: Skeleton[];
  40486. animationGroups: AnimationGroup[];
  40487. }>;
  40488. /**
  40489. * Load into a scene.
  40490. * @param scene The scene to load into
  40491. * @param data The data to import
  40492. * @param rootUrl The root url for scene and resources
  40493. * @param onProgress The callback when the load progresses
  40494. * @param fileName Defines the name of the file to load
  40495. * @returns Nothing
  40496. */
  40497. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40498. /**
  40499. * The callback that returns true if the data can be directly loaded.
  40500. */
  40501. canDirectLoad?: (data: string) => boolean;
  40502. /**
  40503. * The callback that allows custom handling of the root url based on the response url.
  40504. */
  40505. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40506. /**
  40507. * Load into an asset container.
  40508. * @param scene The scene to load into
  40509. * @param data The data to import
  40510. * @param rootUrl The root url for scene and resources
  40511. * @param onProgress The callback when the load progresses
  40512. * @param fileName Defines the name of the file to load
  40513. * @returns The loaded asset container
  40514. */
  40515. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40516. }
  40517. /**
  40518. * Class used to load scene from various file formats using registered plugins
  40519. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40520. */
  40521. export class SceneLoader {
  40522. /**
  40523. * No logging while loading
  40524. */
  40525. static readonly NO_LOGGING: number;
  40526. /**
  40527. * Minimal logging while loading
  40528. */
  40529. static readonly MINIMAL_LOGGING: number;
  40530. /**
  40531. * Summary logging while loading
  40532. */
  40533. static readonly SUMMARY_LOGGING: number;
  40534. /**
  40535. * Detailled logging while loading
  40536. */
  40537. static readonly DETAILED_LOGGING: number;
  40538. /**
  40539. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40540. */
  40541. static ForceFullSceneLoadingForIncremental: boolean;
  40542. /**
  40543. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40544. */
  40545. static ShowLoadingScreen: boolean;
  40546. /**
  40547. * Defines the current logging level (while loading the scene)
  40548. * @ignorenaming
  40549. */
  40550. static loggingLevel: number;
  40551. /**
  40552. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40553. */
  40554. static CleanBoneMatrixWeights: boolean;
  40555. /**
  40556. * Event raised when a plugin is used to load a scene
  40557. */
  40558. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40559. private static _registeredPlugins;
  40560. private static _getDefaultPlugin;
  40561. private static _getPluginForExtension;
  40562. private static _getPluginForDirectLoad;
  40563. private static _getPluginForFilename;
  40564. private static _getDirectLoad;
  40565. private static _loadData;
  40566. private static _getFileInfo;
  40567. /**
  40568. * Gets a plugin that can load the given extension
  40569. * @param extension defines the extension to load
  40570. * @returns a plugin or null if none works
  40571. */
  40572. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40573. /**
  40574. * Gets a boolean indicating that the given extension can be loaded
  40575. * @param extension defines the extension to load
  40576. * @returns true if the extension is supported
  40577. */
  40578. static IsPluginForExtensionAvailable(extension: string): boolean;
  40579. /**
  40580. * Adds a new plugin to the list of registered plugins
  40581. * @param plugin defines the plugin to add
  40582. */
  40583. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  40584. /**
  40585. * Import meshes into a scene
  40586. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40587. * @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)
  40588. * @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)
  40589. * @param scene the instance of BABYLON.Scene to append to
  40590. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  40591. * @param onProgress a callback with a progress event for each file being loaded
  40592. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40593. * @param pluginExtension the extension used to determine the plugin
  40594. * @returns The loaded plugin
  40595. */
  40596. 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>;
  40597. /**
  40598. * Import meshes into a scene
  40599. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40600. * @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)
  40601. * @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)
  40602. * @param scene the instance of BABYLON.Scene to append to
  40603. * @param onProgress a callback with a progress event for each file being loaded
  40604. * @param pluginExtension the extension used to determine the plugin
  40605. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  40606. */
  40607. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  40608. meshes: AbstractMesh[];
  40609. particleSystems: IParticleSystem[];
  40610. skeletons: Skeleton[];
  40611. animationGroups: AnimationGroup[];
  40612. }>;
  40613. /**
  40614. * Load a scene
  40615. * @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)
  40616. * @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)
  40617. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40618. * @param onSuccess a callback with the scene when import succeeds
  40619. * @param onProgress a callback with a progress event for each file being loaded
  40620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40621. * @param pluginExtension the extension used to determine the plugin
  40622. * @returns The loaded plugin
  40623. */
  40624. 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>;
  40625. /**
  40626. * Load a scene
  40627. * @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)
  40628. * @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)
  40629. * @param engine is the instance of BABYLON.Engine to use to create the scene
  40630. * @param onProgress a callback with a progress event for each file being loaded
  40631. * @param pluginExtension the extension used to determine the plugin
  40632. * @returns The loaded scene
  40633. */
  40634. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40635. /**
  40636. * Append a scene
  40637. * @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)
  40638. * @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)
  40639. * @param scene is the instance of BABYLON.Scene to append to
  40640. * @param onSuccess a callback with the scene when import succeeds
  40641. * @param onProgress a callback with a progress event for each file being loaded
  40642. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40643. * @param pluginExtension the extension used to determine the plugin
  40644. * @returns The loaded plugin
  40645. */
  40646. 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>;
  40647. /**
  40648. * Append a scene
  40649. * @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)
  40650. * @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)
  40651. * @param scene is the instance of BABYLON.Scene to append to
  40652. * @param onProgress a callback with a progress event for each file being loaded
  40653. * @param pluginExtension the extension used to determine the plugin
  40654. * @returns The given scene
  40655. */
  40656. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  40657. /**
  40658. * Load a scene into an asset container
  40659. * @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)
  40660. * @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)
  40661. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40662. * @param onSuccess a callback with the scene when import succeeds
  40663. * @param onProgress a callback with a progress event for each file being loaded
  40664. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  40665. * @param pluginExtension the extension used to determine the plugin
  40666. * @returns The loaded plugin
  40667. */
  40668. 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>;
  40669. /**
  40670. * Load a scene into an asset container
  40671. * @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)
  40672. * @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)
  40673. * @param scene is the instance of Scene to append to
  40674. * @param onProgress a callback with a progress event for each file being loaded
  40675. * @param pluginExtension the extension used to determine the plugin
  40676. * @returns The loaded asset container
  40677. */
  40678. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  40679. }
  40680. }
  40681. declare module BABYLON {
  40682. /**
  40683. * Google Daydream controller
  40684. */
  40685. export class DaydreamController extends WebVRController {
  40686. /**
  40687. * Base Url for the controller model.
  40688. */
  40689. static MODEL_BASE_URL: string;
  40690. /**
  40691. * File name for the controller model.
  40692. */
  40693. static MODEL_FILENAME: string;
  40694. /**
  40695. * Gamepad Id prefix used to identify Daydream Controller.
  40696. */
  40697. static readonly GAMEPAD_ID_PREFIX: string;
  40698. /**
  40699. * Creates a new DaydreamController from a gamepad
  40700. * @param vrGamepad the gamepad that the controller should be created from
  40701. */
  40702. constructor(vrGamepad: any);
  40703. /**
  40704. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40705. * @param scene scene in which to add meshes
  40706. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40707. */
  40708. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40709. /**
  40710. * Called once for each button that changed state since the last frame
  40711. * @param buttonIdx Which button index changed
  40712. * @param state New state of the button
  40713. * @param changes Which properties on the state changed since last frame
  40714. */
  40715. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40716. }
  40717. }
  40718. declare module BABYLON {
  40719. /**
  40720. * Gear VR Controller
  40721. */
  40722. export class GearVRController extends WebVRController {
  40723. /**
  40724. * Base Url for the controller model.
  40725. */
  40726. static MODEL_BASE_URL: string;
  40727. /**
  40728. * File name for the controller model.
  40729. */
  40730. static MODEL_FILENAME: string;
  40731. /**
  40732. * Gamepad Id prefix used to identify this controller.
  40733. */
  40734. static readonly GAMEPAD_ID_PREFIX: string;
  40735. private readonly _buttonIndexToObservableNameMap;
  40736. /**
  40737. * Creates a new GearVRController from a gamepad
  40738. * @param vrGamepad the gamepad that the controller should be created from
  40739. */
  40740. constructor(vrGamepad: any);
  40741. /**
  40742. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40743. * @param scene scene in which to add meshes
  40744. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40745. */
  40746. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40747. /**
  40748. * Called once for each button that changed state since the last frame
  40749. * @param buttonIdx Which button index changed
  40750. * @param state New state of the button
  40751. * @param changes Which properties on the state changed since last frame
  40752. */
  40753. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40754. }
  40755. }
  40756. declare module BABYLON {
  40757. /**
  40758. * Generic Controller
  40759. */
  40760. export class GenericController extends WebVRController {
  40761. /**
  40762. * Base Url for the controller model.
  40763. */
  40764. static readonly MODEL_BASE_URL: string;
  40765. /**
  40766. * File name for the controller model.
  40767. */
  40768. static readonly MODEL_FILENAME: string;
  40769. /**
  40770. * Creates a new GenericController from a gamepad
  40771. * @param vrGamepad the gamepad that the controller should be created from
  40772. */
  40773. constructor(vrGamepad: any);
  40774. /**
  40775. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40776. * @param scene scene in which to add meshes
  40777. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40778. */
  40779. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40780. /**
  40781. * Called once for each button that changed state since the last frame
  40782. * @param buttonIdx Which button index changed
  40783. * @param state New state of the button
  40784. * @param changes Which properties on the state changed since last frame
  40785. */
  40786. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40787. }
  40788. }
  40789. declare module BABYLON {
  40790. /**
  40791. * Oculus Touch Controller
  40792. */
  40793. export class OculusTouchController extends WebVRController {
  40794. /**
  40795. * Base Url for the controller model.
  40796. */
  40797. static MODEL_BASE_URL: string;
  40798. /**
  40799. * File name for the left controller model.
  40800. */
  40801. static MODEL_LEFT_FILENAME: string;
  40802. /**
  40803. * File name for the right controller model.
  40804. */
  40805. static MODEL_RIGHT_FILENAME: string;
  40806. /**
  40807. * Fired when the secondary trigger on this controller is modified
  40808. */
  40809. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  40810. /**
  40811. * Fired when the thumb rest on this controller is modified
  40812. */
  40813. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  40814. /**
  40815. * Creates a new OculusTouchController from a gamepad
  40816. * @param vrGamepad the gamepad that the controller should be created from
  40817. */
  40818. constructor(vrGamepad: any);
  40819. /**
  40820. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40821. * @param scene scene in which to add meshes
  40822. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40823. */
  40824. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40825. /**
  40826. * Fired when the A button on this controller is modified
  40827. */
  40828. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40829. /**
  40830. * Fired when the B button on this controller is modified
  40831. */
  40832. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40833. /**
  40834. * Fired when the X button on this controller is modified
  40835. */
  40836. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40837. /**
  40838. * Fired when the Y button on this controller is modified
  40839. */
  40840. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40841. /**
  40842. * Called once for each button that changed state since the last frame
  40843. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  40844. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  40845. * 2) secondary trigger (same)
  40846. * 3) A (right) X (left), touch, pressed = value
  40847. * 4) B / Y
  40848. * 5) thumb rest
  40849. * @param buttonIdx Which button index changed
  40850. * @param state New state of the button
  40851. * @param changes Which properties on the state changed since last frame
  40852. */
  40853. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40854. }
  40855. }
  40856. declare module BABYLON {
  40857. /**
  40858. * Vive Controller
  40859. */
  40860. export class ViveController extends WebVRController {
  40861. /**
  40862. * Base Url for the controller model.
  40863. */
  40864. static MODEL_BASE_URL: string;
  40865. /**
  40866. * File name for the controller model.
  40867. */
  40868. static MODEL_FILENAME: string;
  40869. /**
  40870. * Creates a new ViveController from a gamepad
  40871. * @param vrGamepad the gamepad that the controller should be created from
  40872. */
  40873. constructor(vrGamepad: any);
  40874. /**
  40875. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  40876. * @param scene scene in which to add meshes
  40877. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  40878. */
  40879. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  40880. /**
  40881. * Fired when the left button on this controller is modified
  40882. */
  40883. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40884. /**
  40885. * Fired when the right button on this controller is modified
  40886. */
  40887. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40888. /**
  40889. * Fired when the menu button on this controller is modified
  40890. */
  40891. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40892. /**
  40893. * Called once for each button that changed state since the last frame
  40894. * Vive mapping:
  40895. * 0: touchpad
  40896. * 1: trigger
  40897. * 2: left AND right buttons
  40898. * 3: menu button
  40899. * @param buttonIdx Which button index changed
  40900. * @param state New state of the button
  40901. * @param changes Which properties on the state changed since last frame
  40902. */
  40903. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40904. }
  40905. }
  40906. declare module BABYLON {
  40907. /**
  40908. * Defines the WindowsMotionController object that the state of the windows motion controller
  40909. */
  40910. export class WindowsMotionController extends WebVRController {
  40911. /**
  40912. * The base url used to load the left and right controller models
  40913. */
  40914. static MODEL_BASE_URL: string;
  40915. /**
  40916. * The name of the left controller model file
  40917. */
  40918. static MODEL_LEFT_FILENAME: string;
  40919. /**
  40920. * The name of the right controller model file
  40921. */
  40922. static MODEL_RIGHT_FILENAME: string;
  40923. /**
  40924. * The controller name prefix for this controller type
  40925. */
  40926. static readonly GAMEPAD_ID_PREFIX: string;
  40927. /**
  40928. * The controller id pattern for this controller type
  40929. */
  40930. private static readonly GAMEPAD_ID_PATTERN;
  40931. private _loadedMeshInfo;
  40932. private readonly _mapping;
  40933. /**
  40934. * Fired when the trackpad on this controller is clicked
  40935. */
  40936. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  40937. /**
  40938. * Fired when the trackpad on this controller is modified
  40939. */
  40940. onTrackpadValuesChangedObservable: Observable<StickValues>;
  40941. /**
  40942. * The current x and y values of this controller's trackpad
  40943. */
  40944. trackpad: StickValues;
  40945. /**
  40946. * Creates a new WindowsMotionController from a gamepad
  40947. * @param vrGamepad the gamepad that the controller should be created from
  40948. */
  40949. constructor(vrGamepad: any);
  40950. /**
  40951. * Fired when the trigger on this controller is modified
  40952. */
  40953. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40954. /**
  40955. * Fired when the menu button on this controller is modified
  40956. */
  40957. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40958. /**
  40959. * Fired when the grip button on this controller is modified
  40960. */
  40961. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40962. /**
  40963. * Fired when the thumbstick button on this controller is modified
  40964. */
  40965. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40966. /**
  40967. * Fired when the touchpad button on this controller is modified
  40968. */
  40969. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  40970. /**
  40971. * Fired when the touchpad values on this controller are modified
  40972. */
  40973. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  40974. private _updateTrackpad;
  40975. /**
  40976. * Called once per frame by the engine.
  40977. */
  40978. update(): void;
  40979. /**
  40980. * Called once for each button that changed state since the last frame
  40981. * @param buttonIdx Which button index changed
  40982. * @param state New state of the button
  40983. * @param changes Which properties on the state changed since last frame
  40984. */
  40985. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  40986. /**
  40987. * Moves the buttons on the controller mesh based on their current state
  40988. * @param buttonName the name of the button to move
  40989. * @param buttonValue the value of the button which determines the buttons new position
  40990. */
  40991. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  40992. /**
  40993. * Moves the axis on the controller mesh based on its current state
  40994. * @param axis the index of the axis
  40995. * @param axisValue the value of the axis which determines the meshes new position
  40996. * @hidden
  40997. */
  40998. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  40999. /**
  41000. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41001. * @param scene scene in which to add meshes
  41002. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41003. */
  41004. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41005. /**
  41006. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41007. * can be transformed by button presses and axes values, based on this._mapping.
  41008. *
  41009. * @param scene scene in which the meshes exist
  41010. * @param meshes list of meshes that make up the controller model to process
  41011. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41012. */
  41013. private processModel;
  41014. private createMeshInfo;
  41015. /**
  41016. * Gets the ray of the controller in the direction the controller is pointing
  41017. * @param length the length the resulting ray should be
  41018. * @returns a ray in the direction the controller is pointing
  41019. */
  41020. getForwardRay(length?: number): Ray;
  41021. /**
  41022. * Disposes of the controller
  41023. */
  41024. dispose(): void;
  41025. }
  41026. }
  41027. declare module BABYLON {
  41028. /**
  41029. * Single axis scale gizmo
  41030. */
  41031. export class AxisScaleGizmo extends Gizmo {
  41032. private _coloredMaterial;
  41033. /**
  41034. * Drag behavior responsible for the gizmos dragging interactions
  41035. */
  41036. dragBehavior: PointerDragBehavior;
  41037. private _pointerObserver;
  41038. /**
  41039. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41040. */
  41041. snapDistance: number;
  41042. /**
  41043. * Event that fires each time the gizmo snaps to a new location.
  41044. * * snapDistance is the the change in distance
  41045. */
  41046. onSnapObservable: Observable<{
  41047. snapDistance: number;
  41048. }>;
  41049. /**
  41050. * If the scaling operation should be done on all axis (default: false)
  41051. */
  41052. uniformScaling: boolean;
  41053. /**
  41054. * Creates an AxisScaleGizmo
  41055. * @param gizmoLayer The utility layer the gizmo will be added to
  41056. * @param dragAxis The axis which the gizmo will be able to scale on
  41057. * @param color The color of the gizmo
  41058. */
  41059. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41060. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41061. /**
  41062. * Disposes of the gizmo
  41063. */
  41064. dispose(): void;
  41065. /**
  41066. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41067. * @param mesh The mesh to replace the default mesh of the gizmo
  41068. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41069. */
  41070. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41071. }
  41072. }
  41073. declare module BABYLON {
  41074. /**
  41075. * Bounding box gizmo
  41076. */
  41077. export class BoundingBoxGizmo extends Gizmo {
  41078. private _lineBoundingBox;
  41079. private _rotateSpheresParent;
  41080. private _scaleBoxesParent;
  41081. private _boundingDimensions;
  41082. private _renderObserver;
  41083. private _pointerObserver;
  41084. private _scaleDragSpeed;
  41085. private _tmpQuaternion;
  41086. private _tmpVector;
  41087. private _tmpRotationMatrix;
  41088. /**
  41089. * 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)
  41090. */
  41091. ignoreChildren: boolean;
  41092. /**
  41093. * 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)
  41094. */
  41095. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41096. /**
  41097. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41098. */
  41099. rotationSphereSize: number;
  41100. /**
  41101. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41102. */
  41103. scaleBoxSize: number;
  41104. /**
  41105. * 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)
  41106. */
  41107. fixedDragMeshScreenSize: boolean;
  41108. /**
  41109. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41110. */
  41111. fixedDragMeshScreenSizeDistanceFactor: number;
  41112. /**
  41113. * Fired when a rotation sphere or scale box is dragged
  41114. */
  41115. onDragStartObservable: Observable<{}>;
  41116. /**
  41117. * Fired when a scale box is dragged
  41118. */
  41119. onScaleBoxDragObservable: Observable<{}>;
  41120. /**
  41121. * Fired when a scale box drag is ended
  41122. */
  41123. onScaleBoxDragEndObservable: Observable<{}>;
  41124. /**
  41125. * Fired when a rotation sphere is dragged
  41126. */
  41127. onRotationSphereDragObservable: Observable<{}>;
  41128. /**
  41129. * Fired when a rotation sphere drag is ended
  41130. */
  41131. onRotationSphereDragEndObservable: Observable<{}>;
  41132. /**
  41133. * 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)
  41134. */
  41135. scalePivot: Nullable<Vector3>;
  41136. private _anchorMesh;
  41137. private _existingMeshScale;
  41138. private _dragMesh;
  41139. private pointerDragBehavior;
  41140. /**
  41141. * Creates an BoundingBoxGizmo
  41142. * @param gizmoLayer The utility layer the gizmo will be added to
  41143. * @param color The color of the gizmo
  41144. */
  41145. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41146. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41147. private _selectNode;
  41148. /**
  41149. * Updates the bounding box information for the Gizmo
  41150. */
  41151. updateBoundingBox(): void;
  41152. private _updateRotationSpheres;
  41153. private _updateScaleBoxes;
  41154. /**
  41155. * Enables rotation on the specified axis and disables rotation on the others
  41156. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41157. */
  41158. setEnabledRotationAxis(axis: string): void;
  41159. /**
  41160. * Enables/disables scaling
  41161. * @param enable if scaling should be enabled
  41162. */
  41163. setEnabledScaling(enable: boolean): void;
  41164. private _updateDummy;
  41165. /**
  41166. * Enables a pointer drag behavior on the bounding box of the gizmo
  41167. */
  41168. enableDragBehavior(): void;
  41169. /**
  41170. * Disposes of the gizmo
  41171. */
  41172. dispose(): void;
  41173. /**
  41174. * 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)
  41175. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41176. * @returns the bounding box mesh with the passed in mesh as a child
  41177. */
  41178. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41179. /**
  41180. * CustomMeshes are not supported by this gizmo
  41181. * @param mesh The mesh to replace the default mesh of the gizmo
  41182. */
  41183. setCustomMesh(mesh: Mesh): void;
  41184. }
  41185. }
  41186. declare module BABYLON {
  41187. /**
  41188. * Single plane rotation gizmo
  41189. */
  41190. export class PlaneRotationGizmo extends Gizmo {
  41191. /**
  41192. * Drag behavior responsible for the gizmos dragging interactions
  41193. */
  41194. dragBehavior: PointerDragBehavior;
  41195. private _pointerObserver;
  41196. /**
  41197. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41198. */
  41199. snapDistance: number;
  41200. /**
  41201. * Event that fires each time the gizmo snaps to a new location.
  41202. * * snapDistance is the the change in distance
  41203. */
  41204. onSnapObservable: Observable<{
  41205. snapDistance: number;
  41206. }>;
  41207. /**
  41208. * Creates a PlaneRotationGizmo
  41209. * @param gizmoLayer The utility layer the gizmo will be added to
  41210. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41211. * @param color The color of the gizmo
  41212. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41213. */
  41214. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41215. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41216. /**
  41217. * Disposes of the gizmo
  41218. */
  41219. dispose(): void;
  41220. }
  41221. }
  41222. declare module BABYLON {
  41223. /**
  41224. * Gizmo that enables rotating a mesh along 3 axis
  41225. */
  41226. export class RotationGizmo extends Gizmo {
  41227. /**
  41228. * Internal gizmo used for interactions on the x axis
  41229. */
  41230. xGizmo: PlaneRotationGizmo;
  41231. /**
  41232. * Internal gizmo used for interactions on the y axis
  41233. */
  41234. yGizmo: PlaneRotationGizmo;
  41235. /**
  41236. * Internal gizmo used for interactions on the z axis
  41237. */
  41238. zGizmo: PlaneRotationGizmo;
  41239. /** Fires an event when any of it's sub gizmos are dragged */
  41240. onDragStartObservable: Observable<{}>;
  41241. /** Fires an event when any of it's sub gizmos are released from dragging */
  41242. onDragEndObservable: Observable<{}>;
  41243. attachedMesh: Nullable<AbstractMesh>;
  41244. /**
  41245. * Creates a RotationGizmo
  41246. * @param gizmoLayer The utility layer the gizmo will be added to
  41247. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41248. */
  41249. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41250. updateGizmoRotationToMatchAttachedMesh: boolean;
  41251. /**
  41252. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41253. */
  41254. snapDistance: number;
  41255. /**
  41256. * Ratio for the scale of the gizmo (Default: 1)
  41257. */
  41258. scaleRatio: number;
  41259. /**
  41260. * Disposes of the gizmo
  41261. */
  41262. dispose(): void;
  41263. /**
  41264. * CustomMeshes are not supported by this gizmo
  41265. * @param mesh The mesh to replace the default mesh of the gizmo
  41266. */
  41267. setCustomMesh(mesh: Mesh): void;
  41268. }
  41269. }
  41270. declare module BABYLON {
  41271. /**
  41272. * Gizmo that enables dragging a mesh along 3 axis
  41273. */
  41274. export class PositionGizmo extends Gizmo {
  41275. /**
  41276. * Internal gizmo used for interactions on the x axis
  41277. */
  41278. xGizmo: AxisDragGizmo;
  41279. /**
  41280. * Internal gizmo used for interactions on the y axis
  41281. */
  41282. yGizmo: AxisDragGizmo;
  41283. /**
  41284. * Internal gizmo used for interactions on the z axis
  41285. */
  41286. zGizmo: AxisDragGizmo;
  41287. /** Fires an event when any of it's sub gizmos are dragged */
  41288. onDragStartObservable: Observable<{}>;
  41289. /** Fires an event when any of it's sub gizmos are released from dragging */
  41290. onDragEndObservable: Observable<{}>;
  41291. attachedMesh: Nullable<AbstractMesh>;
  41292. /**
  41293. * Creates a PositionGizmo
  41294. * @param gizmoLayer The utility layer the gizmo will be added to
  41295. */
  41296. constructor(gizmoLayer?: UtilityLayerRenderer);
  41297. updateGizmoRotationToMatchAttachedMesh: boolean;
  41298. /**
  41299. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41300. */
  41301. snapDistance: number;
  41302. /**
  41303. * Ratio for the scale of the gizmo (Default: 1)
  41304. */
  41305. scaleRatio: number;
  41306. /**
  41307. * Disposes of the gizmo
  41308. */
  41309. dispose(): void;
  41310. /**
  41311. * CustomMeshes are not supported by this gizmo
  41312. * @param mesh The mesh to replace the default mesh of the gizmo
  41313. */
  41314. setCustomMesh(mesh: Mesh): void;
  41315. }
  41316. }
  41317. declare module BABYLON {
  41318. /**
  41319. * Class containing static functions to help procedurally build meshes
  41320. */
  41321. export class PolyhedronBuilder {
  41322. /**
  41323. * Creates a polyhedron mesh
  41324. * * 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
  41325. * * The parameter `size` (positive float, default 1) sets the polygon size
  41326. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41327. * * 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`
  41328. * * 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
  41329. * * 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)`)
  41330. * * 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
  41331. * * 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
  41332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41333. * * 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
  41334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41335. * @param name defines the name of the mesh
  41336. * @param options defines the options used to create the mesh
  41337. * @param scene defines the hosting scene
  41338. * @returns the polyhedron mesh
  41339. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41340. */
  41341. static CreatePolyhedron(name: string, options: {
  41342. type?: number;
  41343. size?: number;
  41344. sizeX?: number;
  41345. sizeY?: number;
  41346. sizeZ?: number;
  41347. custom?: any;
  41348. faceUV?: Vector4[];
  41349. faceColors?: Color4[];
  41350. flat?: boolean;
  41351. updatable?: boolean;
  41352. sideOrientation?: number;
  41353. frontUVs?: Vector4;
  41354. backUVs?: Vector4;
  41355. }, scene: Scene): Mesh;
  41356. }
  41357. }
  41358. declare module BABYLON {
  41359. /**
  41360. * Gizmo that enables scaling a mesh along 3 axis
  41361. */
  41362. export class ScaleGizmo extends Gizmo {
  41363. /**
  41364. * Internal gizmo used for interactions on the x axis
  41365. */
  41366. xGizmo: AxisScaleGizmo;
  41367. /**
  41368. * Internal gizmo used for interactions on the y axis
  41369. */
  41370. yGizmo: AxisScaleGizmo;
  41371. /**
  41372. * Internal gizmo used for interactions on the z axis
  41373. */
  41374. zGizmo: AxisScaleGizmo;
  41375. /**
  41376. * Internal gizmo used to scale all axis equally
  41377. */
  41378. uniformScaleGizmo: AxisScaleGizmo;
  41379. /** Fires an event when any of it's sub gizmos are dragged */
  41380. onDragStartObservable: Observable<{}>;
  41381. /** Fires an event when any of it's sub gizmos are released from dragging */
  41382. onDragEndObservable: Observable<{}>;
  41383. attachedMesh: Nullable<AbstractMesh>;
  41384. /**
  41385. * Creates a ScaleGizmo
  41386. * @param gizmoLayer The utility layer the gizmo will be added to
  41387. */
  41388. constructor(gizmoLayer?: UtilityLayerRenderer);
  41389. updateGizmoRotationToMatchAttachedMesh: boolean;
  41390. /**
  41391. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41392. */
  41393. snapDistance: number;
  41394. /**
  41395. * Ratio for the scale of the gizmo (Default: 1)
  41396. */
  41397. scaleRatio: number;
  41398. /**
  41399. * Disposes of the gizmo
  41400. */
  41401. dispose(): void;
  41402. }
  41403. }
  41404. declare module BABYLON {
  41405. /**
  41406. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41407. */
  41408. export class GizmoManager implements IDisposable {
  41409. private scene;
  41410. /**
  41411. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41412. */
  41413. gizmos: {
  41414. positionGizmo: Nullable<PositionGizmo>;
  41415. rotationGizmo: Nullable<RotationGizmo>;
  41416. scaleGizmo: Nullable<ScaleGizmo>;
  41417. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41418. };
  41419. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41420. clearGizmoOnEmptyPointerEvent: boolean;
  41421. /** Fires an event when the manager is attached to a mesh */
  41422. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41423. private _gizmosEnabled;
  41424. private _pointerObserver;
  41425. private _attachedMesh;
  41426. private _boundingBoxColor;
  41427. private _defaultUtilityLayer;
  41428. private _defaultKeepDepthUtilityLayer;
  41429. /**
  41430. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41431. */
  41432. boundingBoxDragBehavior: SixDofDragBehavior;
  41433. /**
  41434. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41435. */
  41436. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41437. /**
  41438. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41439. */
  41440. usePointerToAttachGizmos: boolean;
  41441. /**
  41442. * Instatiates a gizmo manager
  41443. * @param scene the scene to overlay the gizmos on top of
  41444. */
  41445. constructor(scene: Scene);
  41446. /**
  41447. * Attaches a set of gizmos to the specified mesh
  41448. * @param mesh The mesh the gizmo's should be attached to
  41449. */
  41450. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41451. /**
  41452. * If the position gizmo is enabled
  41453. */
  41454. positionGizmoEnabled: boolean;
  41455. /**
  41456. * If the rotation gizmo is enabled
  41457. */
  41458. rotationGizmoEnabled: boolean;
  41459. /**
  41460. * If the scale gizmo is enabled
  41461. */
  41462. scaleGizmoEnabled: boolean;
  41463. /**
  41464. * If the boundingBox gizmo is enabled
  41465. */
  41466. boundingBoxGizmoEnabled: boolean;
  41467. /**
  41468. * Disposes of the gizmo manager
  41469. */
  41470. dispose(): void;
  41471. }
  41472. }
  41473. declare module BABYLON {
  41474. /**
  41475. * Gizmo that enables viewing a light
  41476. */
  41477. export class LightGizmo extends Gizmo {
  41478. private _box;
  41479. /**
  41480. * Creates a LightGizmo
  41481. * @param gizmoLayer The utility layer the gizmo will be added to
  41482. */
  41483. constructor(gizmoLayer?: UtilityLayerRenderer);
  41484. private _light;
  41485. /**
  41486. * The light that the gizmo is attached to
  41487. */
  41488. light: Nullable<Light>;
  41489. /**
  41490. * @hidden
  41491. * Updates the gizmo to match the attached mesh's position/rotation
  41492. */
  41493. protected _update(): void;
  41494. }
  41495. }
  41496. declare module BABYLON {
  41497. /** @hidden */
  41498. export var backgroundFragmentDeclaration: {
  41499. name: string;
  41500. shader: string;
  41501. };
  41502. }
  41503. declare module BABYLON {
  41504. /** @hidden */
  41505. export var backgroundUboDeclaration: {
  41506. name: string;
  41507. shader: string;
  41508. };
  41509. }
  41510. declare module BABYLON {
  41511. /** @hidden */
  41512. export var backgroundPixelShader: {
  41513. name: string;
  41514. shader: string;
  41515. };
  41516. }
  41517. declare module BABYLON {
  41518. /** @hidden */
  41519. export var backgroundVertexDeclaration: {
  41520. name: string;
  41521. shader: string;
  41522. };
  41523. }
  41524. declare module BABYLON {
  41525. /** @hidden */
  41526. export var backgroundVertexShader: {
  41527. name: string;
  41528. shader: string;
  41529. };
  41530. }
  41531. declare module BABYLON {
  41532. /**
  41533. * Background material used to create an efficient environement around your scene.
  41534. */
  41535. export class BackgroundMaterial extends PushMaterial {
  41536. /**
  41537. * Standard reflectance value at parallel view angle.
  41538. */
  41539. static StandardReflectance0: number;
  41540. /**
  41541. * Standard reflectance value at grazing angle.
  41542. */
  41543. static StandardReflectance90: number;
  41544. protected _primaryColor: Color3;
  41545. /**
  41546. * Key light Color (multiply against the environement texture)
  41547. */
  41548. primaryColor: Color3;
  41549. protected __perceptualColor: Nullable<Color3>;
  41550. /**
  41551. * Experimental Internal Use Only.
  41552. *
  41553. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  41554. * This acts as a helper to set the primary color to a more "human friendly" value.
  41555. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  41556. * output color as close as possible from the chosen value.
  41557. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  41558. * part of lighting setup.)
  41559. */
  41560. _perceptualColor: Nullable<Color3>;
  41561. protected _primaryColorShadowLevel: float;
  41562. /**
  41563. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  41564. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  41565. */
  41566. primaryColorShadowLevel: float;
  41567. protected _primaryColorHighlightLevel: float;
  41568. /**
  41569. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  41570. * The primary color is used at the level chosen to define what the white area would look.
  41571. */
  41572. primaryColorHighlightLevel: float;
  41573. protected _reflectionTexture: Nullable<BaseTexture>;
  41574. /**
  41575. * Reflection Texture used in the material.
  41576. * Should be author in a specific way for the best result (refer to the documentation).
  41577. */
  41578. reflectionTexture: Nullable<BaseTexture>;
  41579. protected _reflectionBlur: float;
  41580. /**
  41581. * Reflection Texture level of blur.
  41582. *
  41583. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  41584. * texture twice.
  41585. */
  41586. reflectionBlur: float;
  41587. protected _diffuseTexture: Nullable<BaseTexture>;
  41588. /**
  41589. * Diffuse Texture used in the material.
  41590. * Should be author in a specific way for the best result (refer to the documentation).
  41591. */
  41592. diffuseTexture: Nullable<BaseTexture>;
  41593. protected _shadowLights: Nullable<IShadowLight[]>;
  41594. /**
  41595. * Specify the list of lights casting shadow on the material.
  41596. * All scene shadow lights will be included if null.
  41597. */
  41598. shadowLights: Nullable<IShadowLight[]>;
  41599. protected _shadowLevel: float;
  41600. /**
  41601. * Helps adjusting the shadow to a softer level if required.
  41602. * 0 means black shadows and 1 means no shadows.
  41603. */
  41604. shadowLevel: float;
  41605. protected _sceneCenter: Vector3;
  41606. /**
  41607. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  41608. * It is usually zero but might be interesting to modify according to your setup.
  41609. */
  41610. sceneCenter: Vector3;
  41611. protected _opacityFresnel: boolean;
  41612. /**
  41613. * This helps specifying that the material is falling off to the sky box at grazing angle.
  41614. * This helps ensuring a nice transition when the camera goes under the ground.
  41615. */
  41616. opacityFresnel: boolean;
  41617. protected _reflectionFresnel: boolean;
  41618. /**
  41619. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  41620. * This helps adding a mirror texture on the ground.
  41621. */
  41622. reflectionFresnel: boolean;
  41623. protected _reflectionFalloffDistance: number;
  41624. /**
  41625. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  41626. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  41627. */
  41628. reflectionFalloffDistance: number;
  41629. protected _reflectionAmount: number;
  41630. /**
  41631. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  41632. */
  41633. reflectionAmount: number;
  41634. protected _reflectionReflectance0: number;
  41635. /**
  41636. * This specifies the weight of the reflection at grazing angle.
  41637. */
  41638. reflectionReflectance0: number;
  41639. protected _reflectionReflectance90: number;
  41640. /**
  41641. * This specifies the weight of the reflection at a perpendicular point of view.
  41642. */
  41643. reflectionReflectance90: number;
  41644. /**
  41645. * Sets the reflection reflectance fresnel values according to the default standard
  41646. * empirically know to work well :-)
  41647. */
  41648. reflectionStandardFresnelWeight: number;
  41649. protected _useRGBColor: boolean;
  41650. /**
  41651. * Helps to directly use the maps channels instead of their level.
  41652. */
  41653. useRGBColor: boolean;
  41654. protected _enableNoise: boolean;
  41655. /**
  41656. * This helps reducing the banding effect that could occur on the background.
  41657. */
  41658. enableNoise: boolean;
  41659. /**
  41660. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  41661. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  41662. * Recommended to be keep at 1.0 except for special cases.
  41663. */
  41664. fovMultiplier: number;
  41665. private _fovMultiplier;
  41666. /**
  41667. * Enable the FOV adjustment feature controlled by fovMultiplier.
  41668. */
  41669. useEquirectangularFOV: boolean;
  41670. private _maxSimultaneousLights;
  41671. /**
  41672. * Number of Simultaneous lights allowed on the material.
  41673. */
  41674. maxSimultaneousLights: int;
  41675. /**
  41676. * Default configuration related to image processing available in the Background Material.
  41677. */
  41678. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41679. /**
  41680. * Keep track of the image processing observer to allow dispose and replace.
  41681. */
  41682. private _imageProcessingObserver;
  41683. /**
  41684. * Attaches a new image processing configuration to the PBR Material.
  41685. * @param configuration (if null the scene configuration will be use)
  41686. */
  41687. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41688. /**
  41689. * Gets the image processing configuration used either in this material.
  41690. */
  41691. /**
  41692. * Sets the Default image processing configuration used either in the this material.
  41693. *
  41694. * If sets to null, the scene one is in use.
  41695. */
  41696. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  41697. /**
  41698. * Gets wether the color curves effect is enabled.
  41699. */
  41700. /**
  41701. * Sets wether the color curves effect is enabled.
  41702. */
  41703. cameraColorCurvesEnabled: boolean;
  41704. /**
  41705. * Gets wether the color grading effect is enabled.
  41706. */
  41707. /**
  41708. * Gets wether the color grading effect is enabled.
  41709. */
  41710. cameraColorGradingEnabled: boolean;
  41711. /**
  41712. * Gets wether tonemapping is enabled or not.
  41713. */
  41714. /**
  41715. * Sets wether tonemapping is enabled or not
  41716. */
  41717. cameraToneMappingEnabled: boolean;
  41718. /**
  41719. * The camera exposure used on this material.
  41720. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41721. * This corresponds to a photographic exposure.
  41722. */
  41723. /**
  41724. * The camera exposure used on this material.
  41725. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41726. * This corresponds to a photographic exposure.
  41727. */
  41728. cameraExposure: float;
  41729. /**
  41730. * Gets The camera contrast used on this material.
  41731. */
  41732. /**
  41733. * Sets The camera contrast used on this material.
  41734. */
  41735. cameraContrast: float;
  41736. /**
  41737. * Gets the Color Grading 2D Lookup Texture.
  41738. */
  41739. /**
  41740. * Sets the Color Grading 2D Lookup Texture.
  41741. */
  41742. cameraColorGradingTexture: Nullable<BaseTexture>;
  41743. /**
  41744. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41745. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41746. * 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;
  41747. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41748. */
  41749. /**
  41750. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41751. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41752. * 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;
  41753. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41754. */
  41755. cameraColorCurves: Nullable<ColorCurves>;
  41756. /**
  41757. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  41758. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  41759. */
  41760. switchToBGR: boolean;
  41761. private _renderTargets;
  41762. private _reflectionControls;
  41763. private _white;
  41764. private _primaryShadowColor;
  41765. private _primaryHighlightColor;
  41766. /**
  41767. * Instantiates a Background Material in the given scene
  41768. * @param name The friendly name of the material
  41769. * @param scene The scene to add the material to
  41770. */
  41771. constructor(name: string, scene: Scene);
  41772. /**
  41773. * Gets a boolean indicating that current material needs to register RTT
  41774. */
  41775. readonly hasRenderTargetTextures: boolean;
  41776. /**
  41777. * The entire material has been created in order to prevent overdraw.
  41778. * @returns false
  41779. */
  41780. needAlphaTesting(): boolean;
  41781. /**
  41782. * The entire material has been created in order to prevent overdraw.
  41783. * @returns true if blending is enable
  41784. */
  41785. needAlphaBlending(): boolean;
  41786. /**
  41787. * Checks wether the material is ready to be rendered for a given mesh.
  41788. * @param mesh The mesh to render
  41789. * @param subMesh The submesh to check against
  41790. * @param useInstances Specify wether or not the material is used with instances
  41791. * @returns true if all the dependencies are ready (Textures, Effects...)
  41792. */
  41793. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41794. /**
  41795. * Compute the primary color according to the chosen perceptual color.
  41796. */
  41797. private _computePrimaryColorFromPerceptualColor;
  41798. /**
  41799. * Compute the highlights and shadow colors according to their chosen levels.
  41800. */
  41801. private _computePrimaryColors;
  41802. /**
  41803. * Build the uniform buffer used in the material.
  41804. */
  41805. buildUniformLayout(): void;
  41806. /**
  41807. * Unbind the material.
  41808. */
  41809. unbind(): void;
  41810. /**
  41811. * Bind only the world matrix to the material.
  41812. * @param world The world matrix to bind.
  41813. */
  41814. bindOnlyWorldMatrix(world: Matrix): void;
  41815. /**
  41816. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  41817. * @param world The world matrix to bind.
  41818. * @param subMesh The submesh to bind for.
  41819. */
  41820. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41821. /**
  41822. * Dispose the material.
  41823. * @param forceDisposeEffect Force disposal of the associated effect.
  41824. * @param forceDisposeTextures Force disposal of the associated textures.
  41825. */
  41826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41827. /**
  41828. * Clones the material.
  41829. * @param name The cloned name.
  41830. * @returns The cloned material.
  41831. */
  41832. clone(name: string): BackgroundMaterial;
  41833. /**
  41834. * Serializes the current material to its JSON representation.
  41835. * @returns The JSON representation.
  41836. */
  41837. serialize(): any;
  41838. /**
  41839. * Gets the class name of the material
  41840. * @returns "BackgroundMaterial"
  41841. */
  41842. getClassName(): string;
  41843. /**
  41844. * Parse a JSON input to create back a background material.
  41845. * @param source The JSON data to parse
  41846. * @param scene The scene to create the parsed material in
  41847. * @param rootUrl The root url of the assets the material depends upon
  41848. * @returns the instantiated BackgroundMaterial.
  41849. */
  41850. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  41851. }
  41852. }
  41853. declare module BABYLON {
  41854. /**
  41855. * Represents the different options available during the creation of
  41856. * a Environment helper.
  41857. *
  41858. * This can control the default ground, skybox and image processing setup of your scene.
  41859. */
  41860. export interface IEnvironmentHelperOptions {
  41861. /**
  41862. * Specifies wether or not to create a ground.
  41863. * True by default.
  41864. */
  41865. createGround: boolean;
  41866. /**
  41867. * Specifies the ground size.
  41868. * 15 by default.
  41869. */
  41870. groundSize: number;
  41871. /**
  41872. * The texture used on the ground for the main color.
  41873. * Comes from the BabylonJS CDN by default.
  41874. *
  41875. * Remarks: Can be either a texture or a url.
  41876. */
  41877. groundTexture: string | BaseTexture;
  41878. /**
  41879. * The color mixed in the ground texture by default.
  41880. * BabylonJS clearColor by default.
  41881. */
  41882. groundColor: Color3;
  41883. /**
  41884. * Specifies the ground opacity.
  41885. * 1 by default.
  41886. */
  41887. groundOpacity: number;
  41888. /**
  41889. * Enables the ground to receive shadows.
  41890. * True by default.
  41891. */
  41892. enableGroundShadow: boolean;
  41893. /**
  41894. * Helps preventing the shadow to be fully black on the ground.
  41895. * 0.5 by default.
  41896. */
  41897. groundShadowLevel: number;
  41898. /**
  41899. * Creates a mirror texture attach to the ground.
  41900. * false by default.
  41901. */
  41902. enableGroundMirror: boolean;
  41903. /**
  41904. * Specifies the ground mirror size ratio.
  41905. * 0.3 by default as the default kernel is 64.
  41906. */
  41907. groundMirrorSizeRatio: number;
  41908. /**
  41909. * Specifies the ground mirror blur kernel size.
  41910. * 64 by default.
  41911. */
  41912. groundMirrorBlurKernel: number;
  41913. /**
  41914. * Specifies the ground mirror visibility amount.
  41915. * 1 by default
  41916. */
  41917. groundMirrorAmount: number;
  41918. /**
  41919. * Specifies the ground mirror reflectance weight.
  41920. * This uses the standard weight of the background material to setup the fresnel effect
  41921. * of the mirror.
  41922. * 1 by default.
  41923. */
  41924. groundMirrorFresnelWeight: number;
  41925. /**
  41926. * Specifies the ground mirror Falloff distance.
  41927. * This can helps reducing the size of the reflection.
  41928. * 0 by Default.
  41929. */
  41930. groundMirrorFallOffDistance: number;
  41931. /**
  41932. * Specifies the ground mirror texture type.
  41933. * Unsigned Int by Default.
  41934. */
  41935. groundMirrorTextureType: number;
  41936. /**
  41937. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  41938. * the shown objects.
  41939. */
  41940. groundYBias: number;
  41941. /**
  41942. * Specifies wether or not to create a skybox.
  41943. * True by default.
  41944. */
  41945. createSkybox: boolean;
  41946. /**
  41947. * Specifies the skybox size.
  41948. * 20 by default.
  41949. */
  41950. skyboxSize: number;
  41951. /**
  41952. * The texture used on the skybox for the main color.
  41953. * Comes from the BabylonJS CDN by default.
  41954. *
  41955. * Remarks: Can be either a texture or a url.
  41956. */
  41957. skyboxTexture: string | BaseTexture;
  41958. /**
  41959. * The color mixed in the skybox texture by default.
  41960. * BabylonJS clearColor by default.
  41961. */
  41962. skyboxColor: Color3;
  41963. /**
  41964. * The background rotation around the Y axis of the scene.
  41965. * This helps aligning the key lights of your scene with the background.
  41966. * 0 by default.
  41967. */
  41968. backgroundYRotation: number;
  41969. /**
  41970. * Compute automatically the size of the elements to best fit with the scene.
  41971. */
  41972. sizeAuto: boolean;
  41973. /**
  41974. * Default position of the rootMesh if autoSize is not true.
  41975. */
  41976. rootPosition: Vector3;
  41977. /**
  41978. * Sets up the image processing in the scene.
  41979. * true by default.
  41980. */
  41981. setupImageProcessing: boolean;
  41982. /**
  41983. * The texture used as your environment texture in the scene.
  41984. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  41985. *
  41986. * Remarks: Can be either a texture or a url.
  41987. */
  41988. environmentTexture: string | BaseTexture;
  41989. /**
  41990. * The value of the exposure to apply to the scene.
  41991. * 0.6 by default if setupImageProcessing is true.
  41992. */
  41993. cameraExposure: number;
  41994. /**
  41995. * The value of the contrast to apply to the scene.
  41996. * 1.6 by default if setupImageProcessing is true.
  41997. */
  41998. cameraContrast: number;
  41999. /**
  42000. * Specifies wether or not tonemapping should be enabled in the scene.
  42001. * true by default if setupImageProcessing is true.
  42002. */
  42003. toneMappingEnabled: boolean;
  42004. }
  42005. /**
  42006. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42007. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42008. * It also helps with the default setup of your imageProcessing configuration.
  42009. */
  42010. export class EnvironmentHelper {
  42011. /**
  42012. * Default ground texture URL.
  42013. */
  42014. private static _groundTextureCDNUrl;
  42015. /**
  42016. * Default skybox texture URL.
  42017. */
  42018. private static _skyboxTextureCDNUrl;
  42019. /**
  42020. * Default environment texture URL.
  42021. */
  42022. private static _environmentTextureCDNUrl;
  42023. /**
  42024. * Creates the default options for the helper.
  42025. */
  42026. private static _getDefaultOptions;
  42027. private _rootMesh;
  42028. /**
  42029. * Gets the root mesh created by the helper.
  42030. */
  42031. readonly rootMesh: Mesh;
  42032. private _skybox;
  42033. /**
  42034. * Gets the skybox created by the helper.
  42035. */
  42036. readonly skybox: Nullable<Mesh>;
  42037. private _skyboxTexture;
  42038. /**
  42039. * Gets the skybox texture created by the helper.
  42040. */
  42041. readonly skyboxTexture: Nullable<BaseTexture>;
  42042. private _skyboxMaterial;
  42043. /**
  42044. * Gets the skybox material created by the helper.
  42045. */
  42046. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42047. private _ground;
  42048. /**
  42049. * Gets the ground mesh created by the helper.
  42050. */
  42051. readonly ground: Nullable<Mesh>;
  42052. private _groundTexture;
  42053. /**
  42054. * Gets the ground texture created by the helper.
  42055. */
  42056. readonly groundTexture: Nullable<BaseTexture>;
  42057. private _groundMirror;
  42058. /**
  42059. * Gets the ground mirror created by the helper.
  42060. */
  42061. readonly groundMirror: Nullable<MirrorTexture>;
  42062. /**
  42063. * Gets the ground mirror render list to helps pushing the meshes
  42064. * you wish in the ground reflection.
  42065. */
  42066. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42067. private _groundMaterial;
  42068. /**
  42069. * Gets the ground material created by the helper.
  42070. */
  42071. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42072. /**
  42073. * Stores the creation options.
  42074. */
  42075. private readonly _scene;
  42076. private _options;
  42077. /**
  42078. * This observable will be notified with any error during the creation of the environment,
  42079. * mainly texture creation errors.
  42080. */
  42081. onErrorObservable: Observable<{
  42082. message?: string;
  42083. exception?: any;
  42084. }>;
  42085. /**
  42086. * constructor
  42087. * @param options Defines the options we want to customize the helper
  42088. * @param scene The scene to add the material to
  42089. */
  42090. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42091. /**
  42092. * Updates the background according to the new options
  42093. * @param options
  42094. */
  42095. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42096. /**
  42097. * Sets the primary color of all the available elements.
  42098. * @param color the main color to affect to the ground and the background
  42099. */
  42100. setMainColor(color: Color3): void;
  42101. /**
  42102. * Setup the image processing according to the specified options.
  42103. */
  42104. private _setupImageProcessing;
  42105. /**
  42106. * Setup the environment texture according to the specified options.
  42107. */
  42108. private _setupEnvironmentTexture;
  42109. /**
  42110. * Setup the background according to the specified options.
  42111. */
  42112. private _setupBackground;
  42113. /**
  42114. * Get the scene sizes according to the setup.
  42115. */
  42116. private _getSceneSize;
  42117. /**
  42118. * Setup the ground according to the specified options.
  42119. */
  42120. private _setupGround;
  42121. /**
  42122. * Setup the ground material according to the specified options.
  42123. */
  42124. private _setupGroundMaterial;
  42125. /**
  42126. * Setup the ground diffuse texture according to the specified options.
  42127. */
  42128. private _setupGroundDiffuseTexture;
  42129. /**
  42130. * Setup the ground mirror texture according to the specified options.
  42131. */
  42132. private _setupGroundMirrorTexture;
  42133. /**
  42134. * Setup the ground to receive the mirror texture.
  42135. */
  42136. private _setupMirrorInGroundMaterial;
  42137. /**
  42138. * Setup the skybox according to the specified options.
  42139. */
  42140. private _setupSkybox;
  42141. /**
  42142. * Setup the skybox material according to the specified options.
  42143. */
  42144. private _setupSkyboxMaterial;
  42145. /**
  42146. * Setup the skybox reflection texture according to the specified options.
  42147. */
  42148. private _setupSkyboxReflectionTexture;
  42149. private _errorHandler;
  42150. /**
  42151. * Dispose all the elements created by the Helper.
  42152. */
  42153. dispose(): void;
  42154. }
  42155. }
  42156. declare module BABYLON {
  42157. /**
  42158. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42159. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42160. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42161. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42162. */
  42163. export class PhotoDome extends TransformNode {
  42164. private _useDirectMapping;
  42165. /**
  42166. * The texture being displayed on the sphere
  42167. */
  42168. protected _photoTexture: Texture;
  42169. /**
  42170. * Gets or sets the texture being displayed on the sphere
  42171. */
  42172. photoTexture: Texture;
  42173. /**
  42174. * Observable raised when an error occured while loading the 360 image
  42175. */
  42176. onLoadErrorObservable: Observable<string>;
  42177. /**
  42178. * The skybox material
  42179. */
  42180. protected _material: BackgroundMaterial;
  42181. /**
  42182. * The surface used for the skybox
  42183. */
  42184. protected _mesh: Mesh;
  42185. /**
  42186. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42187. * Also see the options.resolution property.
  42188. */
  42189. fovMultiplier: number;
  42190. /**
  42191. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42192. * @param name Element's name, child elements will append suffixes for their own names.
  42193. * @param urlsOfPhoto defines the url of the photo to display
  42194. * @param options defines an object containing optional or exposed sub element properties
  42195. * @param onError defines a callback called when an error occured while loading the texture
  42196. */
  42197. constructor(name: string, urlOfPhoto: string, options: {
  42198. resolution?: number;
  42199. size?: number;
  42200. useDirectMapping?: boolean;
  42201. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42202. /**
  42203. * Releases resources associated with this node.
  42204. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42205. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42206. */
  42207. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42208. }
  42209. }
  42210. declare module BABYLON {
  42211. /**
  42212. * Class used to host texture specific utilities
  42213. */
  42214. export class TextureTools {
  42215. /**
  42216. * Uses the GPU to create a copy texture rescaled at a given size
  42217. * @param texture Texture to copy from
  42218. * @param width defines the desired width
  42219. * @param height defines the desired height
  42220. * @param useBilinearMode defines if bilinear mode has to be used
  42221. * @return the generated texture
  42222. */
  42223. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  42224. /**
  42225. * Gets an environment BRDF texture for a given scene
  42226. * @param scene defines the hosting scene
  42227. * @returns the environment BRDF texture
  42228. */
  42229. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42230. private static _environmentBRDFBase64Texture;
  42231. }
  42232. }
  42233. declare module BABYLON {
  42234. /** @hidden */
  42235. export var pbrFragmentDeclaration: {
  42236. name: string;
  42237. shader: string;
  42238. };
  42239. }
  42240. declare module BABYLON {
  42241. /** @hidden */
  42242. export var pbrUboDeclaration: {
  42243. name: string;
  42244. shader: string;
  42245. };
  42246. }
  42247. declare module BABYLON {
  42248. /** @hidden */
  42249. export var pbrFunctions: {
  42250. name: string;
  42251. shader: string;
  42252. };
  42253. }
  42254. declare module BABYLON {
  42255. /** @hidden */
  42256. export var harmonicsFunctions: {
  42257. name: string;
  42258. shader: string;
  42259. };
  42260. }
  42261. declare module BABYLON {
  42262. /** @hidden */
  42263. export var pbrLightFunctions: {
  42264. name: string;
  42265. shader: string;
  42266. };
  42267. }
  42268. declare module BABYLON {
  42269. /** @hidden */
  42270. export var pbrPixelShader: {
  42271. name: string;
  42272. shader: string;
  42273. };
  42274. }
  42275. declare module BABYLON {
  42276. /** @hidden */
  42277. export var pbrVertexDeclaration: {
  42278. name: string;
  42279. shader: string;
  42280. };
  42281. }
  42282. declare module BABYLON {
  42283. /** @hidden */
  42284. export var pbrVertexShader: {
  42285. name: string;
  42286. shader: string;
  42287. };
  42288. }
  42289. declare module BABYLON {
  42290. /**
  42291. * The Physically based material base class of BJS.
  42292. *
  42293. * This offers the main features of a standard PBR material.
  42294. * For more information, please refer to the documentation :
  42295. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42296. */
  42297. export abstract class PBRBaseMaterial extends PushMaterial {
  42298. /**
  42299. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42300. */
  42301. static readonly PBRMATERIAL_OPAQUE: number;
  42302. /**
  42303. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42304. */
  42305. static readonly PBRMATERIAL_ALPHATEST: number;
  42306. /**
  42307. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42308. */
  42309. static readonly PBRMATERIAL_ALPHABLEND: number;
  42310. /**
  42311. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42312. * They are also discarded below the alpha cutoff threshold to improve performances.
  42313. */
  42314. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42315. /**
  42316. * Defines the default value of how much AO map is occluding the analytical lights
  42317. * (point spot...).
  42318. */
  42319. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42320. /**
  42321. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  42322. */
  42323. static readonly LIGHTFALLOFF_PHYSICAL: number;
  42324. /**
  42325. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  42326. * to enhance interoperability with other engines.
  42327. */
  42328. static readonly LIGHTFALLOFF_GLTF: number;
  42329. /**
  42330. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  42331. * to enhance interoperability with other materials.
  42332. */
  42333. static readonly LIGHTFALLOFF_STANDARD: number;
  42334. /**
  42335. * Intensity of the direct lights e.g. the four lights available in your scene.
  42336. * This impacts both the direct diffuse and specular highlights.
  42337. */
  42338. protected _directIntensity: number;
  42339. /**
  42340. * Intensity of the emissive part of the material.
  42341. * This helps controlling the emissive effect without modifying the emissive color.
  42342. */
  42343. protected _emissiveIntensity: number;
  42344. /**
  42345. * Intensity of the environment e.g. how much the environment will light the object
  42346. * either through harmonics for rough material or through the refelction for shiny ones.
  42347. */
  42348. protected _environmentIntensity: number;
  42349. /**
  42350. * This is a special control allowing the reduction of the specular highlights coming from the
  42351. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42352. */
  42353. protected _specularIntensity: number;
  42354. /**
  42355. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  42356. */
  42357. private _lightingInfos;
  42358. /**
  42359. * Debug Control allowing disabling the bump map on this material.
  42360. */
  42361. protected _disableBumpMap: boolean;
  42362. /**
  42363. * AKA Diffuse Texture in standard nomenclature.
  42364. */
  42365. protected _albedoTexture: BaseTexture;
  42366. /**
  42367. * AKA Occlusion Texture in other nomenclature.
  42368. */
  42369. protected _ambientTexture: BaseTexture;
  42370. /**
  42371. * AKA Occlusion Texture Intensity in other nomenclature.
  42372. */
  42373. protected _ambientTextureStrength: number;
  42374. /**
  42375. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42376. * 1 means it completely occludes it
  42377. * 0 mean it has no impact
  42378. */
  42379. protected _ambientTextureImpactOnAnalyticalLights: number;
  42380. /**
  42381. * Stores the alpha values in a texture.
  42382. */
  42383. protected _opacityTexture: BaseTexture;
  42384. /**
  42385. * Stores the reflection values in a texture.
  42386. */
  42387. protected _reflectionTexture: BaseTexture;
  42388. /**
  42389. * Stores the refraction values in a texture.
  42390. */
  42391. protected _refractionTexture: BaseTexture;
  42392. /**
  42393. * Stores the emissive values in a texture.
  42394. */
  42395. protected _emissiveTexture: BaseTexture;
  42396. /**
  42397. * AKA Specular texture in other nomenclature.
  42398. */
  42399. protected _reflectivityTexture: BaseTexture;
  42400. /**
  42401. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42402. */
  42403. protected _metallicTexture: BaseTexture;
  42404. /**
  42405. * Specifies the metallic scalar of the metallic/roughness workflow.
  42406. * Can also be used to scale the metalness values of the metallic texture.
  42407. */
  42408. protected _metallic: Nullable<number>;
  42409. /**
  42410. * Specifies the roughness scalar of the metallic/roughness workflow.
  42411. * Can also be used to scale the roughness values of the metallic texture.
  42412. */
  42413. protected _roughness: Nullable<number>;
  42414. /**
  42415. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42416. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42417. */
  42418. protected _microSurfaceTexture: BaseTexture;
  42419. /**
  42420. * Stores surface normal data used to displace a mesh in a texture.
  42421. */
  42422. protected _bumpTexture: BaseTexture;
  42423. /**
  42424. * Stores the pre-calculated light information of a mesh in a texture.
  42425. */
  42426. protected _lightmapTexture: BaseTexture;
  42427. /**
  42428. * The color of a material in ambient lighting.
  42429. */
  42430. protected _ambientColor: Color3;
  42431. /**
  42432. * AKA Diffuse Color in other nomenclature.
  42433. */
  42434. protected _albedoColor: Color3;
  42435. /**
  42436. * AKA Specular Color in other nomenclature.
  42437. */
  42438. protected _reflectivityColor: Color3;
  42439. /**
  42440. * The color applied when light is reflected from a material.
  42441. */
  42442. protected _reflectionColor: Color3;
  42443. /**
  42444. * The color applied when light is emitted from a material.
  42445. */
  42446. protected _emissiveColor: Color3;
  42447. /**
  42448. * AKA Glossiness in other nomenclature.
  42449. */
  42450. protected _microSurface: number;
  42451. /**
  42452. * source material index of refraction (IOR)' / 'destination material IOR.
  42453. */
  42454. protected _indexOfRefraction: number;
  42455. /**
  42456. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42457. */
  42458. protected _invertRefractionY: boolean;
  42459. /**
  42460. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42461. * Materials half opaque for instance using refraction could benefit from this control.
  42462. */
  42463. protected _linkRefractionWithTransparency: boolean;
  42464. /**
  42465. * Specifies that the material will use the light map as a show map.
  42466. */
  42467. protected _useLightmapAsShadowmap: boolean;
  42468. /**
  42469. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  42470. * makes the reflect vector face the model (under horizon).
  42471. */
  42472. protected _useHorizonOcclusion: boolean;
  42473. /**
  42474. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  42475. * too much the area relying on ambient texture to define their ambient occlusion.
  42476. */
  42477. protected _useRadianceOcclusion: boolean;
  42478. /**
  42479. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42480. */
  42481. protected _useAlphaFromAlbedoTexture: boolean;
  42482. /**
  42483. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  42484. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42485. */
  42486. protected _useSpecularOverAlpha: boolean;
  42487. /**
  42488. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42489. */
  42490. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42491. /**
  42492. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42493. */
  42494. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  42495. /**
  42496. * Specifies if the metallic texture contains the roughness information in its green channel.
  42497. */
  42498. protected _useRoughnessFromMetallicTextureGreen: boolean;
  42499. /**
  42500. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42501. */
  42502. protected _useMetallnessFromMetallicTextureBlue: boolean;
  42503. /**
  42504. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42505. */
  42506. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  42507. /**
  42508. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42509. */
  42510. protected _useAmbientInGrayScale: boolean;
  42511. /**
  42512. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42513. * The material will try to infer what glossiness each pixel should be.
  42514. */
  42515. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  42516. /**
  42517. * Defines the falloff type used in this material.
  42518. * It by default is Physical.
  42519. */
  42520. protected _lightFalloff: number;
  42521. /**
  42522. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42523. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42524. */
  42525. protected _useRadianceOverAlpha: boolean;
  42526. /**
  42527. * Allows using an object space normal map (instead of tangent space).
  42528. */
  42529. protected _useObjectSpaceNormalMap: boolean;
  42530. /**
  42531. * Allows using the bump map in parallax mode.
  42532. */
  42533. protected _useParallax: boolean;
  42534. /**
  42535. * Allows using the bump map in parallax occlusion mode.
  42536. */
  42537. protected _useParallaxOcclusion: boolean;
  42538. /**
  42539. * Controls the scale bias of the parallax mode.
  42540. */
  42541. protected _parallaxScaleBias: number;
  42542. /**
  42543. * If sets to true, disables all the lights affecting the material.
  42544. */
  42545. protected _disableLighting: boolean;
  42546. /**
  42547. * Number of Simultaneous lights allowed on the material.
  42548. */
  42549. protected _maxSimultaneousLights: number;
  42550. /**
  42551. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  42552. */
  42553. protected _invertNormalMapX: boolean;
  42554. /**
  42555. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  42556. */
  42557. protected _invertNormalMapY: boolean;
  42558. /**
  42559. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  42560. */
  42561. protected _twoSidedLighting: boolean;
  42562. /**
  42563. * Defines the alpha limits in alpha test mode.
  42564. */
  42565. protected _alphaCutOff: number;
  42566. /**
  42567. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42568. */
  42569. protected _forceAlphaTest: boolean;
  42570. /**
  42571. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42572. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  42573. */
  42574. protected _useAlphaFresnel: boolean;
  42575. /**
  42576. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  42577. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  42578. */
  42579. protected _useLinearAlphaFresnel: boolean;
  42580. /**
  42581. * The transparency mode of the material.
  42582. */
  42583. protected _transparencyMode: Nullable<number>;
  42584. /**
  42585. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  42586. * from cos thetav and roughness:
  42587. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  42588. */
  42589. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  42590. /**
  42591. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  42592. */
  42593. protected _forceIrradianceInFragment: boolean;
  42594. /**
  42595. * Force normal to face away from face.
  42596. */
  42597. protected _forceNormalForward: boolean;
  42598. /**
  42599. * Enables specular anti aliasing in the PBR shader.
  42600. * It will both interacts on the Geometry for analytical and IBL lighting.
  42601. * It also prefilter the roughness map based on the bump values.
  42602. */
  42603. protected _enableSpecularAntiAliasing: boolean;
  42604. /**
  42605. * Default configuration related to image processing available in the PBR Material.
  42606. */
  42607. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42608. /**
  42609. * Keep track of the image processing observer to allow dispose and replace.
  42610. */
  42611. private _imageProcessingObserver;
  42612. /**
  42613. * Attaches a new image processing configuration to the PBR Material.
  42614. * @param configuration
  42615. */
  42616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42617. /**
  42618. * Stores the available render targets.
  42619. */
  42620. private _renderTargets;
  42621. /**
  42622. * Sets the global ambient color for the material used in lighting calculations.
  42623. */
  42624. private _globalAmbientColor;
  42625. /**
  42626. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  42627. */
  42628. private _useLogarithmicDepth;
  42629. /**
  42630. * If set to true, no lighting calculations will be applied.
  42631. */
  42632. private _unlit;
  42633. /**
  42634. * Instantiates a new PBRMaterial instance.
  42635. *
  42636. * @param name The material name
  42637. * @param scene The scene the material will be use in.
  42638. */
  42639. constructor(name: string, scene: Scene);
  42640. /**
  42641. * Gets a boolean indicating that current material needs to register RTT
  42642. */
  42643. readonly hasRenderTargetTextures: boolean;
  42644. /**
  42645. * Gets the name of the material class.
  42646. */
  42647. getClassName(): string;
  42648. /**
  42649. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42650. */
  42651. /**
  42652. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  42653. */
  42654. useLogarithmicDepth: boolean;
  42655. /**
  42656. * Gets the current transparency mode.
  42657. */
  42658. /**
  42659. * Sets the transparency mode of the material.
  42660. *
  42661. * | Value | Type | Description |
  42662. * | ----- | ----------------------------------- | ----------- |
  42663. * | 0 | OPAQUE | |
  42664. * | 1 | ALPHATEST | |
  42665. * | 2 | ALPHABLEND | |
  42666. * | 3 | ALPHATESTANDBLEND | |
  42667. *
  42668. */
  42669. transparencyMode: Nullable<number>;
  42670. /**
  42671. * Returns true if alpha blending should be disabled.
  42672. */
  42673. private readonly _disableAlphaBlending;
  42674. /**
  42675. * Specifies whether or not this material should be rendered in alpha blend mode.
  42676. */
  42677. needAlphaBlending(): boolean;
  42678. /**
  42679. * Specifies if the mesh will require alpha blending.
  42680. * @param mesh - BJS mesh.
  42681. */
  42682. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  42683. /**
  42684. * Specifies whether or not this material should be rendered in alpha test mode.
  42685. */
  42686. needAlphaTesting(): boolean;
  42687. /**
  42688. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  42689. */
  42690. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  42691. /**
  42692. * Gets the texture used for the alpha test.
  42693. */
  42694. getAlphaTestTexture(): BaseTexture;
  42695. /**
  42696. * Specifies that the submesh is ready to be used.
  42697. * @param mesh - BJS mesh.
  42698. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  42699. * @param useInstances - Specifies that instances should be used.
  42700. * @returns - boolean indicating that the submesh is ready or not.
  42701. */
  42702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42703. /**
  42704. * Specifies if the material uses metallic roughness workflow.
  42705. * @returns boolean specifiying if the material uses metallic roughness workflow.
  42706. */
  42707. isMetallicWorkflow(): boolean;
  42708. private _prepareEffect;
  42709. private _prepareDefines;
  42710. /**
  42711. * Force shader compilation
  42712. */
  42713. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  42714. clipPlane: boolean;
  42715. }>): void;
  42716. /**
  42717. * Initializes the uniform buffer layout for the shader.
  42718. */
  42719. buildUniformLayout(): void;
  42720. /**
  42721. * Unbinds the textures.
  42722. */
  42723. unbind(): void;
  42724. /**
  42725. * Binds the submesh data.
  42726. * @param world - The world matrix.
  42727. * @param mesh - The BJS mesh.
  42728. * @param subMesh - A submesh of the BJS mesh.
  42729. */
  42730. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42731. /**
  42732. * Returns the animatable textures.
  42733. * @returns - Array of animatable textures.
  42734. */
  42735. getAnimatables(): IAnimatable[];
  42736. /**
  42737. * Returns the texture used for reflections.
  42738. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  42739. */
  42740. private _getReflectionTexture;
  42741. /**
  42742. * Returns the texture used for refraction or null if none is used.
  42743. * @returns - Refection texture if present. If no refraction texture and refraction
  42744. * is linked with transparency, returns environment texture. Otherwise, returns null.
  42745. */
  42746. private _getRefractionTexture;
  42747. /**
  42748. * Disposes the resources of the material.
  42749. * @param forceDisposeEffect - Forces the disposal of effects.
  42750. * @param forceDisposeTextures - Forces the disposal of all textures.
  42751. */
  42752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42753. }
  42754. }
  42755. declare module BABYLON {
  42756. /**
  42757. * The Physically based material of BJS.
  42758. *
  42759. * This offers the main features of a standard PBR material.
  42760. * For more information, please refer to the documentation :
  42761. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  42762. */
  42763. export class PBRMaterial extends PBRBaseMaterial {
  42764. /**
  42765. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  42766. */
  42767. static readonly PBRMATERIAL_OPAQUE: number;
  42768. /**
  42769. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  42770. */
  42771. static readonly PBRMATERIAL_ALPHATEST: number;
  42772. /**
  42773. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42774. */
  42775. static readonly PBRMATERIAL_ALPHABLEND: number;
  42776. /**
  42777. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  42778. * They are also discarded below the alpha cutoff threshold to improve performances.
  42779. */
  42780. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  42781. /**
  42782. * Defines the default value of how much AO map is occluding the analytical lights
  42783. * (point spot...).
  42784. */
  42785. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  42786. /**
  42787. * Intensity of the direct lights e.g. the four lights available in your scene.
  42788. * This impacts both the direct diffuse and specular highlights.
  42789. */
  42790. directIntensity: number;
  42791. /**
  42792. * Intensity of the emissive part of the material.
  42793. * This helps controlling the emissive effect without modifying the emissive color.
  42794. */
  42795. emissiveIntensity: number;
  42796. /**
  42797. * Intensity of the environment e.g. how much the environment will light the object
  42798. * either through harmonics for rough material or through the refelction for shiny ones.
  42799. */
  42800. environmentIntensity: number;
  42801. /**
  42802. * This is a special control allowing the reduction of the specular highlights coming from the
  42803. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  42804. */
  42805. specularIntensity: number;
  42806. /**
  42807. * Debug Control allowing disabling the bump map on this material.
  42808. */
  42809. disableBumpMap: boolean;
  42810. /**
  42811. * AKA Diffuse Texture in standard nomenclature.
  42812. */
  42813. albedoTexture: BaseTexture;
  42814. /**
  42815. * AKA Occlusion Texture in other nomenclature.
  42816. */
  42817. ambientTexture: BaseTexture;
  42818. /**
  42819. * AKA Occlusion Texture Intensity in other nomenclature.
  42820. */
  42821. ambientTextureStrength: number;
  42822. /**
  42823. * Defines how much the AO map is occluding the analytical lights (point spot...).
  42824. * 1 means it completely occludes it
  42825. * 0 mean it has no impact
  42826. */
  42827. ambientTextureImpactOnAnalyticalLights: number;
  42828. /**
  42829. * Stores the alpha values in a texture.
  42830. */
  42831. opacityTexture: BaseTexture;
  42832. /**
  42833. * Stores the reflection values in a texture.
  42834. */
  42835. reflectionTexture: Nullable<BaseTexture>;
  42836. /**
  42837. * Stores the emissive values in a texture.
  42838. */
  42839. emissiveTexture: BaseTexture;
  42840. /**
  42841. * AKA Specular texture in other nomenclature.
  42842. */
  42843. reflectivityTexture: BaseTexture;
  42844. /**
  42845. * Used to switch from specular/glossiness to metallic/roughness workflow.
  42846. */
  42847. metallicTexture: BaseTexture;
  42848. /**
  42849. * Specifies the metallic scalar of the metallic/roughness workflow.
  42850. * Can also be used to scale the metalness values of the metallic texture.
  42851. */
  42852. metallic: Nullable<number>;
  42853. /**
  42854. * Specifies the roughness scalar of the metallic/roughness workflow.
  42855. * Can also be used to scale the roughness values of the metallic texture.
  42856. */
  42857. roughness: Nullable<number>;
  42858. /**
  42859. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  42860. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  42861. */
  42862. microSurfaceTexture: BaseTexture;
  42863. /**
  42864. * Stores surface normal data used to displace a mesh in a texture.
  42865. */
  42866. bumpTexture: BaseTexture;
  42867. /**
  42868. * Stores the pre-calculated light information of a mesh in a texture.
  42869. */
  42870. lightmapTexture: BaseTexture;
  42871. /**
  42872. * Stores the refracted light information in a texture.
  42873. */
  42874. refractionTexture: BaseTexture;
  42875. /**
  42876. * The color of a material in ambient lighting.
  42877. */
  42878. ambientColor: Color3;
  42879. /**
  42880. * AKA Diffuse Color in other nomenclature.
  42881. */
  42882. albedoColor: Color3;
  42883. /**
  42884. * AKA Specular Color in other nomenclature.
  42885. */
  42886. reflectivityColor: Color3;
  42887. /**
  42888. * The color reflected from the material.
  42889. */
  42890. reflectionColor: Color3;
  42891. /**
  42892. * The color emitted from the material.
  42893. */
  42894. emissiveColor: Color3;
  42895. /**
  42896. * AKA Glossiness in other nomenclature.
  42897. */
  42898. microSurface: number;
  42899. /**
  42900. * source material index of refraction (IOR)' / 'destination material IOR.
  42901. */
  42902. indexOfRefraction: number;
  42903. /**
  42904. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  42905. */
  42906. invertRefractionY: boolean;
  42907. /**
  42908. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  42909. * Materials half opaque for instance using refraction could benefit from this control.
  42910. */
  42911. linkRefractionWithTransparency: boolean;
  42912. /**
  42913. * If true, the light map contains occlusion information instead of lighting info.
  42914. */
  42915. useLightmapAsShadowmap: boolean;
  42916. /**
  42917. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  42918. */
  42919. useAlphaFromAlbedoTexture: boolean;
  42920. /**
  42921. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  42922. */
  42923. forceAlphaTest: boolean;
  42924. /**
  42925. * Defines the alpha limits in alpha test mode.
  42926. */
  42927. alphaCutOff: number;
  42928. /**
  42929. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  42930. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  42931. */
  42932. useSpecularOverAlpha: boolean;
  42933. /**
  42934. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  42935. */
  42936. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  42937. /**
  42938. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  42939. */
  42940. useRoughnessFromMetallicTextureAlpha: boolean;
  42941. /**
  42942. * Specifies if the metallic texture contains the roughness information in its green channel.
  42943. */
  42944. useRoughnessFromMetallicTextureGreen: boolean;
  42945. /**
  42946. * Specifies if the metallic texture contains the metallness information in its blue channel.
  42947. */
  42948. useMetallnessFromMetallicTextureBlue: boolean;
  42949. /**
  42950. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  42951. */
  42952. useAmbientOcclusionFromMetallicTextureRed: boolean;
  42953. /**
  42954. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  42955. */
  42956. useAmbientInGrayScale: boolean;
  42957. /**
  42958. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  42959. * The material will try to infer what glossiness each pixel should be.
  42960. */
  42961. useAutoMicroSurfaceFromReflectivityMap: boolean;
  42962. /**
  42963. * BJS is using an harcoded light falloff based on a manually sets up range.
  42964. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42965. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42966. */
  42967. /**
  42968. * BJS is using an harcoded light falloff based on a manually sets up range.
  42969. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  42970. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  42971. */
  42972. usePhysicalLightFalloff: boolean;
  42973. /**
  42974. * In order to support the falloff compatibility with gltf, a special mode has been added
  42975. * to reproduce the gltf light falloff.
  42976. */
  42977. /**
  42978. * In order to support the falloff compatibility with gltf, a special mode has been added
  42979. * to reproduce the gltf light falloff.
  42980. */
  42981. useGLTFLightFalloff: boolean;
  42982. /**
  42983. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  42984. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  42985. */
  42986. useRadianceOverAlpha: boolean;
  42987. /**
  42988. * Allows using an object space normal map (instead of tangent space).
  42989. */
  42990. useObjectSpaceNormalMap: boolean;
  42991. /**
  42992. * Allows using the bump map in parallax mode.
  42993. */
  42994. useParallax: boolean;
  42995. /**
  42996. * Allows using the bump map in parallax occlusion mode.
  42997. */
  42998. useParallaxOcclusion: boolean;
  42999. /**
  43000. * Controls the scale bias of the parallax mode.
  43001. */
  43002. parallaxScaleBias: number;
  43003. /**
  43004. * If sets to true, disables all the lights affecting the material.
  43005. */
  43006. disableLighting: boolean;
  43007. /**
  43008. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  43009. */
  43010. forceIrradianceInFragment: boolean;
  43011. /**
  43012. * Number of Simultaneous lights allowed on the material.
  43013. */
  43014. maxSimultaneousLights: number;
  43015. /**
  43016. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  43017. */
  43018. invertNormalMapX: boolean;
  43019. /**
  43020. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  43021. */
  43022. invertNormalMapY: boolean;
  43023. /**
  43024. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43025. */
  43026. twoSidedLighting: boolean;
  43027. /**
  43028. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43029. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43030. */
  43031. useAlphaFresnel: boolean;
  43032. /**
  43033. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43034. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43035. */
  43036. useLinearAlphaFresnel: boolean;
  43037. /**
  43038. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43039. * And/Or occlude the blended part.
  43040. */
  43041. environmentBRDFTexture: Nullable<BaseTexture>;
  43042. /**
  43043. * Force normal to face away from face.
  43044. */
  43045. forceNormalForward: boolean;
  43046. /**
  43047. * Enables specular anti aliasing in the PBR shader.
  43048. * It will both interacts on the Geometry for analytical and IBL lighting.
  43049. * It also prefilter the roughness map based on the bump values.
  43050. */
  43051. enableSpecularAntiAliasing: boolean;
  43052. /**
  43053. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43054. * makes the reflect vector face the model (under horizon).
  43055. */
  43056. useHorizonOcclusion: boolean;
  43057. /**
  43058. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43059. * too much the area relying on ambient texture to define their ambient occlusion.
  43060. */
  43061. useRadianceOcclusion: boolean;
  43062. /**
  43063. * If set to true, no lighting calculations will be applied.
  43064. */
  43065. unlit: boolean;
  43066. /**
  43067. * Gets the image processing configuration used either in this material.
  43068. */
  43069. /**
  43070. * Sets the Default image processing configuration used either in the this material.
  43071. *
  43072. * If sets to null, the scene one is in use.
  43073. */
  43074. imageProcessingConfiguration: ImageProcessingConfiguration;
  43075. /**
  43076. * Gets wether the color curves effect is enabled.
  43077. */
  43078. /**
  43079. * Sets wether the color curves effect is enabled.
  43080. */
  43081. cameraColorCurvesEnabled: boolean;
  43082. /**
  43083. * Gets wether the color grading effect is enabled.
  43084. */
  43085. /**
  43086. * Gets wether the color grading effect is enabled.
  43087. */
  43088. cameraColorGradingEnabled: boolean;
  43089. /**
  43090. * Gets wether tonemapping is enabled or not.
  43091. */
  43092. /**
  43093. * Sets wether tonemapping is enabled or not
  43094. */
  43095. cameraToneMappingEnabled: boolean;
  43096. /**
  43097. * The camera exposure used on this material.
  43098. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43099. * This corresponds to a photographic exposure.
  43100. */
  43101. /**
  43102. * The camera exposure used on this material.
  43103. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43104. * This corresponds to a photographic exposure.
  43105. */
  43106. cameraExposure: number;
  43107. /**
  43108. * Gets The camera contrast used on this material.
  43109. */
  43110. /**
  43111. * Sets The camera contrast used on this material.
  43112. */
  43113. cameraContrast: number;
  43114. /**
  43115. * Gets the Color Grading 2D Lookup Texture.
  43116. */
  43117. /**
  43118. * Sets the Color Grading 2D Lookup Texture.
  43119. */
  43120. cameraColorGradingTexture: Nullable<BaseTexture>;
  43121. /**
  43122. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43123. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43124. * 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;
  43125. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43126. */
  43127. /**
  43128. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43129. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43130. * 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;
  43131. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43132. */
  43133. cameraColorCurves: Nullable<ColorCurves>;
  43134. /**
  43135. * Instantiates a new PBRMaterial instance.
  43136. *
  43137. * @param name The material name
  43138. * @param scene The scene the material will be use in.
  43139. */
  43140. constructor(name: string, scene: Scene);
  43141. /**
  43142. * Returns the name of this material class.
  43143. */
  43144. getClassName(): string;
  43145. /**
  43146. * Returns an array of the actively used textures.
  43147. * @returns - Array of BaseTextures
  43148. */
  43149. getActiveTextures(): BaseTexture[];
  43150. /**
  43151. * Checks to see if a texture is used in the material.
  43152. * @param texture - Base texture to use.
  43153. * @returns - Boolean specifying if a texture is used in the material.
  43154. */
  43155. hasTexture(texture: BaseTexture): boolean;
  43156. /**
  43157. * Makes a duplicate of the current material.
  43158. * @param name - name to use for the new material.
  43159. */
  43160. clone(name: string): PBRMaterial;
  43161. /**
  43162. * Serializes this PBR Material.
  43163. * @returns - An object with the serialized material.
  43164. */
  43165. serialize(): any;
  43166. /**
  43167. * Parses a PBR Material from a serialized object.
  43168. * @param source - Serialized object.
  43169. * @param scene - BJS scene instance.
  43170. * @param rootUrl - url for the scene object
  43171. * @returns - PBRMaterial
  43172. */
  43173. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  43174. }
  43175. }
  43176. declare module BABYLON {
  43177. /** @hidden */
  43178. export var _forceSceneHelpersToBundle: boolean;
  43179. interface Scene {
  43180. /**
  43181. * Creates a default light for the scene.
  43182. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  43183. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  43184. */
  43185. createDefaultLight(replace?: boolean): void;
  43186. /**
  43187. * Creates a default camera for the scene.
  43188. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  43189. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43190. * @param replace has default false, when true replaces the active camera in the scene
  43191. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  43192. */
  43193. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43194. /**
  43195. * Creates a default camera and a default light.
  43196. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  43197. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  43198. * @param replace has the default false, when true replaces the active camera/light in the scene
  43199. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  43200. */
  43201. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  43202. /**
  43203. * Creates a new sky box
  43204. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  43205. * @param environmentTexture defines the texture to use as environment texture
  43206. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  43207. * @param scale defines the overall scale of the skybox
  43208. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  43209. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  43210. * @returns a new mesh holding the sky box
  43211. */
  43212. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  43213. /**
  43214. * Creates a new environment
  43215. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  43216. * @param options defines the options you can use to configure the environment
  43217. * @returns the new EnvironmentHelper
  43218. */
  43219. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  43220. /**
  43221. * Creates a new VREXperienceHelper
  43222. * @see http://doc.babylonjs.com/how_to/webvr_helper
  43223. * @param webVROptions defines the options used to create the new VREXperienceHelper
  43224. * @returns a new VREXperienceHelper
  43225. */
  43226. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  43227. /**
  43228. * Creates a new XREXperienceHelper
  43229. * @see http://doc.babylonjs.com/how_to/webxr
  43230. * @returns a promise for a new XREXperienceHelper
  43231. */
  43232. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  43233. }
  43234. }
  43235. declare module BABYLON {
  43236. /**
  43237. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  43238. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  43239. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  43240. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43241. */
  43242. export class VideoDome extends TransformNode {
  43243. private _useDirectMapping;
  43244. /**
  43245. * The video texture being displayed on the sphere
  43246. */
  43247. protected _videoTexture: VideoTexture;
  43248. /**
  43249. * Gets the video texture being displayed on the sphere
  43250. */
  43251. readonly videoTexture: VideoTexture;
  43252. /**
  43253. * The skybox material
  43254. */
  43255. protected _material: BackgroundMaterial;
  43256. /**
  43257. * The surface used for the skybox
  43258. */
  43259. protected _mesh: Mesh;
  43260. /**
  43261. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43262. * Also see the options.resolution property.
  43263. */
  43264. fovMultiplier: number;
  43265. /**
  43266. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  43267. * @param name Element's name, child elements will append suffixes for their own names.
  43268. * @param urlsOrVideo defines the url(s) or the video element to use
  43269. * @param options An object containing optional or exposed sub element properties
  43270. */
  43271. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  43272. resolution?: number;
  43273. clickToPlay?: boolean;
  43274. autoPlay?: boolean;
  43275. loop?: boolean;
  43276. size?: number;
  43277. poster?: string;
  43278. useDirectMapping?: boolean;
  43279. }, scene: Scene);
  43280. /**
  43281. * Releases resources associated with this node.
  43282. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43283. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43284. */
  43285. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43286. }
  43287. }
  43288. declare module BABYLON {
  43289. /**
  43290. * This class can be used to get instrumentation data from a Babylon engine
  43291. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43292. */
  43293. export class EngineInstrumentation implements IDisposable {
  43294. /**
  43295. * Define the instrumented engine.
  43296. */
  43297. engine: Engine;
  43298. private _captureGPUFrameTime;
  43299. private _gpuFrameTimeToken;
  43300. private _gpuFrameTime;
  43301. private _captureShaderCompilationTime;
  43302. private _shaderCompilationTime;
  43303. private _onBeginFrameObserver;
  43304. private _onEndFrameObserver;
  43305. private _onBeforeShaderCompilationObserver;
  43306. private _onAfterShaderCompilationObserver;
  43307. /**
  43308. * Gets the perf counter used for GPU frame time
  43309. */
  43310. readonly gpuFrameTimeCounter: PerfCounter;
  43311. /**
  43312. * Gets the GPU frame time capture status
  43313. */
  43314. /**
  43315. * Enable or disable the GPU frame time capture
  43316. */
  43317. captureGPUFrameTime: boolean;
  43318. /**
  43319. * Gets the perf counter used for shader compilation time
  43320. */
  43321. readonly shaderCompilationTimeCounter: PerfCounter;
  43322. /**
  43323. * Gets the shader compilation time capture status
  43324. */
  43325. /**
  43326. * Enable or disable the shader compilation time capture
  43327. */
  43328. captureShaderCompilationTime: boolean;
  43329. /**
  43330. * Instantiates a new engine instrumentation.
  43331. * This class can be used to get instrumentation data from a Babylon engine
  43332. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  43333. * @param engine Defines the engine to instrument
  43334. */
  43335. constructor(
  43336. /**
  43337. * Define the instrumented engine.
  43338. */
  43339. engine: Engine);
  43340. /**
  43341. * Dispose and release associated resources.
  43342. */
  43343. dispose(): void;
  43344. }
  43345. }
  43346. declare module BABYLON {
  43347. /**
  43348. * This class can be used to get instrumentation data from a Babylon engine
  43349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43350. */
  43351. export class SceneInstrumentation implements IDisposable {
  43352. /**
  43353. * Defines the scene to instrument
  43354. */
  43355. scene: Scene;
  43356. private _captureActiveMeshesEvaluationTime;
  43357. private _activeMeshesEvaluationTime;
  43358. private _captureRenderTargetsRenderTime;
  43359. private _renderTargetsRenderTime;
  43360. private _captureFrameTime;
  43361. private _frameTime;
  43362. private _captureRenderTime;
  43363. private _renderTime;
  43364. private _captureInterFrameTime;
  43365. private _interFrameTime;
  43366. private _captureParticlesRenderTime;
  43367. private _particlesRenderTime;
  43368. private _captureSpritesRenderTime;
  43369. private _spritesRenderTime;
  43370. private _capturePhysicsTime;
  43371. private _physicsTime;
  43372. private _captureAnimationsTime;
  43373. private _animationsTime;
  43374. private _captureCameraRenderTime;
  43375. private _cameraRenderTime;
  43376. private _onBeforeActiveMeshesEvaluationObserver;
  43377. private _onAfterActiveMeshesEvaluationObserver;
  43378. private _onBeforeRenderTargetsRenderObserver;
  43379. private _onAfterRenderTargetsRenderObserver;
  43380. private _onAfterRenderObserver;
  43381. private _onBeforeDrawPhaseObserver;
  43382. private _onAfterDrawPhaseObserver;
  43383. private _onBeforeAnimationsObserver;
  43384. private _onBeforeParticlesRenderingObserver;
  43385. private _onAfterParticlesRenderingObserver;
  43386. private _onBeforeSpritesRenderingObserver;
  43387. private _onAfterSpritesRenderingObserver;
  43388. private _onBeforePhysicsObserver;
  43389. private _onAfterPhysicsObserver;
  43390. private _onAfterAnimationsObserver;
  43391. private _onBeforeCameraRenderObserver;
  43392. private _onAfterCameraRenderObserver;
  43393. /**
  43394. * Gets the perf counter used for active meshes evaluation time
  43395. */
  43396. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  43397. /**
  43398. * Gets the active meshes evaluation time capture status
  43399. */
  43400. /**
  43401. * Enable or disable the active meshes evaluation time capture
  43402. */
  43403. captureActiveMeshesEvaluationTime: boolean;
  43404. /**
  43405. * Gets the perf counter used for render targets render time
  43406. */
  43407. readonly renderTargetsRenderTimeCounter: PerfCounter;
  43408. /**
  43409. * Gets the render targets render time capture status
  43410. */
  43411. /**
  43412. * Enable or disable the render targets render time capture
  43413. */
  43414. captureRenderTargetsRenderTime: boolean;
  43415. /**
  43416. * Gets the perf counter used for particles render time
  43417. */
  43418. readonly particlesRenderTimeCounter: PerfCounter;
  43419. /**
  43420. * Gets the particles render time capture status
  43421. */
  43422. /**
  43423. * Enable or disable the particles render time capture
  43424. */
  43425. captureParticlesRenderTime: boolean;
  43426. /**
  43427. * Gets the perf counter used for sprites render time
  43428. */
  43429. readonly spritesRenderTimeCounter: PerfCounter;
  43430. /**
  43431. * Gets the sprites render time capture status
  43432. */
  43433. /**
  43434. * Enable or disable the sprites render time capture
  43435. */
  43436. captureSpritesRenderTime: boolean;
  43437. /**
  43438. * Gets the perf counter used for physics time
  43439. */
  43440. readonly physicsTimeCounter: PerfCounter;
  43441. /**
  43442. * Gets the physics time capture status
  43443. */
  43444. /**
  43445. * Enable or disable the physics time capture
  43446. */
  43447. capturePhysicsTime: boolean;
  43448. /**
  43449. * Gets the perf counter used for animations time
  43450. */
  43451. readonly animationsTimeCounter: PerfCounter;
  43452. /**
  43453. * Gets the animations time capture status
  43454. */
  43455. /**
  43456. * Enable or disable the animations time capture
  43457. */
  43458. captureAnimationsTime: boolean;
  43459. /**
  43460. * Gets the perf counter used for frame time capture
  43461. */
  43462. readonly frameTimeCounter: PerfCounter;
  43463. /**
  43464. * Gets the frame time capture status
  43465. */
  43466. /**
  43467. * Enable or disable the frame time capture
  43468. */
  43469. captureFrameTime: boolean;
  43470. /**
  43471. * Gets the perf counter used for inter-frames time capture
  43472. */
  43473. readonly interFrameTimeCounter: PerfCounter;
  43474. /**
  43475. * Gets the inter-frames time capture status
  43476. */
  43477. /**
  43478. * Enable or disable the inter-frames time capture
  43479. */
  43480. captureInterFrameTime: boolean;
  43481. /**
  43482. * Gets the perf counter used for render time capture
  43483. */
  43484. readonly renderTimeCounter: PerfCounter;
  43485. /**
  43486. * Gets the render time capture status
  43487. */
  43488. /**
  43489. * Enable or disable the render time capture
  43490. */
  43491. captureRenderTime: boolean;
  43492. /**
  43493. * Gets the perf counter used for camera render time capture
  43494. */
  43495. readonly cameraRenderTimeCounter: PerfCounter;
  43496. /**
  43497. * Gets the camera render time capture status
  43498. */
  43499. /**
  43500. * Enable or disable the camera render time capture
  43501. */
  43502. captureCameraRenderTime: boolean;
  43503. /**
  43504. * Gets the perf counter used for draw calls
  43505. */
  43506. readonly drawCallsCounter: PerfCounter;
  43507. /**
  43508. * Gets the perf counter used for texture collisions
  43509. */
  43510. readonly textureCollisionsCounter: PerfCounter;
  43511. /**
  43512. * Instantiates a new scene instrumentation.
  43513. * This class can be used to get instrumentation data from a Babylon engine
  43514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  43515. * @param scene Defines the scene to instrument
  43516. */
  43517. constructor(
  43518. /**
  43519. * Defines the scene to instrument
  43520. */
  43521. scene: Scene);
  43522. /**
  43523. * Dispose and release associated resources.
  43524. */
  43525. dispose(): void;
  43526. }
  43527. }
  43528. declare module BABYLON {
  43529. /** @hidden */
  43530. export var glowMapGenerationPixelShader: {
  43531. name: string;
  43532. shader: string;
  43533. };
  43534. }
  43535. declare module BABYLON {
  43536. /** @hidden */
  43537. export var glowMapGenerationVertexShader: {
  43538. name: string;
  43539. shader: string;
  43540. };
  43541. }
  43542. declare module BABYLON {
  43543. /**
  43544. * Effect layer options. This helps customizing the behaviour
  43545. * of the effect layer.
  43546. */
  43547. export interface IEffectLayerOptions {
  43548. /**
  43549. * Multiplication factor apply to the canvas size to compute the render target size
  43550. * used to generated the objects (the smaller the faster).
  43551. */
  43552. mainTextureRatio: number;
  43553. /**
  43554. * Enforces a fixed size texture to ensure effect stability across devices.
  43555. */
  43556. mainTextureFixedSize?: number;
  43557. /**
  43558. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  43559. */
  43560. alphaBlendingMode: number;
  43561. /**
  43562. * The camera attached to the layer.
  43563. */
  43564. camera: Nullable<Camera>;
  43565. /**
  43566. * The rendering group to draw the layer in.
  43567. */
  43568. renderingGroupId: number;
  43569. }
  43570. /**
  43571. * The effect layer Helps adding post process effect blended with the main pass.
  43572. *
  43573. * This can be for instance use to generate glow or higlight effects on the scene.
  43574. *
  43575. * The effect layer class can not be used directly and is intented to inherited from to be
  43576. * customized per effects.
  43577. */
  43578. export abstract class EffectLayer {
  43579. private _vertexBuffers;
  43580. private _indexBuffer;
  43581. private _cachedDefines;
  43582. private _effectLayerMapGenerationEffect;
  43583. private _effectLayerOptions;
  43584. private _mergeEffect;
  43585. protected _scene: Scene;
  43586. protected _engine: Engine;
  43587. protected _maxSize: number;
  43588. protected _mainTextureDesiredSize: ISize;
  43589. protected _mainTexture: RenderTargetTexture;
  43590. protected _shouldRender: boolean;
  43591. protected _postProcesses: PostProcess[];
  43592. protected _textures: BaseTexture[];
  43593. protected _emissiveTextureAndColor: {
  43594. texture: Nullable<BaseTexture>;
  43595. color: Color4;
  43596. };
  43597. /**
  43598. * The name of the layer
  43599. */
  43600. name: string;
  43601. /**
  43602. * The clear color of the texture used to generate the glow map.
  43603. */
  43604. neutralColor: Color4;
  43605. /**
  43606. * Specifies wether the highlight layer is enabled or not.
  43607. */
  43608. isEnabled: boolean;
  43609. /**
  43610. * Gets the camera attached to the layer.
  43611. */
  43612. readonly camera: Nullable<Camera>;
  43613. /**
  43614. * Gets the rendering group id the layer should render in.
  43615. */
  43616. readonly renderingGroupId: number;
  43617. /**
  43618. * An event triggered when the effect layer has been disposed.
  43619. */
  43620. onDisposeObservable: Observable<EffectLayer>;
  43621. /**
  43622. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  43623. */
  43624. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  43625. /**
  43626. * An event triggered when the generated texture is being merged in the scene.
  43627. */
  43628. onBeforeComposeObservable: Observable<EffectLayer>;
  43629. /**
  43630. * An event triggered when the generated texture has been merged in the scene.
  43631. */
  43632. onAfterComposeObservable: Observable<EffectLayer>;
  43633. /**
  43634. * An event triggered when the efffect layer changes its size.
  43635. */
  43636. onSizeChangedObservable: Observable<EffectLayer>;
  43637. /** @hidden */
  43638. static _SceneComponentInitialization: (scene: Scene) => void;
  43639. /**
  43640. * Instantiates a new effect Layer and references it in the scene.
  43641. * @param name The name of the layer
  43642. * @param scene The scene to use the layer in
  43643. */
  43644. constructor(
  43645. /** The Friendly of the effect in the scene */
  43646. name: string, scene: Scene);
  43647. /**
  43648. * Get the effect name of the layer.
  43649. * @return The effect name
  43650. */
  43651. abstract getEffectName(): string;
  43652. /**
  43653. * Checks for the readiness of the element composing the layer.
  43654. * @param subMesh the mesh to check for
  43655. * @param useInstances specify wether or not to use instances to render the mesh
  43656. * @return true if ready otherwise, false
  43657. */
  43658. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  43659. /**
  43660. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  43661. * @returns true if the effect requires stencil during the main canvas render pass.
  43662. */
  43663. abstract needStencil(): boolean;
  43664. /**
  43665. * Create the merge effect. This is the shader use to blit the information back
  43666. * to the main canvas at the end of the scene rendering.
  43667. * @returns The effect containing the shader used to merge the effect on the main canvas
  43668. */
  43669. protected abstract _createMergeEffect(): Effect;
  43670. /**
  43671. * Creates the render target textures and post processes used in the effect layer.
  43672. */
  43673. protected abstract _createTextureAndPostProcesses(): void;
  43674. /**
  43675. * Implementation specific of rendering the generating effect on the main canvas.
  43676. * @param effect The effect used to render through
  43677. */
  43678. protected abstract _internalRender(effect: Effect): void;
  43679. /**
  43680. * Sets the required values for both the emissive texture and and the main color.
  43681. */
  43682. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  43683. /**
  43684. * Free any resources and references associated to a mesh.
  43685. * Internal use
  43686. * @param mesh The mesh to free.
  43687. */
  43688. abstract _disposeMesh(mesh: Mesh): void;
  43689. /**
  43690. * Serializes this layer (Glow or Highlight for example)
  43691. * @returns a serialized layer object
  43692. */
  43693. abstract serialize?(): any;
  43694. /**
  43695. * Initializes the effect layer with the required options.
  43696. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  43697. */
  43698. protected _init(options: Partial<IEffectLayerOptions>): void;
  43699. /**
  43700. * Generates the index buffer of the full screen quad blending to the main canvas.
  43701. */
  43702. private _generateIndexBuffer;
  43703. /**
  43704. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  43705. */
  43706. private _genrateVertexBuffer;
  43707. /**
  43708. * Sets the main texture desired size which is the closest power of two
  43709. * of the engine canvas size.
  43710. */
  43711. private _setMainTextureSize;
  43712. /**
  43713. * Creates the main texture for the effect layer.
  43714. */
  43715. protected _createMainTexture(): void;
  43716. /**
  43717. * Adds specific effects defines.
  43718. * @param defines The defines to add specifics to.
  43719. */
  43720. protected _addCustomEffectDefines(defines: string[]): void;
  43721. /**
  43722. * Checks for the readiness of the element composing the layer.
  43723. * @param subMesh the mesh to check for
  43724. * @param useInstances specify wether or not to use instances to render the mesh
  43725. * @param emissiveTexture the associated emissive texture used to generate the glow
  43726. * @return true if ready otherwise, false
  43727. */
  43728. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  43729. /**
  43730. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  43731. */
  43732. render(): void;
  43733. /**
  43734. * Determine if a given mesh will be used in the current effect.
  43735. * @param mesh mesh to test
  43736. * @returns true if the mesh will be used
  43737. */
  43738. hasMesh(mesh: AbstractMesh): boolean;
  43739. /**
  43740. * Returns true if the layer contains information to display, otherwise false.
  43741. * @returns true if the glow layer should be rendered
  43742. */
  43743. shouldRender(): boolean;
  43744. /**
  43745. * Returns true if the mesh should render, otherwise false.
  43746. * @param mesh The mesh to render
  43747. * @returns true if it should render otherwise false
  43748. */
  43749. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  43750. /**
  43751. * Returns true if the mesh can be rendered, otherwise false.
  43752. * @param mesh The mesh to render
  43753. * @param material The material used on the mesh
  43754. * @returns true if it can be rendered otherwise false
  43755. */
  43756. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  43757. /**
  43758. * Returns true if the mesh should render, otherwise false.
  43759. * @param mesh The mesh to render
  43760. * @returns true if it should render otherwise false
  43761. */
  43762. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  43763. /**
  43764. * Renders the submesh passed in parameter to the generation map.
  43765. */
  43766. protected _renderSubMesh(subMesh: SubMesh): void;
  43767. /**
  43768. * Rebuild the required buffers.
  43769. * @hidden Internal use only.
  43770. */
  43771. _rebuild(): void;
  43772. /**
  43773. * Dispose only the render target textures and post process.
  43774. */
  43775. private _disposeTextureAndPostProcesses;
  43776. /**
  43777. * Dispose the highlight layer and free resources.
  43778. */
  43779. dispose(): void;
  43780. /**
  43781. * Gets the class name of the effect layer
  43782. * @returns the string with the class name of the effect layer
  43783. */
  43784. getClassName(): string;
  43785. /**
  43786. * Creates an effect layer from parsed effect layer data
  43787. * @param parsedEffectLayer defines effect layer data
  43788. * @param scene defines the current scene
  43789. * @param rootUrl defines the root URL containing the effect layer information
  43790. * @returns a parsed effect Layer
  43791. */
  43792. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  43793. }
  43794. }
  43795. declare module BABYLON {
  43796. interface AbstractScene {
  43797. /**
  43798. * The list of effect layers (highlights/glow) added to the scene
  43799. * @see http://doc.babylonjs.com/how_to/highlight_layer
  43800. * @see http://doc.babylonjs.com/how_to/glow_layer
  43801. */
  43802. effectLayers: Array<EffectLayer>;
  43803. /**
  43804. * Removes the given effect layer from this scene.
  43805. * @param toRemove defines the effect layer to remove
  43806. * @returns the index of the removed effect layer
  43807. */
  43808. removeEffectLayer(toRemove: EffectLayer): number;
  43809. /**
  43810. * Adds the given effect layer to this scene
  43811. * @param newEffectLayer defines the effect layer to add
  43812. */
  43813. addEffectLayer(newEffectLayer: EffectLayer): void;
  43814. }
  43815. /**
  43816. * Defines the layer scene component responsible to manage any effect layers
  43817. * in a given scene.
  43818. */
  43819. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  43820. /**
  43821. * The component name helpfull to identify the component in the list of scene components.
  43822. */
  43823. readonly name: string;
  43824. /**
  43825. * The scene the component belongs to.
  43826. */
  43827. scene: Scene;
  43828. private _engine;
  43829. private _renderEffects;
  43830. private _needStencil;
  43831. private _previousStencilState;
  43832. /**
  43833. * Creates a new instance of the component for the given scene
  43834. * @param scene Defines the scene to register the component in
  43835. */
  43836. constructor(scene: Scene);
  43837. /**
  43838. * Registers the component in a given scene
  43839. */
  43840. register(): void;
  43841. /**
  43842. * Rebuilds the elements related to this component in case of
  43843. * context lost for instance.
  43844. */
  43845. rebuild(): void;
  43846. /**
  43847. * Serializes the component data to the specified json object
  43848. * @param serializationObject The object to serialize to
  43849. */
  43850. serialize(serializationObject: any): void;
  43851. /**
  43852. * Adds all the element from the container to the scene
  43853. * @param container the container holding the elements
  43854. */
  43855. addFromContainer(container: AbstractScene): void;
  43856. /**
  43857. * Removes all the elements in the container from the scene
  43858. * @param container contains the elements to remove
  43859. */
  43860. removeFromContainer(container: AbstractScene): void;
  43861. /**
  43862. * Disposes the component and the associated ressources.
  43863. */
  43864. dispose(): void;
  43865. private _isReadyForMesh;
  43866. private _renderMainTexture;
  43867. private _setStencil;
  43868. private _setStencilBack;
  43869. private _draw;
  43870. private _drawCamera;
  43871. private _drawRenderingGroup;
  43872. }
  43873. }
  43874. declare module BABYLON {
  43875. /** @hidden */
  43876. export var glowMapMergePixelShader: {
  43877. name: string;
  43878. shader: string;
  43879. };
  43880. }
  43881. declare module BABYLON {
  43882. /** @hidden */
  43883. export var glowMapMergeVertexShader: {
  43884. name: string;
  43885. shader: string;
  43886. };
  43887. }
  43888. declare module BABYLON {
  43889. interface AbstractScene {
  43890. /**
  43891. * Return a the first highlight layer of the scene with a given name.
  43892. * @param name The name of the highlight layer to look for.
  43893. * @return The highlight layer if found otherwise null.
  43894. */
  43895. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  43896. }
  43897. /**
  43898. * Glow layer options. This helps customizing the behaviour
  43899. * of the glow layer.
  43900. */
  43901. export interface IGlowLayerOptions {
  43902. /**
  43903. * Multiplication factor apply to the canvas size to compute the render target size
  43904. * used to generated the glowing objects (the smaller the faster).
  43905. */
  43906. mainTextureRatio: number;
  43907. /**
  43908. * Enforces a fixed size texture to ensure resize independant blur.
  43909. */
  43910. mainTextureFixedSize?: number;
  43911. /**
  43912. * How big is the kernel of the blur texture.
  43913. */
  43914. blurKernelSize: number;
  43915. /**
  43916. * The camera attached to the layer.
  43917. */
  43918. camera: Nullable<Camera>;
  43919. /**
  43920. * Enable MSAA by chosing the number of samples.
  43921. */
  43922. mainTextureSamples?: number;
  43923. /**
  43924. * The rendering group to draw the layer in.
  43925. */
  43926. renderingGroupId: number;
  43927. }
  43928. /**
  43929. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  43930. *
  43931. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  43932. * glowy meshes to your scene.
  43933. *
  43934. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  43935. */
  43936. export class GlowLayer extends EffectLayer {
  43937. /**
  43938. * Effect Name of the layer.
  43939. */
  43940. static readonly EffectName: string;
  43941. /**
  43942. * The default blur kernel size used for the glow.
  43943. */
  43944. static DefaultBlurKernelSize: number;
  43945. /**
  43946. * The default texture size ratio used for the glow.
  43947. */
  43948. static DefaultTextureRatio: number;
  43949. /**
  43950. * Sets the kernel size of the blur.
  43951. */
  43952. /**
  43953. * Gets the kernel size of the blur.
  43954. */
  43955. blurKernelSize: number;
  43956. /**
  43957. * Sets the glow intensity.
  43958. */
  43959. /**
  43960. * Gets the glow intensity.
  43961. */
  43962. intensity: number;
  43963. private _options;
  43964. private _intensity;
  43965. private _horizontalBlurPostprocess1;
  43966. private _verticalBlurPostprocess1;
  43967. private _horizontalBlurPostprocess2;
  43968. private _verticalBlurPostprocess2;
  43969. private _blurTexture1;
  43970. private _blurTexture2;
  43971. private _postProcesses1;
  43972. private _postProcesses2;
  43973. private _includedOnlyMeshes;
  43974. private _excludedMeshes;
  43975. /**
  43976. * Callback used to let the user override the color selection on a per mesh basis
  43977. */
  43978. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  43979. /**
  43980. * Callback used to let the user override the texture selection on a per mesh basis
  43981. */
  43982. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  43983. /**
  43984. * Instantiates a new glow Layer and references it to the scene.
  43985. * @param name The name of the layer
  43986. * @param scene The scene to use the layer in
  43987. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  43988. */
  43989. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  43990. /**
  43991. * Get the effect name of the layer.
  43992. * @return The effect name
  43993. */
  43994. getEffectName(): string;
  43995. /**
  43996. * Create the merge effect. This is the shader use to blit the information back
  43997. * to the main canvas at the end of the scene rendering.
  43998. */
  43999. protected _createMergeEffect(): Effect;
  44000. /**
  44001. * Creates the render target textures and post processes used in the glow layer.
  44002. */
  44003. protected _createTextureAndPostProcesses(): void;
  44004. /**
  44005. * Checks for the readiness of the element composing the layer.
  44006. * @param subMesh the mesh to check for
  44007. * @param useInstances specify wether or not to use instances to render the mesh
  44008. * @param emissiveTexture the associated emissive texture used to generate the glow
  44009. * @return true if ready otherwise, false
  44010. */
  44011. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44012. /**
  44013. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44014. */
  44015. needStencil(): boolean;
  44016. /**
  44017. * Returns true if the mesh can be rendered, otherwise false.
  44018. * @param mesh The mesh to render
  44019. * @param material The material used on the mesh
  44020. * @returns true if it can be rendered otherwise false
  44021. */
  44022. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  44023. /**
  44024. * Implementation specific of rendering the generating effect on the main canvas.
  44025. * @param effect The effect used to render through
  44026. */
  44027. protected _internalRender(effect: Effect): void;
  44028. /**
  44029. * Sets the required values for both the emissive texture and and the main color.
  44030. */
  44031. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44032. /**
  44033. * Returns true if the mesh should render, otherwise false.
  44034. * @param mesh The mesh to render
  44035. * @returns true if it should render otherwise false
  44036. */
  44037. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44038. /**
  44039. * Adds specific effects defines.
  44040. * @param defines The defines to add specifics to.
  44041. */
  44042. protected _addCustomEffectDefines(defines: string[]): void;
  44043. /**
  44044. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  44045. * @param mesh The mesh to exclude from the glow layer
  44046. */
  44047. addExcludedMesh(mesh: Mesh): void;
  44048. /**
  44049. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  44050. * @param mesh The mesh to remove
  44051. */
  44052. removeExcludedMesh(mesh: Mesh): void;
  44053. /**
  44054. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  44055. * @param mesh The mesh to include in the glow layer
  44056. */
  44057. addIncludedOnlyMesh(mesh: Mesh): void;
  44058. /**
  44059. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  44060. * @param mesh The mesh to remove
  44061. */
  44062. removeIncludedOnlyMesh(mesh: Mesh): void;
  44063. /**
  44064. * Determine if a given mesh will be used in the glow layer
  44065. * @param mesh The mesh to test
  44066. * @returns true if the mesh will be highlighted by the current glow layer
  44067. */
  44068. hasMesh(mesh: AbstractMesh): boolean;
  44069. /**
  44070. * Free any resources and references associated to a mesh.
  44071. * Internal use
  44072. * @param mesh The mesh to free.
  44073. * @hidden
  44074. */
  44075. _disposeMesh(mesh: Mesh): void;
  44076. /**
  44077. * Gets the class name of the effect layer
  44078. * @returns the string with the class name of the effect layer
  44079. */
  44080. getClassName(): string;
  44081. /**
  44082. * Serializes this glow layer
  44083. * @returns a serialized glow layer object
  44084. */
  44085. serialize(): any;
  44086. /**
  44087. * Creates a Glow Layer from parsed glow layer data
  44088. * @param parsedGlowLayer defines glow layer data
  44089. * @param scene defines the current scene
  44090. * @param rootUrl defines the root URL containing the glow layer information
  44091. * @returns a parsed Glow Layer
  44092. */
  44093. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  44094. }
  44095. }
  44096. declare module BABYLON {
  44097. /** @hidden */
  44098. export var glowBlurPostProcessPixelShader: {
  44099. name: string;
  44100. shader: string;
  44101. };
  44102. }
  44103. declare module BABYLON {
  44104. interface AbstractScene {
  44105. /**
  44106. * Return a the first highlight layer of the scene with a given name.
  44107. * @param name The name of the highlight layer to look for.
  44108. * @return The highlight layer if found otherwise null.
  44109. */
  44110. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  44111. }
  44112. /**
  44113. * Highlight layer options. This helps customizing the behaviour
  44114. * of the highlight layer.
  44115. */
  44116. export interface IHighlightLayerOptions {
  44117. /**
  44118. * Multiplication factor apply to the canvas size to compute the render target size
  44119. * used to generated the glowing objects (the smaller the faster).
  44120. */
  44121. mainTextureRatio: number;
  44122. /**
  44123. * Enforces a fixed size texture to ensure resize independant blur.
  44124. */
  44125. mainTextureFixedSize?: number;
  44126. /**
  44127. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  44128. * of the picture to blur (the smaller the faster).
  44129. */
  44130. blurTextureSizeRatio: number;
  44131. /**
  44132. * How big in texel of the blur texture is the vertical blur.
  44133. */
  44134. blurVerticalSize: number;
  44135. /**
  44136. * How big in texel of the blur texture is the horizontal blur.
  44137. */
  44138. blurHorizontalSize: number;
  44139. /**
  44140. * Alpha blending mode used to apply the blur. Default is combine.
  44141. */
  44142. alphaBlendingMode: number;
  44143. /**
  44144. * The camera attached to the layer.
  44145. */
  44146. camera: Nullable<Camera>;
  44147. /**
  44148. * Should we display highlight as a solid stroke?
  44149. */
  44150. isStroke?: boolean;
  44151. /**
  44152. * The rendering group to draw the layer in.
  44153. */
  44154. renderingGroupId: number;
  44155. }
  44156. /**
  44157. * The highlight layer Helps adding a glow effect around a mesh.
  44158. *
  44159. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  44160. * glowy meshes to your scene.
  44161. *
  44162. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  44163. */
  44164. export class HighlightLayer extends EffectLayer {
  44165. name: string;
  44166. /**
  44167. * Effect Name of the highlight layer.
  44168. */
  44169. static readonly EffectName: string;
  44170. /**
  44171. * The neutral color used during the preparation of the glow effect.
  44172. * This is black by default as the blend operation is a blend operation.
  44173. */
  44174. static NeutralColor: Color4;
  44175. /**
  44176. * Stencil value used for glowing meshes.
  44177. */
  44178. static GlowingMeshStencilReference: number;
  44179. /**
  44180. * Stencil value used for the other meshes in the scene.
  44181. */
  44182. static NormalMeshStencilReference: number;
  44183. /**
  44184. * Specifies whether or not the inner glow is ACTIVE in the layer.
  44185. */
  44186. innerGlow: boolean;
  44187. /**
  44188. * Specifies whether or not the outer glow is ACTIVE in the layer.
  44189. */
  44190. outerGlow: boolean;
  44191. /**
  44192. * Specifies the horizontal size of the blur.
  44193. */
  44194. /**
  44195. * Gets the horizontal size of the blur.
  44196. */
  44197. blurHorizontalSize: number;
  44198. /**
  44199. * Specifies the vertical size of the blur.
  44200. */
  44201. /**
  44202. * Gets the vertical size of the blur.
  44203. */
  44204. blurVerticalSize: number;
  44205. /**
  44206. * An event triggered when the highlight layer is being blurred.
  44207. */
  44208. onBeforeBlurObservable: Observable<HighlightLayer>;
  44209. /**
  44210. * An event triggered when the highlight layer has been blurred.
  44211. */
  44212. onAfterBlurObservable: Observable<HighlightLayer>;
  44213. private _instanceGlowingMeshStencilReference;
  44214. private _options;
  44215. private _downSamplePostprocess;
  44216. private _horizontalBlurPostprocess;
  44217. private _verticalBlurPostprocess;
  44218. private _blurTexture;
  44219. private _meshes;
  44220. private _excludedMeshes;
  44221. /**
  44222. * Instantiates a new highlight Layer and references it to the scene..
  44223. * @param name The name of the layer
  44224. * @param scene The scene to use the layer in
  44225. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  44226. */
  44227. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  44228. /**
  44229. * Get the effect name of the layer.
  44230. * @return The effect name
  44231. */
  44232. getEffectName(): string;
  44233. /**
  44234. * Create the merge effect. This is the shader use to blit the information back
  44235. * to the main canvas at the end of the scene rendering.
  44236. */
  44237. protected _createMergeEffect(): Effect;
  44238. /**
  44239. * Creates the render target textures and post processes used in the highlight layer.
  44240. */
  44241. protected _createTextureAndPostProcesses(): void;
  44242. /**
  44243. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  44244. */
  44245. needStencil(): boolean;
  44246. /**
  44247. * Checks for the readiness of the element composing the layer.
  44248. * @param subMesh the mesh to check for
  44249. * @param useInstances specify wether or not to use instances to render the mesh
  44250. * @param emissiveTexture the associated emissive texture used to generate the glow
  44251. * @return true if ready otherwise, false
  44252. */
  44253. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44254. /**
  44255. * Implementation specific of rendering the generating effect on the main canvas.
  44256. * @param effect The effect used to render through
  44257. */
  44258. protected _internalRender(effect: Effect): void;
  44259. /**
  44260. * Returns true if the layer contains information to display, otherwise false.
  44261. */
  44262. shouldRender(): boolean;
  44263. /**
  44264. * Returns true if the mesh should render, otherwise false.
  44265. * @param mesh The mesh to render
  44266. * @returns true if it should render otherwise false
  44267. */
  44268. protected _shouldRenderMesh(mesh: Mesh): boolean;
  44269. /**
  44270. * Sets the required values for both the emissive texture and and the main color.
  44271. */
  44272. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  44273. /**
  44274. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  44275. * @param mesh The mesh to exclude from the highlight layer
  44276. */
  44277. addExcludedMesh(mesh: Mesh): void;
  44278. /**
  44279. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  44280. * @param mesh The mesh to highlight
  44281. */
  44282. removeExcludedMesh(mesh: Mesh): void;
  44283. /**
  44284. * Determine if a given mesh will be highlighted by the current HighlightLayer
  44285. * @param mesh mesh to test
  44286. * @returns true if the mesh will be highlighted by the current HighlightLayer
  44287. */
  44288. hasMesh(mesh: AbstractMesh): boolean;
  44289. /**
  44290. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  44291. * @param mesh The mesh to highlight
  44292. * @param color The color of the highlight
  44293. * @param glowEmissiveOnly Extract the glow from the emissive texture
  44294. */
  44295. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  44296. /**
  44297. * Remove a mesh from the highlight layer in order to make it stop glowing.
  44298. * @param mesh The mesh to highlight
  44299. */
  44300. removeMesh(mesh: Mesh): void;
  44301. /**
  44302. * Force the stencil to the normal expected value for none glowing parts
  44303. */
  44304. private _defaultStencilReference;
  44305. /**
  44306. * Free any resources and references associated to a mesh.
  44307. * Internal use
  44308. * @param mesh The mesh to free.
  44309. * @hidden
  44310. */
  44311. _disposeMesh(mesh: Mesh): void;
  44312. /**
  44313. * Dispose the highlight layer and free resources.
  44314. */
  44315. dispose(): void;
  44316. /**
  44317. * Gets the class name of the effect layer
  44318. * @returns the string with the class name of the effect layer
  44319. */
  44320. getClassName(): string;
  44321. /**
  44322. * Serializes this Highlight layer
  44323. * @returns a serialized Highlight layer object
  44324. */
  44325. serialize(): any;
  44326. /**
  44327. * Creates a Highlight layer from parsed Highlight layer data
  44328. * @param parsedHightlightLayer defines the Highlight layer data
  44329. * @param scene defines the current scene
  44330. * @param rootUrl defines the root URL containing the Highlight layer information
  44331. * @returns a parsed Highlight layer
  44332. */
  44333. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  44334. }
  44335. }
  44336. declare module BABYLON {
  44337. /** @hidden */
  44338. export var lensFlarePixelShader: {
  44339. name: string;
  44340. shader: string;
  44341. };
  44342. }
  44343. declare module BABYLON {
  44344. /** @hidden */
  44345. export var lensFlareVertexShader: {
  44346. name: string;
  44347. shader: string;
  44348. };
  44349. }
  44350. declare module BABYLON {
  44351. /**
  44352. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44353. * It is usually composed of several `lensFlare`.
  44354. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44355. */
  44356. export class LensFlareSystem {
  44357. /**
  44358. * Define the name of the lens flare system
  44359. */
  44360. name: string;
  44361. /**
  44362. * List of lens flares used in this system.
  44363. */
  44364. lensFlares: LensFlare[];
  44365. /**
  44366. * Define a limit from the border the lens flare can be visible.
  44367. */
  44368. borderLimit: number;
  44369. /**
  44370. * Define a viewport border we do not want to see the lens flare in.
  44371. */
  44372. viewportBorder: number;
  44373. /**
  44374. * Define a predicate which could limit the list of meshes able to occlude the effect.
  44375. */
  44376. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44377. /**
  44378. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  44379. */
  44380. layerMask: number;
  44381. /**
  44382. * Define the id of the lens flare system in the scene.
  44383. * (equal to name by default)
  44384. */
  44385. id: string;
  44386. private _scene;
  44387. private _emitter;
  44388. private _vertexBuffers;
  44389. private _indexBuffer;
  44390. private _effect;
  44391. private _positionX;
  44392. private _positionY;
  44393. private _isEnabled;
  44394. /** @hidden */
  44395. static _SceneComponentInitialization: (scene: Scene) => void;
  44396. /**
  44397. * Instantiates a lens flare system.
  44398. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  44399. * It is usually composed of several `lensFlare`.
  44400. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44401. * @param name Define the name of the lens flare system in the scene
  44402. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  44403. * @param scene Define the scene the lens flare system belongs to
  44404. */
  44405. constructor(
  44406. /**
  44407. * Define the name of the lens flare system
  44408. */
  44409. name: string, emitter: any, scene: Scene);
  44410. /**
  44411. * Define if the lens flare system is enabled.
  44412. */
  44413. isEnabled: boolean;
  44414. /**
  44415. * Get the scene the effects belongs to.
  44416. * @returns the scene holding the lens flare system
  44417. */
  44418. getScene(): Scene;
  44419. /**
  44420. * Get the emitter of the lens flare system.
  44421. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44422. * @returns the emitter of the lens flare system
  44423. */
  44424. getEmitter(): any;
  44425. /**
  44426. * Set the emitter of the lens flare system.
  44427. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  44428. * @param newEmitter Define the new emitter of the system
  44429. */
  44430. setEmitter(newEmitter: any): void;
  44431. /**
  44432. * Get the lens flare system emitter position.
  44433. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  44434. * @returns the position
  44435. */
  44436. getEmitterPosition(): Vector3;
  44437. /**
  44438. * @hidden
  44439. */
  44440. computeEffectivePosition(globalViewport: Viewport): boolean;
  44441. /** @hidden */
  44442. _isVisible(): boolean;
  44443. /**
  44444. * @hidden
  44445. */
  44446. render(): boolean;
  44447. /**
  44448. * Dispose and release the lens flare with its associated resources.
  44449. */
  44450. dispose(): void;
  44451. /**
  44452. * Parse a lens flare system from a JSON repressentation
  44453. * @param parsedLensFlareSystem Define the JSON to parse
  44454. * @param scene Define the scene the parsed system should be instantiated in
  44455. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44456. * @returns the parsed system
  44457. */
  44458. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  44459. /**
  44460. * Serialize the current Lens Flare System into a JSON representation.
  44461. * @returns the serialized JSON
  44462. */
  44463. serialize(): any;
  44464. }
  44465. }
  44466. declare module BABYLON {
  44467. /**
  44468. * This represents one of the lens effect in a `lensFlareSystem`.
  44469. * It controls one of the indiviual texture used in the effect.
  44470. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44471. */
  44472. export class LensFlare {
  44473. /**
  44474. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44475. */
  44476. size: number;
  44477. /**
  44478. * 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.
  44479. */
  44480. position: number;
  44481. /**
  44482. * Define the lens color.
  44483. */
  44484. color: Color3;
  44485. /**
  44486. * Define the lens texture.
  44487. */
  44488. texture: Nullable<Texture>;
  44489. /**
  44490. * Define the alpha mode to render this particular lens.
  44491. */
  44492. alphaMode: number;
  44493. private _system;
  44494. /**
  44495. * Creates a new Lens Flare.
  44496. * This represents one of the lens effect in a `lensFlareSystem`.
  44497. * It controls one of the indiviual texture used in the effect.
  44498. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44499. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  44500. * @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.
  44501. * @param color Define the lens color
  44502. * @param imgUrl Define the lens texture url
  44503. * @param system Define the `lensFlareSystem` this flare is part of
  44504. * @returns The newly created Lens Flare
  44505. */
  44506. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  44507. /**
  44508. * Instantiates a new Lens Flare.
  44509. * This represents one of the lens effect in a `lensFlareSystem`.
  44510. * It controls one of the indiviual texture used in the effect.
  44511. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44512. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  44513. * @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.
  44514. * @param color Define the lens color
  44515. * @param imgUrl Define the lens texture url
  44516. * @param system Define the `lensFlareSystem` this flare is part of
  44517. */
  44518. constructor(
  44519. /**
  44520. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  44521. */
  44522. size: number,
  44523. /**
  44524. * 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.
  44525. */
  44526. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  44527. /**
  44528. * Dispose and release the lens flare with its associated resources.
  44529. */
  44530. dispose(): void;
  44531. }
  44532. }
  44533. declare module BABYLON {
  44534. interface AbstractScene {
  44535. /**
  44536. * The list of lens flare system added to the scene
  44537. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  44538. */
  44539. lensFlareSystems: Array<LensFlareSystem>;
  44540. /**
  44541. * Removes the given lens flare system from this scene.
  44542. * @param toRemove The lens flare system to remove
  44543. * @returns The index of the removed lens flare system
  44544. */
  44545. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  44546. /**
  44547. * Adds the given lens flare system to this scene
  44548. * @param newLensFlareSystem The lens flare system to add
  44549. */
  44550. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  44551. /**
  44552. * Gets a lens flare system using its name
  44553. * @param name defines the name to look for
  44554. * @returns the lens flare system or null if not found
  44555. */
  44556. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  44557. /**
  44558. * Gets a lens flare system using its id
  44559. * @param id defines the id to look for
  44560. * @returns the lens flare system or null if not found
  44561. */
  44562. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  44563. }
  44564. /**
  44565. * Defines the lens flare scene component responsible to manage any lens flares
  44566. * in a given scene.
  44567. */
  44568. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  44569. /**
  44570. * The component name helpfull to identify the component in the list of scene components.
  44571. */
  44572. readonly name: string;
  44573. /**
  44574. * The scene the component belongs to.
  44575. */
  44576. scene: Scene;
  44577. /**
  44578. * Creates a new instance of the component for the given scene
  44579. * @param scene Defines the scene to register the component in
  44580. */
  44581. constructor(scene: Scene);
  44582. /**
  44583. * Registers the component in a given scene
  44584. */
  44585. register(): void;
  44586. /**
  44587. * Rebuilds the elements related to this component in case of
  44588. * context lost for instance.
  44589. */
  44590. rebuild(): void;
  44591. /**
  44592. * Adds all the element from the container to the scene
  44593. * @param container the container holding the elements
  44594. */
  44595. addFromContainer(container: AbstractScene): void;
  44596. /**
  44597. * Removes all the elements in the container from the scene
  44598. * @param container contains the elements to remove
  44599. */
  44600. removeFromContainer(container: AbstractScene): void;
  44601. /**
  44602. * Serializes the component data to the specified json object
  44603. * @param serializationObject The object to serialize to
  44604. */
  44605. serialize(serializationObject: any): void;
  44606. /**
  44607. * Disposes the component and the associated ressources.
  44608. */
  44609. dispose(): void;
  44610. private _draw;
  44611. }
  44612. }
  44613. declare module BABYLON {
  44614. /**
  44615. * Defines the shadow generator component responsible to manage any shadow generators
  44616. * in a given scene.
  44617. */
  44618. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44619. /**
  44620. * The component name helpfull to identify the component in the list of scene components.
  44621. */
  44622. readonly name: string;
  44623. /**
  44624. * The scene the component belongs to.
  44625. */
  44626. scene: Scene;
  44627. /**
  44628. * Creates a new instance of the component for the given scene
  44629. * @param scene Defines the scene to register the component in
  44630. */
  44631. constructor(scene: Scene);
  44632. /**
  44633. * Registers the component in a given scene
  44634. */
  44635. register(): void;
  44636. /**
  44637. * Rebuilds the elements related to this component in case of
  44638. * context lost for instance.
  44639. */
  44640. rebuild(): void;
  44641. /**
  44642. * Serializes the component data to the specified json object
  44643. * @param serializationObject The object to serialize to
  44644. */
  44645. serialize(serializationObject: any): void;
  44646. /**
  44647. * Adds all the element from the container to the scene
  44648. * @param container the container holding the elements
  44649. */
  44650. addFromContainer(container: AbstractScene): void;
  44651. /**
  44652. * Removes all the elements in the container from the scene
  44653. * @param container contains the elements to remove
  44654. */
  44655. removeFromContainer(container: AbstractScene): void;
  44656. /**
  44657. * Rebuilds the elements related to this component in case of
  44658. * context lost for instance.
  44659. */
  44660. dispose(): void;
  44661. private _gatherRenderTargets;
  44662. }
  44663. }
  44664. declare module BABYLON {
  44665. /**
  44666. * A directional light is defined by a direction (what a surprise!).
  44667. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44668. * 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.
  44669. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44670. */
  44671. export class DirectionalLight extends ShadowLight {
  44672. private _shadowFrustumSize;
  44673. /**
  44674. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44675. */
  44676. /**
  44677. * Specifies a fix frustum size for the shadow generation.
  44678. */
  44679. shadowFrustumSize: number;
  44680. private _shadowOrthoScale;
  44681. /**
  44682. * Gets the shadow projection scale against the optimal computed one.
  44683. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44684. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44685. */
  44686. /**
  44687. * Sets the shadow projection scale against the optimal computed one.
  44688. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44689. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44690. */
  44691. shadowOrthoScale: number;
  44692. /**
  44693. * Automatically compute the projection matrix to best fit (including all the casters)
  44694. * on each frame.
  44695. */
  44696. autoUpdateExtends: boolean;
  44697. private _orthoLeft;
  44698. private _orthoRight;
  44699. private _orthoTop;
  44700. private _orthoBottom;
  44701. /**
  44702. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44703. * The directional light is emitted from everywhere in the given direction.
  44704. * It can cast shadows.
  44705. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44706. * @param name The friendly name of the light
  44707. * @param direction The direction of the light
  44708. * @param scene The scene the light belongs to
  44709. */
  44710. constructor(name: string, direction: Vector3, scene: Scene);
  44711. /**
  44712. * Returns the string "DirectionalLight".
  44713. * @return The class name
  44714. */
  44715. getClassName(): string;
  44716. /**
  44717. * Returns the integer 1.
  44718. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44719. */
  44720. getTypeID(): number;
  44721. /**
  44722. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44723. * Returns the DirectionalLight Shadow projection matrix.
  44724. */
  44725. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44726. /**
  44727. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44728. * Returns the DirectionalLight Shadow projection matrix.
  44729. */
  44730. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44731. /**
  44732. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44733. * Returns the DirectionalLight Shadow projection matrix.
  44734. */
  44735. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44736. protected _buildUniformLayout(): void;
  44737. /**
  44738. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44739. * @param effect The effect to update
  44740. * @param lightIndex The index of the light in the effect to update
  44741. * @returns The directional light
  44742. */
  44743. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44744. /**
  44745. * Gets the minZ used for shadow according to both the scene and the light.
  44746. *
  44747. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44748. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44749. * @param activeCamera The camera we are returning the min for
  44750. * @returns the depth min z
  44751. */
  44752. getDepthMinZ(activeCamera: Camera): number;
  44753. /**
  44754. * Gets the maxZ used for shadow according to both the scene and the light.
  44755. *
  44756. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44757. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44758. * @param activeCamera The camera we are returning the max for
  44759. * @returns the depth max z
  44760. */
  44761. getDepthMaxZ(activeCamera: Camera): number;
  44762. /**
  44763. * Prepares the list of defines specific to the light type.
  44764. * @param defines the list of defines
  44765. * @param lightIndex defines the index of the light for the effect
  44766. */
  44767. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44768. }
  44769. }
  44770. declare module BABYLON {
  44771. /**
  44772. * A point light is a light defined by an unique point in world space.
  44773. * The light is emitted in every direction from this point.
  44774. * A good example of a point light is a standard light bulb.
  44775. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44776. */
  44777. export class PointLight extends ShadowLight {
  44778. private _shadowAngle;
  44779. /**
  44780. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44781. * This specifies what angle the shadow will use to be created.
  44782. *
  44783. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44784. */
  44785. /**
  44786. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44787. * This specifies what angle the shadow will use to be created.
  44788. *
  44789. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  44790. */
  44791. shadowAngle: number;
  44792. /**
  44793. * Gets the direction if it has been set.
  44794. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44795. */
  44796. /**
  44797. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  44798. */
  44799. direction: Vector3;
  44800. /**
  44801. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  44802. * A PointLight emits the light in every direction.
  44803. * It can cast shadows.
  44804. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  44805. * ```javascript
  44806. * var pointLight = new PointLight("pl", camera.position, scene);
  44807. * ```
  44808. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44809. * @param name The light friendly name
  44810. * @param position The position of the point light in the scene
  44811. * @param scene The scene the lights belongs to
  44812. */
  44813. constructor(name: string, position: Vector3, scene: Scene);
  44814. /**
  44815. * Returns the string "PointLight"
  44816. * @returns the class name
  44817. */
  44818. getClassName(): string;
  44819. /**
  44820. * Returns the integer 0.
  44821. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44822. */
  44823. getTypeID(): number;
  44824. /**
  44825. * Specifies wether or not the shadowmap should be a cube texture.
  44826. * @returns true if the shadowmap needs to be a cube texture.
  44827. */
  44828. needCube(): boolean;
  44829. /**
  44830. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  44831. * @param faceIndex The index of the face we are computed the direction to generate shadow
  44832. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  44833. */
  44834. getShadowDirection(faceIndex?: number): Vector3;
  44835. /**
  44836. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  44837. * - fov = PI / 2
  44838. * - aspect ratio : 1.0
  44839. * - z-near and far equal to the active camera minZ and maxZ.
  44840. * Returns the PointLight.
  44841. */
  44842. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44843. protected _buildUniformLayout(): void;
  44844. /**
  44845. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  44846. * @param effect The effect to update
  44847. * @param lightIndex The index of the light in the effect to update
  44848. * @returns The point light
  44849. */
  44850. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  44851. /**
  44852. * Prepares the list of defines specific to the light type.
  44853. * @param defines the list of defines
  44854. * @param lightIndex defines the index of the light for the effect
  44855. */
  44856. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44857. }
  44858. }
  44859. declare module BABYLON {
  44860. /**
  44861. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44862. * These values define a cone of light starting from the position, emitting toward the direction.
  44863. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44864. * and the exponent defines the speed of the decay of the light with distance (reach).
  44865. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44866. */
  44867. export class SpotLight extends ShadowLight {
  44868. private _angle;
  44869. private _innerAngle;
  44870. private _cosHalfAngle;
  44871. private _lightAngleScale;
  44872. private _lightAngleOffset;
  44873. /**
  44874. * Gets the cone angle of the spot light in Radians.
  44875. */
  44876. /**
  44877. * Sets the cone angle of the spot light in Radians.
  44878. */
  44879. angle: number;
  44880. /**
  44881. * Only used in gltf falloff mode, this defines the angle where
  44882. * the directional falloff will start before cutting at angle which could be seen
  44883. * as outer angle.
  44884. */
  44885. /**
  44886. * Only used in gltf falloff mode, this defines the angle where
  44887. * the directional falloff will start before cutting at angle which could be seen
  44888. * as outer angle.
  44889. */
  44890. innerAngle: number;
  44891. private _shadowAngleScale;
  44892. /**
  44893. * Allows scaling the angle of the light for shadow generation only.
  44894. */
  44895. /**
  44896. * Allows scaling the angle of the light for shadow generation only.
  44897. */
  44898. shadowAngleScale: number;
  44899. /**
  44900. * The light decay speed with the distance from the emission spot.
  44901. */
  44902. exponent: number;
  44903. private _projectionTextureMatrix;
  44904. /**
  44905. * Allows reading the projecton texture
  44906. */
  44907. readonly projectionTextureMatrix: Matrix;
  44908. protected _projectionTextureLightNear: number;
  44909. /**
  44910. * Gets the near clip of the Spotlight for texture projection.
  44911. */
  44912. /**
  44913. * Sets the near clip of the Spotlight for texture projection.
  44914. */
  44915. projectionTextureLightNear: number;
  44916. protected _projectionTextureLightFar: number;
  44917. /**
  44918. * Gets the far clip of the Spotlight for texture projection.
  44919. */
  44920. /**
  44921. * Sets the far clip of the Spotlight for texture projection.
  44922. */
  44923. projectionTextureLightFar: number;
  44924. protected _projectionTextureUpDirection: Vector3;
  44925. /**
  44926. * Gets the Up vector of the Spotlight for texture projection.
  44927. */
  44928. /**
  44929. * Sets the Up vector of the Spotlight for texture projection.
  44930. */
  44931. projectionTextureUpDirection: Vector3;
  44932. private _projectionTexture;
  44933. /**
  44934. * Gets the projection texture of the light.
  44935. */
  44936. /**
  44937. * Sets the projection texture of the light.
  44938. */
  44939. projectionTexture: Nullable<BaseTexture>;
  44940. private _projectionTextureViewLightDirty;
  44941. private _projectionTextureProjectionLightDirty;
  44942. private _projectionTextureDirty;
  44943. private _projectionTextureViewTargetVector;
  44944. private _projectionTextureViewLightMatrix;
  44945. private _projectionTextureProjectionLightMatrix;
  44946. private _projectionTextureScalingMatrix;
  44947. /**
  44948. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44949. * It can cast shadows.
  44950. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44951. * @param name The light friendly name
  44952. * @param position The position of the spot light in the scene
  44953. * @param direction The direction of the light in the scene
  44954. * @param angle The cone angle of the light in Radians
  44955. * @param exponent The light decay speed with the distance from the emission spot
  44956. * @param scene The scene the lights belongs to
  44957. */
  44958. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44959. /**
  44960. * Returns the string "SpotLight".
  44961. * @returns the class name
  44962. */
  44963. getClassName(): string;
  44964. /**
  44965. * Returns the integer 2.
  44966. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44967. */
  44968. getTypeID(): number;
  44969. /**
  44970. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44971. */
  44972. protected _setDirection(value: Vector3): void;
  44973. /**
  44974. * Overrides the position setter to recompute the projection texture view light Matrix.
  44975. */
  44976. protected _setPosition(value: Vector3): void;
  44977. /**
  44978. * 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.
  44979. * Returns the SpotLight.
  44980. */
  44981. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44982. protected _computeProjectionTextureViewLightMatrix(): void;
  44983. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44984. /**
  44985. * Main function for light texture projection matrix computing.
  44986. */
  44987. protected _computeProjectionTextureMatrix(): void;
  44988. protected _buildUniformLayout(): void;
  44989. private _computeAngleValues;
  44990. /**
  44991. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44992. * @param effect The effect to update
  44993. * @param lightIndex The index of the light in the effect to update
  44994. * @returns The spot light
  44995. */
  44996. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44997. /**
  44998. * Disposes the light and the associated resources.
  44999. */
  45000. dispose(): void;
  45001. /**
  45002. * Prepares the list of defines specific to the light type.
  45003. * @param defines the list of defines
  45004. * @param lightIndex defines the index of the light for the effect
  45005. */
  45006. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45007. }
  45008. }
  45009. declare module BABYLON {
  45010. /**
  45011. * Header information of HDR texture files.
  45012. */
  45013. export interface HDRInfo {
  45014. /**
  45015. * The height of the texture in pixels.
  45016. */
  45017. height: number;
  45018. /**
  45019. * The width of the texture in pixels.
  45020. */
  45021. width: number;
  45022. /**
  45023. * The index of the beginning of the data in the binary file.
  45024. */
  45025. dataPosition: number;
  45026. }
  45027. /**
  45028. * This groups tools to convert HDR texture to native colors array.
  45029. */
  45030. export class HDRTools {
  45031. private static Ldexp;
  45032. private static Rgbe2float;
  45033. private static readStringLine;
  45034. /**
  45035. * Reads header information from an RGBE texture stored in a native array.
  45036. * More information on this format are available here:
  45037. * https://en.wikipedia.org/wiki/RGBE_image_format
  45038. *
  45039. * @param uint8array The binary file stored in native array.
  45040. * @return The header information.
  45041. */
  45042. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  45043. /**
  45044. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  45045. * This RGBE texture needs to store the information as a panorama.
  45046. *
  45047. * More information on this format are available here:
  45048. * https://en.wikipedia.org/wiki/RGBE_image_format
  45049. *
  45050. * @param buffer The binary file stored in an array buffer.
  45051. * @param size The expected size of the extracted cubemap.
  45052. * @return The Cube Map information.
  45053. */
  45054. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  45055. /**
  45056. * Returns the pixels data extracted from an RGBE texture.
  45057. * This pixels will be stored left to right up to down in the R G B order in one array.
  45058. *
  45059. * More information on this format are available here:
  45060. * https://en.wikipedia.org/wiki/RGBE_image_format
  45061. *
  45062. * @param uint8array The binary file stored in an array buffer.
  45063. * @param hdrInfo The header information of the file.
  45064. * @return The pixels data in RGB right to left up to down order.
  45065. */
  45066. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  45067. private static RGBE_ReadPixels_RLE;
  45068. }
  45069. }
  45070. declare module BABYLON {
  45071. /**
  45072. * This represents a texture coming from an HDR input.
  45073. *
  45074. * The only supported format is currently panorama picture stored in RGBE format.
  45075. * Example of such files can be found on HDRLib: http://hdrlib.com/
  45076. */
  45077. export class HDRCubeTexture extends BaseTexture {
  45078. private static _facesMapping;
  45079. private _generateHarmonics;
  45080. private _noMipmap;
  45081. private _textureMatrix;
  45082. private _size;
  45083. private _onLoad;
  45084. private _onError;
  45085. /**
  45086. * The texture URL.
  45087. */
  45088. url: string;
  45089. /**
  45090. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  45091. */
  45092. coordinatesMode: number;
  45093. protected _isBlocking: boolean;
  45094. /**
  45095. * Sets wether or not the texture is blocking during loading.
  45096. */
  45097. /**
  45098. * Gets wether or not the texture is blocking during loading.
  45099. */
  45100. isBlocking: boolean;
  45101. protected _rotationY: number;
  45102. /**
  45103. * Sets texture matrix rotation angle around Y axis in radians.
  45104. */
  45105. /**
  45106. * Gets texture matrix rotation angle around Y axis radians.
  45107. */
  45108. rotationY: number;
  45109. /**
  45110. * Gets or sets the center of the bounding box associated with the cube texture
  45111. * It must define where the camera used to render the texture was set
  45112. */
  45113. boundingBoxPosition: Vector3;
  45114. private _boundingBoxSize;
  45115. /**
  45116. * Gets or sets the size of the bounding box associated with the cube texture
  45117. * When defined, the cubemap will switch to local mode
  45118. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  45119. * @example https://www.babylonjs-playground.com/#RNASML
  45120. */
  45121. boundingBoxSize: Vector3;
  45122. /**
  45123. * Instantiates an HDRTexture from the following parameters.
  45124. *
  45125. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  45126. * @param scene The scene the texture will be used in
  45127. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  45128. * @param noMipmap Forces to not generate the mipmap if true
  45129. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  45130. * @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)
  45131. * @param reserved Reserved flag for internal use.
  45132. */
  45133. 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>);
  45134. /**
  45135. * Get the current class name of the texture useful for serialization or dynamic coding.
  45136. * @returns "HDRCubeTexture"
  45137. */
  45138. getClassName(): string;
  45139. /**
  45140. * Occurs when the file is raw .hdr file.
  45141. */
  45142. private loadTexture;
  45143. clone(): HDRCubeTexture;
  45144. delayLoad(): void;
  45145. /**
  45146. * Get the texture reflection matrix used to rotate/transform the reflection.
  45147. * @returns the reflection matrix
  45148. */
  45149. getReflectionTextureMatrix(): Matrix;
  45150. /**
  45151. * Set the texture reflection matrix used to rotate/transform the reflection.
  45152. * @param value Define the reflection matrix to set
  45153. */
  45154. setReflectionTextureMatrix(value: Matrix): void;
  45155. /**
  45156. * Parses a JSON representation of an HDR Texture in order to create the texture
  45157. * @param parsedTexture Define the JSON representation
  45158. * @param scene Define the scene the texture should be created in
  45159. * @param rootUrl Define the root url in case we need to load relative dependencies
  45160. * @returns the newly created texture after parsing
  45161. */
  45162. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  45163. serialize(): any;
  45164. }
  45165. }
  45166. declare module BABYLON {
  45167. /**
  45168. * Class used to control physics engine
  45169. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  45170. */
  45171. export class PhysicsEngine implements IPhysicsEngine {
  45172. private _physicsPlugin;
  45173. /**
  45174. * Global value used to control the smallest number supported by the simulation
  45175. */
  45176. static Epsilon: number;
  45177. private _impostors;
  45178. private _joints;
  45179. /**
  45180. * Gets the gravity vector used by the simulation
  45181. */
  45182. gravity: Vector3;
  45183. /**
  45184. * Factory used to create the default physics plugin.
  45185. * @returns The default physics plugin
  45186. */
  45187. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  45188. /**
  45189. * Creates a new Physics Engine
  45190. * @param gravity defines the gravity vector used by the simulation
  45191. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  45192. */
  45193. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  45194. /**
  45195. * Sets the gravity vector used by the simulation
  45196. * @param gravity defines the gravity vector to use
  45197. */
  45198. setGravity(gravity: Vector3): void;
  45199. /**
  45200. * Set the time step of the physics engine.
  45201. * Default is 1/60.
  45202. * To slow it down, enter 1/600 for example.
  45203. * To speed it up, 1/30
  45204. * @param newTimeStep defines the new timestep to apply to this world.
  45205. */
  45206. setTimeStep(newTimeStep?: number): void;
  45207. /**
  45208. * Get the time step of the physics engine.
  45209. * @returns the current time step
  45210. */
  45211. getTimeStep(): number;
  45212. /**
  45213. * Release all resources
  45214. */
  45215. dispose(): void;
  45216. /**
  45217. * Gets the name of the current physics plugin
  45218. * @returns the name of the plugin
  45219. */
  45220. getPhysicsPluginName(): string;
  45221. /**
  45222. * Adding a new impostor for the impostor tracking.
  45223. * This will be done by the impostor itself.
  45224. * @param impostor the impostor to add
  45225. */
  45226. addImpostor(impostor: PhysicsImpostor): void;
  45227. /**
  45228. * Remove an impostor from the engine.
  45229. * This impostor and its mesh will not longer be updated by the physics engine.
  45230. * @param impostor the impostor to remove
  45231. */
  45232. removeImpostor(impostor: PhysicsImpostor): void;
  45233. /**
  45234. * Add a joint to the physics engine
  45235. * @param mainImpostor defines the main impostor to which the joint is added.
  45236. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  45237. * @param joint defines the joint that will connect both impostors.
  45238. */
  45239. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45240. /**
  45241. * Removes a joint from the simulation
  45242. * @param mainImpostor defines the impostor used with the joint
  45243. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  45244. * @param joint defines the joint to remove
  45245. */
  45246. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  45247. /**
  45248. * Called by the scene. No need to call it.
  45249. * @param delta defines the timespam between frames
  45250. */
  45251. _step(delta: number): void;
  45252. /**
  45253. * Gets the current plugin used to run the simulation
  45254. * @returns current plugin
  45255. */
  45256. getPhysicsPlugin(): IPhysicsEnginePlugin;
  45257. /**
  45258. * Gets the list of physic impostors
  45259. * @returns an array of PhysicsImpostor
  45260. */
  45261. getImpostors(): Array<PhysicsImpostor>;
  45262. /**
  45263. * Gets the impostor for a physics enabled object
  45264. * @param object defines the object impersonated by the impostor
  45265. * @returns the PhysicsImpostor or null if not found
  45266. */
  45267. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  45268. /**
  45269. * Gets the impostor for a physics body object
  45270. * @param body defines physics body used by the impostor
  45271. * @returns the PhysicsImpostor or null if not found
  45272. */
  45273. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  45274. }
  45275. }
  45276. declare module BABYLON {
  45277. /** @hidden */
  45278. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  45279. private _useDeltaForWorldStep;
  45280. world: any;
  45281. name: string;
  45282. private _physicsMaterials;
  45283. private _fixedTimeStep;
  45284. BJSCANNON: any;
  45285. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  45286. setGravity(gravity: Vector3): void;
  45287. setTimeStep(timeStep: number): void;
  45288. getTimeStep(): number;
  45289. executeStep(delta: number): void;
  45290. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45291. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45292. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45293. private _processChildMeshes;
  45294. removePhysicsBody(impostor: PhysicsImpostor): void;
  45295. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45296. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45297. private _addMaterial;
  45298. private _checkWithEpsilon;
  45299. private _createShape;
  45300. private _createHeightmap;
  45301. private _minus90X;
  45302. private _plus90X;
  45303. private _tmpPosition;
  45304. private _tmpDeltaPosition;
  45305. private _tmpUnityRotation;
  45306. private _updatePhysicsBodyTransformation;
  45307. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45308. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45309. isSupported(): boolean;
  45310. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45311. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45312. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45313. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45314. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45315. getBodyMass(impostor: PhysicsImpostor): number;
  45316. getBodyFriction(impostor: PhysicsImpostor): number;
  45317. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45318. getBodyRestitution(impostor: PhysicsImpostor): number;
  45319. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45320. sleepBody(impostor: PhysicsImpostor): void;
  45321. wakeUpBody(impostor: PhysicsImpostor): void;
  45322. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  45323. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  45324. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  45325. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45326. getRadius(impostor: PhysicsImpostor): number;
  45327. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45328. dispose(): void;
  45329. private _extendNamespace;
  45330. }
  45331. }
  45332. declare module BABYLON {
  45333. /** @hidden */
  45334. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  45335. world: any;
  45336. name: string;
  45337. BJSOIMO: any;
  45338. constructor(iterations?: number, oimoInjection?: any);
  45339. setGravity(gravity: Vector3): void;
  45340. setTimeStep(timeStep: number): void;
  45341. getTimeStep(): number;
  45342. private _tmpImpostorsArray;
  45343. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  45344. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45345. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  45346. generatePhysicsBody(impostor: PhysicsImpostor): void;
  45347. private _tmpPositionVector;
  45348. removePhysicsBody(impostor: PhysicsImpostor): void;
  45349. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  45350. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  45351. isSupported(): boolean;
  45352. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  45353. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  45354. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45355. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  45356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45357. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  45358. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  45359. getBodyMass(impostor: PhysicsImpostor): number;
  45360. getBodyFriction(impostor: PhysicsImpostor): number;
  45361. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  45362. getBodyRestitution(impostor: PhysicsImpostor): number;
  45363. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  45364. sleepBody(impostor: PhysicsImpostor): void;
  45365. wakeUpBody(impostor: PhysicsImpostor): void;
  45366. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  45367. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  45368. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  45369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  45370. getRadius(impostor: PhysicsImpostor): number;
  45371. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  45372. dispose(): void;
  45373. }
  45374. }
  45375. declare module BABYLON {
  45376. interface AbstractScene {
  45377. /**
  45378. * The list of reflection probes added to the scene
  45379. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45380. */
  45381. reflectionProbes: Array<ReflectionProbe>;
  45382. /**
  45383. * Removes the given reflection probe from this scene.
  45384. * @param toRemove The reflection probe to remove
  45385. * @returns The index of the removed reflection probe
  45386. */
  45387. removeReflectionProbe(toRemove: ReflectionProbe): number;
  45388. /**
  45389. * Adds the given reflection probe to this scene.
  45390. * @param newReflectionProbe The reflection probe to add
  45391. */
  45392. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  45393. }
  45394. /**
  45395. * Class used to generate realtime reflection / refraction cube textures
  45396. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  45397. */
  45398. export class ReflectionProbe {
  45399. /** defines the name of the probe */
  45400. name: string;
  45401. private _scene;
  45402. private _renderTargetTexture;
  45403. private _projectionMatrix;
  45404. private _viewMatrix;
  45405. private _target;
  45406. private _add;
  45407. private _attachedMesh;
  45408. private _invertYAxis;
  45409. /** Gets or sets probe position (center of the cube map) */
  45410. position: Vector3;
  45411. /**
  45412. * Creates a new reflection probe
  45413. * @param name defines the name of the probe
  45414. * @param size defines the texture resolution (for each face)
  45415. * @param scene defines the hosting scene
  45416. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  45417. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  45418. */
  45419. constructor(
  45420. /** defines the name of the probe */
  45421. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  45422. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  45423. samples: number;
  45424. /** Gets or sets the refresh rate to use (on every frame by default) */
  45425. refreshRate: number;
  45426. /**
  45427. * Gets the hosting scene
  45428. * @returns a Scene
  45429. */
  45430. getScene(): Scene;
  45431. /** Gets the internal CubeTexture used to render to */
  45432. readonly cubeTexture: RenderTargetTexture;
  45433. /** Gets the list of meshes to render */
  45434. readonly renderList: Nullable<AbstractMesh[]>;
  45435. /**
  45436. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  45437. * @param mesh defines the mesh to attach to
  45438. */
  45439. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45440. /**
  45441. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  45442. * @param renderingGroupId The rendering group id corresponding to its index
  45443. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  45444. */
  45445. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  45446. /**
  45447. * Clean all associated resources
  45448. */
  45449. dispose(): void;
  45450. /**
  45451. * Converts the reflection probe information to a readable string for debug purpose.
  45452. * @param fullDetails Supports for multiple levels of logging within scene loading
  45453. * @returns the human readable reflection probe info
  45454. */
  45455. toString(fullDetails?: boolean): string;
  45456. /**
  45457. * Get the class name of the relfection probe.
  45458. * @returns "ReflectionProbe"
  45459. */
  45460. getClassName(): string;
  45461. /**
  45462. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  45463. * @returns The JSON representation of the texture
  45464. */
  45465. serialize(): any;
  45466. /**
  45467. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  45468. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  45469. * @param scene Define the scene the parsed reflection probe should be instantiated in
  45470. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  45471. * @returns The parsed reflection probe if successful
  45472. */
  45473. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  45474. }
  45475. }
  45476. declare module BABYLON {
  45477. /** @hidden */
  45478. export var _BabylonLoaderRegistered: boolean;
  45479. }
  45480. declare module BABYLON {
  45481. /**
  45482. * The Physically based simple base material of BJS.
  45483. *
  45484. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45485. * It is used as the base class for both the specGloss and metalRough conventions.
  45486. */
  45487. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45488. /**
  45489. * Number of Simultaneous lights allowed on the material.
  45490. */
  45491. maxSimultaneousLights: number;
  45492. /**
  45493. * If sets to true, disables all the lights affecting the material.
  45494. */
  45495. disableLighting: boolean;
  45496. /**
  45497. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45498. */
  45499. environmentTexture: BaseTexture;
  45500. /**
  45501. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45502. */
  45503. invertNormalMapX: boolean;
  45504. /**
  45505. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45506. */
  45507. invertNormalMapY: boolean;
  45508. /**
  45509. * Normal map used in the model.
  45510. */
  45511. normalTexture: BaseTexture;
  45512. /**
  45513. * Emissivie color used to self-illuminate the model.
  45514. */
  45515. emissiveColor: Color3;
  45516. /**
  45517. * Emissivie texture used to self-illuminate the model.
  45518. */
  45519. emissiveTexture: BaseTexture;
  45520. /**
  45521. * Occlusion Channel Strenght.
  45522. */
  45523. occlusionStrength: number;
  45524. /**
  45525. * Occlusion Texture of the material (adding extra occlusion effects).
  45526. */
  45527. occlusionTexture: BaseTexture;
  45528. /**
  45529. * Defines the alpha limits in alpha test mode.
  45530. */
  45531. alphaCutOff: number;
  45532. /**
  45533. * Gets the current double sided mode.
  45534. */
  45535. /**
  45536. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45537. */
  45538. doubleSided: boolean;
  45539. /**
  45540. * Stores the pre-calculated light information of a mesh in a texture.
  45541. */
  45542. lightmapTexture: BaseTexture;
  45543. /**
  45544. * If true, the light map contains occlusion information instead of lighting info.
  45545. */
  45546. useLightmapAsShadowmap: boolean;
  45547. /**
  45548. * Return the active textures of the material.
  45549. */
  45550. getActiveTextures(): BaseTexture[];
  45551. hasTexture(texture: BaseTexture): boolean;
  45552. /**
  45553. * Instantiates a new PBRMaterial instance.
  45554. *
  45555. * @param name The material name
  45556. * @param scene The scene the material will be use in.
  45557. */
  45558. constructor(name: string, scene: Scene);
  45559. getClassName(): string;
  45560. }
  45561. }
  45562. declare module BABYLON {
  45563. /**
  45564. * The PBR material of BJS following the metal roughness convention.
  45565. *
  45566. * This fits to the PBR convention in the GLTF definition:
  45567. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45568. */
  45569. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  45570. /**
  45571. * The base color has two different interpretations depending on the value of metalness.
  45572. * When the material is a metal, the base color is the specific measured reflectance value
  45573. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  45574. * of the material.
  45575. */
  45576. baseColor: Color3;
  45577. /**
  45578. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  45579. * well as opacity information in the alpha channel.
  45580. */
  45581. baseTexture: BaseTexture;
  45582. /**
  45583. * Specifies the metallic scalar value of the material.
  45584. * Can also be used to scale the metalness values of the metallic texture.
  45585. */
  45586. metallic: number;
  45587. /**
  45588. * Specifies the roughness scalar value of the material.
  45589. * Can also be used to scale the roughness values of the metallic texture.
  45590. */
  45591. roughness: number;
  45592. /**
  45593. * Texture containing both the metallic value in the B channel and the
  45594. * roughness value in the G channel to keep better precision.
  45595. */
  45596. metallicRoughnessTexture: BaseTexture;
  45597. /**
  45598. * Instantiates a new PBRMetalRoughnessMaterial instance.
  45599. *
  45600. * @param name The material name
  45601. * @param scene The scene the material will be use in.
  45602. */
  45603. constructor(name: string, scene: Scene);
  45604. /**
  45605. * Return the currrent class name of the material.
  45606. */
  45607. getClassName(): string;
  45608. /**
  45609. * Return the active textures of the material.
  45610. */
  45611. getActiveTextures(): BaseTexture[];
  45612. /**
  45613. * Checks to see if a texture is used in the material.
  45614. * @param texture - Base texture to use.
  45615. * @returns - Boolean specifying if a texture is used in the material.
  45616. */
  45617. hasTexture(texture: BaseTexture): boolean;
  45618. /**
  45619. * Makes a duplicate of the current material.
  45620. * @param name - name to use for the new material.
  45621. */
  45622. clone(name: string): PBRMetallicRoughnessMaterial;
  45623. /**
  45624. * Serialize the material to a parsable JSON object.
  45625. */
  45626. serialize(): any;
  45627. /**
  45628. * Parses a JSON object correponding to the serialize function.
  45629. */
  45630. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  45631. }
  45632. }
  45633. declare module BABYLON {
  45634. /**
  45635. * The PBR material of BJS following the specular glossiness convention.
  45636. *
  45637. * This fits to the PBR convention in the GLTF definition:
  45638. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  45639. */
  45640. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  45641. /**
  45642. * Specifies the diffuse color of the material.
  45643. */
  45644. diffuseColor: Color3;
  45645. /**
  45646. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  45647. * channel.
  45648. */
  45649. diffuseTexture: BaseTexture;
  45650. /**
  45651. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  45652. */
  45653. specularColor: Color3;
  45654. /**
  45655. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  45656. */
  45657. glossiness: number;
  45658. /**
  45659. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  45660. */
  45661. specularGlossinessTexture: BaseTexture;
  45662. /**
  45663. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  45664. *
  45665. * @param name The material name
  45666. * @param scene The scene the material will be use in.
  45667. */
  45668. constructor(name: string, scene: Scene);
  45669. /**
  45670. * Return the currrent class name of the material.
  45671. */
  45672. getClassName(): string;
  45673. /**
  45674. * Return the active textures of the material.
  45675. */
  45676. getActiveTextures(): BaseTexture[];
  45677. /**
  45678. * Checks to see if a texture is used in the material.
  45679. * @param texture - Base texture to use.
  45680. * @returns - Boolean specifying if a texture is used in the material.
  45681. */
  45682. hasTexture(texture: BaseTexture): boolean;
  45683. /**
  45684. * Makes a duplicate of the current material.
  45685. * @param name - name to use for the new material.
  45686. */
  45687. clone(name: string): PBRSpecularGlossinessMaterial;
  45688. /**
  45689. * Serialize the material to a parsable JSON object.
  45690. */
  45691. serialize(): any;
  45692. /**
  45693. * Parses a JSON object correponding to the serialize function.
  45694. */
  45695. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  45696. }
  45697. }
  45698. declare module BABYLON {
  45699. /**
  45700. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  45701. * It can help converting any input color in a desired output one. This can then be used to create effects
  45702. * from sepia, black and white to sixties or futuristic rendering...
  45703. *
  45704. * The only supported format is currently 3dl.
  45705. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  45706. */
  45707. export class ColorGradingTexture extends BaseTexture {
  45708. /**
  45709. * The current texture matrix. (will always be identity in color grading texture)
  45710. */
  45711. private _textureMatrix;
  45712. /**
  45713. * The texture URL.
  45714. */
  45715. url: string;
  45716. /**
  45717. * Empty line regex stored for GC.
  45718. */
  45719. private static _noneEmptyLineRegex;
  45720. private _engine;
  45721. /**
  45722. * Instantiates a ColorGradingTexture from the following parameters.
  45723. *
  45724. * @param url The location of the color gradind data (currently only supporting 3dl)
  45725. * @param scene The scene the texture will be used in
  45726. */
  45727. constructor(url: string, scene: Scene);
  45728. /**
  45729. * Returns the texture matrix used in most of the material.
  45730. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  45731. */
  45732. getTextureMatrix(): Matrix;
  45733. /**
  45734. * Occurs when the file being loaded is a .3dl LUT file.
  45735. */
  45736. private load3dlTexture;
  45737. /**
  45738. * Starts the loading process of the texture.
  45739. */
  45740. private loadTexture;
  45741. /**
  45742. * Clones the color gradind texture.
  45743. */
  45744. clone(): ColorGradingTexture;
  45745. /**
  45746. * Called during delayed load for textures.
  45747. */
  45748. delayLoad(): void;
  45749. /**
  45750. * Parses a color grading texture serialized by Babylon.
  45751. * @param parsedTexture The texture information being parsedTexture
  45752. * @param scene The scene to load the texture in
  45753. * @param rootUrl The root url of the data assets to load
  45754. * @return A color gradind texture
  45755. */
  45756. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  45757. /**
  45758. * Serializes the LUT texture to json format.
  45759. */
  45760. serialize(): any;
  45761. }
  45762. }
  45763. declare module BABYLON {
  45764. /**
  45765. * Direct draw surface info
  45766. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45767. */
  45768. export interface DDSInfo {
  45769. /**
  45770. * Width of the texture
  45771. */
  45772. width: number;
  45773. /**
  45774. * Width of the texture
  45775. */
  45776. height: number;
  45777. /**
  45778. * Number of Mipmaps for the texture
  45779. * @see https://en.wikipedia.org/wiki/Mipmap
  45780. */
  45781. mipmapCount: number;
  45782. /**
  45783. * If the textures format is a known fourCC format
  45784. * @see https://www.fourcc.org/
  45785. */
  45786. isFourCC: boolean;
  45787. /**
  45788. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45789. */
  45790. isRGB: boolean;
  45791. /**
  45792. * If the texture is a lumincance format
  45793. */
  45794. isLuminance: boolean;
  45795. /**
  45796. * If this is a cube texture
  45797. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45798. */
  45799. isCube: boolean;
  45800. /**
  45801. * If the texture is a compressed format eg. FOURCC_DXT1
  45802. */
  45803. isCompressed: boolean;
  45804. /**
  45805. * The dxgiFormat of the texture
  45806. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45807. */
  45808. dxgiFormat: number;
  45809. /**
  45810. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45811. */
  45812. textureType: number;
  45813. /**
  45814. * Sphericle polynomial created for the dds texture
  45815. */
  45816. sphericalPolynomial?: SphericalPolynomial;
  45817. }
  45818. /**
  45819. * Class used to provide DDS decompression tools
  45820. */
  45821. export class DDSTools {
  45822. /**
  45823. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45824. */
  45825. static StoreLODInAlphaChannel: boolean;
  45826. /**
  45827. * Gets DDS information from an array buffer
  45828. * @param arrayBuffer defines the array buffer to read data from
  45829. * @returns the DDS information
  45830. */
  45831. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45832. private static _FloatView;
  45833. private static _Int32View;
  45834. private static _ToHalfFloat;
  45835. private static _FromHalfFloat;
  45836. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45837. private static _GetHalfFloatRGBAArrayBuffer;
  45838. private static _GetFloatRGBAArrayBuffer;
  45839. private static _GetFloatAsUIntRGBAArrayBuffer;
  45840. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45841. private static _GetRGBAArrayBuffer;
  45842. private static _ExtractLongWordOrder;
  45843. private static _GetRGBArrayBuffer;
  45844. private static _GetLuminanceArrayBuffer;
  45845. /**
  45846. * Uploads DDS Levels to a Babylon Texture
  45847. * @hidden
  45848. */
  45849. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45850. }
  45851. interface Engine {
  45852. /**
  45853. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45854. * @param rootUrl defines the url where the file to load is located
  45855. * @param scene defines the current scene
  45856. * @param lodScale defines scale to apply to the mip map selection
  45857. * @param lodOffset defines offset to apply to the mip map selection
  45858. * @param onLoad defines an optional callback raised when the texture is loaded
  45859. * @param onError defines an optional callback raised if there is an issue to load the texture
  45860. * @param format defines the format of the data
  45861. * @param forcedExtension defines the extension to use to pick the right loader
  45862. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45863. * @returns the cube texture as an InternalTexture
  45864. */
  45865. 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;
  45866. }
  45867. }
  45868. declare module BABYLON {
  45869. /**
  45870. * Implementation of the DDS Texture Loader.
  45871. * @hidden
  45872. */
  45873. export class _DDSTextureLoader implements IInternalTextureLoader {
  45874. /**
  45875. * Defines wether the loader supports cascade loading the different faces.
  45876. */
  45877. readonly supportCascades: boolean;
  45878. /**
  45879. * This returns if the loader support the current file information.
  45880. * @param extension defines the file extension of the file being loaded
  45881. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45882. * @param fallback defines the fallback internal texture if any
  45883. * @param isBase64 defines whether the texture is encoded as a base64
  45884. * @param isBuffer defines whether the texture data are stored as a buffer
  45885. * @returns true if the loader can load the specified file
  45886. */
  45887. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45888. /**
  45889. * Transform the url before loading if required.
  45890. * @param rootUrl the url of the texture
  45891. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45892. * @returns the transformed texture
  45893. */
  45894. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45895. /**
  45896. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45897. * @param rootUrl the url of the texture
  45898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45899. * @returns the fallback texture
  45900. */
  45901. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45902. /**
  45903. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45904. * @param data contains the texture data
  45905. * @param texture defines the BabylonJS internal texture
  45906. * @param createPolynomials will be true if polynomials have been requested
  45907. * @param onLoad defines the callback to trigger once the texture is ready
  45908. * @param onError defines the callback to trigger in case of error
  45909. */
  45910. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45911. /**
  45912. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45913. * @param data contains the texture data
  45914. * @param texture defines the BabylonJS internal texture
  45915. * @param callback defines the method to call once ready to upload
  45916. */
  45917. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45918. }
  45919. }
  45920. declare module BABYLON {
  45921. /** @hidden */
  45922. export var rgbdEncodePixelShader: {
  45923. name: string;
  45924. shader: string;
  45925. };
  45926. }
  45927. declare module BABYLON {
  45928. /** @hidden */
  45929. export var rgbdDecodePixelShader: {
  45930. name: string;
  45931. shader: string;
  45932. };
  45933. }
  45934. declare module BABYLON {
  45935. /**
  45936. * Raw texture data and descriptor sufficient for WebGL texture upload
  45937. */
  45938. export interface EnvironmentTextureInfo {
  45939. /**
  45940. * Version of the environment map
  45941. */
  45942. version: number;
  45943. /**
  45944. * Width of image
  45945. */
  45946. width: number;
  45947. /**
  45948. * Irradiance information stored in the file.
  45949. */
  45950. irradiance: any;
  45951. /**
  45952. * Specular information stored in the file.
  45953. */
  45954. specular: any;
  45955. }
  45956. /**
  45957. * Sets of helpers addressing the serialization and deserialization of environment texture
  45958. * stored in a BabylonJS env file.
  45959. * Those files are usually stored as .env files.
  45960. */
  45961. export class EnvironmentTextureTools {
  45962. /**
  45963. * Magic number identifying the env file.
  45964. */
  45965. private static _MagicBytes;
  45966. /**
  45967. * Gets the environment info from an env file.
  45968. * @param data The array buffer containing the .env bytes.
  45969. * @returns the environment file info (the json header) if successfully parsed.
  45970. */
  45971. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45972. /**
  45973. * Creates an environment texture from a loaded cube texture.
  45974. * @param texture defines the cube texture to convert in env file
  45975. * @return a promise containing the environment data if succesfull.
  45976. */
  45977. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45978. /**
  45979. * Creates a JSON representation of the spherical data.
  45980. * @param texture defines the texture containing the polynomials
  45981. * @return the JSON representation of the spherical info
  45982. */
  45983. private static _CreateEnvTextureIrradiance;
  45984. /**
  45985. * Uploads the texture info contained in the env file to the GPU.
  45986. * @param texture defines the internal texture to upload to
  45987. * @param arrayBuffer defines the buffer cotaining the data to load
  45988. * @param info defines the texture info retrieved through the GetEnvInfo method
  45989. * @returns a promise
  45990. */
  45991. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45992. /**
  45993. * Uploads the levels of image data to the GPU.
  45994. * @param texture defines the internal texture to upload to
  45995. * @param imageData defines the array buffer views of image data [mipmap][face]
  45996. * @returns a promise
  45997. */
  45998. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45999. /**
  46000. * Uploads spherical polynomials information to the texture.
  46001. * @param texture defines the texture we are trying to upload the information to
  46002. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46003. */
  46004. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46005. /** @hidden */
  46006. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46007. }
  46008. }
  46009. declare module BABYLON {
  46010. /**
  46011. * Implementation of the ENV Texture Loader.
  46012. * @hidden
  46013. */
  46014. export class _ENVTextureLoader implements IInternalTextureLoader {
  46015. /**
  46016. * Defines wether the loader supports cascade loading the different faces.
  46017. */
  46018. readonly supportCascades: boolean;
  46019. /**
  46020. * This returns if the loader support the current file information.
  46021. * @param extension defines the file extension of the file being loaded
  46022. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46023. * @param fallback defines the fallback internal texture if any
  46024. * @param isBase64 defines whether the texture is encoded as a base64
  46025. * @param isBuffer defines whether the texture data are stored as a buffer
  46026. * @returns true if the loader can load the specified file
  46027. */
  46028. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46029. /**
  46030. * Transform the url before loading if required.
  46031. * @param rootUrl the url of the texture
  46032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46033. * @returns the transformed texture
  46034. */
  46035. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46036. /**
  46037. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46038. * @param rootUrl the url of the texture
  46039. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46040. * @returns the fallback texture
  46041. */
  46042. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46043. /**
  46044. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46045. * @param data contains the texture data
  46046. * @param texture defines the BabylonJS internal texture
  46047. * @param createPolynomials will be true if polynomials have been requested
  46048. * @param onLoad defines the callback to trigger once the texture is ready
  46049. * @param onError defines the callback to trigger in case of error
  46050. */
  46051. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46052. /**
  46053. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46054. * @param data contains the texture data
  46055. * @param texture defines the BabylonJS internal texture
  46056. * @param callback defines the method to call once ready to upload
  46057. */
  46058. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46059. }
  46060. }
  46061. declare module BABYLON {
  46062. /**
  46063. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46064. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46065. */
  46066. export class KhronosTextureContainer {
  46067. /** contents of the KTX container file */
  46068. arrayBuffer: any;
  46069. private static HEADER_LEN;
  46070. private static COMPRESSED_2D;
  46071. private static COMPRESSED_3D;
  46072. private static TEX_2D;
  46073. private static TEX_3D;
  46074. /**
  46075. * Gets the openGL type
  46076. */
  46077. glType: number;
  46078. /**
  46079. * Gets the openGL type size
  46080. */
  46081. glTypeSize: number;
  46082. /**
  46083. * Gets the openGL format
  46084. */
  46085. glFormat: number;
  46086. /**
  46087. * Gets the openGL internal format
  46088. */
  46089. glInternalFormat: number;
  46090. /**
  46091. * Gets the base internal format
  46092. */
  46093. glBaseInternalFormat: number;
  46094. /**
  46095. * Gets image width in pixel
  46096. */
  46097. pixelWidth: number;
  46098. /**
  46099. * Gets image height in pixel
  46100. */
  46101. pixelHeight: number;
  46102. /**
  46103. * Gets image depth in pixels
  46104. */
  46105. pixelDepth: number;
  46106. /**
  46107. * Gets the number of array elements
  46108. */
  46109. numberOfArrayElements: number;
  46110. /**
  46111. * Gets the number of faces
  46112. */
  46113. numberOfFaces: number;
  46114. /**
  46115. * Gets the number of mipmap levels
  46116. */
  46117. numberOfMipmapLevels: number;
  46118. /**
  46119. * Gets the bytes of key value data
  46120. */
  46121. bytesOfKeyValueData: number;
  46122. /**
  46123. * Gets the load type
  46124. */
  46125. loadType: number;
  46126. /**
  46127. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46128. */
  46129. isInvalid: boolean;
  46130. /**
  46131. * Creates a new KhronosTextureContainer
  46132. * @param arrayBuffer contents of the KTX container file
  46133. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46134. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46135. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46136. */
  46137. constructor(
  46138. /** contents of the KTX container file */
  46139. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46140. /**
  46141. * Uploads KTX content to a Babylon Texture.
  46142. * It is assumed that the texture has already been created & is currently bound
  46143. * @hidden
  46144. */
  46145. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46146. private _upload2DCompressedLevels;
  46147. }
  46148. }
  46149. declare module BABYLON {
  46150. /**
  46151. * Implementation of the KTX Texture Loader.
  46152. * @hidden
  46153. */
  46154. export class _KTXTextureLoader implements IInternalTextureLoader {
  46155. /**
  46156. * Defines wether the loader supports cascade loading the different faces.
  46157. */
  46158. readonly supportCascades: boolean;
  46159. /**
  46160. * This returns if the loader support the current file information.
  46161. * @param extension defines the file extension of the file being loaded
  46162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46163. * @param fallback defines the fallback internal texture if any
  46164. * @param isBase64 defines whether the texture is encoded as a base64
  46165. * @param isBuffer defines whether the texture data are stored as a buffer
  46166. * @returns true if the loader can load the specified file
  46167. */
  46168. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46169. /**
  46170. * Transform the url before loading if required.
  46171. * @param rootUrl the url of the texture
  46172. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46173. * @returns the transformed texture
  46174. */
  46175. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46176. /**
  46177. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46178. * @param rootUrl the url of the texture
  46179. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46180. * @returns the fallback texture
  46181. */
  46182. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46183. /**
  46184. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46185. * @param data contains the texture data
  46186. * @param texture defines the BabylonJS internal texture
  46187. * @param createPolynomials will be true if polynomials have been requested
  46188. * @param onLoad defines the callback to trigger once the texture is ready
  46189. * @param onError defines the callback to trigger in case of error
  46190. */
  46191. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46192. /**
  46193. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46194. * @param data contains the texture data
  46195. * @param texture defines the BabylonJS internal texture
  46196. * @param callback defines the method to call once ready to upload
  46197. */
  46198. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  46199. }
  46200. }
  46201. declare module BABYLON {
  46202. /**
  46203. * Based on jsTGALoader - Javascript loader for TGA file
  46204. * By Vincent Thibault
  46205. * @see http://blog.robrowser.com/javascript-tga-loader.html
  46206. */
  46207. export class TGATools {
  46208. private static _TYPE_INDEXED;
  46209. private static _TYPE_RGB;
  46210. private static _TYPE_GREY;
  46211. private static _TYPE_RLE_INDEXED;
  46212. private static _TYPE_RLE_RGB;
  46213. private static _TYPE_RLE_GREY;
  46214. private static _ORIGIN_MASK;
  46215. private static _ORIGIN_SHIFT;
  46216. private static _ORIGIN_BL;
  46217. private static _ORIGIN_BR;
  46218. private static _ORIGIN_UL;
  46219. private static _ORIGIN_UR;
  46220. /**
  46221. * Gets the header of a TGA file
  46222. * @param data defines the TGA data
  46223. * @returns the header
  46224. */
  46225. static GetTGAHeader(data: Uint8Array): any;
  46226. /**
  46227. * Uploads TGA content to a Babylon Texture
  46228. * @hidden
  46229. */
  46230. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  46231. /** @hidden */
  46232. 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;
  46233. /** @hidden */
  46234. 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;
  46235. /** @hidden */
  46236. 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;
  46237. /** @hidden */
  46238. 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;
  46239. /** @hidden */
  46240. 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;
  46241. /** @hidden */
  46242. 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;
  46243. }
  46244. }
  46245. declare module BABYLON {
  46246. /**
  46247. * Implementation of the TGA Texture Loader.
  46248. * @hidden
  46249. */
  46250. export class _TGATextureLoader implements IInternalTextureLoader {
  46251. /**
  46252. * Defines wether the loader supports cascade loading the different faces.
  46253. */
  46254. readonly supportCascades: boolean;
  46255. /**
  46256. * This returns if the loader support the current file information.
  46257. * @param extension defines the file extension of the file being loaded
  46258. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46259. * @param fallback defines the fallback internal texture if any
  46260. * @param isBase64 defines whether the texture is encoded as a base64
  46261. * @param isBuffer defines whether the texture data are stored as a buffer
  46262. * @returns true if the loader can load the specified file
  46263. */
  46264. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46265. /**
  46266. * Transform the url before loading if required.
  46267. * @param rootUrl the url of the texture
  46268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46269. * @returns the transformed texture
  46270. */
  46271. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46272. /**
  46273. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46274. * @param rootUrl the url of the texture
  46275. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46276. * @returns the fallback texture
  46277. */
  46278. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46279. /**
  46280. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46281. * @param data contains the texture data
  46282. * @param texture defines the BabylonJS internal texture
  46283. * @param createPolynomials will be true if polynomials have been requested
  46284. * @param onLoad defines the callback to trigger once the texture is ready
  46285. * @param onError defines the callback to trigger in case of error
  46286. */
  46287. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46288. /**
  46289. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46290. * @param data contains the texture data
  46291. * @param texture defines the BabylonJS internal texture
  46292. * @param callback defines the method to call once ready to upload
  46293. */
  46294. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46295. }
  46296. }
  46297. declare module BABYLON {
  46298. /**
  46299. * 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.
  46300. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46301. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46302. */
  46303. export class CustomProceduralTexture extends ProceduralTexture {
  46304. private _animate;
  46305. private _time;
  46306. private _config;
  46307. private _texturePath;
  46308. /**
  46309. * Instantiates a new Custom Procedural Texture.
  46310. * 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.
  46311. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  46312. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  46313. * @param name Define the name of the texture
  46314. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  46315. * @param size Define the size of the texture to create
  46316. * @param scene Define the scene the texture belongs to
  46317. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  46318. * @param generateMipMaps Define if the texture should creates mip maps or not
  46319. */
  46320. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46321. private _loadJson;
  46322. /**
  46323. * Is the texture ready to be used ? (rendered at least once)
  46324. * @returns true if ready, otherwise, false.
  46325. */
  46326. isReady(): boolean;
  46327. /**
  46328. * Render the texture to its associated render target.
  46329. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  46330. */
  46331. render(useCameraPostProcess?: boolean): void;
  46332. /**
  46333. * Update the list of dependant textures samplers in the shader.
  46334. */
  46335. updateTextures(): void;
  46336. /**
  46337. * Update the uniform values of the procedural texture in the shader.
  46338. */
  46339. updateShaderUniforms(): void;
  46340. /**
  46341. * Define if the texture animates or not.
  46342. */
  46343. animate: boolean;
  46344. }
  46345. }
  46346. declare module BABYLON {
  46347. /** @hidden */
  46348. export var noisePixelShader: {
  46349. name: string;
  46350. shader: string;
  46351. };
  46352. }
  46353. declare module BABYLON {
  46354. /**
  46355. * Class used to generate noise procedural textures
  46356. */
  46357. export class NoiseProceduralTexture extends ProceduralTexture {
  46358. private _time;
  46359. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  46360. brightness: number;
  46361. /** Defines the number of octaves to process */
  46362. octaves: number;
  46363. /** Defines the level of persistence (0.8 by default) */
  46364. persistence: number;
  46365. /** Gets or sets animation speed factor (default is 1) */
  46366. animationSpeedFactor: number;
  46367. /**
  46368. * Creates a new NoiseProceduralTexture
  46369. * @param name defines the name fo the texture
  46370. * @param size defines the size of the texture (default is 256)
  46371. * @param scene defines the hosting scene
  46372. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  46373. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  46374. */
  46375. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  46376. private _updateShaderUniforms;
  46377. protected _getDefines(): string;
  46378. /** Generate the current state of the procedural texture */
  46379. render(useCameraPostProcess?: boolean): void;
  46380. /**
  46381. * Serializes this noise procedural texture
  46382. * @returns a serialized noise procedural texture object
  46383. */
  46384. serialize(): any;
  46385. /**
  46386. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  46387. * @param parsedTexture defines parsed texture data
  46388. * @param scene defines the current scene
  46389. * @param rootUrl defines the root URL containing noise procedural texture information
  46390. * @returns a parsed NoiseProceduralTexture
  46391. */
  46392. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  46393. }
  46394. }
  46395. declare module BABYLON {
  46396. /**
  46397. * Raw cube texture where the raw buffers are passed in
  46398. */
  46399. export class RawCubeTexture extends CubeTexture {
  46400. /**
  46401. * Creates a cube texture where the raw buffers are passed in.
  46402. * @param scene defines the scene the texture is attached to
  46403. * @param data defines the array of data to use to create each face
  46404. * @param size defines the size of the textures
  46405. * @param format defines the format of the data
  46406. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  46407. * @param generateMipMaps defines if the engine should generate the mip levels
  46408. * @param invertY defines if data must be stored with Y axis inverted
  46409. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  46410. * @param compression defines the compression used (null by default)
  46411. */
  46412. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  46413. /**
  46414. * Updates the raw cube texture.
  46415. * @param data defines the data to store
  46416. * @param format defines the data format
  46417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  46418. * @param invertY defines if data must be stored with Y axis inverted
  46419. * @param compression defines the compression used (null by default)
  46420. * @param level defines which level of the texture to update
  46421. */
  46422. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  46423. /**
  46424. * Updates a raw cube texture with RGBD encoded data.
  46425. * @param data defines the array of data [mipmap][face] to use to create each face
  46426. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  46427. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46428. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46429. * @returns a promsie that resolves when the operation is complete
  46430. */
  46431. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  46432. /**
  46433. * Clones the raw cube texture.
  46434. * @return a new cube texture
  46435. */
  46436. clone(): CubeTexture;
  46437. /** @hidden */
  46438. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46439. }
  46440. }
  46441. declare module BABYLON {
  46442. /**
  46443. * Class used to store 3D textures containing user data
  46444. */
  46445. export class RawTexture3D extends Texture {
  46446. /** Gets or sets the texture format to use */
  46447. format: number;
  46448. private _engine;
  46449. /**
  46450. * Create a new RawTexture3D
  46451. * @param data defines the data of the texture
  46452. * @param width defines the width of the texture
  46453. * @param height defines the height of the texture
  46454. * @param depth defines the depth of the texture
  46455. * @param format defines the texture format to use
  46456. * @param scene defines the hosting scene
  46457. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  46458. * @param invertY defines if texture must be stored with Y axis inverted
  46459. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  46460. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  46461. */
  46462. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  46463. /** Gets or sets the texture format to use */
  46464. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  46465. /**
  46466. * Update the texture with new data
  46467. * @param data defines the data to store in the texture
  46468. */
  46469. update(data: ArrayBufferView): void;
  46470. }
  46471. }
  46472. declare module BABYLON {
  46473. /**
  46474. * Creates a refraction texture used by refraction channel of the standard material.
  46475. * It is like a mirror but to see through a material.
  46476. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46477. */
  46478. export class RefractionTexture extends RenderTargetTexture {
  46479. /**
  46480. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  46481. * 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.
  46482. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46483. */
  46484. refractionPlane: Plane;
  46485. /**
  46486. * Define how deep under the surface we should see.
  46487. */
  46488. depth: number;
  46489. /**
  46490. * Creates a refraction texture used by refraction channel of the standard material.
  46491. * It is like a mirror but to see through a material.
  46492. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  46493. * @param name Define the texture name
  46494. * @param size Define the size of the underlying texture
  46495. * @param scene Define the scene the refraction belongs to
  46496. * @param generateMipMaps Define if we need to generate mips level for the refraction
  46497. */
  46498. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  46499. /**
  46500. * Clone the refraction texture.
  46501. * @returns the cloned texture
  46502. */
  46503. clone(): RefractionTexture;
  46504. /**
  46505. * Serialize the texture to a JSON representation you could use in Parse later on
  46506. * @returns the serialized JSON representation
  46507. */
  46508. serialize(): any;
  46509. }
  46510. }
  46511. declare module BABYLON {
  46512. /**
  46513. * Configuration for Draco compression
  46514. */
  46515. export interface IDracoCompressionConfiguration {
  46516. /**
  46517. * Configuration for the decoder.
  46518. */
  46519. decoder?: {
  46520. /**
  46521. * The url to the WebAssembly module.
  46522. */
  46523. wasmUrl?: string;
  46524. /**
  46525. * The url to the WebAssembly binary.
  46526. */
  46527. wasmBinaryUrl?: string;
  46528. /**
  46529. * The url to the fallback JavaScript module.
  46530. */
  46531. fallbackUrl?: string;
  46532. };
  46533. }
  46534. /**
  46535. * Draco compression (https://google.github.io/draco/)
  46536. *
  46537. * This class wraps the Draco module.
  46538. *
  46539. * **Encoder**
  46540. *
  46541. * The encoder is not currently implemented.
  46542. *
  46543. * **Decoder**
  46544. *
  46545. * 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.
  46546. *
  46547. * To update the configuration, use the following code:
  46548. * ```javascript
  46549. * DracoCompression.Configuration = {
  46550. * decoder: {
  46551. * wasmUrl: "<url to the WebAssembly library>",
  46552. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  46553. * fallbackUrl: "<url to the fallback JavaScript library>",
  46554. * }
  46555. * };
  46556. * ```
  46557. *
  46558. * 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.
  46559. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  46560. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  46561. *
  46562. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  46563. * ```javascript
  46564. * var dracoCompression = new DracoCompression();
  46565. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  46566. * [VertexBuffer.PositionKind]: 0
  46567. * });
  46568. * ```
  46569. *
  46570. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  46571. */
  46572. export class DracoCompression implements IDisposable {
  46573. private static _DecoderModulePromise;
  46574. /**
  46575. * The configuration. Defaults to the following urls:
  46576. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  46577. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  46578. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  46579. */
  46580. static Configuration: IDracoCompressionConfiguration;
  46581. /**
  46582. * Returns true if the decoder is available.
  46583. */
  46584. static readonly DecoderAvailable: boolean;
  46585. /**
  46586. * Constructor
  46587. */
  46588. constructor();
  46589. /**
  46590. * Stop all async operations and release resources.
  46591. */
  46592. dispose(): void;
  46593. /**
  46594. * Decode Draco compressed mesh data to vertex data.
  46595. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  46596. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  46597. * @returns A promise that resolves with the decoded vertex data
  46598. */
  46599. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  46600. [kind: string]: number;
  46601. }): Promise<VertexData>;
  46602. private static _GetDecoderModule;
  46603. private static _LoadScriptAsync;
  46604. private static _LoadFileAsync;
  46605. }
  46606. }
  46607. declare module BABYLON {
  46608. /**
  46609. * Class for building Constructive Solid Geometry
  46610. */
  46611. export class CSG {
  46612. private polygons;
  46613. /**
  46614. * The world matrix
  46615. */
  46616. matrix: Matrix;
  46617. /**
  46618. * Stores the position
  46619. */
  46620. position: Vector3;
  46621. /**
  46622. * Stores the rotation
  46623. */
  46624. rotation: Vector3;
  46625. /**
  46626. * Stores the rotation quaternion
  46627. */
  46628. rotationQuaternion: Nullable<Quaternion>;
  46629. /**
  46630. * Stores the scaling vector
  46631. */
  46632. scaling: Vector3;
  46633. /**
  46634. * Convert the Mesh to CSG
  46635. * @param mesh The Mesh to convert to CSG
  46636. * @returns A new CSG from the Mesh
  46637. */
  46638. static FromMesh(mesh: Mesh): CSG;
  46639. /**
  46640. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  46641. * @param polygons Polygons used to construct a CSG solid
  46642. */
  46643. private static FromPolygons;
  46644. /**
  46645. * Clones, or makes a deep copy, of the CSG
  46646. * @returns A new CSG
  46647. */
  46648. clone(): CSG;
  46649. /**
  46650. * Unions this CSG with another CSG
  46651. * @param csg The CSG to union against this CSG
  46652. * @returns The unioned CSG
  46653. */
  46654. union(csg: CSG): CSG;
  46655. /**
  46656. * Unions this CSG with another CSG in place
  46657. * @param csg The CSG to union against this CSG
  46658. */
  46659. unionInPlace(csg: CSG): void;
  46660. /**
  46661. * Subtracts this CSG with another CSG
  46662. * @param csg The CSG to subtract against this CSG
  46663. * @returns A new CSG
  46664. */
  46665. subtract(csg: CSG): CSG;
  46666. /**
  46667. * Subtracts this CSG with another CSG in place
  46668. * @param csg The CSG to subtact against this CSG
  46669. */
  46670. subtractInPlace(csg: CSG): void;
  46671. /**
  46672. * Intersect this CSG with another CSG
  46673. * @param csg The CSG to intersect against this CSG
  46674. * @returns A new CSG
  46675. */
  46676. intersect(csg: CSG): CSG;
  46677. /**
  46678. * Intersects this CSG with another CSG in place
  46679. * @param csg The CSG to intersect against this CSG
  46680. */
  46681. intersectInPlace(csg: CSG): void;
  46682. /**
  46683. * Return a new CSG solid with solid and empty space switched. This solid is
  46684. * not modified.
  46685. * @returns A new CSG solid with solid and empty space switched
  46686. */
  46687. inverse(): CSG;
  46688. /**
  46689. * Inverses the CSG in place
  46690. */
  46691. inverseInPlace(): void;
  46692. /**
  46693. * This is used to keep meshes transformations so they can be restored
  46694. * when we build back a Babylon Mesh
  46695. * NB : All CSG operations are performed in world coordinates
  46696. * @param csg The CSG to copy the transform attributes from
  46697. * @returns This CSG
  46698. */
  46699. copyTransformAttributes(csg: CSG): CSG;
  46700. /**
  46701. * Build Raw mesh from CSG
  46702. * Coordinates here are in world space
  46703. * @param name The name of the mesh geometry
  46704. * @param scene The Scene
  46705. * @param keepSubMeshes Specifies if the submeshes should be kept
  46706. * @returns A new Mesh
  46707. */
  46708. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  46709. /**
  46710. * Build Mesh from CSG taking material and transforms into account
  46711. * @param name The name of the Mesh
  46712. * @param material The material of the Mesh
  46713. * @param scene The Scene
  46714. * @param keepSubMeshes Specifies if submeshes should be kept
  46715. * @returns The new Mesh
  46716. */
  46717. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  46718. }
  46719. }
  46720. declare module BABYLON {
  46721. /**
  46722. * Class containing static functions to help procedurally build meshes
  46723. */
  46724. export class RibbonBuilder {
  46725. /**
  46726. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  46727. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  46728. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  46729. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  46730. * * 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
  46731. * * 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
  46732. * * 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
  46733. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46734. * * 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
  46735. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46736. * * 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
  46737. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  46738. * * 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
  46739. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  46740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46741. * @param name defines the name of the mesh
  46742. * @param options defines the options used to create the mesh
  46743. * @param scene defines the hosting scene
  46744. * @returns the ribbon mesh
  46745. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  46746. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46747. */
  46748. static CreateRibbon(name: string, options: {
  46749. pathArray: Vector3[][];
  46750. closeArray?: boolean;
  46751. closePath?: boolean;
  46752. offset?: number;
  46753. updatable?: boolean;
  46754. sideOrientation?: number;
  46755. frontUVs?: Vector4;
  46756. backUVs?: Vector4;
  46757. instance?: Mesh;
  46758. invertUV?: boolean;
  46759. uvs?: Vector2[];
  46760. colors?: Color4[];
  46761. }, scene?: Nullable<Scene>): Mesh;
  46762. }
  46763. }
  46764. declare module BABYLON {
  46765. /**
  46766. * Class containing static functions to help procedurally build meshes
  46767. */
  46768. export class TorusKnotBuilder {
  46769. /**
  46770. * Creates a torus knot mesh
  46771. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  46772. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  46773. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  46774. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  46775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46776. * * 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
  46777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46778. * @param name defines the name of the mesh
  46779. * @param options defines the options used to create the mesh
  46780. * @param scene defines the hosting scene
  46781. * @returns the torus knot mesh
  46782. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  46783. */
  46784. static CreateTorusKnot(name: string, options: {
  46785. radius?: number;
  46786. tube?: number;
  46787. radialSegments?: number;
  46788. tubularSegments?: number;
  46789. p?: number;
  46790. q?: number;
  46791. updatable?: boolean;
  46792. sideOrientation?: number;
  46793. frontUVs?: Vector4;
  46794. backUVs?: Vector4;
  46795. }, scene: any): Mesh;
  46796. }
  46797. }
  46798. declare module BABYLON {
  46799. /**
  46800. * Polygon
  46801. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  46802. */
  46803. export class Polygon {
  46804. /**
  46805. * Creates a rectangle
  46806. * @param xmin bottom X coord
  46807. * @param ymin bottom Y coord
  46808. * @param xmax top X coord
  46809. * @param ymax top Y coord
  46810. * @returns points that make the resulting rectation
  46811. */
  46812. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  46813. /**
  46814. * Creates a circle
  46815. * @param radius radius of circle
  46816. * @param cx scale in x
  46817. * @param cy scale in y
  46818. * @param numberOfSides number of sides that make up the circle
  46819. * @returns points that make the resulting circle
  46820. */
  46821. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  46822. /**
  46823. * Creates a polygon from input string
  46824. * @param input Input polygon data
  46825. * @returns the parsed points
  46826. */
  46827. static Parse(input: string): Vector2[];
  46828. /**
  46829. * Starts building a polygon from x and y coordinates
  46830. * @param x x coordinate
  46831. * @param y y coordinate
  46832. * @returns the started path2
  46833. */
  46834. static StartingAt(x: number, y: number): Path2;
  46835. }
  46836. /**
  46837. * Builds a polygon
  46838. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  46839. */
  46840. export class PolygonMeshBuilder {
  46841. private _points;
  46842. private _outlinepoints;
  46843. private _holes;
  46844. private _name;
  46845. private _scene;
  46846. private _epoints;
  46847. private _eholes;
  46848. private _addToepoint;
  46849. /**
  46850. * Babylon reference to the earcut plugin.
  46851. */
  46852. bjsEarcut: any;
  46853. /**
  46854. * Creates a PolygonMeshBuilder
  46855. * @param name name of the builder
  46856. * @param contours Path of the polygon
  46857. * @param scene scene to add to
  46858. * @param earcutInjection can be used to inject your own earcut reference
  46859. */
  46860. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  46861. /**
  46862. * Adds a whole within the polygon
  46863. * @param hole Array of points defining the hole
  46864. * @returns this
  46865. */
  46866. addHole(hole: Vector2[]): PolygonMeshBuilder;
  46867. /**
  46868. * Creates the polygon
  46869. * @param updatable If the mesh should be updatable
  46870. * @param depth The depth of the mesh created
  46871. * @returns the created mesh
  46872. */
  46873. build(updatable?: boolean, depth?: number): Mesh;
  46874. /**
  46875. * Adds a side to the polygon
  46876. * @param positions points that make the polygon
  46877. * @param normals normals of the polygon
  46878. * @param uvs uvs of the polygon
  46879. * @param indices indices of the polygon
  46880. * @param bounds bounds of the polygon
  46881. * @param points points of the polygon
  46882. * @param depth depth of the polygon
  46883. * @param flip flip of the polygon
  46884. */
  46885. private addSide;
  46886. }
  46887. }
  46888. declare module BABYLON {
  46889. /**
  46890. * Class containing static functions to help procedurally build meshes
  46891. */
  46892. export class PolygonBuilder {
  46893. /**
  46894. * Creates a polygon mesh
  46895. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  46896. * * 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
  46897. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  46898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46899. * * 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)
  46900. * * Remember you can only change the shape positions, not their number when updating a polygon
  46901. * @param name defines the name of the mesh
  46902. * @param options defines the options used to create the mesh
  46903. * @param scene defines the hosting scene
  46904. * @param earcutInjection can be used to inject your own earcut reference
  46905. * @returns the polygon mesh
  46906. */
  46907. static CreatePolygon(name: string, options: {
  46908. shape: Vector3[];
  46909. holes?: Vector3[][];
  46910. depth?: number;
  46911. faceUV?: Vector4[];
  46912. faceColors?: Color4[];
  46913. updatable?: boolean;
  46914. sideOrientation?: number;
  46915. frontUVs?: Vector4;
  46916. backUVs?: Vector4;
  46917. }, scene: Scene, earcutInjection?: any): Mesh;
  46918. /**
  46919. * Creates an extruded polygon mesh, with depth in the Y direction.
  46920. * * 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)
  46921. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46922. * @param name defines the name of the mesh
  46923. * @param options defines the options used to create the mesh
  46924. * @param scene defines the hosting scene
  46925. * @param earcutInjection can be used to inject your own earcut reference
  46926. * @returns the polygon mesh
  46927. */
  46928. static ExtrudePolygon(name: string, options: {
  46929. shape: Vector3[];
  46930. holes?: Vector3[][];
  46931. depth?: number;
  46932. faceUV?: Vector4[];
  46933. faceColors?: Color4[];
  46934. updatable?: boolean;
  46935. sideOrientation?: number;
  46936. frontUVs?: Vector4;
  46937. backUVs?: Vector4;
  46938. }, scene: Scene, earcutInjection?: any): Mesh;
  46939. }
  46940. }
  46941. declare module BABYLON {
  46942. /**
  46943. * Class containing static functions to help procedurally build meshes
  46944. */
  46945. export class ShapeBuilder {
  46946. /**
  46947. * 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.
  46948. * * 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.
  46949. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46950. * * 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.
  46951. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  46952. * * 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
  46953. * * 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
  46954. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  46955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46956. * * 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
  46957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  46958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46959. * @param name defines the name of the mesh
  46960. * @param options defines the options used to create the mesh
  46961. * @param scene defines the hosting scene
  46962. * @returns the extruded shape mesh
  46963. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  46964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  46965. */
  46966. static ExtrudeShape(name: string, options: {
  46967. shape: Vector3[];
  46968. path: Vector3[];
  46969. scale?: number;
  46970. rotation?: number;
  46971. cap?: number;
  46972. updatable?: boolean;
  46973. sideOrientation?: number;
  46974. frontUVs?: Vector4;
  46975. backUVs?: Vector4;
  46976. instance?: Mesh;
  46977. invertUV?: boolean;
  46978. }, scene?: Nullable<Scene>): Mesh;
  46979. /**
  46980. * Creates an custom extruded shape mesh.
  46981. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  46982. * * 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.
  46983. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  46984. * * 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
  46985. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  46986. * * 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
  46987. * * It must returns a float value that will be the scale value applied to the shape on each path point
  46988. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  46989. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  46990. * * 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
  46991. * * 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
  46992. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  46993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46994. * * 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
  46995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  46996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46997. * @param name defines the name of the mesh
  46998. * @param options defines the options used to create the mesh
  46999. * @param scene defines the hosting scene
  47000. * @returns the custom extruded shape mesh
  47001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47004. */
  47005. static ExtrudeShapeCustom(name: string, options: {
  47006. shape: Vector3[];
  47007. path: Vector3[];
  47008. scaleFunction?: any;
  47009. rotationFunction?: any;
  47010. ribbonCloseArray?: boolean;
  47011. ribbonClosePath?: boolean;
  47012. cap?: number;
  47013. updatable?: boolean;
  47014. sideOrientation?: number;
  47015. frontUVs?: Vector4;
  47016. backUVs?: Vector4;
  47017. instance?: Mesh;
  47018. invertUV?: boolean;
  47019. }, scene: Scene): Mesh;
  47020. private static _ExtrudeShapeGeneric;
  47021. }
  47022. }
  47023. declare module BABYLON {
  47024. /**
  47025. * Class containing static functions to help procedurally build meshes
  47026. */
  47027. export class LatheBuilder {
  47028. /**
  47029. * Creates lathe mesh.
  47030. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  47031. * * 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
  47032. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  47033. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  47034. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  47035. * * 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
  47036. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  47037. * * 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
  47038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47039. * * 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
  47040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47042. * @param name defines the name of the mesh
  47043. * @param options defines the options used to create the mesh
  47044. * @param scene defines the hosting scene
  47045. * @returns the lathe mesh
  47046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  47047. */
  47048. static CreateLathe(name: string, options: {
  47049. shape: Vector3[];
  47050. radius?: number;
  47051. tessellation?: number;
  47052. clip?: number;
  47053. arc?: number;
  47054. closed?: boolean;
  47055. updatable?: boolean;
  47056. sideOrientation?: number;
  47057. frontUVs?: Vector4;
  47058. backUVs?: Vector4;
  47059. cap?: number;
  47060. invertUV?: boolean;
  47061. }, scene: Scene): Mesh;
  47062. }
  47063. }
  47064. declare module BABYLON {
  47065. /**
  47066. * Class containing static functions to help procedurally build meshes
  47067. */
  47068. export class TubeBuilder {
  47069. /**
  47070. * Creates a tube mesh.
  47071. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47072. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47073. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47074. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47075. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47076. * * 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)
  47077. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47078. * * 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
  47079. * * 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
  47080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47081. * * 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
  47082. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47084. * @param name defines the name of the mesh
  47085. * @param options defines the options used to create the mesh
  47086. * @param scene defines the hosting scene
  47087. * @returns the tube mesh
  47088. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47089. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47090. */
  47091. static CreateTube(name: string, options: {
  47092. path: Vector3[];
  47093. radius?: number;
  47094. tessellation?: number;
  47095. radiusFunction?: {
  47096. (i: number, distance: number): number;
  47097. };
  47098. cap?: number;
  47099. arc?: number;
  47100. updatable?: boolean;
  47101. sideOrientation?: number;
  47102. frontUVs?: Vector4;
  47103. backUVs?: Vector4;
  47104. instance?: Mesh;
  47105. invertUV?: boolean;
  47106. }, scene: Scene): Mesh;
  47107. }
  47108. }
  47109. declare module BABYLON {
  47110. /**
  47111. * Class containing static functions to help procedurally build meshes
  47112. */
  47113. export class IcoSphereBuilder {
  47114. /**
  47115. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47116. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47117. * * 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`)
  47118. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47119. * * 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
  47120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47121. * * 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
  47122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47123. * @param name defines the name of the mesh
  47124. * @param options defines the options used to create the mesh
  47125. * @param scene defines the hosting scene
  47126. * @returns the icosahedron mesh
  47127. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47128. */
  47129. static CreateIcoSphere(name: string, options: {
  47130. radius?: number;
  47131. radiusX?: number;
  47132. radiusY?: number;
  47133. radiusZ?: number;
  47134. flat?: boolean;
  47135. subdivisions?: number;
  47136. sideOrientation?: number;
  47137. frontUVs?: Vector4;
  47138. backUVs?: Vector4;
  47139. updatable?: boolean;
  47140. }, scene: Scene): Mesh;
  47141. }
  47142. }
  47143. declare module BABYLON {
  47144. /**
  47145. * Class containing static functions to help procedurally build meshes
  47146. */
  47147. export class DecalBuilder {
  47148. /**
  47149. * Creates a decal mesh.
  47150. * 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
  47151. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47152. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47153. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47154. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47155. * @param name defines the name of the mesh
  47156. * @param sourceMesh defines the mesh where the decal must be applied
  47157. * @param options defines the options used to create the mesh
  47158. * @param scene defines the hosting scene
  47159. * @returns the decal mesh
  47160. * @see https://doc.babylonjs.com/how_to/decals
  47161. */
  47162. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47163. position?: Vector3;
  47164. normal?: Vector3;
  47165. size?: Vector3;
  47166. angle?: number;
  47167. }): Mesh;
  47168. }
  47169. }
  47170. declare module BABYLON {
  47171. /**
  47172. * Class containing static functions to help procedurally build meshes
  47173. */
  47174. export class MeshBuilder {
  47175. /**
  47176. * Creates a box mesh
  47177. * * The parameter `size` sets the size (float) of each box side (default 1)
  47178. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47179. * * 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)
  47180. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47182. * * 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
  47183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47184. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47185. * @param name defines the name of the mesh
  47186. * @param options defines the options used to create the mesh
  47187. * @param scene defines the hosting scene
  47188. * @returns the box mesh
  47189. */
  47190. static CreateBox(name: string, options: {
  47191. size?: number;
  47192. width?: number;
  47193. height?: number;
  47194. depth?: number;
  47195. faceUV?: Vector4[];
  47196. faceColors?: Color4[];
  47197. sideOrientation?: number;
  47198. frontUVs?: Vector4;
  47199. backUVs?: Vector4;
  47200. updatable?: boolean;
  47201. }, scene?: Nullable<Scene>): Mesh;
  47202. /**
  47203. * Creates a sphere mesh
  47204. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47205. * * 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`)
  47206. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47207. * * 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
  47208. * * 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)
  47209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47210. * * 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
  47211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47212. * @param name defines the name of the mesh
  47213. * @param options defines the options used to create the mesh
  47214. * @param scene defines the hosting scene
  47215. * @returns the sphere mesh
  47216. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47217. */
  47218. static CreateSphere(name: string, options: {
  47219. segments?: number;
  47220. diameter?: number;
  47221. diameterX?: number;
  47222. diameterY?: number;
  47223. diameterZ?: number;
  47224. arc?: number;
  47225. slice?: number;
  47226. sideOrientation?: number;
  47227. frontUVs?: Vector4;
  47228. backUVs?: Vector4;
  47229. updatable?: boolean;
  47230. }, scene: any): Mesh;
  47231. /**
  47232. * Creates a plane polygonal mesh. By default, this is a disc
  47233. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  47234. * * 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
  47235. * * 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
  47236. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47237. * * 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
  47238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47239. * @param name defines the name of the mesh
  47240. * @param options defines the options used to create the mesh
  47241. * @param scene defines the hosting scene
  47242. * @returns the plane polygonal mesh
  47243. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  47244. */
  47245. static CreateDisc(name: string, options: {
  47246. radius?: number;
  47247. tessellation?: number;
  47248. arc?: number;
  47249. updatable?: boolean;
  47250. sideOrientation?: number;
  47251. frontUVs?: Vector4;
  47252. backUVs?: Vector4;
  47253. }, scene?: Nullable<Scene>): Mesh;
  47254. /**
  47255. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  47256. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  47257. * * 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`)
  47258. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  47259. * * 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
  47260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47263. * @param name defines the name of the mesh
  47264. * @param options defines the options used to create the mesh
  47265. * @param scene defines the hosting scene
  47266. * @returns the icosahedron mesh
  47267. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  47268. */
  47269. static CreateIcoSphere(name: string, options: {
  47270. radius?: number;
  47271. radiusX?: number;
  47272. radiusY?: number;
  47273. radiusZ?: number;
  47274. flat?: boolean;
  47275. subdivisions?: number;
  47276. sideOrientation?: number;
  47277. frontUVs?: Vector4;
  47278. backUVs?: Vector4;
  47279. updatable?: boolean;
  47280. }, scene: Scene): Mesh;
  47281. /**
  47282. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47283. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47284. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47285. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47286. * * 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
  47287. * * 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
  47288. * * 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
  47289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47290. * * 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
  47291. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47292. * * 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
  47293. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47294. * * 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
  47295. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47297. * @param name defines the name of the mesh
  47298. * @param options defines the options used to create the mesh
  47299. * @param scene defines the hosting scene
  47300. * @returns the ribbon mesh
  47301. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47302. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47303. */
  47304. static CreateRibbon(name: string, options: {
  47305. pathArray: Vector3[][];
  47306. closeArray?: boolean;
  47307. closePath?: boolean;
  47308. offset?: number;
  47309. updatable?: boolean;
  47310. sideOrientation?: number;
  47311. frontUVs?: Vector4;
  47312. backUVs?: Vector4;
  47313. instance?: Mesh;
  47314. invertUV?: boolean;
  47315. uvs?: Vector2[];
  47316. colors?: Color4[];
  47317. }, scene?: Nullable<Scene>): Mesh;
  47318. /**
  47319. * Creates a cylinder or a cone mesh
  47320. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47321. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47322. * * 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.
  47323. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47324. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47325. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47326. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47327. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47328. * * 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).
  47329. * * 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
  47330. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47331. * * 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
  47332. * * 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.
  47333. * * If `enclose` is false, a ring surface is one element.
  47334. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47335. * * 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
  47336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47337. * * 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
  47338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47339. * @param name defines the name of the mesh
  47340. * @param options defines the options used to create the mesh
  47341. * @param scene defines the hosting scene
  47342. * @returns the cylinder mesh
  47343. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47344. */
  47345. static CreateCylinder(name: string, options: {
  47346. height?: number;
  47347. diameterTop?: number;
  47348. diameterBottom?: number;
  47349. diameter?: number;
  47350. tessellation?: number;
  47351. subdivisions?: number;
  47352. arc?: number;
  47353. faceColors?: Color4[];
  47354. faceUV?: Vector4[];
  47355. updatable?: boolean;
  47356. hasRings?: boolean;
  47357. enclose?: boolean;
  47358. sideOrientation?: number;
  47359. frontUVs?: Vector4;
  47360. backUVs?: Vector4;
  47361. }, scene: any): Mesh;
  47362. /**
  47363. * Creates a torus mesh
  47364. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47365. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47366. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47368. * * 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
  47369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47370. * @param name defines the name of the mesh
  47371. * @param options defines the options used to create the mesh
  47372. * @param scene defines the hosting scene
  47373. * @returns the torus mesh
  47374. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47375. */
  47376. static CreateTorus(name: string, options: {
  47377. diameter?: number;
  47378. thickness?: number;
  47379. tessellation?: number;
  47380. updatable?: boolean;
  47381. sideOrientation?: number;
  47382. frontUVs?: Vector4;
  47383. backUVs?: Vector4;
  47384. }, scene: any): Mesh;
  47385. /**
  47386. * Creates a torus knot mesh
  47387. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  47388. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  47389. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  47390. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  47391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47392. * * 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
  47393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47394. * @param name defines the name of the mesh
  47395. * @param options defines the options used to create the mesh
  47396. * @param scene defines the hosting scene
  47397. * @returns the torus knot mesh
  47398. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  47399. */
  47400. static CreateTorusKnot(name: string, options: {
  47401. radius?: number;
  47402. tube?: number;
  47403. radialSegments?: number;
  47404. tubularSegments?: number;
  47405. p?: number;
  47406. q?: number;
  47407. updatable?: boolean;
  47408. sideOrientation?: number;
  47409. frontUVs?: Vector4;
  47410. backUVs?: Vector4;
  47411. }, scene: any): Mesh;
  47412. /**
  47413. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47414. * * 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
  47415. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47416. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47417. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47418. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47419. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47420. * * 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
  47421. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47423. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47424. * @param name defines the name of the new line system
  47425. * @param options defines the options used to create the line system
  47426. * @param scene defines the hosting scene
  47427. * @returns a new line system mesh
  47428. */
  47429. static CreateLineSystem(name: string, options: {
  47430. lines: Vector3[][];
  47431. updatable?: boolean;
  47432. instance?: Nullable<LinesMesh>;
  47433. colors?: Nullable<Color4[][]>;
  47434. useVertexAlpha?: boolean;
  47435. }, scene: Nullable<Scene>): LinesMesh;
  47436. /**
  47437. * Creates a line mesh
  47438. * 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
  47439. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47440. * * The parameter `points` is an array successive Vector3
  47441. * * 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
  47442. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47443. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47444. * * When updating an instance, remember that only point positions can change, not the number of points
  47445. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47446. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47447. * @param name defines the name of the new line system
  47448. * @param options defines the options used to create the line system
  47449. * @param scene defines the hosting scene
  47450. * @returns a new line mesh
  47451. */
  47452. static CreateLines(name: string, options: {
  47453. points: Vector3[];
  47454. updatable?: boolean;
  47455. instance?: Nullable<LinesMesh>;
  47456. colors?: Color4[];
  47457. useVertexAlpha?: boolean;
  47458. }, scene?: Nullable<Scene>): LinesMesh;
  47459. /**
  47460. * Creates a dashed line mesh
  47461. * * 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
  47462. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47463. * * The parameter `points` is an array successive Vector3
  47464. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47465. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47466. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47467. * * 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
  47468. * * When updating an instance, remember that only point positions can change, not the number of points
  47469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47470. * @param name defines the name of the mesh
  47471. * @param options defines the options used to create the mesh
  47472. * @param scene defines the hosting scene
  47473. * @returns the dashed line mesh
  47474. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47475. */
  47476. static CreateDashedLines(name: string, options: {
  47477. points: Vector3[];
  47478. dashSize?: number;
  47479. gapSize?: number;
  47480. dashNb?: number;
  47481. updatable?: boolean;
  47482. instance?: LinesMesh;
  47483. }, scene?: Nullable<Scene>): LinesMesh;
  47484. /**
  47485. * 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.
  47486. * * 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.
  47487. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47488. * * 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.
  47489. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47490. * * 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
  47491. * * 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
  47492. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47493. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47494. * * 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
  47495. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47497. * @param name defines the name of the mesh
  47498. * @param options defines the options used to create the mesh
  47499. * @param scene defines the hosting scene
  47500. * @returns the extruded shape mesh
  47501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47503. */
  47504. static ExtrudeShape(name: string, options: {
  47505. shape: Vector3[];
  47506. path: Vector3[];
  47507. scale?: number;
  47508. rotation?: number;
  47509. cap?: number;
  47510. updatable?: boolean;
  47511. sideOrientation?: number;
  47512. frontUVs?: Vector4;
  47513. backUVs?: Vector4;
  47514. instance?: Mesh;
  47515. invertUV?: boolean;
  47516. }, scene?: Nullable<Scene>): Mesh;
  47517. /**
  47518. * Creates an custom extruded shape mesh.
  47519. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47520. * * 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.
  47521. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47522. * * 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
  47523. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47524. * * 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
  47525. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47526. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47527. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47528. * * 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
  47529. * * 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
  47530. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47532. * * 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
  47533. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47535. * @param name defines the name of the mesh
  47536. * @param options defines the options used to create the mesh
  47537. * @param scene defines the hosting scene
  47538. * @returns the custom extruded shape mesh
  47539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47541. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47542. */
  47543. static ExtrudeShapeCustom(name: string, options: {
  47544. shape: Vector3[];
  47545. path: Vector3[];
  47546. scaleFunction?: any;
  47547. rotationFunction?: any;
  47548. ribbonCloseArray?: boolean;
  47549. ribbonClosePath?: boolean;
  47550. cap?: number;
  47551. updatable?: boolean;
  47552. sideOrientation?: number;
  47553. frontUVs?: Vector4;
  47554. backUVs?: Vector4;
  47555. instance?: Mesh;
  47556. invertUV?: boolean;
  47557. }, scene: Scene): Mesh;
  47558. /**
  47559. * Creates lathe mesh.
  47560. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  47561. * * 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
  47562. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  47563. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  47564. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  47565. * * 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
  47566. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  47567. * * 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
  47568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47569. * * 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
  47570. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47572. * @param name defines the name of the mesh
  47573. * @param options defines the options used to create the mesh
  47574. * @param scene defines the hosting scene
  47575. * @returns the lathe mesh
  47576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  47577. */
  47578. static CreateLathe(name: string, options: {
  47579. shape: Vector3[];
  47580. radius?: number;
  47581. tessellation?: number;
  47582. clip?: number;
  47583. arc?: number;
  47584. closed?: boolean;
  47585. updatable?: boolean;
  47586. sideOrientation?: number;
  47587. frontUVs?: Vector4;
  47588. backUVs?: Vector4;
  47589. cap?: number;
  47590. invertUV?: boolean;
  47591. }, scene: Scene): Mesh;
  47592. /**
  47593. * Creates a plane mesh
  47594. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47595. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47596. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47598. * * 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
  47599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47600. * @param name defines the name of the mesh
  47601. * @param options defines the options used to create the mesh
  47602. * @param scene defines the hosting scene
  47603. * @returns the plane mesh
  47604. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47605. */
  47606. static CreatePlane(name: string, options: {
  47607. size?: number;
  47608. width?: number;
  47609. height?: number;
  47610. sideOrientation?: number;
  47611. frontUVs?: Vector4;
  47612. backUVs?: Vector4;
  47613. updatable?: boolean;
  47614. sourcePlane?: Plane;
  47615. }, scene: Scene): Mesh;
  47616. /**
  47617. * Creates a ground mesh
  47618. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47619. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47621. * @param name defines the name of the mesh
  47622. * @param options defines the options used to create the mesh
  47623. * @param scene defines the hosting scene
  47624. * @returns the ground mesh
  47625. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47626. */
  47627. static CreateGround(name: string, options: {
  47628. width?: number;
  47629. height?: number;
  47630. subdivisions?: number;
  47631. subdivisionsX?: number;
  47632. subdivisionsY?: number;
  47633. updatable?: boolean;
  47634. }, scene: any): Mesh;
  47635. /**
  47636. * Creates a tiled ground mesh
  47637. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47638. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47639. * * 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
  47640. * * 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
  47641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47642. * @param name defines the name of the mesh
  47643. * @param options defines the options used to create the mesh
  47644. * @param scene defines the hosting scene
  47645. * @returns the tiled ground mesh
  47646. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47647. */
  47648. static CreateTiledGround(name: string, options: {
  47649. xmin: number;
  47650. zmin: number;
  47651. xmax: number;
  47652. zmax: number;
  47653. subdivisions?: {
  47654. w: number;
  47655. h: number;
  47656. };
  47657. precision?: {
  47658. w: number;
  47659. h: number;
  47660. };
  47661. updatable?: boolean;
  47662. }, scene: Scene): Mesh;
  47663. /**
  47664. * Creates a ground mesh from a height map
  47665. * * The parameter `url` sets the URL of the height map image resource.
  47666. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47667. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47668. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47669. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47670. * * 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.
  47671. * * 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).
  47672. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47674. * @param name defines the name of the mesh
  47675. * @param url defines the url to the height map
  47676. * @param options defines the options used to create the mesh
  47677. * @param scene defines the hosting scene
  47678. * @returns the ground mesh
  47679. * @see https://doc.babylonjs.com/babylon101/height_map
  47680. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47681. */
  47682. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47683. width?: number;
  47684. height?: number;
  47685. subdivisions?: number;
  47686. minHeight?: number;
  47687. maxHeight?: number;
  47688. colorFilter?: Color3;
  47689. alphaFilter?: number;
  47690. updatable?: boolean;
  47691. onReady?: (mesh: GroundMesh) => void;
  47692. }, scene: Scene): GroundMesh;
  47693. /**
  47694. * Creates a polygon mesh
  47695. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  47696. * * 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
  47697. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  47698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47699. * * 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)
  47700. * * Remember you can only change the shape positions, not their number when updating a polygon
  47701. * @param name defines the name of the mesh
  47702. * @param options defines the options used to create the mesh
  47703. * @param scene defines the hosting scene
  47704. * @param earcutInjection can be used to inject your own earcut reference
  47705. * @returns the polygon mesh
  47706. */
  47707. static CreatePolygon(name: string, options: {
  47708. shape: Vector3[];
  47709. holes?: Vector3[][];
  47710. depth?: number;
  47711. faceUV?: Vector4[];
  47712. faceColors?: Color4[];
  47713. updatable?: boolean;
  47714. sideOrientation?: number;
  47715. frontUVs?: Vector4;
  47716. backUVs?: Vector4;
  47717. }, scene: Scene, earcutInjection?: any): Mesh;
  47718. /**
  47719. * Creates an extruded polygon mesh, with depth in the Y direction.
  47720. * * 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)
  47721. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47722. * @param name defines the name of the mesh
  47723. * @param options defines the options used to create the mesh
  47724. * @param scene defines the hosting scene
  47725. * @param earcutInjection can be used to inject your own earcut reference
  47726. * @returns the polygon mesh
  47727. */
  47728. static ExtrudePolygon(name: string, options: {
  47729. shape: Vector3[];
  47730. holes?: Vector3[][];
  47731. depth?: number;
  47732. faceUV?: Vector4[];
  47733. faceColors?: Color4[];
  47734. updatable?: boolean;
  47735. sideOrientation?: number;
  47736. frontUVs?: Vector4;
  47737. backUVs?: Vector4;
  47738. }, scene: Scene, earcutInjection?: any): Mesh;
  47739. /**
  47740. * Creates a tube mesh.
  47741. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47742. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  47743. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  47744. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  47745. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  47746. * * 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)
  47747. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  47748. * * 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
  47749. * * 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
  47750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47751. * * 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
  47752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47754. * @param name defines the name of the mesh
  47755. * @param options defines the options used to create the mesh
  47756. * @param scene defines the hosting scene
  47757. * @returns the tube mesh
  47758. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47759. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  47760. */
  47761. static CreateTube(name: string, options: {
  47762. path: Vector3[];
  47763. radius?: number;
  47764. tessellation?: number;
  47765. radiusFunction?: {
  47766. (i: number, distance: number): number;
  47767. };
  47768. cap?: number;
  47769. arc?: number;
  47770. updatable?: boolean;
  47771. sideOrientation?: number;
  47772. frontUVs?: Vector4;
  47773. backUVs?: Vector4;
  47774. instance?: Mesh;
  47775. invertUV?: boolean;
  47776. }, scene: Scene): Mesh;
  47777. /**
  47778. * Creates a polyhedron mesh
  47779. * * 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
  47780. * * The parameter `size` (positive float, default 1) sets the polygon size
  47781. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  47782. * * 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`
  47783. * * 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
  47784. * * 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)`)
  47785. * * 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
  47786. * * 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
  47787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47788. * * 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
  47789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47790. * @param name defines the name of the mesh
  47791. * @param options defines the options used to create the mesh
  47792. * @param scene defines the hosting scene
  47793. * @returns the polyhedron mesh
  47794. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  47795. */
  47796. static CreatePolyhedron(name: string, options: {
  47797. type?: number;
  47798. size?: number;
  47799. sizeX?: number;
  47800. sizeY?: number;
  47801. sizeZ?: number;
  47802. custom?: any;
  47803. faceUV?: Vector4[];
  47804. faceColors?: Color4[];
  47805. flat?: boolean;
  47806. updatable?: boolean;
  47807. sideOrientation?: number;
  47808. frontUVs?: Vector4;
  47809. backUVs?: Vector4;
  47810. }, scene: Scene): Mesh;
  47811. /**
  47812. * Creates a decal mesh.
  47813. * 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
  47814. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  47815. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  47816. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  47817. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  47818. * @param name defines the name of the mesh
  47819. * @param sourceMesh defines the mesh where the decal must be applied
  47820. * @param options defines the options used to create the mesh
  47821. * @param scene defines the hosting scene
  47822. * @returns the decal mesh
  47823. * @see https://doc.babylonjs.com/how_to/decals
  47824. */
  47825. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  47826. position?: Vector3;
  47827. normal?: Vector3;
  47828. size?: Vector3;
  47829. angle?: number;
  47830. }): Mesh;
  47831. }
  47832. }
  47833. declare module BABYLON {
  47834. /**
  47835. * A simplifier interface for future simplification implementations
  47836. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47837. */
  47838. export interface ISimplifier {
  47839. /**
  47840. * Simplification of a given mesh according to the given settings.
  47841. * Since this requires computation, it is assumed that the function runs async.
  47842. * @param settings The settings of the simplification, including quality and distance
  47843. * @param successCallback A callback that will be called after the mesh was simplified.
  47844. * @param errorCallback in case of an error, this callback will be called. optional.
  47845. */
  47846. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  47847. }
  47848. /**
  47849. * Expected simplification settings.
  47850. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  47851. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47852. */
  47853. export interface ISimplificationSettings {
  47854. /**
  47855. * Gets or sets the expected quality
  47856. */
  47857. quality: number;
  47858. /**
  47859. * Gets or sets the distance when this optimized version should be used
  47860. */
  47861. distance: number;
  47862. /**
  47863. * Gets an already optimized mesh
  47864. */
  47865. optimizeMesh?: boolean;
  47866. }
  47867. /**
  47868. * Class used to specify simplification options
  47869. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47870. */
  47871. export class SimplificationSettings implements ISimplificationSettings {
  47872. /** expected quality */
  47873. quality: number;
  47874. /** distance when this optimized version should be used */
  47875. distance: number;
  47876. /** already optimized mesh */
  47877. optimizeMesh?: boolean | undefined;
  47878. /**
  47879. * Creates a SimplificationSettings
  47880. * @param quality expected quality
  47881. * @param distance distance when this optimized version should be used
  47882. * @param optimizeMesh already optimized mesh
  47883. */
  47884. constructor(
  47885. /** expected quality */
  47886. quality: number,
  47887. /** distance when this optimized version should be used */
  47888. distance: number,
  47889. /** already optimized mesh */
  47890. optimizeMesh?: boolean | undefined);
  47891. }
  47892. /**
  47893. * Interface used to define a simplification task
  47894. */
  47895. export interface ISimplificationTask {
  47896. /**
  47897. * Array of settings
  47898. */
  47899. settings: Array<ISimplificationSettings>;
  47900. /**
  47901. * Simplification type
  47902. */
  47903. simplificationType: SimplificationType;
  47904. /**
  47905. * Mesh to simplify
  47906. */
  47907. mesh: Mesh;
  47908. /**
  47909. * Callback called on success
  47910. */
  47911. successCallback?: () => void;
  47912. /**
  47913. * Defines if parallel processing can be used
  47914. */
  47915. parallelProcessing: boolean;
  47916. }
  47917. /**
  47918. * Queue used to order the simplification tasks
  47919. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47920. */
  47921. export class SimplificationQueue {
  47922. private _simplificationArray;
  47923. /**
  47924. * Gets a boolean indicating that the process is still running
  47925. */
  47926. running: boolean;
  47927. /**
  47928. * Creates a new queue
  47929. */
  47930. constructor();
  47931. /**
  47932. * Adds a new simplification task
  47933. * @param task defines a task to add
  47934. */
  47935. addTask(task: ISimplificationTask): void;
  47936. /**
  47937. * Execute next task
  47938. */
  47939. executeNext(): void;
  47940. /**
  47941. * Execute a simplification task
  47942. * @param task defines the task to run
  47943. */
  47944. runSimplification(task: ISimplificationTask): void;
  47945. private getSimplifier;
  47946. }
  47947. /**
  47948. * The implemented types of simplification
  47949. * At the moment only Quadratic Error Decimation is implemented
  47950. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47951. */
  47952. export enum SimplificationType {
  47953. /** Quadratic error decimation */
  47954. QUADRATIC = 0
  47955. }
  47956. }
  47957. declare module BABYLON {
  47958. interface Scene {
  47959. /** @hidden (Backing field) */
  47960. _simplificationQueue: SimplificationQueue;
  47961. /**
  47962. * Gets or sets the simplification queue attached to the scene
  47963. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  47964. */
  47965. simplificationQueue: SimplificationQueue;
  47966. }
  47967. interface Mesh {
  47968. /**
  47969. * Simplify the mesh according to the given array of settings.
  47970. * Function will return immediately and will simplify async
  47971. * @param settings a collection of simplification settings
  47972. * @param parallelProcessing should all levels calculate parallel or one after the other
  47973. * @param simplificationType the type of simplification to run
  47974. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  47975. * @returns the current mesh
  47976. */
  47977. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  47978. }
  47979. /**
  47980. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  47981. * created in a scene
  47982. */
  47983. export class SimplicationQueueSceneComponent implements ISceneComponent {
  47984. /**
  47985. * The component name helpfull to identify the component in the list of scene components.
  47986. */
  47987. readonly name: string;
  47988. /**
  47989. * The scene the component belongs to.
  47990. */
  47991. scene: Scene;
  47992. /**
  47993. * Creates a new instance of the component for the given scene
  47994. * @param scene Defines the scene to register the component in
  47995. */
  47996. constructor(scene: Scene);
  47997. /**
  47998. * Registers the component in a given scene
  47999. */
  48000. register(): void;
  48001. /**
  48002. * Rebuilds the elements related to this component in case of
  48003. * context lost for instance.
  48004. */
  48005. rebuild(): void;
  48006. /**
  48007. * Disposes the component and the associated ressources
  48008. */
  48009. dispose(): void;
  48010. private _beforeCameraUpdate;
  48011. }
  48012. }
  48013. declare module BABYLON {
  48014. /**
  48015. * Class used to enable access to IndexedDB
  48016. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  48017. */
  48018. export class Database implements IOfflineProvider {
  48019. private _callbackManifestChecked;
  48020. private _currentSceneUrl;
  48021. private _db;
  48022. private _enableSceneOffline;
  48023. private _enableTexturesOffline;
  48024. private _manifestVersionFound;
  48025. private _mustUpdateRessources;
  48026. private _hasReachedQuota;
  48027. private _isSupported;
  48028. private _idbFactory;
  48029. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  48030. private static IsUASupportingBlobStorage;
  48031. /**
  48032. * Gets a boolean indicating if Database storate is enabled (off by default)
  48033. */
  48034. static IDBStorageEnabled: boolean;
  48035. /**
  48036. * Gets a boolean indicating if scene must be saved in the database
  48037. */
  48038. readonly enableSceneOffline: boolean;
  48039. /**
  48040. * Gets a boolean indicating if textures must be saved in the database
  48041. */
  48042. readonly enableTexturesOffline: boolean;
  48043. /**
  48044. * Creates a new Database
  48045. * @param urlToScene defines the url to load the scene
  48046. * @param callbackManifestChecked defines the callback to use when manifest is checked
  48047. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  48048. */
  48049. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  48050. private static _ParseURL;
  48051. private static _ReturnFullUrlLocation;
  48052. private _checkManifestFile;
  48053. /**
  48054. * Open the database and make it available
  48055. * @param successCallback defines the callback to call on success
  48056. * @param errorCallback defines the callback to call on error
  48057. */
  48058. open(successCallback: () => void, errorCallback: () => void): void;
  48059. /**
  48060. * Loads an image from the database
  48061. * @param url defines the url to load from
  48062. * @param image defines the target DOM image
  48063. */
  48064. loadImage(url: string, image: HTMLImageElement): void;
  48065. private _loadImageFromDBAsync;
  48066. private _saveImageIntoDBAsync;
  48067. private _checkVersionFromDB;
  48068. private _loadVersionFromDBAsync;
  48069. private _saveVersionIntoDBAsync;
  48070. /**
  48071. * Loads a file from database
  48072. * @param url defines the URL to load from
  48073. * @param sceneLoaded defines a callback to call on success
  48074. * @param progressCallBack defines a callback to call when progress changed
  48075. * @param errorCallback defines a callback to call on error
  48076. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  48077. */
  48078. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  48079. private _loadFileAsync;
  48080. private _saveFileAsync;
  48081. /**
  48082. * Validates if xhr data is correct
  48083. * @param xhr defines the request to validate
  48084. * @param dataType defines the expected data type
  48085. * @returns true if data is correct
  48086. */
  48087. private static _ValidateXHRData;
  48088. }
  48089. }
  48090. declare module BABYLON {
  48091. /** @hidden */
  48092. export var gpuUpdateParticlesPixelShader: {
  48093. name: string;
  48094. shader: string;
  48095. };
  48096. }
  48097. declare module BABYLON {
  48098. /** @hidden */
  48099. export var gpuUpdateParticlesVertexShader: {
  48100. name: string;
  48101. shader: string;
  48102. };
  48103. }
  48104. declare module BABYLON {
  48105. /** @hidden */
  48106. export var clipPlaneFragmentDeclaration2: {
  48107. name: string;
  48108. shader: string;
  48109. };
  48110. }
  48111. declare module BABYLON {
  48112. /** @hidden */
  48113. export var gpuRenderParticlesPixelShader: {
  48114. name: string;
  48115. shader: string;
  48116. };
  48117. }
  48118. declare module BABYLON {
  48119. /** @hidden */
  48120. export var clipPlaneVertexDeclaration2: {
  48121. name: string;
  48122. shader: string;
  48123. };
  48124. }
  48125. declare module BABYLON {
  48126. /** @hidden */
  48127. export var gpuRenderParticlesVertexShader: {
  48128. name: string;
  48129. shader: string;
  48130. };
  48131. }
  48132. declare module BABYLON {
  48133. /**
  48134. * This represents a GPU particle system in Babylon
  48135. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  48136. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  48137. */
  48138. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  48139. /**
  48140. * The layer mask we are rendering the particles through.
  48141. */
  48142. layerMask: number;
  48143. private _capacity;
  48144. private _activeCount;
  48145. private _currentActiveCount;
  48146. private _accumulatedCount;
  48147. private _renderEffect;
  48148. private _updateEffect;
  48149. private _buffer0;
  48150. private _buffer1;
  48151. private _spriteBuffer;
  48152. private _updateVAO;
  48153. private _renderVAO;
  48154. private _targetIndex;
  48155. private _sourceBuffer;
  48156. private _targetBuffer;
  48157. private _engine;
  48158. private _currentRenderId;
  48159. private _started;
  48160. private _stopped;
  48161. private _timeDelta;
  48162. private _randomTexture;
  48163. private _randomTexture2;
  48164. private _attributesStrideSize;
  48165. private _updateEffectOptions;
  48166. private _randomTextureSize;
  48167. private _actualFrame;
  48168. private readonly _rawTextureWidth;
  48169. /**
  48170. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  48171. */
  48172. static readonly IsSupported: boolean;
  48173. /**
  48174. * An event triggered when the system is disposed.
  48175. */
  48176. onDisposeObservable: Observable<GPUParticleSystem>;
  48177. /**
  48178. * Gets the maximum number of particles active at the same time.
  48179. * @returns The max number of active particles.
  48180. */
  48181. getCapacity(): number;
  48182. /**
  48183. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  48184. * to override the particles.
  48185. */
  48186. forceDepthWrite: boolean;
  48187. /**
  48188. * Gets or set the number of active particles
  48189. */
  48190. activeParticleCount: number;
  48191. private _preWarmDone;
  48192. /**
  48193. * Is this system ready to be used/rendered
  48194. * @return true if the system is ready
  48195. */
  48196. isReady(): boolean;
  48197. /**
  48198. * Gets if the system has been started. (Note: this will still be true after stop is called)
  48199. * @returns True if it has been started, otherwise false.
  48200. */
  48201. isStarted(): boolean;
  48202. /**
  48203. * Starts the particle system and begins to emit
  48204. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  48205. */
  48206. start(delay?: number): void;
  48207. /**
  48208. * Stops the particle system.
  48209. */
  48210. stop(): void;
  48211. /**
  48212. * Remove all active particles
  48213. */
  48214. reset(): void;
  48215. /**
  48216. * Returns the string "GPUParticleSystem"
  48217. * @returns a string containing the class name
  48218. */
  48219. getClassName(): string;
  48220. private _colorGradientsTexture;
  48221. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  48222. /**
  48223. * Adds a new color gradient
  48224. * @param gradient defines the gradient to use (between 0 and 1)
  48225. * @param color1 defines the color to affect to the specified gradient
  48226. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  48227. * @returns the current particle system
  48228. */
  48229. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  48230. /**
  48231. * Remove a specific color gradient
  48232. * @param gradient defines the gradient to remove
  48233. * @returns the current particle system
  48234. */
  48235. removeColorGradient(gradient: number): GPUParticleSystem;
  48236. private _angularSpeedGradientsTexture;
  48237. private _sizeGradientsTexture;
  48238. private _velocityGradientsTexture;
  48239. private _limitVelocityGradientsTexture;
  48240. private _dragGradientsTexture;
  48241. private _addFactorGradient;
  48242. /**
  48243. * Adds a new size gradient
  48244. * @param gradient defines the gradient to use (between 0 and 1)
  48245. * @param factor defines the size factor to affect to the specified gradient
  48246. * @returns the current particle system
  48247. */
  48248. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  48249. /**
  48250. * Remove a specific size gradient
  48251. * @param gradient defines the gradient to remove
  48252. * @returns the current particle system
  48253. */
  48254. removeSizeGradient(gradient: number): GPUParticleSystem;
  48255. /**
  48256. * Adds a new angular speed gradient
  48257. * @param gradient defines the gradient to use (between 0 and 1)
  48258. * @param factor defines the angular speed to affect to the specified gradient
  48259. * @returns the current particle system
  48260. */
  48261. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  48262. /**
  48263. * Remove a specific angular speed gradient
  48264. * @param gradient defines the gradient to remove
  48265. * @returns the current particle system
  48266. */
  48267. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  48268. /**
  48269. * Adds a new velocity gradient
  48270. * @param gradient defines the gradient to use (between 0 and 1)
  48271. * @param factor defines the velocity to affect to the specified gradient
  48272. * @returns the current particle system
  48273. */
  48274. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48275. /**
  48276. * Remove a specific velocity gradient
  48277. * @param gradient defines the gradient to remove
  48278. * @returns the current particle system
  48279. */
  48280. removeVelocityGradient(gradient: number): GPUParticleSystem;
  48281. /**
  48282. * Adds a new limit velocity gradient
  48283. * @param gradient defines the gradient to use (between 0 and 1)
  48284. * @param factor defines the limit velocity value to affect to the specified gradient
  48285. * @returns the current particle system
  48286. */
  48287. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  48288. /**
  48289. * Remove a specific limit velocity gradient
  48290. * @param gradient defines the gradient to remove
  48291. * @returns the current particle system
  48292. */
  48293. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  48294. /**
  48295. * Adds a new drag gradient
  48296. * @param gradient defines the gradient to use (between 0 and 1)
  48297. * @param factor defines the drag value to affect to the specified gradient
  48298. * @returns the current particle system
  48299. */
  48300. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  48301. /**
  48302. * Remove a specific drag gradient
  48303. * @param gradient defines the gradient to remove
  48304. * @returns the current particle system
  48305. */
  48306. removeDragGradient(gradient: number): GPUParticleSystem;
  48307. /**
  48308. * Not supported by GPUParticleSystem
  48309. * @param gradient defines the gradient to use (between 0 and 1)
  48310. * @param factor defines the emit rate value to affect to the specified gradient
  48311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48312. * @returns the current particle system
  48313. */
  48314. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48315. /**
  48316. * Not supported by GPUParticleSystem
  48317. * @param gradient defines the gradient to remove
  48318. * @returns the current particle system
  48319. */
  48320. removeEmitRateGradient(gradient: number): IParticleSystem;
  48321. /**
  48322. * Not supported by GPUParticleSystem
  48323. * @param gradient defines the gradient to use (between 0 and 1)
  48324. * @param factor defines the start size value to affect to the specified gradient
  48325. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48326. * @returns the current particle system
  48327. */
  48328. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48329. /**
  48330. * Not supported by GPUParticleSystem
  48331. * @param gradient defines the gradient to remove
  48332. * @returns the current particle system
  48333. */
  48334. removeStartSizeGradient(gradient: number): IParticleSystem;
  48335. /**
  48336. * Not supported by GPUParticleSystem
  48337. * @param gradient defines the gradient to use (between 0 and 1)
  48338. * @param min defines the color remap minimal range
  48339. * @param max defines the color remap maximal range
  48340. * @returns the current particle system
  48341. */
  48342. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48343. /**
  48344. * Not supported by GPUParticleSystem
  48345. * @param gradient defines the gradient to remove
  48346. * @returns the current particle system
  48347. */
  48348. removeColorRemapGradient(): IParticleSystem;
  48349. /**
  48350. * Not supported by GPUParticleSystem
  48351. * @param gradient defines the gradient to use (between 0 and 1)
  48352. * @param min defines the alpha remap minimal range
  48353. * @param max defines the alpha remap maximal range
  48354. * @returns the current particle system
  48355. */
  48356. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  48357. /**
  48358. * Not supported by GPUParticleSystem
  48359. * @param gradient defines the gradient to remove
  48360. * @returns the current particle system
  48361. */
  48362. removeAlphaRemapGradient(): IParticleSystem;
  48363. /**
  48364. * Not supported by GPUParticleSystem
  48365. * @param gradient defines the gradient to use (between 0 and 1)
  48366. * @param color defines the color to affect to the specified gradient
  48367. * @returns the current particle system
  48368. */
  48369. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  48370. /**
  48371. * Not supported by GPUParticleSystem
  48372. * @param gradient defines the gradient to remove
  48373. * @returns the current particle system
  48374. */
  48375. removeRampGradient(): IParticleSystem;
  48376. /**
  48377. * Not supported by GPUParticleSystem
  48378. * @returns the list of ramp gradients
  48379. */
  48380. getRampGradients(): Nullable<Array<Color3Gradient>>;
  48381. /**
  48382. * Not supported by GPUParticleSystem
  48383. * Gets or sets a boolean indicating that ramp gradients must be used
  48384. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  48385. */
  48386. useRampGradients: boolean;
  48387. /**
  48388. * Not supported by GPUParticleSystem
  48389. * @param gradient defines the gradient to use (between 0 and 1)
  48390. * @param factor defines the life time factor to affect to the specified gradient
  48391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  48392. * @returns the current particle system
  48393. */
  48394. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  48395. /**
  48396. * Not supported by GPUParticleSystem
  48397. * @param gradient defines the gradient to remove
  48398. * @returns the current particle system
  48399. */
  48400. removeLifeTimeGradient(gradient: number): IParticleSystem;
  48401. /**
  48402. * Instantiates a GPU particle system.
  48403. * 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.
  48404. * @param name The name of the particle system
  48405. * @param options The options used to create the system
  48406. * @param scene The scene the particle system belongs to
  48407. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  48408. */
  48409. constructor(name: string, options: Partial<{
  48410. capacity: number;
  48411. randomTextureSize: number;
  48412. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  48413. protected _reset(): void;
  48414. private _createUpdateVAO;
  48415. private _createRenderVAO;
  48416. private _initialize;
  48417. /** @hidden */
  48418. _recreateUpdateEffect(): void;
  48419. /** @hidden */
  48420. _recreateRenderEffect(): void;
  48421. /**
  48422. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  48423. * @param preWarm defines if we are in the pre-warmimg phase
  48424. */
  48425. animate(preWarm?: boolean): void;
  48426. private _createFactorGradientTexture;
  48427. private _createSizeGradientTexture;
  48428. private _createAngularSpeedGradientTexture;
  48429. private _createVelocityGradientTexture;
  48430. private _createLimitVelocityGradientTexture;
  48431. private _createDragGradientTexture;
  48432. private _createColorGradientTexture;
  48433. /**
  48434. * Renders the particle system in its current state
  48435. * @param preWarm defines if the system should only update the particles but not render them
  48436. * @returns the current number of particles
  48437. */
  48438. render(preWarm?: boolean): number;
  48439. /**
  48440. * Rebuilds the particle system
  48441. */
  48442. rebuild(): void;
  48443. private _releaseBuffers;
  48444. private _releaseVAOs;
  48445. /**
  48446. * Disposes the particle system and free the associated resources
  48447. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  48448. */
  48449. dispose(disposeTexture?: boolean): void;
  48450. /**
  48451. * Clones the particle system.
  48452. * @param name The name of the cloned object
  48453. * @param newEmitter The new emitter to use
  48454. * @returns the cloned particle system
  48455. */
  48456. clone(name: string, newEmitter: any): GPUParticleSystem;
  48457. /**
  48458. * Serializes the particle system to a JSON object.
  48459. * @returns the JSON object
  48460. */
  48461. serialize(): any;
  48462. /**
  48463. * Parses a JSON object to create a GPU particle system.
  48464. * @param parsedParticleSystem The JSON object to parse
  48465. * @param scene The scene to create the particle system in
  48466. * @param rootUrl The root url to use to load external dependencies like texture
  48467. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  48468. * @returns the parsed GPU particle system
  48469. */
  48470. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  48471. }
  48472. }
  48473. declare module BABYLON {
  48474. /**
  48475. * Represents a set of particle systems working together to create a specific effect
  48476. */
  48477. export class ParticleSystemSet implements IDisposable {
  48478. private _emitterCreationOptions;
  48479. private _emitterNode;
  48480. /**
  48481. * Gets the particle system list
  48482. */
  48483. systems: IParticleSystem[];
  48484. /**
  48485. * Gets the emitter node used with this set
  48486. */
  48487. readonly emitterNode: Nullable<TransformNode>;
  48488. /**
  48489. * Creates a new emitter mesh as a sphere
  48490. * @param options defines the options used to create the sphere
  48491. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  48492. * @param scene defines the hosting scene
  48493. */
  48494. setEmitterAsSphere(options: {
  48495. diameter: number;
  48496. segments: number;
  48497. color: Color3;
  48498. }, renderingGroupId: number, scene: Scene): void;
  48499. /**
  48500. * Starts all particle systems of the set
  48501. * @param emitter defines an optional mesh to use as emitter for the particle systems
  48502. */
  48503. start(emitter?: AbstractMesh): void;
  48504. /**
  48505. * Release all associated resources
  48506. */
  48507. dispose(): void;
  48508. /**
  48509. * Serialize the set into a JSON compatible object
  48510. * @returns a JSON compatible representation of the set
  48511. */
  48512. serialize(): any;
  48513. /**
  48514. * Parse a new ParticleSystemSet from a serialized source
  48515. * @param data defines a JSON compatible representation of the set
  48516. * @param scene defines the hosting scene
  48517. * @param gpu defines if we want GPU particles or CPU particles
  48518. * @returns a new ParticleSystemSet
  48519. */
  48520. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  48521. }
  48522. }
  48523. declare module BABYLON {
  48524. /**
  48525. * This class is made for on one-liner static method to help creating particle system set.
  48526. */
  48527. export class ParticleHelper {
  48528. /**
  48529. * Gets or sets base Assets URL
  48530. */
  48531. static BaseAssetsUrl: string;
  48532. /**
  48533. * Create a default particle system that you can tweak
  48534. * @param emitter defines the emitter to use
  48535. * @param capacity defines the system capacity (default is 500 particles)
  48536. * @param scene defines the hosting scene
  48537. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  48538. * @returns the new Particle system
  48539. */
  48540. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  48541. /**
  48542. * This is the main static method (one-liner) of this helper to create different particle systems
  48543. * @param type This string represents the type to the particle system to create
  48544. * @param scene The scene where the particle system should live
  48545. * @param gpu If the system will use gpu
  48546. * @returns the ParticleSystemSet created
  48547. */
  48548. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  48549. /**
  48550. * Static function used to export a particle system to a ParticleSystemSet variable.
  48551. * Please note that the emitter shape is not exported
  48552. * @param systems defines the particle systems to export
  48553. * @returns the created particle system set
  48554. */
  48555. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  48556. }
  48557. }
  48558. declare module BABYLON {
  48559. interface Engine {
  48560. /**
  48561. * Create an effect to use with particle systems.
  48562. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  48563. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  48564. * @param uniformsNames defines a list of attribute names
  48565. * @param samplers defines an array of string used to represent textures
  48566. * @param defines defines the string containing the defines to use to compile the shaders
  48567. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  48568. * @param onCompiled defines a function to call when the effect creation is successful
  48569. * @param onError defines a function to call when the effect creation has failed
  48570. * @returns the new Effect
  48571. */
  48572. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  48573. }
  48574. interface Mesh {
  48575. /**
  48576. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  48577. * @returns an array of IParticleSystem
  48578. */
  48579. getEmittedParticleSystems(): IParticleSystem[];
  48580. /**
  48581. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  48582. * @returns an array of IParticleSystem
  48583. */
  48584. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  48585. }
  48586. /**
  48587. * @hidden
  48588. */
  48589. export var _IDoNeedToBeInTheBuild: number;
  48590. }
  48591. declare module BABYLON {
  48592. interface Scene {
  48593. /** @hidden (Backing field) */
  48594. _physicsEngine: Nullable<IPhysicsEngine>;
  48595. /**
  48596. * Gets the current physics engine
  48597. * @returns a IPhysicsEngine or null if none attached
  48598. */
  48599. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  48600. /**
  48601. * Enables physics to the current scene
  48602. * @param gravity defines the scene's gravity for the physics engine
  48603. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  48604. * @return a boolean indicating if the physics engine was initialized
  48605. */
  48606. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  48607. /**
  48608. * Disables and disposes the physics engine associated with the scene
  48609. */
  48610. disablePhysicsEngine(): void;
  48611. /**
  48612. * Gets a boolean indicating if there is an active physics engine
  48613. * @returns a boolean indicating if there is an active physics engine
  48614. */
  48615. isPhysicsEnabled(): boolean;
  48616. /**
  48617. * Deletes a physics compound impostor
  48618. * @param compound defines the compound to delete
  48619. */
  48620. deleteCompoundImpostor(compound: any): void;
  48621. /**
  48622. * An event triggered when physic simulation is about to be run
  48623. */
  48624. onBeforePhysicsObservable: Observable<Scene>;
  48625. /**
  48626. * An event triggered when physic simulation has been done
  48627. */
  48628. onAfterPhysicsObservable: Observable<Scene>;
  48629. }
  48630. interface AbstractMesh {
  48631. /** @hidden */
  48632. _physicsImpostor: Nullable<PhysicsImpostor>;
  48633. /**
  48634. * Gets or sets impostor used for physic simulation
  48635. * @see http://doc.babylonjs.com/features/physics_engine
  48636. */
  48637. physicsImpostor: Nullable<PhysicsImpostor>;
  48638. /**
  48639. * Gets the current physics impostor
  48640. * @see http://doc.babylonjs.com/features/physics_engine
  48641. * @returns a physics impostor or null
  48642. */
  48643. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  48644. /** Apply a physic impulse to the mesh
  48645. * @param force defines the force to apply
  48646. * @param contactPoint defines where to apply the force
  48647. * @returns the current mesh
  48648. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  48649. */
  48650. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  48651. /**
  48652. * Creates a physic joint between two meshes
  48653. * @param otherMesh defines the other mesh to use
  48654. * @param pivot1 defines the pivot to use on this mesh
  48655. * @param pivot2 defines the pivot to use on the other mesh
  48656. * @param options defines additional options (can be plugin dependent)
  48657. * @returns the current mesh
  48658. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  48659. */
  48660. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  48661. /** @hidden */
  48662. _disposePhysicsObserver: Nullable<Observer<Node>>;
  48663. }
  48664. /**
  48665. * Defines the physics engine scene component responsible to manage a physics engine
  48666. */
  48667. export class PhysicsEngineSceneComponent implements ISceneComponent {
  48668. /**
  48669. * The component name helpful to identify the component in the list of scene components.
  48670. */
  48671. readonly name: string;
  48672. /**
  48673. * The scene the component belongs to.
  48674. */
  48675. scene: Scene;
  48676. /**
  48677. * Creates a new instance of the component for the given scene
  48678. * @param scene Defines the scene to register the component in
  48679. */
  48680. constructor(scene: Scene);
  48681. /**
  48682. * Registers the component in a given scene
  48683. */
  48684. register(): void;
  48685. /**
  48686. * Rebuilds the elements related to this component in case of
  48687. * context lost for instance.
  48688. */
  48689. rebuild(): void;
  48690. /**
  48691. * Disposes the component and the associated ressources
  48692. */
  48693. dispose(): void;
  48694. }
  48695. }
  48696. declare module BABYLON {
  48697. /**
  48698. * A helper for physics simulations
  48699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48700. */
  48701. export class PhysicsHelper {
  48702. private _scene;
  48703. private _physicsEngine;
  48704. /**
  48705. * Initializes the Physics helper
  48706. * @param scene Babylon.js scene
  48707. */
  48708. constructor(scene: Scene);
  48709. /**
  48710. * Applies a radial explosion impulse
  48711. * @param origin the origin of the explosion
  48712. * @param radius the explosion radius
  48713. * @param strength the explosion strength
  48714. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48715. * @returns A physics radial explosion event, or null
  48716. */
  48717. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48718. /**
  48719. * Applies a radial explosion force
  48720. * @param origin the origin of the explosion
  48721. * @param radius the explosion radius
  48722. * @param strength the explosion strength
  48723. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48724. * @returns A physics radial explosion event, or null
  48725. */
  48726. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  48727. /**
  48728. * Creates a gravitational field
  48729. * @param origin the origin of the explosion
  48730. * @param radius the explosion radius
  48731. * @param strength the explosion strength
  48732. * @param falloff possible options: Constant & Linear. Defaults to Constant
  48733. * @returns A physics gravitational field event, or null
  48734. */
  48735. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  48736. /**
  48737. * Creates a physics updraft event
  48738. * @param origin the origin of the updraft
  48739. * @param radius the radius of the updraft
  48740. * @param strength the strength of the updraft
  48741. * @param height the height of the updraft
  48742. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  48743. * @returns A physics updraft event, or null
  48744. */
  48745. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  48746. /**
  48747. * Creates a physics vortex event
  48748. * @param origin the of the vortex
  48749. * @param radius the radius of the vortex
  48750. * @param strength the strength of the vortex
  48751. * @param height the height of the vortex
  48752. * @returns a Physics vortex event, or null
  48753. * A physics vortex event or null
  48754. */
  48755. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  48756. }
  48757. /**
  48758. * Represents a physics radial explosion event
  48759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48760. */
  48761. export class PhysicsRadialExplosionEvent {
  48762. private _scene;
  48763. private _sphere;
  48764. private _sphereOptions;
  48765. private _rays;
  48766. private _dataFetched;
  48767. /**
  48768. * Initializes a radial explosioin event
  48769. * @param scene BabylonJS scene
  48770. */
  48771. constructor(scene: Scene);
  48772. /**
  48773. * Returns the data related to the radial explosion event (sphere & rays).
  48774. * @returns The radial explosion event data
  48775. */
  48776. getData(): PhysicsRadialExplosionEventData;
  48777. /**
  48778. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  48779. * @param impostor A physics imposter
  48780. * @param origin the origin of the explosion
  48781. * @param radius the explosion radius
  48782. * @param strength the explosion strength
  48783. * @param falloff possible options: Constant & Linear
  48784. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  48785. */
  48786. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  48787. /**
  48788. * Disposes the sphere.
  48789. * @param force Specifies if the sphere should be disposed by force
  48790. */
  48791. dispose(force?: boolean): void;
  48792. /*** Helpers ***/
  48793. private _prepareSphere;
  48794. private _intersectsWithSphere;
  48795. }
  48796. /**
  48797. * Represents a gravitational field event
  48798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48799. */
  48800. export class PhysicsGravitationalFieldEvent {
  48801. private _physicsHelper;
  48802. private _scene;
  48803. private _origin;
  48804. private _radius;
  48805. private _strength;
  48806. private _falloff;
  48807. private _tickCallback;
  48808. private _sphere;
  48809. private _dataFetched;
  48810. /**
  48811. * Initializes the physics gravitational field event
  48812. * @param physicsHelper A physics helper
  48813. * @param scene BabylonJS scene
  48814. * @param origin The origin position of the gravitational field event
  48815. * @param radius The radius of the gravitational field event
  48816. * @param strength The strength of the gravitational field event
  48817. * @param falloff The falloff for the gravitational field event
  48818. */
  48819. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  48820. /**
  48821. * Returns the data related to the gravitational field event (sphere).
  48822. * @returns A gravitational field event
  48823. */
  48824. getData(): PhysicsGravitationalFieldEventData;
  48825. /**
  48826. * Enables the gravitational field.
  48827. */
  48828. enable(): void;
  48829. /**
  48830. * Disables the gravitational field.
  48831. */
  48832. disable(): void;
  48833. /**
  48834. * Disposes the sphere.
  48835. * @param force The force to dispose from the gravitational field event
  48836. */
  48837. dispose(force?: boolean): void;
  48838. private _tick;
  48839. }
  48840. /**
  48841. * Represents a physics updraft event
  48842. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48843. */
  48844. export class PhysicsUpdraftEvent {
  48845. private _scene;
  48846. private _origin;
  48847. private _radius;
  48848. private _strength;
  48849. private _height;
  48850. private _updraftMode;
  48851. private _physicsEngine;
  48852. private _originTop;
  48853. private _originDirection;
  48854. private _tickCallback;
  48855. private _cylinder;
  48856. private _cylinderPosition;
  48857. private _dataFetched;
  48858. /**
  48859. * Initializes the physics updraft event
  48860. * @param _scene BabylonJS scene
  48861. * @param _origin The origin position of the updraft
  48862. * @param _radius The radius of the updraft
  48863. * @param _strength The strength of the updraft
  48864. * @param _height The height of the updraft
  48865. * @param _updraftMode The mode of the updraft
  48866. */
  48867. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  48868. /**
  48869. * Returns the data related to the updraft event (cylinder).
  48870. * @returns A physics updraft event
  48871. */
  48872. getData(): PhysicsUpdraftEventData;
  48873. /**
  48874. * Enables the updraft.
  48875. */
  48876. enable(): void;
  48877. /**
  48878. * Disables the cortex.
  48879. */
  48880. disable(): void;
  48881. /**
  48882. * Disposes the sphere.
  48883. * @param force Specifies if the updraft should be disposed by force
  48884. */
  48885. dispose(force?: boolean): void;
  48886. private getImpostorForceAndContactPoint;
  48887. private _tick;
  48888. /*** Helpers ***/
  48889. private _prepareCylinder;
  48890. private _intersectsWithCylinder;
  48891. }
  48892. /**
  48893. * Represents a physics vortex event
  48894. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48895. */
  48896. export class PhysicsVortexEvent {
  48897. private _scene;
  48898. private _origin;
  48899. private _radius;
  48900. private _strength;
  48901. private _height;
  48902. private _physicsEngine;
  48903. private _originTop;
  48904. private _centripetalForceThreshold;
  48905. private _updraftMultiplier;
  48906. private _tickCallback;
  48907. private _cylinder;
  48908. private _cylinderPosition;
  48909. private _dataFetched;
  48910. /**
  48911. * Initializes the physics vortex event
  48912. * @param _scene The BabylonJS scene
  48913. * @param _origin The origin position of the vortex
  48914. * @param _radius The radius of the vortex
  48915. * @param _strength The strength of the vortex
  48916. * @param _height The height of the vortex
  48917. */
  48918. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  48919. /**
  48920. * Returns the data related to the vortex event (cylinder).
  48921. * @returns The physics vortex event data
  48922. */
  48923. getData(): PhysicsVortexEventData;
  48924. /**
  48925. * Enables the vortex.
  48926. */
  48927. enable(): void;
  48928. /**
  48929. * Disables the cortex.
  48930. */
  48931. disable(): void;
  48932. /**
  48933. * Disposes the sphere.
  48934. * @param force
  48935. */
  48936. dispose(force?: boolean): void;
  48937. private getImpostorForceAndContactPoint;
  48938. private _tick;
  48939. /*** Helpers ***/
  48940. private _prepareCylinder;
  48941. private _intersectsWithCylinder;
  48942. }
  48943. /**
  48944. * The strenght of the force in correspondence to the distance of the affected object
  48945. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48946. */
  48947. export enum PhysicsRadialImpulseFalloff {
  48948. /** Defines that impulse is constant in strength across it's whole radius */
  48949. Constant = 0,
  48950. /** DEfines that impulse gets weaker if it's further from the origin */
  48951. Linear = 1
  48952. }
  48953. /**
  48954. * The strength of the force in correspondence to the distance of the affected object
  48955. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48956. */
  48957. export enum PhysicsUpdraftMode {
  48958. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  48959. Center = 0,
  48960. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  48961. Perpendicular = 1
  48962. }
  48963. /**
  48964. * Interface for a physics force and contact point
  48965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48966. */
  48967. export interface PhysicsForceAndContactPoint {
  48968. /**
  48969. * The force applied at the contact point
  48970. */
  48971. force: Vector3;
  48972. /**
  48973. * The contact point
  48974. */
  48975. contactPoint: Vector3;
  48976. }
  48977. /**
  48978. * Interface for radial explosion event data
  48979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48980. */
  48981. export interface PhysicsRadialExplosionEventData {
  48982. /**
  48983. * A sphere used for the radial explosion event
  48984. */
  48985. sphere: Mesh;
  48986. /**
  48987. * An array of rays for the radial explosion event
  48988. */
  48989. rays: Array<Ray>;
  48990. }
  48991. /**
  48992. * Interface for gravitational field event data
  48993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48994. */
  48995. export interface PhysicsGravitationalFieldEventData {
  48996. /**
  48997. * A sphere mesh used for the gravitational field event
  48998. */
  48999. sphere: Mesh;
  49000. }
  49001. /**
  49002. * Interface for updraft event data
  49003. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49004. */
  49005. export interface PhysicsUpdraftEventData {
  49006. /**
  49007. * A cylinder used for the updraft event
  49008. */
  49009. cylinder: Mesh;
  49010. }
  49011. /**
  49012. * Interface for vortex event data
  49013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49014. */
  49015. export interface PhysicsVortexEventData {
  49016. /**
  49017. * A cylinder used for the vortex event
  49018. */
  49019. cylinder: Mesh;
  49020. }
  49021. }
  49022. declare module BABYLON {
  49023. /**
  49024. * AmmoJS Physics plugin
  49025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49026. * @see https://github.com/kripken/ammo.js/
  49027. */
  49028. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49029. private _useDeltaForWorldStep;
  49030. /**
  49031. * Reference to the Ammo library
  49032. */
  49033. bjsAMMO: any;
  49034. /**
  49035. * Created ammoJS world which physics bodies are added to
  49036. */
  49037. world: any;
  49038. /**
  49039. * Name of the plugin
  49040. */
  49041. name: string;
  49042. private _timeStep;
  49043. private _fixedTimeStep;
  49044. private _maxSteps;
  49045. private _tmpQuaternion;
  49046. private _tmpAmmoTransform;
  49047. private _tmpAmmoQuaternion;
  49048. private _tmpAmmoConcreteContactResultCallback;
  49049. private _collisionConfiguration;
  49050. private _dispatcher;
  49051. private _overlappingPairCache;
  49052. private _solver;
  49053. private _tmpAmmoVectorA;
  49054. private _tmpAmmoVectorB;
  49055. private _tmpAmmoVectorC;
  49056. private _tmpContactCallbackResult;
  49057. private static readonly DISABLE_COLLISION_FLAG;
  49058. private static readonly KINEMATIC_FLAG;
  49059. private static readonly DISABLE_DEACTIVATION_FLAG;
  49060. /**
  49061. * Initializes the ammoJS plugin
  49062. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49063. * @param ammoInjection can be used to inject your own ammo reference
  49064. */
  49065. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  49066. /**
  49067. * Sets the gravity of the physics world (m/(s^2))
  49068. * @param gravity Gravity to set
  49069. */
  49070. setGravity(gravity: Vector3): void;
  49071. /**
  49072. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49073. * @param timeStep timestep to use in seconds
  49074. */
  49075. setTimeStep(timeStep: number): void;
  49076. /**
  49077. * 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)
  49078. * @param fixedTimeStep fixedTimeStep to use in seconds
  49079. */
  49080. setFixedTimeStep(fixedTimeStep: number): void;
  49081. /**
  49082. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49083. * @param maxSteps the maximum number of steps by the physics engine per frame
  49084. */
  49085. setMaxSteps(maxSteps: number): void;
  49086. /**
  49087. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49088. * @returns the current timestep in seconds
  49089. */
  49090. getTimeStep(): number;
  49091. private _isImpostorInContact;
  49092. private _isImpostorPairInContact;
  49093. private _stepSimulation;
  49094. /**
  49095. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49096. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49097. * After the step the babylon meshes are set to the position of the physics imposters
  49098. * @param delta amount of time to step forward
  49099. * @param impostors array of imposters to update before/after the step
  49100. */
  49101. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49102. private _tmpVector;
  49103. private _tmpMatrix;
  49104. /**
  49105. * Applies an implulse on the imposter
  49106. * @param impostor imposter to apply impulse
  49107. * @param force amount of force to be applied to the imposter
  49108. * @param contactPoint the location to apply the impulse on the imposter
  49109. */
  49110. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49111. /**
  49112. * Applies a force on the imposter
  49113. * @param impostor imposter to apply force
  49114. * @param force amount of force to be applied to the imposter
  49115. * @param contactPoint the location to apply the force on the imposter
  49116. */
  49117. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49118. /**
  49119. * Creates a physics body using the plugin
  49120. * @param impostor the imposter to create the physics body on
  49121. */
  49122. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49123. /**
  49124. * Removes the physics body from the imposter and disposes of the body's memory
  49125. * @param impostor imposter to remove the physics body from
  49126. */
  49127. removePhysicsBody(impostor: PhysicsImpostor): void;
  49128. /**
  49129. * Generates a joint
  49130. * @param impostorJoint the imposter joint to create the joint with
  49131. */
  49132. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49133. /**
  49134. * Removes a joint
  49135. * @param impostorJoint the imposter joint to remove the joint from
  49136. */
  49137. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49138. private _addMeshVerts;
  49139. private _createShape;
  49140. /**
  49141. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49142. * @param impostor imposter containing the physics body and babylon object
  49143. */
  49144. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49145. /**
  49146. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49147. * @param impostor imposter containing the physics body and babylon object
  49148. * @param newPosition new position
  49149. * @param newRotation new rotation
  49150. */
  49151. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49152. /**
  49153. * If this plugin is supported
  49154. * @returns true if its supported
  49155. */
  49156. isSupported(): boolean;
  49157. /**
  49158. * Sets the linear velocity of the physics body
  49159. * @param impostor imposter to set the velocity on
  49160. * @param velocity velocity to set
  49161. */
  49162. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49163. /**
  49164. * Sets the angular velocity of the physics body
  49165. * @param impostor imposter to set the velocity on
  49166. * @param velocity velocity to set
  49167. */
  49168. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49169. /**
  49170. * gets the linear velocity
  49171. * @param impostor imposter to get linear velocity from
  49172. * @returns linear velocity
  49173. */
  49174. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49175. /**
  49176. * gets the angular velocity
  49177. * @param impostor imposter to get angular velocity from
  49178. * @returns angular velocity
  49179. */
  49180. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49181. /**
  49182. * Sets the mass of physics body
  49183. * @param impostor imposter to set the mass on
  49184. * @param mass mass to set
  49185. */
  49186. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49187. /**
  49188. * Gets the mass of the physics body
  49189. * @param impostor imposter to get the mass from
  49190. * @returns mass
  49191. */
  49192. getBodyMass(impostor: PhysicsImpostor): number;
  49193. /**
  49194. * Gets friction of the impostor
  49195. * @param impostor impostor to get friction from
  49196. * @returns friction value
  49197. */
  49198. getBodyFriction(impostor: PhysicsImpostor): number;
  49199. /**
  49200. * Sets friction of the impostor
  49201. * @param impostor impostor to set friction on
  49202. * @param friction friction value
  49203. */
  49204. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49205. /**
  49206. * Gets restitution of the impostor
  49207. * @param impostor impostor to get restitution from
  49208. * @returns restitution value
  49209. */
  49210. getBodyRestitution(impostor: PhysicsImpostor): number;
  49211. /**
  49212. * Sets resitution of the impostor
  49213. * @param impostor impostor to set resitution on
  49214. * @param restitution resitution value
  49215. */
  49216. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49217. /**
  49218. * Sleeps the physics body and stops it from being active
  49219. * @param impostor impostor to sleep
  49220. */
  49221. sleepBody(impostor: PhysicsImpostor): void;
  49222. /**
  49223. * Activates the physics body
  49224. * @param impostor impostor to activate
  49225. */
  49226. wakeUpBody(impostor: PhysicsImpostor): void;
  49227. /**
  49228. * Updates the distance parameters of the joint
  49229. * @param joint joint to update
  49230. * @param maxDistance maximum distance of the joint
  49231. * @param minDistance minimum distance of the joint
  49232. */
  49233. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49234. /**
  49235. * Sets a motor on the joint
  49236. * @param joint joint to set motor on
  49237. * @param speed speed of the motor
  49238. * @param maxForce maximum force of the motor
  49239. * @param motorIndex index of the motor
  49240. */
  49241. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49242. /**
  49243. * Sets the motors limit
  49244. * @param joint joint to set limit on
  49245. * @param upperLimit upper limit
  49246. * @param lowerLimit lower limit
  49247. */
  49248. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49249. /**
  49250. * Syncs the position and rotation of a mesh with the impostor
  49251. * @param mesh mesh to sync
  49252. * @param impostor impostor to update the mesh with
  49253. */
  49254. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49255. /**
  49256. * Gets the radius of the impostor
  49257. * @param impostor impostor to get radius from
  49258. * @returns the radius
  49259. */
  49260. getRadius(impostor: PhysicsImpostor): number;
  49261. /**
  49262. * Gets the box size of the impostor
  49263. * @param impostor impostor to get box size from
  49264. * @param result the resulting box size
  49265. */
  49266. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49267. /**
  49268. * Disposes of the impostor
  49269. */
  49270. dispose(): void;
  49271. }
  49272. }
  49273. declare module BABYLON {
  49274. /** @hidden */
  49275. export var blackAndWhitePixelShader: {
  49276. name: string;
  49277. shader: string;
  49278. };
  49279. }
  49280. declare module BABYLON {
  49281. /**
  49282. * Post process used to render in black and white
  49283. */
  49284. export class BlackAndWhitePostProcess extends PostProcess {
  49285. /**
  49286. * Linear about to convert he result to black and white (default: 1)
  49287. */
  49288. degree: number;
  49289. /**
  49290. * Creates a black and white post process
  49291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  49292. * @param name The name of the effect.
  49293. * @param options The required width/height ratio to downsize to before computing the render pass.
  49294. * @param camera The camera to apply the render pass to.
  49295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49296. * @param engine The engine which the post process will be applied. (default: current engine)
  49297. * @param reusable If the post process can be reused on the same frame. (default: false)
  49298. */
  49299. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49300. }
  49301. }
  49302. declare module BABYLON {
  49303. /**
  49304. * This represents a set of one or more post processes in Babylon.
  49305. * A post process can be used to apply a shader to a texture after it is rendered.
  49306. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49307. */
  49308. export class PostProcessRenderEffect {
  49309. private _postProcesses;
  49310. private _getPostProcesses;
  49311. private _singleInstance;
  49312. private _cameras;
  49313. private _indicesForCamera;
  49314. /**
  49315. * Name of the effect
  49316. * @hidden
  49317. */
  49318. _name: string;
  49319. /**
  49320. * Instantiates a post process render effect.
  49321. * A post process can be used to apply a shader to a texture after it is rendered.
  49322. * @param engine The engine the effect is tied to
  49323. * @param name The name of the effect
  49324. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49325. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49326. */
  49327. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49328. /**
  49329. * Checks if all the post processes in the effect are supported.
  49330. */
  49331. readonly isSupported: boolean;
  49332. /**
  49333. * Updates the current state of the effect
  49334. * @hidden
  49335. */
  49336. _update(): void;
  49337. /**
  49338. * Attaches the effect on cameras
  49339. * @param cameras The camera to attach to.
  49340. * @hidden
  49341. */
  49342. _attachCameras(cameras: Camera): void;
  49343. /**
  49344. * Attaches the effect on cameras
  49345. * @param cameras The camera to attach to.
  49346. * @hidden
  49347. */
  49348. _attachCameras(cameras: Camera[]): void;
  49349. /**
  49350. * Detatches the effect on cameras
  49351. * @param cameras The camera to detatch from.
  49352. * @hidden
  49353. */
  49354. _detachCameras(cameras: Camera): void;
  49355. /**
  49356. * Detatches the effect on cameras
  49357. * @param cameras The camera to detatch from.
  49358. * @hidden
  49359. */
  49360. _detachCameras(cameras: Camera[]): void;
  49361. /**
  49362. * Enables the effect on given cameras
  49363. * @param cameras The camera to enable.
  49364. * @hidden
  49365. */
  49366. _enable(cameras: Camera): void;
  49367. /**
  49368. * Enables the effect on given cameras
  49369. * @param cameras The camera to enable.
  49370. * @hidden
  49371. */
  49372. _enable(cameras: Nullable<Camera[]>): void;
  49373. /**
  49374. * Disables the effect on the given cameras
  49375. * @param cameras The camera to disable.
  49376. * @hidden
  49377. */
  49378. _disable(cameras: Camera): void;
  49379. /**
  49380. * Disables the effect on the given cameras
  49381. * @param cameras The camera to disable.
  49382. * @hidden
  49383. */
  49384. _disable(cameras: Nullable<Camera[]>): void;
  49385. /**
  49386. * Gets a list of the post processes contained in the effect.
  49387. * @param camera The camera to get the post processes on.
  49388. * @returns The list of the post processes in the effect.
  49389. */
  49390. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49391. }
  49392. }
  49393. declare module BABYLON {
  49394. /** @hidden */
  49395. export var extractHighlightsPixelShader: {
  49396. name: string;
  49397. shader: string;
  49398. };
  49399. }
  49400. declare module BABYLON {
  49401. /**
  49402. * 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.
  49403. */
  49404. export class ExtractHighlightsPostProcess extends PostProcess {
  49405. /**
  49406. * The luminance threshold, pixels below this value will be set to black.
  49407. */
  49408. threshold: number;
  49409. /** @hidden */
  49410. _exposure: number;
  49411. /**
  49412. * Post process which has the input texture to be used when performing highlight extraction
  49413. * @hidden
  49414. */
  49415. _inputPostProcess: Nullable<PostProcess>;
  49416. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49417. }
  49418. }
  49419. declare module BABYLON {
  49420. /** @hidden */
  49421. export var bloomMergePixelShader: {
  49422. name: string;
  49423. shader: string;
  49424. };
  49425. }
  49426. declare module BABYLON {
  49427. /**
  49428. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49429. */
  49430. export class BloomMergePostProcess extends PostProcess {
  49431. /** Weight of the bloom to be added to the original input. */
  49432. weight: number;
  49433. /**
  49434. * Creates a new instance of @see BloomMergePostProcess
  49435. * @param name The name of the effect.
  49436. * @param originalFromInput Post process which's input will be used for the merge.
  49437. * @param blurred Blurred highlights post process which's output will be used.
  49438. * @param weight Weight of the bloom to be added to the original input.
  49439. * @param options The required width/height ratio to downsize to before computing the render pass.
  49440. * @param camera The camera to apply the render pass to.
  49441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49442. * @param engine The engine which the post process will be applied. (default: current engine)
  49443. * @param reusable If the post process can be reused on the same frame. (default: false)
  49444. * @param textureType Type of textures used when performing the post process. (default: 0)
  49445. * @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)
  49446. */
  49447. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  49448. /** Weight of the bloom to be added to the original input. */
  49449. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49450. }
  49451. }
  49452. declare module BABYLON {
  49453. /**
  49454. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  49455. */
  49456. export class BloomEffect extends PostProcessRenderEffect {
  49457. private bloomScale;
  49458. /**
  49459. * @hidden Internal
  49460. */
  49461. _effects: Array<PostProcess>;
  49462. /**
  49463. * @hidden Internal
  49464. */
  49465. _downscale: ExtractHighlightsPostProcess;
  49466. private _blurX;
  49467. private _blurY;
  49468. private _merge;
  49469. /**
  49470. * The luminance threshold to find bright areas of the image to bloom.
  49471. */
  49472. threshold: number;
  49473. /**
  49474. * The strength of the bloom.
  49475. */
  49476. weight: number;
  49477. /**
  49478. * Specifies the size of the bloom blur kernel, relative to the final output size
  49479. */
  49480. kernel: number;
  49481. /**
  49482. * Creates a new instance of @see BloomEffect
  49483. * @param scene The scene the effect belongs to.
  49484. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  49485. * @param bloomKernel The size of the kernel to be used when applying the blur.
  49486. * @param bloomWeight The the strength of bloom.
  49487. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49488. * @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)
  49489. */
  49490. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  49491. /**
  49492. * Disposes each of the internal effects for a given camera.
  49493. * @param camera The camera to dispose the effect on.
  49494. */
  49495. disposeEffects(camera: Camera): void;
  49496. /**
  49497. * @hidden Internal
  49498. */
  49499. _updateEffects(): void;
  49500. /**
  49501. * Internal
  49502. * @returns if all the contained post processes are ready.
  49503. * @hidden
  49504. */
  49505. _isReady(): boolean;
  49506. }
  49507. }
  49508. declare module BABYLON {
  49509. /** @hidden */
  49510. export var chromaticAberrationPixelShader: {
  49511. name: string;
  49512. shader: string;
  49513. };
  49514. }
  49515. declare module BABYLON {
  49516. /**
  49517. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  49518. */
  49519. export class ChromaticAberrationPostProcess extends PostProcess {
  49520. /**
  49521. * The amount of seperation of rgb channels (default: 30)
  49522. */
  49523. aberrationAmount: number;
  49524. /**
  49525. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  49526. */
  49527. radialIntensity: number;
  49528. /**
  49529. * 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))
  49530. */
  49531. direction: Vector2;
  49532. /**
  49533. * 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))
  49534. */
  49535. centerPosition: Vector2;
  49536. /**
  49537. * Creates a new instance ChromaticAberrationPostProcess
  49538. * @param name The name of the effect.
  49539. * @param screenWidth The width of the screen to apply the effect on.
  49540. * @param screenHeight The height of the screen to apply the effect on.
  49541. * @param options The required width/height ratio to downsize to before computing the render pass.
  49542. * @param camera The camera to apply the render pass to.
  49543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49544. * @param engine The engine which the post process will be applied. (default: current engine)
  49545. * @param reusable If the post process can be reused on the same frame. (default: false)
  49546. * @param textureType Type of textures used when performing the post process. (default: 0)
  49547. * @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)
  49548. */
  49549. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49550. }
  49551. }
  49552. declare module BABYLON {
  49553. /** @hidden */
  49554. export var circleOfConfusionPixelShader: {
  49555. name: string;
  49556. shader: string;
  49557. };
  49558. }
  49559. declare module BABYLON {
  49560. /**
  49561. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  49562. */
  49563. export class CircleOfConfusionPostProcess extends PostProcess {
  49564. /**
  49565. * 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.
  49566. */
  49567. lensSize: number;
  49568. /**
  49569. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49570. */
  49571. fStop: number;
  49572. /**
  49573. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49574. */
  49575. focusDistance: number;
  49576. /**
  49577. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  49578. */
  49579. focalLength: number;
  49580. private _depthTexture;
  49581. /**
  49582. * Creates a new instance CircleOfConfusionPostProcess
  49583. * @param name The name of the effect.
  49584. * @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.
  49585. * @param options The required width/height ratio to downsize to before computing the render pass.
  49586. * @param camera The camera to apply the render pass to.
  49587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49588. * @param engine The engine which the post process will be applied. (default: current engine)
  49589. * @param reusable If the post process can be reused on the same frame. (default: false)
  49590. * @param textureType Type of textures used when performing the post process. (default: 0)
  49591. * @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)
  49592. */
  49593. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49594. /**
  49595. * 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.
  49596. */
  49597. depthTexture: RenderTargetTexture;
  49598. }
  49599. }
  49600. declare module BABYLON {
  49601. /** @hidden */
  49602. export var colorCorrectionPixelShader: {
  49603. name: string;
  49604. shader: string;
  49605. };
  49606. }
  49607. declare module BABYLON {
  49608. /**
  49609. *
  49610. * This post-process allows the modification of rendered colors by using
  49611. * a 'look-up table' (LUT). This effect is also called Color Grading.
  49612. *
  49613. * The object needs to be provided an url to a texture containing the color
  49614. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  49615. * Use an image editing software to tweak the LUT to match your needs.
  49616. *
  49617. * For an example of a color LUT, see here:
  49618. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  49619. * For explanations on color grading, see here:
  49620. * @see http://udn.epicgames.com/Three/ColorGrading.html
  49621. *
  49622. */
  49623. export class ColorCorrectionPostProcess extends PostProcess {
  49624. private _colorTableTexture;
  49625. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49626. }
  49627. }
  49628. declare module BABYLON {
  49629. /** @hidden */
  49630. export var convolutionPixelShader: {
  49631. name: string;
  49632. shader: string;
  49633. };
  49634. }
  49635. declare module BABYLON {
  49636. /**
  49637. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  49638. * input texture to perform effects such as edge detection or sharpening
  49639. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  49640. */
  49641. export class ConvolutionPostProcess extends PostProcess {
  49642. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49643. kernel: number[];
  49644. /**
  49645. * Creates a new instance ConvolutionPostProcess
  49646. * @param name The name of the effect.
  49647. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  49648. * @param options The required width/height ratio to downsize to before computing the render pass.
  49649. * @param camera The camera to apply the render pass to.
  49650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49651. * @param engine The engine which the post process will be applied. (default: current engine)
  49652. * @param reusable If the post process can be reused on the same frame. (default: false)
  49653. * @param textureType Type of textures used when performing the post process. (default: 0)
  49654. */
  49655. constructor(name: string,
  49656. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  49657. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49658. /**
  49659. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49660. */
  49661. static EdgeDetect0Kernel: number[];
  49662. /**
  49663. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49664. */
  49665. static EdgeDetect1Kernel: number[];
  49666. /**
  49667. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49668. */
  49669. static EdgeDetect2Kernel: number[];
  49670. /**
  49671. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49672. */
  49673. static SharpenKernel: number[];
  49674. /**
  49675. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49676. */
  49677. static EmbossKernel: number[];
  49678. /**
  49679. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  49680. */
  49681. static GaussianKernel: number[];
  49682. }
  49683. }
  49684. declare module BABYLON {
  49685. /**
  49686. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  49687. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  49688. * based on samples that have a large difference in distance than the center pixel.
  49689. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  49690. */
  49691. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  49692. direction: Vector2;
  49693. /**
  49694. * Creates a new instance CircleOfConfusionPostProcess
  49695. * @param name The name of the effect.
  49696. * @param scene The scene the effect belongs to.
  49697. * @param direction The direction the blur should be applied.
  49698. * @param kernel The size of the kernel used to blur.
  49699. * @param options The required width/height ratio to downsize to before computing the render pass.
  49700. * @param camera The camera to apply the render pass to.
  49701. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  49702. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  49703. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49704. * @param engine The engine which the post process will be applied. (default: current engine)
  49705. * @param reusable If the post process can be reused on the same frame. (default: false)
  49706. * @param textureType Type of textures used when performing the post process. (default: 0)
  49707. * @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)
  49708. */
  49709. 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);
  49710. }
  49711. }
  49712. declare module BABYLON {
  49713. /** @hidden */
  49714. export var depthOfFieldMergePixelShader: {
  49715. name: string;
  49716. shader: string;
  49717. };
  49718. }
  49719. declare module BABYLON {
  49720. /**
  49721. * Options to be set when merging outputs from the default pipeline.
  49722. */
  49723. export class DepthOfFieldMergePostProcessOptions {
  49724. /**
  49725. * The original image to merge on top of
  49726. */
  49727. originalFromInput: PostProcess;
  49728. /**
  49729. * Parameters to perform the merge of the depth of field effect
  49730. */
  49731. depthOfField?: {
  49732. circleOfConfusion: PostProcess;
  49733. blurSteps: Array<PostProcess>;
  49734. };
  49735. /**
  49736. * Parameters to perform the merge of bloom effect
  49737. */
  49738. bloom?: {
  49739. blurred: PostProcess;
  49740. weight: number;
  49741. };
  49742. }
  49743. /**
  49744. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  49745. */
  49746. export class DepthOfFieldMergePostProcess extends PostProcess {
  49747. private blurSteps;
  49748. /**
  49749. * Creates a new instance of DepthOfFieldMergePostProcess
  49750. * @param name The name of the effect.
  49751. * @param originalFromInput Post process which's input will be used for the merge.
  49752. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  49753. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  49754. * @param options The required width/height ratio to downsize to before computing the render pass.
  49755. * @param camera The camera to apply the render pass to.
  49756. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49757. * @param engine The engine which the post process will be applied. (default: current engine)
  49758. * @param reusable If the post process can be reused on the same frame. (default: false)
  49759. * @param textureType Type of textures used when performing the post process. (default: 0)
  49760. * @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)
  49761. */
  49762. 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);
  49763. /**
  49764. * Updates the effect with the current post process compile time values and recompiles the shader.
  49765. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  49766. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  49767. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  49768. * @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
  49769. * @param onCompiled Called when the shader has been compiled.
  49770. * @param onError Called if there is an error when compiling a shader.
  49771. */
  49772. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  49773. }
  49774. }
  49775. declare module BABYLON {
  49776. /**
  49777. * Specifies the level of max blur that should be applied when using the depth of field effect
  49778. */
  49779. export enum DepthOfFieldEffectBlurLevel {
  49780. /**
  49781. * Subtle blur
  49782. */
  49783. Low = 0,
  49784. /**
  49785. * Medium blur
  49786. */
  49787. Medium = 1,
  49788. /**
  49789. * Large blur
  49790. */
  49791. High = 2
  49792. }
  49793. /**
  49794. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  49795. */
  49796. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  49797. private _circleOfConfusion;
  49798. /**
  49799. * @hidden Internal, blurs from high to low
  49800. */
  49801. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  49802. private _depthOfFieldBlurY;
  49803. private _dofMerge;
  49804. /**
  49805. * @hidden Internal post processes in depth of field effect
  49806. */
  49807. _effects: Array<PostProcess>;
  49808. /**
  49809. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  49810. */
  49811. focalLength: number;
  49812. /**
  49813. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  49814. */
  49815. fStop: number;
  49816. /**
  49817. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  49818. */
  49819. focusDistance: number;
  49820. /**
  49821. * 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.
  49822. */
  49823. lensSize: number;
  49824. /**
  49825. * Creates a new instance DepthOfFieldEffect
  49826. * @param scene The scene the effect belongs to.
  49827. * @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.
  49828. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  49829. * @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)
  49830. */
  49831. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  49832. /**
  49833. * 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.
  49834. */
  49835. depthTexture: RenderTargetTexture;
  49836. /**
  49837. * Disposes each of the internal effects for a given camera.
  49838. * @param camera The camera to dispose the effect on.
  49839. */
  49840. disposeEffects(camera: Camera): void;
  49841. /**
  49842. * @hidden Internal
  49843. */
  49844. _updateEffects(): void;
  49845. /**
  49846. * Internal
  49847. * @returns if all the contained post processes are ready.
  49848. * @hidden
  49849. */
  49850. _isReady(): boolean;
  49851. }
  49852. }
  49853. declare module BABYLON {
  49854. /** @hidden */
  49855. export var displayPassPixelShader: {
  49856. name: string;
  49857. shader: string;
  49858. };
  49859. }
  49860. declare module BABYLON {
  49861. /**
  49862. * DisplayPassPostProcess which produces an output the same as it's input
  49863. */
  49864. export class DisplayPassPostProcess extends PostProcess {
  49865. /**
  49866. * Creates the DisplayPassPostProcess
  49867. * @param name The name of the effect.
  49868. * @param options The required width/height ratio to downsize to before computing the render pass.
  49869. * @param camera The camera to apply the render pass to.
  49870. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49871. * @param engine The engine which the post process will be applied. (default: current engine)
  49872. * @param reusable If the post process can be reused on the same frame. (default: false)
  49873. */
  49874. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49875. }
  49876. }
  49877. declare module BABYLON {
  49878. /** @hidden */
  49879. export var filterPixelShader: {
  49880. name: string;
  49881. shader: string;
  49882. };
  49883. }
  49884. declare module BABYLON {
  49885. /**
  49886. * Applies a kernel filter to the image
  49887. */
  49888. export class FilterPostProcess extends PostProcess {
  49889. /** The matrix to be applied to the image */
  49890. kernelMatrix: Matrix;
  49891. /**
  49892. *
  49893. * @param name The name of the effect.
  49894. * @param kernelMatrix The matrix to be applied to the image
  49895. * @param options The required width/height ratio to downsize to before computing the render pass.
  49896. * @param camera The camera to apply the render pass to.
  49897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49898. * @param engine The engine which the post process will be applied. (default: current engine)
  49899. * @param reusable If the post process can be reused on the same frame. (default: false)
  49900. */
  49901. constructor(name: string,
  49902. /** The matrix to be applied to the image */
  49903. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  49904. }
  49905. }
  49906. declare module BABYLON {
  49907. /** @hidden */
  49908. export var fxaaPixelShader: {
  49909. name: string;
  49910. shader: string;
  49911. };
  49912. }
  49913. declare module BABYLON {
  49914. /** @hidden */
  49915. export var fxaaVertexShader: {
  49916. name: string;
  49917. shader: string;
  49918. };
  49919. }
  49920. declare module BABYLON {
  49921. /**
  49922. * Fxaa post process
  49923. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  49924. */
  49925. export class FxaaPostProcess extends PostProcess {
  49926. /** @hidden */
  49927. texelWidth: number;
  49928. /** @hidden */
  49929. texelHeight: number;
  49930. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49931. private _getDefines;
  49932. }
  49933. }
  49934. declare module BABYLON {
  49935. /** @hidden */
  49936. export var grainPixelShader: {
  49937. name: string;
  49938. shader: string;
  49939. };
  49940. }
  49941. declare module BABYLON {
  49942. /**
  49943. * The GrainPostProcess adds noise to the image at mid luminance levels
  49944. */
  49945. export class GrainPostProcess extends PostProcess {
  49946. /**
  49947. * The intensity of the grain added (default: 30)
  49948. */
  49949. intensity: number;
  49950. /**
  49951. * If the grain should be randomized on every frame
  49952. */
  49953. animated: boolean;
  49954. /**
  49955. * Creates a new instance of @see GrainPostProcess
  49956. * @param name The name of the effect.
  49957. * @param options The required width/height ratio to downsize to before computing the render pass.
  49958. * @param camera The camera to apply the render pass to.
  49959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49960. * @param engine The engine which the post process will be applied. (default: current engine)
  49961. * @param reusable If the post process can be reused on the same frame. (default: false)
  49962. * @param textureType Type of textures used when performing the post process. (default: 0)
  49963. * @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)
  49964. */
  49965. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49966. }
  49967. }
  49968. declare module BABYLON {
  49969. /** @hidden */
  49970. export var highlightsPixelShader: {
  49971. name: string;
  49972. shader: string;
  49973. };
  49974. }
  49975. declare module BABYLON {
  49976. /**
  49977. * Extracts highlights from the image
  49978. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49979. */
  49980. export class HighlightsPostProcess extends PostProcess {
  49981. /**
  49982. * Extracts highlights from the image
  49983. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  49984. * @param name The name of the effect.
  49985. * @param options The required width/height ratio to downsize to before computing the render pass.
  49986. * @param camera The camera to apply the render pass to.
  49987. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49988. * @param engine The engine which the post process will be applied. (default: current engine)
  49989. * @param reusable If the post process can be reused on the same frame. (default: false)
  49990. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  49991. */
  49992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  49993. }
  49994. }
  49995. declare module BABYLON {
  49996. /** @hidden */
  49997. export var mrtFragmentDeclaration: {
  49998. name: string;
  49999. shader: string;
  50000. };
  50001. }
  50002. declare module BABYLON {
  50003. /** @hidden */
  50004. export var geometryPixelShader: {
  50005. name: string;
  50006. shader: string;
  50007. };
  50008. }
  50009. declare module BABYLON {
  50010. /** @hidden */
  50011. export var geometryVertexShader: {
  50012. name: string;
  50013. shader: string;
  50014. };
  50015. }
  50016. declare module BABYLON {
  50017. /**
  50018. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  50019. */
  50020. export class GeometryBufferRenderer {
  50021. /**
  50022. * Constant used to retrieve the position texture index in the G-Buffer textures array
  50023. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  50024. */
  50025. static readonly POSITION_TEXTURE_TYPE: number;
  50026. /**
  50027. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  50028. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  50029. */
  50030. static readonly VELOCITY_TEXTURE_TYPE: number;
  50031. /**
  50032. * Dictionary used to store the previous transformation matrices of each rendered mesh
  50033. * in order to compute objects velocities when enableVelocity is set to "true"
  50034. * @hidden
  50035. */
  50036. _previousTransformationMatrices: {
  50037. [index: number]: Matrix;
  50038. };
  50039. private _scene;
  50040. private _multiRenderTarget;
  50041. private _ratio;
  50042. private _enablePosition;
  50043. private _enableVelocity;
  50044. private _positionIndex;
  50045. private _velocityIndex;
  50046. protected _effect: Effect;
  50047. protected _cachedDefines: string;
  50048. /**
  50049. * Set the render list (meshes to be rendered) used in the G buffer.
  50050. */
  50051. renderList: Mesh[];
  50052. /**
  50053. * Gets wether or not G buffer are supported by the running hardware.
  50054. * This requires draw buffer supports
  50055. */
  50056. readonly isSupported: boolean;
  50057. /**
  50058. * Returns the index of the given texture type in the G-Buffer textures array
  50059. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  50060. * @returns the index of the given texture type in the G-Buffer textures array
  50061. */
  50062. getTextureIndex(textureType: number): number;
  50063. /**
  50064. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  50065. */
  50066. /**
  50067. * Sets whether or not objects positions are enabled for the G buffer.
  50068. */
  50069. enablePosition: boolean;
  50070. /**
  50071. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  50072. */
  50073. /**
  50074. * Sets wether or not objects velocities are enabled for the G buffer.
  50075. */
  50076. enableVelocity: boolean;
  50077. /**
  50078. * Gets the scene associated with the buffer.
  50079. */
  50080. readonly scene: Scene;
  50081. /**
  50082. * Gets the ratio used by the buffer during its creation.
  50083. * How big is the buffer related to the main canvas.
  50084. */
  50085. readonly ratio: number;
  50086. /** @hidden */
  50087. static _SceneComponentInitialization: (scene: Scene) => void;
  50088. /**
  50089. * Creates a new G Buffer for the scene
  50090. * @param scene The scene the buffer belongs to
  50091. * @param ratio How big is the buffer related to the main canvas.
  50092. */
  50093. constructor(scene: Scene, ratio?: number);
  50094. /**
  50095. * Checks wether everything is ready to render a submesh to the G buffer.
  50096. * @param subMesh the submesh to check readiness for
  50097. * @param useInstances is the mesh drawn using instance or not
  50098. * @returns true if ready otherwise false
  50099. */
  50100. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50101. /**
  50102. * Gets the current underlying G Buffer.
  50103. * @returns the buffer
  50104. */
  50105. getGBuffer(): MultiRenderTarget;
  50106. /**
  50107. * Gets the number of samples used to render the buffer (anti aliasing).
  50108. */
  50109. /**
  50110. * Sets the number of samples used to render the buffer (anti aliasing).
  50111. */
  50112. samples: number;
  50113. /**
  50114. * Disposes the renderer and frees up associated resources.
  50115. */
  50116. dispose(): void;
  50117. protected _createRenderTargets(): void;
  50118. }
  50119. }
  50120. declare module BABYLON {
  50121. /** @hidden */
  50122. export var motionBlurPixelShader: {
  50123. name: string;
  50124. shader: string;
  50125. };
  50126. }
  50127. declare module BABYLON {
  50128. /**
  50129. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  50130. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  50131. * As an example, all you have to do is to create the post-process:
  50132. * var mb = new BABYLON.MotionBlurPostProcess(
  50133. * 'mb', // The name of the effect.
  50134. * scene, // The scene containing the objects to blur according to their velocity.
  50135. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  50136. * camera // The camera to apply the render pass to.
  50137. * );
  50138. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  50139. */
  50140. export class MotionBlurPostProcess extends PostProcess {
  50141. /**
  50142. * Defines how much the image is blurred by the movement. Default value is equal to 1
  50143. */
  50144. motionStrength: number;
  50145. /**
  50146. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  50147. */
  50148. /**
  50149. * Sets the number of iterations to be used for motion blur quality
  50150. */
  50151. motionBlurSamples: number;
  50152. private _motionBlurSamples;
  50153. private _geometryBufferRenderer;
  50154. /**
  50155. * Creates a new instance MotionBlurPostProcess
  50156. * @param name The name of the effect.
  50157. * @param scene The scene containing the objects to blur according to their velocity.
  50158. * @param options The required width/height ratio to downsize to before computing the render pass.
  50159. * @param camera The camera to apply the render pass to.
  50160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50161. * @param engine The engine which the post process will be applied. (default: current engine)
  50162. * @param reusable If the post process can be reused on the same frame. (default: false)
  50163. * @param textureType Type of textures used when performing the post process. (default: 0)
  50164. * @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)
  50165. */
  50166. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50167. /**
  50168. * Disposes the post process.
  50169. * @param camera The camera to dispose the post process on.
  50170. */
  50171. dispose(camera?: Camera): void;
  50172. }
  50173. }
  50174. declare module BABYLON {
  50175. /** @hidden */
  50176. export var refractionPixelShader: {
  50177. name: string;
  50178. shader: string;
  50179. };
  50180. }
  50181. declare module BABYLON {
  50182. /**
  50183. * Post process which applies a refractin texture
  50184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50185. */
  50186. export class RefractionPostProcess extends PostProcess {
  50187. /** the base color of the refraction (used to taint the rendering) */
  50188. color: Color3;
  50189. /** simulated refraction depth */
  50190. depth: number;
  50191. /** the coefficient of the base color (0 to remove base color tainting) */
  50192. colorLevel: number;
  50193. private _refTexture;
  50194. private _ownRefractionTexture;
  50195. /**
  50196. * Gets or sets the refraction texture
  50197. * Please note that you are responsible for disposing the texture if you set it manually
  50198. */
  50199. refractionTexture: Texture;
  50200. /**
  50201. * Initializes the RefractionPostProcess
  50202. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  50203. * @param name The name of the effect.
  50204. * @param refractionTextureUrl Url of the refraction texture to use
  50205. * @param color the base color of the refraction (used to taint the rendering)
  50206. * @param depth simulated refraction depth
  50207. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  50208. * @param camera The camera to apply the render pass to.
  50209. * @param options The required width/height ratio to downsize to before computing the render pass.
  50210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50211. * @param engine The engine which the post process will be applied. (default: current engine)
  50212. * @param reusable If the post process can be reused on the same frame. (default: false)
  50213. */
  50214. constructor(name: string, refractionTextureUrl: string,
  50215. /** the base color of the refraction (used to taint the rendering) */
  50216. color: Color3,
  50217. /** simulated refraction depth */
  50218. depth: number,
  50219. /** the coefficient of the base color (0 to remove base color tainting) */
  50220. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50221. /**
  50222. * Disposes of the post process
  50223. * @param camera Camera to dispose post process on
  50224. */
  50225. dispose(camera: Camera): void;
  50226. }
  50227. }
  50228. declare module BABYLON {
  50229. /** @hidden */
  50230. export var sharpenPixelShader: {
  50231. name: string;
  50232. shader: string;
  50233. };
  50234. }
  50235. declare module BABYLON {
  50236. /**
  50237. * The SharpenPostProcess applies a sharpen kernel to every pixel
  50238. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  50239. */
  50240. export class SharpenPostProcess extends PostProcess {
  50241. /**
  50242. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  50243. */
  50244. colorAmount: number;
  50245. /**
  50246. * How much sharpness should be applied (default: 0.3)
  50247. */
  50248. edgeAmount: number;
  50249. /**
  50250. * Creates a new instance ConvolutionPostProcess
  50251. * @param name The name of the effect.
  50252. * @param options The required width/height ratio to downsize to before computing the render pass.
  50253. * @param camera The camera to apply the render pass to.
  50254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50255. * @param engine The engine which the post process will be applied. (default: current engine)
  50256. * @param reusable If the post process can be reused on the same frame. (default: false)
  50257. * @param textureType Type of textures used when performing the post process. (default: 0)
  50258. * @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)
  50259. */
  50260. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50261. }
  50262. }
  50263. declare module BABYLON {
  50264. /**
  50265. * PostProcessRenderPipeline
  50266. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50267. */
  50268. export class PostProcessRenderPipeline {
  50269. private engine;
  50270. private _renderEffects;
  50271. private _renderEffectsForIsolatedPass;
  50272. /**
  50273. * @hidden
  50274. */
  50275. protected _cameras: Camera[];
  50276. /** @hidden */
  50277. _name: string;
  50278. /**
  50279. * Gets pipeline name
  50280. */
  50281. readonly name: string;
  50282. /**
  50283. * Initializes a PostProcessRenderPipeline
  50284. * @param engine engine to add the pipeline to
  50285. * @param name name of the pipeline
  50286. */
  50287. constructor(engine: Engine, name: string);
  50288. /**
  50289. * Gets the class name
  50290. * @returns "PostProcessRenderPipeline"
  50291. */
  50292. getClassName(): string;
  50293. /**
  50294. * If all the render effects in the pipeline are supported
  50295. */
  50296. readonly isSupported: boolean;
  50297. /**
  50298. * Adds an effect to the pipeline
  50299. * @param renderEffect the effect to add
  50300. */
  50301. addEffect(renderEffect: PostProcessRenderEffect): void;
  50302. /** @hidden */
  50303. _rebuild(): void;
  50304. /** @hidden */
  50305. _enableEffect(renderEffectName: string, cameras: Camera): void;
  50306. /** @hidden */
  50307. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  50308. /** @hidden */
  50309. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50310. /** @hidden */
  50311. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  50312. /** @hidden */
  50313. _attachCameras(cameras: Camera, unique: boolean): void;
  50314. /** @hidden */
  50315. _attachCameras(cameras: Camera[], unique: boolean): void;
  50316. /** @hidden */
  50317. _detachCameras(cameras: Camera): void;
  50318. /** @hidden */
  50319. _detachCameras(cameras: Nullable<Camera[]>): void;
  50320. /** @hidden */
  50321. _update(): void;
  50322. /** @hidden */
  50323. _reset(): void;
  50324. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  50325. /**
  50326. * Disposes of the pipeline
  50327. */
  50328. dispose(): void;
  50329. }
  50330. }
  50331. declare module BABYLON {
  50332. /**
  50333. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  50334. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  50335. */
  50336. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50337. private _scene;
  50338. private _camerasToBeAttached;
  50339. /**
  50340. * ID of the sharpen post process,
  50341. */
  50342. private readonly SharpenPostProcessId;
  50343. /**
  50344. * @ignore
  50345. * ID of the image processing post process;
  50346. */
  50347. readonly ImageProcessingPostProcessId: string;
  50348. /**
  50349. * @ignore
  50350. * ID of the Fast Approximate Anti-Aliasing post process;
  50351. */
  50352. readonly FxaaPostProcessId: string;
  50353. /**
  50354. * ID of the chromatic aberration post process,
  50355. */
  50356. private readonly ChromaticAberrationPostProcessId;
  50357. /**
  50358. * ID of the grain post process
  50359. */
  50360. private readonly GrainPostProcessId;
  50361. /**
  50362. * Sharpen post process which will apply a sharpen convolution to enhance edges
  50363. */
  50364. sharpen: SharpenPostProcess;
  50365. private _sharpenEffect;
  50366. private bloom;
  50367. /**
  50368. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  50369. */
  50370. depthOfField: DepthOfFieldEffect;
  50371. /**
  50372. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50373. */
  50374. fxaa: FxaaPostProcess;
  50375. /**
  50376. * Image post processing pass used to perform operations such as tone mapping or color grading.
  50377. */
  50378. imageProcessing: ImageProcessingPostProcess;
  50379. /**
  50380. * Chromatic aberration post process which will shift rgb colors in the image
  50381. */
  50382. chromaticAberration: ChromaticAberrationPostProcess;
  50383. private _chromaticAberrationEffect;
  50384. /**
  50385. * Grain post process which add noise to the image
  50386. */
  50387. grain: GrainPostProcess;
  50388. private _grainEffect;
  50389. /**
  50390. * Glow post process which adds a glow to emissive areas of the image
  50391. */
  50392. private _glowLayer;
  50393. /**
  50394. * Animations which can be used to tweak settings over a period of time
  50395. */
  50396. animations: Animation[];
  50397. private _imageProcessingConfigurationObserver;
  50398. private _sharpenEnabled;
  50399. private _bloomEnabled;
  50400. private _depthOfFieldEnabled;
  50401. private _depthOfFieldBlurLevel;
  50402. private _fxaaEnabled;
  50403. private _imageProcessingEnabled;
  50404. private _defaultPipelineTextureType;
  50405. private _bloomScale;
  50406. private _chromaticAberrationEnabled;
  50407. private _grainEnabled;
  50408. private _buildAllowed;
  50409. /**
  50410. * Gets active scene
  50411. */
  50412. readonly scene: Scene;
  50413. /**
  50414. * Enable or disable the sharpen process from the pipeline
  50415. */
  50416. sharpenEnabled: boolean;
  50417. private _resizeObserver;
  50418. private _hardwareScaleLevel;
  50419. private _bloomKernel;
  50420. /**
  50421. * Specifies the size of the bloom blur kernel, relative to the final output size
  50422. */
  50423. bloomKernel: number;
  50424. /**
  50425. * Specifies the weight of the bloom in the final rendering
  50426. */
  50427. private _bloomWeight;
  50428. /**
  50429. * Specifies the luma threshold for the area that will be blurred by the bloom
  50430. */
  50431. private _bloomThreshold;
  50432. private _hdr;
  50433. /**
  50434. * The strength of the bloom.
  50435. */
  50436. bloomWeight: number;
  50437. /**
  50438. * The strength of the bloom.
  50439. */
  50440. bloomThreshold: number;
  50441. /**
  50442. * The scale of the bloom, lower value will provide better performance.
  50443. */
  50444. bloomScale: number;
  50445. /**
  50446. * Enable or disable the bloom from the pipeline
  50447. */
  50448. bloomEnabled: boolean;
  50449. private _rebuildBloom;
  50450. /**
  50451. * If the depth of field is enabled.
  50452. */
  50453. depthOfFieldEnabled: boolean;
  50454. /**
  50455. * Blur level of the depth of field effect. (Higher blur will effect performance)
  50456. */
  50457. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  50458. /**
  50459. * If the anti aliasing is enabled.
  50460. */
  50461. fxaaEnabled: boolean;
  50462. private _samples;
  50463. /**
  50464. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50465. */
  50466. samples: number;
  50467. /**
  50468. * If image processing is enabled.
  50469. */
  50470. imageProcessingEnabled: boolean;
  50471. /**
  50472. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  50473. */
  50474. glowLayerEnabled: boolean;
  50475. /**
  50476. * Enable or disable the chromaticAberration process from the pipeline
  50477. */
  50478. chromaticAberrationEnabled: boolean;
  50479. /**
  50480. * Enable or disable the grain process from the pipeline
  50481. */
  50482. grainEnabled: boolean;
  50483. /**
  50484. * @constructor
  50485. * @param name - The rendering pipeline name (default: "")
  50486. * @param hdr - If high dynamic range textures should be used (default: true)
  50487. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50488. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50489. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50490. */
  50491. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50492. /**
  50493. * Get the class name
  50494. * @returns "DefaultRenderingPipeline"
  50495. */
  50496. getClassName(): string;
  50497. /**
  50498. * Force the compilation of the entire pipeline.
  50499. */
  50500. prepare(): void;
  50501. private _hasCleared;
  50502. private _prevPostProcess;
  50503. private _prevPrevPostProcess;
  50504. private _setAutoClearAndTextureSharing;
  50505. private _depthOfFieldSceneObserver;
  50506. private _buildPipeline;
  50507. private _disposePostProcesses;
  50508. /**
  50509. * Adds a camera to the pipeline
  50510. * @param camera the camera to be added
  50511. */
  50512. addCamera(camera: Camera): void;
  50513. /**
  50514. * Removes a camera from the pipeline
  50515. * @param camera the camera to remove
  50516. */
  50517. removeCamera(camera: Camera): void;
  50518. /**
  50519. * Dispose of the pipeline and stop all post processes
  50520. */
  50521. dispose(): void;
  50522. /**
  50523. * Serialize the rendering pipeline (Used when exporting)
  50524. * @returns the serialized object
  50525. */
  50526. serialize(): any;
  50527. /**
  50528. * Parse the serialized pipeline
  50529. * @param source Source pipeline.
  50530. * @param scene The scene to load the pipeline to.
  50531. * @param rootUrl The URL of the serialized pipeline.
  50532. * @returns An instantiated pipeline from the serialized object.
  50533. */
  50534. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50535. }
  50536. }
  50537. declare module BABYLON {
  50538. /** @hidden */
  50539. export var lensHighlightsPixelShader: {
  50540. name: string;
  50541. shader: string;
  50542. };
  50543. }
  50544. declare module BABYLON {
  50545. /** @hidden */
  50546. export var depthOfFieldPixelShader: {
  50547. name: string;
  50548. shader: string;
  50549. };
  50550. }
  50551. declare module BABYLON {
  50552. /**
  50553. * BABYLON.JS Chromatic Aberration GLSL Shader
  50554. * Author: Olivier Guyot
  50555. * Separates very slightly R, G and B colors on the edges of the screen
  50556. * Inspired by Francois Tarlier & Martins Upitis
  50557. */
  50558. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  50559. /**
  50560. * @ignore
  50561. * The chromatic aberration PostProcess id in the pipeline
  50562. */
  50563. LensChromaticAberrationEffect: string;
  50564. /**
  50565. * @ignore
  50566. * The highlights enhancing PostProcess id in the pipeline
  50567. */
  50568. HighlightsEnhancingEffect: string;
  50569. /**
  50570. * @ignore
  50571. * The depth-of-field PostProcess id in the pipeline
  50572. */
  50573. LensDepthOfFieldEffect: string;
  50574. private _scene;
  50575. private _depthTexture;
  50576. private _grainTexture;
  50577. private _chromaticAberrationPostProcess;
  50578. private _highlightsPostProcess;
  50579. private _depthOfFieldPostProcess;
  50580. private _edgeBlur;
  50581. private _grainAmount;
  50582. private _chromaticAberration;
  50583. private _distortion;
  50584. private _highlightsGain;
  50585. private _highlightsThreshold;
  50586. private _dofDistance;
  50587. private _dofAperture;
  50588. private _dofDarken;
  50589. private _dofPentagon;
  50590. private _blurNoise;
  50591. /**
  50592. * @constructor
  50593. *
  50594. * Effect parameters are as follow:
  50595. * {
  50596. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50597. * edge_blur: number; // from 0 to x (1 for realism)
  50598. * distortion: number; // from 0 to x (1 for realism)
  50599. * grain_amount: number; // from 0 to 1
  50600. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50601. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50602. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50603. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50604. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50605. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50606. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50607. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50608. * }
  50609. * Note: if an effect parameter is unset, effect is disabled
  50610. *
  50611. * @param name The rendering pipeline name
  50612. * @param parameters - An object containing all parameters (see above)
  50613. * @param scene The scene linked to this pipeline
  50614. * @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)
  50615. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50616. */
  50617. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50618. /**
  50619. * Sets the amount of blur at the edges
  50620. * @param amount blur amount
  50621. */
  50622. setEdgeBlur(amount: number): void;
  50623. /**
  50624. * Sets edge blur to 0
  50625. */
  50626. disableEdgeBlur(): void;
  50627. /**
  50628. * Sets the amout of grain
  50629. * @param amount Amount of grain
  50630. */
  50631. setGrainAmount(amount: number): void;
  50632. /**
  50633. * Set grain amount to 0
  50634. */
  50635. disableGrain(): void;
  50636. /**
  50637. * Sets the chromatic aberration amount
  50638. * @param amount amount of chromatic aberration
  50639. */
  50640. setChromaticAberration(amount: number): void;
  50641. /**
  50642. * Sets chromatic aberration amount to 0
  50643. */
  50644. disableChromaticAberration(): void;
  50645. /**
  50646. * Sets the EdgeDistortion amount
  50647. * @param amount amount of EdgeDistortion
  50648. */
  50649. setEdgeDistortion(amount: number): void;
  50650. /**
  50651. * Sets edge distortion to 0
  50652. */
  50653. disableEdgeDistortion(): void;
  50654. /**
  50655. * Sets the FocusDistance amount
  50656. * @param amount amount of FocusDistance
  50657. */
  50658. setFocusDistance(amount: number): void;
  50659. /**
  50660. * Disables depth of field
  50661. */
  50662. disableDepthOfField(): void;
  50663. /**
  50664. * Sets the Aperture amount
  50665. * @param amount amount of Aperture
  50666. */
  50667. setAperture(amount: number): void;
  50668. /**
  50669. * Sets the DarkenOutOfFocus amount
  50670. * @param amount amount of DarkenOutOfFocus
  50671. */
  50672. setDarkenOutOfFocus(amount: number): void;
  50673. /**
  50674. * Creates a pentagon bokeh effect
  50675. */
  50676. enablePentagonBokeh(): void;
  50677. /**
  50678. * Disables the pentagon bokeh effect
  50679. */
  50680. disablePentagonBokeh(): void;
  50681. /**
  50682. * Enables noise blur
  50683. */
  50684. enableNoiseBlur(): void;
  50685. /**
  50686. * Disables noise blur
  50687. */
  50688. disableNoiseBlur(): void;
  50689. /**
  50690. * Sets the HighlightsGain amount
  50691. * @param amount amount of HighlightsGain
  50692. */
  50693. setHighlightsGain(amount: number): void;
  50694. /**
  50695. * Sets the HighlightsThreshold amount
  50696. * @param amount amount of HighlightsThreshold
  50697. */
  50698. setHighlightsThreshold(amount: number): void;
  50699. /**
  50700. * Disables highlights
  50701. */
  50702. disableHighlights(): void;
  50703. /**
  50704. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50705. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50706. */
  50707. dispose(disableDepthRender?: boolean): void;
  50708. private _createChromaticAberrationPostProcess;
  50709. private _createHighlightsPostProcess;
  50710. private _createDepthOfFieldPostProcess;
  50711. private _createGrainTexture;
  50712. }
  50713. }
  50714. declare module BABYLON {
  50715. /** @hidden */
  50716. export var ssao2PixelShader: {
  50717. name: string;
  50718. shader: string;
  50719. };
  50720. }
  50721. declare module BABYLON {
  50722. /** @hidden */
  50723. export var ssaoCombinePixelShader: {
  50724. name: string;
  50725. shader: string;
  50726. };
  50727. }
  50728. declare module BABYLON {
  50729. /**
  50730. * Render pipeline to produce ssao effect
  50731. */
  50732. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50733. /**
  50734. * @ignore
  50735. * The PassPostProcess id in the pipeline that contains the original scene color
  50736. */
  50737. SSAOOriginalSceneColorEffect: string;
  50738. /**
  50739. * @ignore
  50740. * The SSAO PostProcess id in the pipeline
  50741. */
  50742. SSAORenderEffect: string;
  50743. /**
  50744. * @ignore
  50745. * The horizontal blur PostProcess id in the pipeline
  50746. */
  50747. SSAOBlurHRenderEffect: string;
  50748. /**
  50749. * @ignore
  50750. * The vertical blur PostProcess id in the pipeline
  50751. */
  50752. SSAOBlurVRenderEffect: string;
  50753. /**
  50754. * @ignore
  50755. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50756. */
  50757. SSAOCombineRenderEffect: string;
  50758. /**
  50759. * The output strength of the SSAO post-process. Default value is 1.0.
  50760. */
  50761. totalStrength: number;
  50762. /**
  50763. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50764. */
  50765. maxZ: number;
  50766. /**
  50767. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50768. */
  50769. minZAspect: number;
  50770. private _samples;
  50771. /**
  50772. * Number of samples used for the SSAO calculations. Default value is 8
  50773. */
  50774. samples: number;
  50775. private _textureSamples;
  50776. /**
  50777. * Number of samples to use for antialiasing
  50778. */
  50779. textureSamples: number;
  50780. /**
  50781. * Ratio object used for SSAO ratio and blur ratio
  50782. */
  50783. private _ratio;
  50784. /**
  50785. * Dynamically generated sphere sampler.
  50786. */
  50787. private _sampleSphere;
  50788. /**
  50789. * Blur filter offsets
  50790. */
  50791. private _samplerOffsets;
  50792. private _expensiveBlur;
  50793. /**
  50794. * If bilateral blur should be used
  50795. */
  50796. expensiveBlur: boolean;
  50797. /**
  50798. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50799. */
  50800. radius: number;
  50801. /**
  50802. * The base color of the SSAO post-process
  50803. * The final result is "base + ssao" between [0, 1]
  50804. */
  50805. base: number;
  50806. /**
  50807. * Support test.
  50808. */
  50809. static readonly IsSupported: boolean;
  50810. private _scene;
  50811. private _depthTexture;
  50812. private _normalTexture;
  50813. private _randomTexture;
  50814. private _originalColorPostProcess;
  50815. private _ssaoPostProcess;
  50816. private _blurHPostProcess;
  50817. private _blurVPostProcess;
  50818. private _ssaoCombinePostProcess;
  50819. private _firstUpdate;
  50820. /**
  50821. * Gets active scene
  50822. */
  50823. readonly scene: Scene;
  50824. /**
  50825. * @constructor
  50826. * @param name The rendering pipeline name
  50827. * @param scene The scene linked to this pipeline
  50828. * @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 }
  50829. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50830. */
  50831. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50832. /**
  50833. * Get the class name
  50834. * @returns "SSAO2RenderingPipeline"
  50835. */
  50836. getClassName(): string;
  50837. /**
  50838. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50839. */
  50840. dispose(disableGeometryBufferRenderer?: boolean): void;
  50841. private _createBlurPostProcess;
  50842. /** @hidden */
  50843. _rebuild(): void;
  50844. private _bits;
  50845. private _radicalInverse_VdC;
  50846. private _hammersley;
  50847. private _hemisphereSample_uniform;
  50848. private _generateHemisphere;
  50849. private _createSSAOPostProcess;
  50850. private _createSSAOCombinePostProcess;
  50851. private _createRandomTexture;
  50852. /**
  50853. * Serialize the rendering pipeline (Used when exporting)
  50854. * @returns the serialized object
  50855. */
  50856. serialize(): any;
  50857. /**
  50858. * Parse the serialized pipeline
  50859. * @param source Source pipeline.
  50860. * @param scene The scene to load the pipeline to.
  50861. * @param rootUrl The URL of the serialized pipeline.
  50862. * @returns An instantiated pipeline from the serialized object.
  50863. */
  50864. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50865. }
  50866. }
  50867. declare module BABYLON {
  50868. /** @hidden */
  50869. export var ssaoPixelShader: {
  50870. name: string;
  50871. shader: string;
  50872. };
  50873. }
  50874. declare module BABYLON {
  50875. /**
  50876. * Render pipeline to produce ssao effect
  50877. */
  50878. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50879. /**
  50880. * @ignore
  50881. * The PassPostProcess id in the pipeline that contains the original scene color
  50882. */
  50883. SSAOOriginalSceneColorEffect: string;
  50884. /**
  50885. * @ignore
  50886. * The SSAO PostProcess id in the pipeline
  50887. */
  50888. SSAORenderEffect: string;
  50889. /**
  50890. * @ignore
  50891. * The horizontal blur PostProcess id in the pipeline
  50892. */
  50893. SSAOBlurHRenderEffect: string;
  50894. /**
  50895. * @ignore
  50896. * The vertical blur PostProcess id in the pipeline
  50897. */
  50898. SSAOBlurVRenderEffect: string;
  50899. /**
  50900. * @ignore
  50901. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50902. */
  50903. SSAOCombineRenderEffect: string;
  50904. /**
  50905. * The output strength of the SSAO post-process. Default value is 1.0.
  50906. */
  50907. totalStrength: number;
  50908. /**
  50909. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50910. */
  50911. radius: number;
  50912. /**
  50913. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50914. * Must not be equal to fallOff and superior to fallOff.
  50915. * Default value is 0.0075
  50916. */
  50917. area: number;
  50918. /**
  50919. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50920. * Must not be equal to area and inferior to area.
  50921. * Default value is 0.000001
  50922. */
  50923. fallOff: number;
  50924. /**
  50925. * The base color of the SSAO post-process
  50926. * The final result is "base + ssao" between [0, 1]
  50927. */
  50928. base: number;
  50929. private _scene;
  50930. private _depthTexture;
  50931. private _randomTexture;
  50932. private _originalColorPostProcess;
  50933. private _ssaoPostProcess;
  50934. private _blurHPostProcess;
  50935. private _blurVPostProcess;
  50936. private _ssaoCombinePostProcess;
  50937. private _firstUpdate;
  50938. /**
  50939. * Gets active scene
  50940. */
  50941. readonly scene: Scene;
  50942. /**
  50943. * @constructor
  50944. * @param name - The rendering pipeline name
  50945. * @param scene - The scene linked to this pipeline
  50946. * @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 }
  50947. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50948. */
  50949. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50950. /**
  50951. * Get the class name
  50952. * @returns "SSAORenderingPipeline"
  50953. */
  50954. getClassName(): string;
  50955. /**
  50956. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50957. */
  50958. dispose(disableDepthRender?: boolean): void;
  50959. private _createBlurPostProcess;
  50960. /** @hidden */
  50961. _rebuild(): void;
  50962. private _createSSAOPostProcess;
  50963. private _createSSAOCombinePostProcess;
  50964. private _createRandomTexture;
  50965. }
  50966. }
  50967. declare module BABYLON {
  50968. /** @hidden */
  50969. export var standardPixelShader: {
  50970. name: string;
  50971. shader: string;
  50972. };
  50973. }
  50974. declare module BABYLON {
  50975. /**
  50976. * Standard rendering pipeline
  50977. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50978. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50979. */
  50980. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50981. /**
  50982. * Public members
  50983. */
  50984. /**
  50985. * Post-process which contains the original scene color before the pipeline applies all the effects
  50986. */
  50987. originalPostProcess: Nullable<PostProcess>;
  50988. /**
  50989. * Post-process used to down scale an image x4
  50990. */
  50991. downSampleX4PostProcess: Nullable<PostProcess>;
  50992. /**
  50993. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50994. */
  50995. brightPassPostProcess: Nullable<PostProcess>;
  50996. /**
  50997. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50998. */
  50999. blurHPostProcesses: PostProcess[];
  51000. /**
  51001. * Post-process array storing all the vertical blur post-processes used by the pipeline
  51002. */
  51003. blurVPostProcesses: PostProcess[];
  51004. /**
  51005. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  51006. */
  51007. textureAdderPostProcess: Nullable<PostProcess>;
  51008. /**
  51009. * Post-process used to create volumetric lighting effect
  51010. */
  51011. volumetricLightPostProcess: Nullable<PostProcess>;
  51012. /**
  51013. * Post-process used to smooth the previous volumetric light post-process on the X axis
  51014. */
  51015. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  51016. /**
  51017. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  51018. */
  51019. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  51020. /**
  51021. * Post-process used to merge the volumetric light effect and the real scene color
  51022. */
  51023. volumetricLightMergePostProces: Nullable<PostProcess>;
  51024. /**
  51025. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  51026. */
  51027. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  51028. /**
  51029. * Base post-process used to calculate the average luminance of the final image for HDR
  51030. */
  51031. luminancePostProcess: Nullable<PostProcess>;
  51032. /**
  51033. * Post-processes used to create down sample post-processes in order to get
  51034. * the average luminance of the final image for HDR
  51035. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  51036. */
  51037. luminanceDownSamplePostProcesses: PostProcess[];
  51038. /**
  51039. * Post-process used to create a HDR effect (light adaptation)
  51040. */
  51041. hdrPostProcess: Nullable<PostProcess>;
  51042. /**
  51043. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  51044. */
  51045. textureAdderFinalPostProcess: Nullable<PostProcess>;
  51046. /**
  51047. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  51048. */
  51049. lensFlareFinalPostProcess: Nullable<PostProcess>;
  51050. /**
  51051. * Post-process used to merge the final HDR post-process and the real scene color
  51052. */
  51053. hdrFinalPostProcess: Nullable<PostProcess>;
  51054. /**
  51055. * Post-process used to create a lens flare effect
  51056. */
  51057. lensFlarePostProcess: Nullable<PostProcess>;
  51058. /**
  51059. * Post-process that merges the result of the lens flare post-process and the real scene color
  51060. */
  51061. lensFlareComposePostProcess: Nullable<PostProcess>;
  51062. /**
  51063. * Post-process used to create a motion blur effect
  51064. */
  51065. motionBlurPostProcess: Nullable<PostProcess>;
  51066. /**
  51067. * Post-process used to create a depth of field effect
  51068. */
  51069. depthOfFieldPostProcess: Nullable<PostProcess>;
  51070. /**
  51071. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  51072. */
  51073. fxaaPostProcess: Nullable<FxaaPostProcess>;
  51074. /**
  51075. * Represents the brightness threshold in order to configure the illuminated surfaces
  51076. */
  51077. brightThreshold: number;
  51078. /**
  51079. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  51080. */
  51081. blurWidth: number;
  51082. /**
  51083. * Sets if the blur for highlighted surfaces must be only horizontal
  51084. */
  51085. horizontalBlur: boolean;
  51086. /**
  51087. * Sets the overall exposure used by the pipeline
  51088. */
  51089. exposure: number;
  51090. /**
  51091. * Texture used typically to simulate "dirty" on camera lens
  51092. */
  51093. lensTexture: Nullable<Texture>;
  51094. /**
  51095. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  51096. */
  51097. volumetricLightCoefficient: number;
  51098. /**
  51099. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  51100. */
  51101. volumetricLightPower: number;
  51102. /**
  51103. * Used the set the blur intensity to smooth the volumetric lights
  51104. */
  51105. volumetricLightBlurScale: number;
  51106. /**
  51107. * Light (spot or directional) used to generate the volumetric lights rays
  51108. * The source light must have a shadow generate so the pipeline can get its
  51109. * depth map
  51110. */
  51111. sourceLight: Nullable<SpotLight | DirectionalLight>;
  51112. /**
  51113. * For eye adaptation, represents the minimum luminance the eye can see
  51114. */
  51115. hdrMinimumLuminance: number;
  51116. /**
  51117. * For eye adaptation, represents the decrease luminance speed
  51118. */
  51119. hdrDecreaseRate: number;
  51120. /**
  51121. * For eye adaptation, represents the increase luminance speed
  51122. */
  51123. hdrIncreaseRate: number;
  51124. /**
  51125. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  51126. */
  51127. lensColorTexture: Nullable<Texture>;
  51128. /**
  51129. * The overall strengh for the lens flare effect
  51130. */
  51131. lensFlareStrength: number;
  51132. /**
  51133. * Dispersion coefficient for lens flare ghosts
  51134. */
  51135. lensFlareGhostDispersal: number;
  51136. /**
  51137. * Main lens flare halo width
  51138. */
  51139. lensFlareHaloWidth: number;
  51140. /**
  51141. * Based on the lens distortion effect, defines how much the lens flare result
  51142. * is distorted
  51143. */
  51144. lensFlareDistortionStrength: number;
  51145. /**
  51146. * Lens star texture must be used to simulate rays on the flares and is available
  51147. * in the documentation
  51148. */
  51149. lensStarTexture: Nullable<Texture>;
  51150. /**
  51151. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  51152. * flare effect by taking account of the dirt texture
  51153. */
  51154. lensFlareDirtTexture: Nullable<Texture>;
  51155. /**
  51156. * Represents the focal length for the depth of field effect
  51157. */
  51158. depthOfFieldDistance: number;
  51159. /**
  51160. * Represents the blur intensity for the blurred part of the depth of field effect
  51161. */
  51162. depthOfFieldBlurWidth: number;
  51163. /**
  51164. * For motion blur, defines how much the image is blurred by the movement
  51165. */
  51166. motionStrength: number;
  51167. /**
  51168. * List of animations for the pipeline (IAnimatable implementation)
  51169. */
  51170. animations: Animation[];
  51171. /**
  51172. * Private members
  51173. */
  51174. private _scene;
  51175. private _currentDepthOfFieldSource;
  51176. private _basePostProcess;
  51177. private _hdrCurrentLuminance;
  51178. private _floatTextureType;
  51179. private _ratio;
  51180. private _bloomEnabled;
  51181. private _depthOfFieldEnabled;
  51182. private _vlsEnabled;
  51183. private _lensFlareEnabled;
  51184. private _hdrEnabled;
  51185. private _motionBlurEnabled;
  51186. private _fxaaEnabled;
  51187. private _motionBlurSamples;
  51188. private _volumetricLightStepsCount;
  51189. private _samples;
  51190. /**
  51191. * @ignore
  51192. * Specifies if the bloom pipeline is enabled
  51193. */
  51194. BloomEnabled: boolean;
  51195. /**
  51196. * @ignore
  51197. * Specifies if the depth of field pipeline is enabed
  51198. */
  51199. DepthOfFieldEnabled: boolean;
  51200. /**
  51201. * @ignore
  51202. * Specifies if the lens flare pipeline is enabed
  51203. */
  51204. LensFlareEnabled: boolean;
  51205. /**
  51206. * @ignore
  51207. * Specifies if the HDR pipeline is enabled
  51208. */
  51209. HDREnabled: boolean;
  51210. /**
  51211. * @ignore
  51212. * Specifies if the volumetric lights scattering effect is enabled
  51213. */
  51214. VLSEnabled: boolean;
  51215. /**
  51216. * @ignore
  51217. * Specifies if the motion blur effect is enabled
  51218. */
  51219. MotionBlurEnabled: boolean;
  51220. /**
  51221. * Specifies if anti-aliasing is enabled
  51222. */
  51223. fxaaEnabled: boolean;
  51224. /**
  51225. * Specifies the number of steps used to calculate the volumetric lights
  51226. * Typically in interval [50, 200]
  51227. */
  51228. volumetricLightStepsCount: number;
  51229. /**
  51230. * Specifies the number of samples used for the motion blur effect
  51231. * Typically in interval [16, 64]
  51232. */
  51233. motionBlurSamples: number;
  51234. /**
  51235. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  51236. */
  51237. samples: number;
  51238. /**
  51239. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  51240. * @constructor
  51241. * @param name The rendering pipeline name
  51242. * @param scene The scene linked to this pipeline
  51243. * @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)
  51244. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  51245. * @param cameras The array of cameras that the rendering pipeline will be attached to
  51246. */
  51247. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  51248. private _buildPipeline;
  51249. private _createDownSampleX4PostProcess;
  51250. private _createBrightPassPostProcess;
  51251. private _createBlurPostProcesses;
  51252. private _createTextureAdderPostProcess;
  51253. private _createVolumetricLightPostProcess;
  51254. private _createLuminancePostProcesses;
  51255. private _createHdrPostProcess;
  51256. private _createLensFlarePostProcess;
  51257. private _createDepthOfFieldPostProcess;
  51258. private _createMotionBlurPostProcess;
  51259. private _getDepthTexture;
  51260. private _disposePostProcesses;
  51261. /**
  51262. * Dispose of the pipeline and stop all post processes
  51263. */
  51264. dispose(): void;
  51265. /**
  51266. * Serialize the rendering pipeline (Used when exporting)
  51267. * @returns the serialized object
  51268. */
  51269. serialize(): any;
  51270. /**
  51271. * Parse the serialized pipeline
  51272. * @param source Source pipeline.
  51273. * @param scene The scene to load the pipeline to.
  51274. * @param rootUrl The URL of the serialized pipeline.
  51275. * @returns An instantiated pipeline from the serialized object.
  51276. */
  51277. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  51278. /**
  51279. * Luminance steps
  51280. */
  51281. static LuminanceSteps: number;
  51282. }
  51283. }
  51284. declare module BABYLON {
  51285. /**
  51286. * PostProcessRenderPipelineManager class
  51287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51288. */
  51289. export class PostProcessRenderPipelineManager {
  51290. private _renderPipelines;
  51291. /**
  51292. * Initializes a PostProcessRenderPipelineManager
  51293. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51294. */
  51295. constructor();
  51296. /**
  51297. * Gets the list of supported render pipelines
  51298. */
  51299. readonly supportedPipelines: PostProcessRenderPipeline[];
  51300. /**
  51301. * Adds a pipeline to the manager
  51302. * @param renderPipeline The pipeline to add
  51303. */
  51304. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  51305. /**
  51306. * Attaches a camera to the pipeline
  51307. * @param renderPipelineName The name of the pipeline to attach to
  51308. * @param cameras the camera to attach
  51309. * @param unique if the camera can be attached multiple times to the pipeline
  51310. */
  51311. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  51312. /**
  51313. * Detaches a camera from the pipeline
  51314. * @param renderPipelineName The name of the pipeline to detach from
  51315. * @param cameras the camera to detach
  51316. */
  51317. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  51318. /**
  51319. * Enables an effect by name on a pipeline
  51320. * @param renderPipelineName the name of the pipeline to enable the effect in
  51321. * @param renderEffectName the name of the effect to enable
  51322. * @param cameras the cameras that the effect should be enabled on
  51323. */
  51324. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51325. /**
  51326. * Disables an effect by name on a pipeline
  51327. * @param renderPipelineName the name of the pipeline to disable the effect in
  51328. * @param renderEffectName the name of the effect to disable
  51329. * @param cameras the cameras that the effect should be disabled on
  51330. */
  51331. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51332. /**
  51333. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  51334. */
  51335. update(): void;
  51336. /** @hidden */
  51337. _rebuild(): void;
  51338. /**
  51339. * Disposes of the manager and pipelines
  51340. */
  51341. dispose(): void;
  51342. }
  51343. }
  51344. declare module BABYLON {
  51345. interface Scene {
  51346. /** @hidden (Backing field) */
  51347. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51348. /**
  51349. * Gets the postprocess render pipeline manager
  51350. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51351. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  51352. */
  51353. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51354. }
  51355. /**
  51356. * Defines the Render Pipeline scene component responsible to rendering pipelines
  51357. */
  51358. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  51359. /**
  51360. * The component name helpfull to identify the component in the list of scene components.
  51361. */
  51362. readonly name: string;
  51363. /**
  51364. * The scene the component belongs to.
  51365. */
  51366. scene: Scene;
  51367. /**
  51368. * Creates a new instance of the component for the given scene
  51369. * @param scene Defines the scene to register the component in
  51370. */
  51371. constructor(scene: Scene);
  51372. /**
  51373. * Registers the component in a given scene
  51374. */
  51375. register(): void;
  51376. /**
  51377. * Rebuilds the elements related to this component in case of
  51378. * context lost for instance.
  51379. */
  51380. rebuild(): void;
  51381. /**
  51382. * Disposes the component and the associated ressources
  51383. */
  51384. dispose(): void;
  51385. private _gatherRenderTargets;
  51386. }
  51387. }
  51388. declare module BABYLON {
  51389. /** @hidden */
  51390. export var tonemapPixelShader: {
  51391. name: string;
  51392. shader: string;
  51393. };
  51394. }
  51395. declare module BABYLON {
  51396. /** Defines operator used for tonemapping */
  51397. export enum TonemappingOperator {
  51398. /** Hable */
  51399. Hable = 0,
  51400. /** Reinhard */
  51401. Reinhard = 1,
  51402. /** HejiDawson */
  51403. HejiDawson = 2,
  51404. /** Photographic */
  51405. Photographic = 3
  51406. }
  51407. /**
  51408. * Defines a post process to apply tone mapping
  51409. */
  51410. export class TonemapPostProcess extends PostProcess {
  51411. private _operator;
  51412. /** Defines the required exposure adjustement */
  51413. exposureAdjustment: number;
  51414. /**
  51415. * Creates a new TonemapPostProcess
  51416. * @param name defines the name of the postprocess
  51417. * @param _operator defines the operator to use
  51418. * @param exposureAdjustment defines the required exposure adjustement
  51419. * @param camera defines the camera to use (can be null)
  51420. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  51421. * @param engine defines the hosting engine (can be ignore if camera is set)
  51422. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51423. */
  51424. constructor(name: string, _operator: TonemappingOperator,
  51425. /** Defines the required exposure adjustement */
  51426. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  51427. }
  51428. }
  51429. declare module BABYLON {
  51430. /** @hidden */
  51431. export var depthVertexShader: {
  51432. name: string;
  51433. shader: string;
  51434. };
  51435. }
  51436. declare module BABYLON {
  51437. /** @hidden */
  51438. export var volumetricLightScatteringPixelShader: {
  51439. name: string;
  51440. shader: string;
  51441. };
  51442. }
  51443. declare module BABYLON {
  51444. /** @hidden */
  51445. export var volumetricLightScatteringPassPixelShader: {
  51446. name: string;
  51447. shader: string;
  51448. };
  51449. }
  51450. declare module BABYLON {
  51451. /**
  51452. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  51453. */
  51454. export class VolumetricLightScatteringPostProcess extends PostProcess {
  51455. private _volumetricLightScatteringPass;
  51456. private _volumetricLightScatteringRTT;
  51457. private _viewPort;
  51458. private _screenCoordinates;
  51459. private _cachedDefines;
  51460. /**
  51461. * If not undefined, the mesh position is computed from the attached node position
  51462. */
  51463. attachedNode: {
  51464. position: Vector3;
  51465. };
  51466. /**
  51467. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  51468. */
  51469. customMeshPosition: Vector3;
  51470. /**
  51471. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  51472. */
  51473. useCustomMeshPosition: boolean;
  51474. /**
  51475. * If the post-process should inverse the light scattering direction
  51476. */
  51477. invert: boolean;
  51478. /**
  51479. * The internal mesh used by the post-process
  51480. */
  51481. mesh: Mesh;
  51482. /**
  51483. * @hidden
  51484. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  51485. */
  51486. useDiffuseColor: boolean;
  51487. /**
  51488. * Array containing the excluded meshes not rendered in the internal pass
  51489. */
  51490. excludedMeshes: AbstractMesh[];
  51491. /**
  51492. * Controls the overall intensity of the post-process
  51493. */
  51494. exposure: number;
  51495. /**
  51496. * Dissipates each sample's contribution in range [0, 1]
  51497. */
  51498. decay: number;
  51499. /**
  51500. * Controls the overall intensity of each sample
  51501. */
  51502. weight: number;
  51503. /**
  51504. * Controls the density of each sample
  51505. */
  51506. density: number;
  51507. /**
  51508. * @constructor
  51509. * @param name The post-process name
  51510. * @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)
  51511. * @param camera The camera that the post-process will be attached to
  51512. * @param mesh The mesh used to create the light scattering
  51513. * @param samples The post-process quality, default 100
  51514. * @param samplingModeThe post-process filtering mode
  51515. * @param engine The babylon engine
  51516. * @param reusable If the post-process is reusable
  51517. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  51518. */
  51519. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  51520. /**
  51521. * Returns the string "VolumetricLightScatteringPostProcess"
  51522. * @returns "VolumetricLightScatteringPostProcess"
  51523. */
  51524. getClassName(): string;
  51525. private _isReady;
  51526. /**
  51527. * Sets the new light position for light scattering effect
  51528. * @param position The new custom light position
  51529. */
  51530. setCustomMeshPosition(position: Vector3): void;
  51531. /**
  51532. * Returns the light position for light scattering effect
  51533. * @return Vector3 The custom light position
  51534. */
  51535. getCustomMeshPosition(): Vector3;
  51536. /**
  51537. * Disposes the internal assets and detaches the post-process from the camera
  51538. */
  51539. dispose(camera: Camera): void;
  51540. /**
  51541. * Returns the render target texture used by the post-process
  51542. * @return the render target texture used by the post-process
  51543. */
  51544. getPass(): RenderTargetTexture;
  51545. private _meshExcluded;
  51546. private _createPass;
  51547. private _updateMeshScreenCoordinates;
  51548. /**
  51549. * Creates a default mesh for the Volumeric Light Scattering post-process
  51550. * @param name The mesh name
  51551. * @param scene The scene where to create the mesh
  51552. * @return the default mesh
  51553. */
  51554. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  51555. }
  51556. }
  51557. declare module BABYLON {
  51558. interface Scene {
  51559. /** @hidden (Backing field) */
  51560. _boundingBoxRenderer: BoundingBoxRenderer;
  51561. /** @hidden (Backing field) */
  51562. _forceShowBoundingBoxes: boolean;
  51563. /**
  51564. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  51565. */
  51566. forceShowBoundingBoxes: boolean;
  51567. /**
  51568. * Gets the bounding box renderer associated with the scene
  51569. * @returns a BoundingBoxRenderer
  51570. */
  51571. getBoundingBoxRenderer(): BoundingBoxRenderer;
  51572. }
  51573. interface AbstractMesh {
  51574. /** @hidden (Backing field) */
  51575. _showBoundingBox: boolean;
  51576. /**
  51577. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  51578. */
  51579. showBoundingBox: boolean;
  51580. }
  51581. /**
  51582. * Component responsible of rendering the bounding box of the meshes in a scene.
  51583. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  51584. */
  51585. export class BoundingBoxRenderer implements ISceneComponent {
  51586. /**
  51587. * The component name helpfull to identify the component in the list of scene components.
  51588. */
  51589. readonly name: string;
  51590. /**
  51591. * The scene the component belongs to.
  51592. */
  51593. scene: Scene;
  51594. /**
  51595. * Color of the bounding box lines placed in front of an object
  51596. */
  51597. frontColor: Color3;
  51598. /**
  51599. * Color of the bounding box lines placed behind an object
  51600. */
  51601. backColor: Color3;
  51602. /**
  51603. * Defines if the renderer should show the back lines or not
  51604. */
  51605. showBackLines: boolean;
  51606. /**
  51607. * @hidden
  51608. */
  51609. renderList: SmartArray<BoundingBox>;
  51610. private _colorShader;
  51611. private _vertexBuffers;
  51612. private _indexBuffer;
  51613. /**
  51614. * Instantiates a new bounding box renderer in a scene.
  51615. * @param scene the scene the renderer renders in
  51616. */
  51617. constructor(scene: Scene);
  51618. /**
  51619. * Registers the component in a given scene
  51620. */
  51621. register(): void;
  51622. private _evaluateSubMesh;
  51623. private _activeMesh;
  51624. private _prepareRessources;
  51625. private _createIndexBuffer;
  51626. /**
  51627. * Rebuilds the elements related to this component in case of
  51628. * context lost for instance.
  51629. */
  51630. rebuild(): void;
  51631. /**
  51632. * @hidden
  51633. */
  51634. reset(): void;
  51635. /**
  51636. * Render the bounding boxes of a specific rendering group
  51637. * @param renderingGroupId defines the rendering group to render
  51638. */
  51639. render(renderingGroupId: number): void;
  51640. /**
  51641. * In case of occlusion queries, we can render the occlusion bounding box through this method
  51642. * @param mesh Define the mesh to render the occlusion bounding box for
  51643. */
  51644. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  51645. /**
  51646. * Dispose and release the resources attached to this renderer.
  51647. */
  51648. dispose(): void;
  51649. }
  51650. }
  51651. declare module BABYLON {
  51652. /** @hidden */
  51653. export var depthPixelShader: {
  51654. name: string;
  51655. shader: string;
  51656. };
  51657. }
  51658. declare module BABYLON {
  51659. /**
  51660. * This represents a depth renderer in Babylon.
  51661. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  51662. */
  51663. export class DepthRenderer {
  51664. private _scene;
  51665. private _depthMap;
  51666. private _effect;
  51667. private _cachedDefines;
  51668. private _camera;
  51669. /**
  51670. * Specifiess that the depth renderer will only be used within
  51671. * the camera it is created for.
  51672. * This can help forcing its rendering during the camera processing.
  51673. */
  51674. useOnlyInActiveCamera: boolean;
  51675. /** @hidden */
  51676. static _SceneComponentInitialization: (scene: Scene) => void;
  51677. /**
  51678. * Instantiates a depth renderer
  51679. * @param scene The scene the renderer belongs to
  51680. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  51681. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  51682. */
  51683. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  51684. /**
  51685. * Creates the depth rendering effect and checks if the effect is ready.
  51686. * @param subMesh The submesh to be used to render the depth map of
  51687. * @param useInstances If multiple world instances should be used
  51688. * @returns if the depth renderer is ready to render the depth map
  51689. */
  51690. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51691. /**
  51692. * Gets the texture which the depth map will be written to.
  51693. * @returns The depth map texture
  51694. */
  51695. getDepthMap(): RenderTargetTexture;
  51696. /**
  51697. * Disposes of the depth renderer.
  51698. */
  51699. dispose(): void;
  51700. }
  51701. }
  51702. declare module BABYLON {
  51703. interface Scene {
  51704. /** @hidden (Backing field) */
  51705. _depthRenderer: {
  51706. [id: string]: DepthRenderer;
  51707. };
  51708. /**
  51709. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  51710. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  51711. * @returns the created depth renderer
  51712. */
  51713. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  51714. /**
  51715. * Disables a depth renderer for a given camera
  51716. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  51717. */
  51718. disableDepthRenderer(camera?: Nullable<Camera>): void;
  51719. }
  51720. /**
  51721. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  51722. * in several rendering techniques.
  51723. */
  51724. export class DepthRendererSceneComponent implements ISceneComponent {
  51725. /**
  51726. * The component name helpfull to identify the component in the list of scene components.
  51727. */
  51728. readonly name: string;
  51729. /**
  51730. * The scene the component belongs to.
  51731. */
  51732. scene: Scene;
  51733. /**
  51734. * Creates a new instance of the component for the given scene
  51735. * @param scene Defines the scene to register the component in
  51736. */
  51737. constructor(scene: Scene);
  51738. /**
  51739. * Registers the component in a given scene
  51740. */
  51741. register(): void;
  51742. /**
  51743. * Rebuilds the elements related to this component in case of
  51744. * context lost for instance.
  51745. */
  51746. rebuild(): void;
  51747. /**
  51748. * Disposes the component and the associated ressources
  51749. */
  51750. dispose(): void;
  51751. private _gatherRenderTargets;
  51752. private _gatherActiveCameraRenderTargets;
  51753. }
  51754. }
  51755. declare module BABYLON {
  51756. interface Scene {
  51757. /** @hidden (Backing field) */
  51758. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51759. /**
  51760. * Gets or Sets the current geometry buffer associated to the scene.
  51761. */
  51762. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51763. /**
  51764. * Enables a GeometryBufferRender and associates it with the scene
  51765. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51766. * @returns the GeometryBufferRenderer
  51767. */
  51768. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51769. /**
  51770. * Disables the GeometryBufferRender associated with the scene
  51771. */
  51772. disableGeometryBufferRenderer(): void;
  51773. }
  51774. /**
  51775. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51776. * in several rendering techniques.
  51777. */
  51778. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51779. /**
  51780. * The component name helpful to identify the component in the list of scene components.
  51781. */
  51782. readonly name: string;
  51783. /**
  51784. * The scene the component belongs to.
  51785. */
  51786. scene: Scene;
  51787. /**
  51788. * Creates a new instance of the component for the given scene
  51789. * @param scene Defines the scene to register the component in
  51790. */
  51791. constructor(scene: Scene);
  51792. /**
  51793. * Registers the component in a given scene
  51794. */
  51795. register(): void;
  51796. /**
  51797. * Rebuilds the elements related to this component in case of
  51798. * context lost for instance.
  51799. */
  51800. rebuild(): void;
  51801. /**
  51802. * Disposes the component and the associated ressources
  51803. */
  51804. dispose(): void;
  51805. private _gatherRenderTargets;
  51806. }
  51807. }
  51808. declare module BABYLON {
  51809. /** @hidden */
  51810. export var outlinePixelShader: {
  51811. name: string;
  51812. shader: string;
  51813. };
  51814. }
  51815. declare module BABYLON {
  51816. /** @hidden */
  51817. export var outlineVertexShader: {
  51818. name: string;
  51819. shader: string;
  51820. };
  51821. }
  51822. declare module BABYLON {
  51823. interface Scene {
  51824. /** @hidden */
  51825. _outlineRenderer: OutlineRenderer;
  51826. /**
  51827. * Gets the outline renderer associated with the scene
  51828. * @returns a OutlineRenderer
  51829. */
  51830. getOutlineRenderer(): OutlineRenderer;
  51831. }
  51832. interface AbstractMesh {
  51833. /** @hidden (Backing field) */
  51834. _renderOutline: boolean;
  51835. /**
  51836. * Gets or sets a boolean indicating if the outline must be rendered as well
  51837. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  51838. */
  51839. renderOutline: boolean;
  51840. /** @hidden (Backing field) */
  51841. _renderOverlay: boolean;
  51842. /**
  51843. * Gets or sets a boolean indicating if the overlay must be rendered as well
  51844. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  51845. */
  51846. renderOverlay: boolean;
  51847. }
  51848. /**
  51849. * This class is responsible to draw bothe outline/overlay of meshes.
  51850. * It should not be used directly but through the available method on mesh.
  51851. */
  51852. export class OutlineRenderer implements ISceneComponent {
  51853. /**
  51854. * The name of the component. Each component must have a unique name.
  51855. */
  51856. name: string;
  51857. /**
  51858. * The scene the component belongs to.
  51859. */
  51860. scene: Scene;
  51861. /**
  51862. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  51863. */
  51864. zOffset: number;
  51865. private _engine;
  51866. private _effect;
  51867. private _cachedDefines;
  51868. private _savedDepthWrite;
  51869. /**
  51870. * Instantiates a new outline renderer. (There could be only one per scene).
  51871. * @param scene Defines the scene it belongs to
  51872. */
  51873. constructor(scene: Scene);
  51874. /**
  51875. * Register the component to one instance of a scene.
  51876. */
  51877. register(): void;
  51878. /**
  51879. * Rebuilds the elements related to this component in case of
  51880. * context lost for instance.
  51881. */
  51882. rebuild(): void;
  51883. /**
  51884. * Disposes the component and the associated ressources.
  51885. */
  51886. dispose(): void;
  51887. /**
  51888. * Renders the outline in the canvas.
  51889. * @param subMesh Defines the sumesh to render
  51890. * @param batch Defines the batch of meshes in case of instances
  51891. * @param useOverlay Defines if the rendering is for the overlay or the outline
  51892. */
  51893. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  51894. /**
  51895. * Returns whether or not the outline renderer is ready for a given submesh.
  51896. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  51897. * @param subMesh Defines the submesh to check readyness for
  51898. * @param useInstances Defines wheter wee are trying to render instances or not
  51899. * @returns true if ready otherwise false
  51900. */
  51901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51902. private _beforeRenderingMesh;
  51903. private _afterRenderingMesh;
  51904. }
  51905. }
  51906. declare module BABYLON {
  51907. /**
  51908. * Defines the list of states available for a task inside a AssetsManager
  51909. */
  51910. export enum AssetTaskState {
  51911. /**
  51912. * Initialization
  51913. */
  51914. INIT = 0,
  51915. /**
  51916. * Running
  51917. */
  51918. RUNNING = 1,
  51919. /**
  51920. * Done
  51921. */
  51922. DONE = 2,
  51923. /**
  51924. * Error
  51925. */
  51926. ERROR = 3
  51927. }
  51928. /**
  51929. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  51930. */
  51931. export abstract class AbstractAssetTask {
  51932. /**
  51933. * Task name
  51934. */ name: string;
  51935. /**
  51936. * Callback called when the task is successful
  51937. */
  51938. onSuccess: (task: any) => void;
  51939. /**
  51940. * Callback called when the task is not successful
  51941. */
  51942. onError: (task: any, message?: string, exception?: any) => void;
  51943. /**
  51944. * Creates a new AssetsManager
  51945. * @param name defines the name of the task
  51946. */
  51947. constructor(
  51948. /**
  51949. * Task name
  51950. */ name: string);
  51951. private _isCompleted;
  51952. private _taskState;
  51953. private _errorObject;
  51954. /**
  51955. * Get if the task is completed
  51956. */
  51957. readonly isCompleted: boolean;
  51958. /**
  51959. * Gets the current state of the task
  51960. */
  51961. readonly taskState: AssetTaskState;
  51962. /**
  51963. * Gets the current error object (if task is in error)
  51964. */
  51965. readonly errorObject: {
  51966. message?: string;
  51967. exception?: any;
  51968. };
  51969. /**
  51970. * Internal only
  51971. * @hidden
  51972. */
  51973. _setErrorObject(message?: string, exception?: any): void;
  51974. /**
  51975. * Execute the current task
  51976. * @param scene defines the scene where you want your assets to be loaded
  51977. * @param onSuccess is a callback called when the task is successfully executed
  51978. * @param onError is a callback called if an error occurs
  51979. */
  51980. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51981. /**
  51982. * Execute the current task
  51983. * @param scene defines the scene where you want your assets to be loaded
  51984. * @param onSuccess is a callback called when the task is successfully executed
  51985. * @param onError is a callback called if an error occurs
  51986. */
  51987. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  51988. /**
  51989. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  51990. * This can be used with failed tasks that have the reason for failure fixed.
  51991. */
  51992. reset(): void;
  51993. private onErrorCallback;
  51994. private onDoneCallback;
  51995. }
  51996. /**
  51997. * Define the interface used by progress events raised during assets loading
  51998. */
  51999. export interface IAssetsProgressEvent {
  52000. /**
  52001. * Defines the number of remaining tasks to process
  52002. */
  52003. remainingCount: number;
  52004. /**
  52005. * Defines the total number of tasks
  52006. */
  52007. totalCount: number;
  52008. /**
  52009. * Defines the task that was just processed
  52010. */
  52011. task: AbstractAssetTask;
  52012. }
  52013. /**
  52014. * Class used to share progress information about assets loading
  52015. */
  52016. export class AssetsProgressEvent implements IAssetsProgressEvent {
  52017. /**
  52018. * Defines the number of remaining tasks to process
  52019. */
  52020. remainingCount: number;
  52021. /**
  52022. * Defines the total number of tasks
  52023. */
  52024. totalCount: number;
  52025. /**
  52026. * Defines the task that was just processed
  52027. */
  52028. task: AbstractAssetTask;
  52029. /**
  52030. * Creates a AssetsProgressEvent
  52031. * @param remainingCount defines the number of remaining tasks to process
  52032. * @param totalCount defines the total number of tasks
  52033. * @param task defines the task that was just processed
  52034. */
  52035. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  52036. }
  52037. /**
  52038. * Define a task used by AssetsManager to load meshes
  52039. */
  52040. export class MeshAssetTask extends AbstractAssetTask {
  52041. /**
  52042. * Defines the name of the task
  52043. */
  52044. name: string;
  52045. /**
  52046. * Defines the list of mesh's names you want to load
  52047. */
  52048. meshesNames: any;
  52049. /**
  52050. * Defines the root url to use as a base to load your meshes and associated resources
  52051. */
  52052. rootUrl: string;
  52053. /**
  52054. * Defines the filename of the scene to load from
  52055. */
  52056. sceneFilename: string;
  52057. /**
  52058. * Gets the list of loaded meshes
  52059. */
  52060. loadedMeshes: Array<AbstractMesh>;
  52061. /**
  52062. * Gets the list of loaded particle systems
  52063. */
  52064. loadedParticleSystems: Array<IParticleSystem>;
  52065. /**
  52066. * Gets the list of loaded skeletons
  52067. */
  52068. loadedSkeletons: Array<Skeleton>;
  52069. /**
  52070. * Gets the list of loaded animation groups
  52071. */
  52072. loadedAnimationGroups: Array<AnimationGroup>;
  52073. /**
  52074. * Callback called when the task is successful
  52075. */
  52076. onSuccess: (task: MeshAssetTask) => void;
  52077. /**
  52078. * Callback called when the task is successful
  52079. */
  52080. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  52081. /**
  52082. * Creates a new MeshAssetTask
  52083. * @param name defines the name of the task
  52084. * @param meshesNames defines the list of mesh's names you want to load
  52085. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  52086. * @param sceneFilename defines the filename of the scene to load from
  52087. */
  52088. constructor(
  52089. /**
  52090. * Defines the name of the task
  52091. */
  52092. name: string,
  52093. /**
  52094. * Defines the list of mesh's names you want to load
  52095. */
  52096. meshesNames: any,
  52097. /**
  52098. * Defines the root url to use as a base to load your meshes and associated resources
  52099. */
  52100. rootUrl: string,
  52101. /**
  52102. * Defines the filename of the scene to load from
  52103. */
  52104. sceneFilename: string);
  52105. /**
  52106. * Execute the current task
  52107. * @param scene defines the scene where you want your assets to be loaded
  52108. * @param onSuccess is a callback called when the task is successfully executed
  52109. * @param onError is a callback called if an error occurs
  52110. */
  52111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52112. }
  52113. /**
  52114. * Define a task used by AssetsManager to load text content
  52115. */
  52116. export class TextFileAssetTask extends AbstractAssetTask {
  52117. /**
  52118. * Defines the name of the task
  52119. */
  52120. name: string;
  52121. /**
  52122. * Defines the location of the file to load
  52123. */
  52124. url: string;
  52125. /**
  52126. * Gets the loaded text string
  52127. */
  52128. text: string;
  52129. /**
  52130. * Callback called when the task is successful
  52131. */
  52132. onSuccess: (task: TextFileAssetTask) => void;
  52133. /**
  52134. * Callback called when the task is successful
  52135. */
  52136. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  52137. /**
  52138. * Creates a new TextFileAssetTask object
  52139. * @param name defines the name of the task
  52140. * @param url defines the location of the file to load
  52141. */
  52142. constructor(
  52143. /**
  52144. * Defines the name of the task
  52145. */
  52146. name: string,
  52147. /**
  52148. * Defines the location of the file to load
  52149. */
  52150. url: string);
  52151. /**
  52152. * Execute the current task
  52153. * @param scene defines the scene where you want your assets to be loaded
  52154. * @param onSuccess is a callback called when the task is successfully executed
  52155. * @param onError is a callback called if an error occurs
  52156. */
  52157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52158. }
  52159. /**
  52160. * Define a task used by AssetsManager to load binary data
  52161. */
  52162. export class BinaryFileAssetTask extends AbstractAssetTask {
  52163. /**
  52164. * Defines the name of the task
  52165. */
  52166. name: string;
  52167. /**
  52168. * Defines the location of the file to load
  52169. */
  52170. url: string;
  52171. /**
  52172. * Gets the lodaded data (as an array buffer)
  52173. */
  52174. data: ArrayBuffer;
  52175. /**
  52176. * Callback called when the task is successful
  52177. */
  52178. onSuccess: (task: BinaryFileAssetTask) => void;
  52179. /**
  52180. * Callback called when the task is successful
  52181. */
  52182. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  52183. /**
  52184. * Creates a new BinaryFileAssetTask object
  52185. * @param name defines the name of the new task
  52186. * @param url defines the location of the file to load
  52187. */
  52188. constructor(
  52189. /**
  52190. * Defines the name of the task
  52191. */
  52192. name: string,
  52193. /**
  52194. * Defines the location of the file to load
  52195. */
  52196. url: string);
  52197. /**
  52198. * Execute the current task
  52199. * @param scene defines the scene where you want your assets to be loaded
  52200. * @param onSuccess is a callback called when the task is successfully executed
  52201. * @param onError is a callback called if an error occurs
  52202. */
  52203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52204. }
  52205. /**
  52206. * Define a task used by AssetsManager to load images
  52207. */
  52208. export class ImageAssetTask extends AbstractAssetTask {
  52209. /**
  52210. * Defines the name of the task
  52211. */
  52212. name: string;
  52213. /**
  52214. * Defines the location of the image to load
  52215. */
  52216. url: string;
  52217. /**
  52218. * Gets the loaded images
  52219. */
  52220. image: HTMLImageElement;
  52221. /**
  52222. * Callback called when the task is successful
  52223. */
  52224. onSuccess: (task: ImageAssetTask) => void;
  52225. /**
  52226. * Callback called when the task is successful
  52227. */
  52228. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  52229. /**
  52230. * Creates a new ImageAssetTask
  52231. * @param name defines the name of the task
  52232. * @param url defines the location of the image to load
  52233. */
  52234. constructor(
  52235. /**
  52236. * Defines the name of the task
  52237. */
  52238. name: string,
  52239. /**
  52240. * Defines the location of the image to load
  52241. */
  52242. url: string);
  52243. /**
  52244. * Execute the current task
  52245. * @param scene defines the scene where you want your assets to be loaded
  52246. * @param onSuccess is a callback called when the task is successfully executed
  52247. * @param onError is a callback called if an error occurs
  52248. */
  52249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52250. }
  52251. /**
  52252. * Defines the interface used by texture loading tasks
  52253. */
  52254. export interface ITextureAssetTask<TEX extends BaseTexture> {
  52255. /**
  52256. * Gets the loaded texture
  52257. */
  52258. texture: TEX;
  52259. }
  52260. /**
  52261. * Define a task used by AssetsManager to load 2D textures
  52262. */
  52263. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  52264. /**
  52265. * Defines the name of the task
  52266. */
  52267. name: string;
  52268. /**
  52269. * Defines the location of the file to load
  52270. */
  52271. url: string;
  52272. /**
  52273. * Defines if mipmap should not be generated (default is false)
  52274. */
  52275. noMipmap?: boolean | undefined;
  52276. /**
  52277. * Defines if texture must be inverted on Y axis (default is false)
  52278. */
  52279. invertY?: boolean | undefined;
  52280. /**
  52281. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52282. */
  52283. samplingMode: number;
  52284. /**
  52285. * Gets the loaded texture
  52286. */
  52287. texture: Texture;
  52288. /**
  52289. * Callback called when the task is successful
  52290. */
  52291. onSuccess: (task: TextureAssetTask) => void;
  52292. /**
  52293. * Callback called when the task is successful
  52294. */
  52295. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  52296. /**
  52297. * Creates a new TextureAssetTask object
  52298. * @param name defines the name of the task
  52299. * @param url defines the location of the file to load
  52300. * @param noMipmap defines if mipmap should not be generated (default is false)
  52301. * @param invertY defines if texture must be inverted on Y axis (default is false)
  52302. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52303. */
  52304. constructor(
  52305. /**
  52306. * Defines the name of the task
  52307. */
  52308. name: string,
  52309. /**
  52310. * Defines the location of the file to load
  52311. */
  52312. url: string,
  52313. /**
  52314. * Defines if mipmap should not be generated (default is false)
  52315. */
  52316. noMipmap?: boolean | undefined,
  52317. /**
  52318. * Defines if texture must be inverted on Y axis (default is false)
  52319. */
  52320. invertY?: boolean | undefined,
  52321. /**
  52322. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52323. */
  52324. samplingMode?: number);
  52325. /**
  52326. * Execute the current task
  52327. * @param scene defines the scene where you want your assets to be loaded
  52328. * @param onSuccess is a callback called when the task is successfully executed
  52329. * @param onError is a callback called if an error occurs
  52330. */
  52331. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52332. }
  52333. /**
  52334. * Define a task used by AssetsManager to load cube textures
  52335. */
  52336. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  52337. /**
  52338. * Defines the name of the task
  52339. */
  52340. name: string;
  52341. /**
  52342. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52343. */
  52344. url: string;
  52345. /**
  52346. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52347. */
  52348. extensions?: string[] | undefined;
  52349. /**
  52350. * Defines if mipmaps should not be generated (default is false)
  52351. */
  52352. noMipmap?: boolean | undefined;
  52353. /**
  52354. * Defines the explicit list of files (undefined by default)
  52355. */
  52356. files?: string[] | undefined;
  52357. /**
  52358. * Gets the loaded texture
  52359. */
  52360. texture: CubeTexture;
  52361. /**
  52362. * Callback called when the task is successful
  52363. */
  52364. onSuccess: (task: CubeTextureAssetTask) => void;
  52365. /**
  52366. * Callback called when the task is successful
  52367. */
  52368. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  52369. /**
  52370. * Creates a new CubeTextureAssetTask
  52371. * @param name defines the name of the task
  52372. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52373. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52374. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52375. * @param files defines the explicit list of files (undefined by default)
  52376. */
  52377. constructor(
  52378. /**
  52379. * Defines the name of the task
  52380. */
  52381. name: string,
  52382. /**
  52383. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  52384. */
  52385. url: string,
  52386. /**
  52387. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  52388. */
  52389. extensions?: string[] | undefined,
  52390. /**
  52391. * Defines if mipmaps should not be generated (default is false)
  52392. */
  52393. noMipmap?: boolean | undefined,
  52394. /**
  52395. * Defines the explicit list of files (undefined by default)
  52396. */
  52397. files?: string[] | undefined);
  52398. /**
  52399. * Execute the current task
  52400. * @param scene defines the scene where you want your assets to be loaded
  52401. * @param onSuccess is a callback called when the task is successfully executed
  52402. * @param onError is a callback called if an error occurs
  52403. */
  52404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52405. }
  52406. /**
  52407. * Define a task used by AssetsManager to load HDR cube textures
  52408. */
  52409. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  52410. /**
  52411. * Defines the name of the task
  52412. */
  52413. name: string;
  52414. /**
  52415. * Defines the location of the file to load
  52416. */
  52417. url: string;
  52418. /**
  52419. * Defines the desired size (the more it increases the longer the generation will be)
  52420. */
  52421. size: number;
  52422. /**
  52423. * Defines if mipmaps should not be generated (default is false)
  52424. */
  52425. noMipmap: boolean;
  52426. /**
  52427. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52428. */
  52429. generateHarmonics: boolean;
  52430. /**
  52431. * 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)
  52432. */
  52433. gammaSpace: boolean;
  52434. /**
  52435. * Internal Use Only
  52436. */
  52437. reserved: boolean;
  52438. /**
  52439. * Gets the loaded texture
  52440. */
  52441. texture: HDRCubeTexture;
  52442. /**
  52443. * Callback called when the task is successful
  52444. */
  52445. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  52446. /**
  52447. * Callback called when the task is successful
  52448. */
  52449. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  52450. /**
  52451. * Creates a new HDRCubeTextureAssetTask object
  52452. * @param name defines the name of the task
  52453. * @param url defines the location of the file to load
  52454. * @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.
  52455. * @param noMipmap defines if mipmaps should not be generated (default is false)
  52456. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52457. * @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)
  52458. * @param reserved Internal use only
  52459. */
  52460. constructor(
  52461. /**
  52462. * Defines the name of the task
  52463. */
  52464. name: string,
  52465. /**
  52466. * Defines the location of the file to load
  52467. */
  52468. url: string,
  52469. /**
  52470. * Defines the desired size (the more it increases the longer the generation will be)
  52471. */
  52472. size: number,
  52473. /**
  52474. * Defines if mipmaps should not be generated (default is false)
  52475. */
  52476. noMipmap?: boolean,
  52477. /**
  52478. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  52479. */
  52480. generateHarmonics?: boolean,
  52481. /**
  52482. * 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)
  52483. */
  52484. gammaSpace?: boolean,
  52485. /**
  52486. * Internal Use Only
  52487. */
  52488. reserved?: boolean);
  52489. /**
  52490. * Execute the current task
  52491. * @param scene defines the scene where you want your assets to be loaded
  52492. * @param onSuccess is a callback called when the task is successfully executed
  52493. * @param onError is a callback called if an error occurs
  52494. */
  52495. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  52496. }
  52497. /**
  52498. * This class can be used to easily import assets into a scene
  52499. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  52500. */
  52501. export class AssetsManager {
  52502. private _scene;
  52503. private _isLoading;
  52504. protected _tasks: AbstractAssetTask[];
  52505. protected _waitingTasksCount: number;
  52506. protected _totalTasksCount: number;
  52507. /**
  52508. * Callback called when all tasks are processed
  52509. */
  52510. onFinish: (tasks: AbstractAssetTask[]) => void;
  52511. /**
  52512. * Callback called when a task is successful
  52513. */
  52514. onTaskSuccess: (task: AbstractAssetTask) => void;
  52515. /**
  52516. * Callback called when a task had an error
  52517. */
  52518. onTaskError: (task: AbstractAssetTask) => void;
  52519. /**
  52520. * Callback called when a task is done (whatever the result is)
  52521. */
  52522. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  52523. /**
  52524. * Observable called when all tasks are processed
  52525. */
  52526. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  52527. /**
  52528. * Observable called when a task had an error
  52529. */
  52530. onTaskErrorObservable: Observable<AbstractAssetTask>;
  52531. /**
  52532. * Observable called when a task is successful
  52533. */
  52534. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  52535. /**
  52536. * Observable called when a task is done (whatever the result is)
  52537. */
  52538. onProgressObservable: Observable<IAssetsProgressEvent>;
  52539. /**
  52540. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  52541. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  52542. */
  52543. useDefaultLoadingScreen: boolean;
  52544. /**
  52545. * Creates a new AssetsManager
  52546. * @param scene defines the scene to work on
  52547. */
  52548. constructor(scene: Scene);
  52549. /**
  52550. * Add a MeshAssetTask to the list of active tasks
  52551. * @param taskName defines the name of the new task
  52552. * @param meshesNames defines the name of meshes to load
  52553. * @param rootUrl defines the root url to use to locate files
  52554. * @param sceneFilename defines the filename of the scene file
  52555. * @returns a new MeshAssetTask object
  52556. */
  52557. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  52558. /**
  52559. * Add a TextFileAssetTask to the list of active tasks
  52560. * @param taskName defines the name of the new task
  52561. * @param url defines the url of the file to load
  52562. * @returns a new TextFileAssetTask object
  52563. */
  52564. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  52565. /**
  52566. * Add a BinaryFileAssetTask to the list of active tasks
  52567. * @param taskName defines the name of the new task
  52568. * @param url defines the url of the file to load
  52569. * @returns a new BinaryFileAssetTask object
  52570. */
  52571. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  52572. /**
  52573. * Add a ImageAssetTask to the list of active tasks
  52574. * @param taskName defines the name of the new task
  52575. * @param url defines the url of the file to load
  52576. * @returns a new ImageAssetTask object
  52577. */
  52578. addImageTask(taskName: string, url: string): ImageAssetTask;
  52579. /**
  52580. * Add a TextureAssetTask to the list of active tasks
  52581. * @param taskName defines the name of the new task
  52582. * @param url defines the url of the file to load
  52583. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52584. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  52585. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52586. * @returns a new TextureAssetTask object
  52587. */
  52588. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  52589. /**
  52590. * Add a CubeTextureAssetTask to the list of active tasks
  52591. * @param taskName defines the name of the new task
  52592. * @param url defines the url of the file to load
  52593. * @param extensions defines the extension to use to load the cube map (can be null)
  52594. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52595. * @param files defines the list of files to load (can be null)
  52596. * @returns a new CubeTextureAssetTask object
  52597. */
  52598. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  52599. /**
  52600. *
  52601. * Add a HDRCubeTextureAssetTask to the list of active tasks
  52602. * @param taskName defines the name of the new task
  52603. * @param url defines the url of the file to load
  52604. * @param size defines the size you want for the cubemap (can be null)
  52605. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  52606. * @param generateHarmonics defines if you want to automatically generate (true by default)
  52607. * @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)
  52608. * @param reserved Internal use only
  52609. * @returns a new HDRCubeTextureAssetTask object
  52610. */
  52611. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  52612. /**
  52613. * Remove a task from the assets manager.
  52614. * @param task the task to remove
  52615. */
  52616. removeTask(task: AbstractAssetTask): void;
  52617. private _decreaseWaitingTasksCount;
  52618. private _runTask;
  52619. /**
  52620. * Reset the AssetsManager and remove all tasks
  52621. * @return the current instance of the AssetsManager
  52622. */
  52623. reset(): AssetsManager;
  52624. /**
  52625. * Start the loading process
  52626. * @return the current instance of the AssetsManager
  52627. */
  52628. load(): AssetsManager;
  52629. }
  52630. }
  52631. declare module BABYLON {
  52632. /**
  52633. * Wrapper class for promise with external resolve and reject.
  52634. */
  52635. export class Deferred<T> {
  52636. /**
  52637. * The promise associated with this deferred object.
  52638. */
  52639. readonly promise: Promise<T>;
  52640. private _resolve;
  52641. private _reject;
  52642. /**
  52643. * The resolve method of the promise associated with this deferred object.
  52644. */
  52645. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  52646. /**
  52647. * The reject method of the promise associated with this deferred object.
  52648. */
  52649. readonly reject: (reason?: any) => void;
  52650. /**
  52651. * Constructor for this deferred object.
  52652. */
  52653. constructor();
  52654. }
  52655. }
  52656. declare module BABYLON {
  52657. /**
  52658. * Class used to help managing file picking and drag'n'drop
  52659. */
  52660. export class FilesInput {
  52661. /**
  52662. * List of files ready to be loaded
  52663. */
  52664. static readonly FilesToLoad: {
  52665. [key: string]: File;
  52666. };
  52667. /**
  52668. * Callback called when a file is processed
  52669. */
  52670. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  52671. private _engine;
  52672. private _currentScene;
  52673. private _sceneLoadedCallback;
  52674. private _progressCallback;
  52675. private _additionalRenderLoopLogicCallback;
  52676. private _textureLoadingCallback;
  52677. private _startingProcessingFilesCallback;
  52678. private _onReloadCallback;
  52679. private _errorCallback;
  52680. private _elementToMonitor;
  52681. private _sceneFileToLoad;
  52682. private _filesToLoad;
  52683. /**
  52684. * Creates a new FilesInput
  52685. * @param engine defines the rendering engine
  52686. * @param scene defines the hosting scene
  52687. * @param sceneLoadedCallback callback called when scene is loaded
  52688. * @param progressCallback callback called to track progress
  52689. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  52690. * @param textureLoadingCallback callback called when a texture is loading
  52691. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  52692. * @param onReloadCallback callback called when a reload is requested
  52693. * @param errorCallback callback call if an error occurs
  52694. */
  52695. 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);
  52696. private _dragEnterHandler;
  52697. private _dragOverHandler;
  52698. private _dropHandler;
  52699. /**
  52700. * Calls this function to listen to drag'n'drop events on a specific DOM element
  52701. * @param elementToMonitor defines the DOM element to track
  52702. */
  52703. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  52704. /**
  52705. * Release all associated resources
  52706. */
  52707. dispose(): void;
  52708. private renderFunction;
  52709. private drag;
  52710. private drop;
  52711. private _traverseFolder;
  52712. private _processFiles;
  52713. /**
  52714. * Load files from a drop event
  52715. * @param event defines the drop event to use as source
  52716. */
  52717. loadFiles(event: any): void;
  52718. private _processReload;
  52719. /**
  52720. * Reload the current scene from the loaded files
  52721. */
  52722. reload(): void;
  52723. }
  52724. }
  52725. declare module BABYLON {
  52726. /**
  52727. * Defines the root class used to create scene optimization to use with SceneOptimizer
  52728. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52729. */
  52730. export class SceneOptimization {
  52731. /**
  52732. * Defines the priority of this optimization (0 by default which means first in the list)
  52733. */
  52734. priority: number;
  52735. /**
  52736. * Gets a string describing the action executed by the current optimization
  52737. * @returns description string
  52738. */
  52739. getDescription(): string;
  52740. /**
  52741. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52742. * @param scene defines the current scene where to apply this optimization
  52743. * @param optimizer defines the current optimizer
  52744. * @returns true if everything that can be done was applied
  52745. */
  52746. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52747. /**
  52748. * Creates the SceneOptimization object
  52749. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52750. * @param desc defines the description associated with the optimization
  52751. */
  52752. constructor(
  52753. /**
  52754. * Defines the priority of this optimization (0 by default which means first in the list)
  52755. */
  52756. priority?: number);
  52757. }
  52758. /**
  52759. * Defines an optimization used to reduce the size of render target textures
  52760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52761. */
  52762. export class TextureOptimization extends SceneOptimization {
  52763. /**
  52764. * Defines the priority of this optimization (0 by default which means first in the list)
  52765. */
  52766. priority: number;
  52767. /**
  52768. * 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
  52769. */
  52770. maximumSize: number;
  52771. /**
  52772. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52773. */
  52774. step: number;
  52775. /**
  52776. * Gets a string describing the action executed by the current optimization
  52777. * @returns description string
  52778. */
  52779. getDescription(): string;
  52780. /**
  52781. * Creates the TextureOptimization object
  52782. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52783. * @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
  52784. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52785. */
  52786. constructor(
  52787. /**
  52788. * Defines the priority of this optimization (0 by default which means first in the list)
  52789. */
  52790. priority?: number,
  52791. /**
  52792. * 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
  52793. */
  52794. maximumSize?: number,
  52795. /**
  52796. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  52797. */
  52798. step?: number);
  52799. /**
  52800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52801. * @param scene defines the current scene where to apply this optimization
  52802. * @param optimizer defines the current optimizer
  52803. * @returns true if everything that can be done was applied
  52804. */
  52805. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52806. }
  52807. /**
  52808. * Defines an optimization used to increase or decrease the rendering resolution
  52809. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52810. */
  52811. export class HardwareScalingOptimization extends SceneOptimization {
  52812. /**
  52813. * Defines the priority of this optimization (0 by default which means first in the list)
  52814. */
  52815. priority: number;
  52816. /**
  52817. * Defines the maximum scale to use (2 by default)
  52818. */
  52819. maximumScale: number;
  52820. /**
  52821. * Defines the step to use between two passes (0.5 by default)
  52822. */
  52823. step: number;
  52824. private _currentScale;
  52825. private _directionOffset;
  52826. /**
  52827. * Gets a string describing the action executed by the current optimization
  52828. * @return description string
  52829. */
  52830. getDescription(): string;
  52831. /**
  52832. * Creates the HardwareScalingOptimization object
  52833. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  52834. * @param maximumScale defines the maximum scale to use (2 by default)
  52835. * @param step defines the step to use between two passes (0.5 by default)
  52836. */
  52837. constructor(
  52838. /**
  52839. * Defines the priority of this optimization (0 by default which means first in the list)
  52840. */
  52841. priority?: number,
  52842. /**
  52843. * Defines the maximum scale to use (2 by default)
  52844. */
  52845. maximumScale?: number,
  52846. /**
  52847. * Defines the step to use between two passes (0.5 by default)
  52848. */
  52849. step?: number);
  52850. /**
  52851. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52852. * @param scene defines the current scene where to apply this optimization
  52853. * @param optimizer defines the current optimizer
  52854. * @returns true if everything that can be done was applied
  52855. */
  52856. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52857. }
  52858. /**
  52859. * Defines an optimization used to remove shadows
  52860. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52861. */
  52862. export class ShadowsOptimization extends SceneOptimization {
  52863. /**
  52864. * Gets a string describing the action executed by the current optimization
  52865. * @return description string
  52866. */
  52867. getDescription(): string;
  52868. /**
  52869. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52870. * @param scene defines the current scene where to apply this optimization
  52871. * @param optimizer defines the current optimizer
  52872. * @returns true if everything that can be done was applied
  52873. */
  52874. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52875. }
  52876. /**
  52877. * Defines an optimization used to turn post-processes off
  52878. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52879. */
  52880. export class PostProcessesOptimization extends SceneOptimization {
  52881. /**
  52882. * Gets a string describing the action executed by the current optimization
  52883. * @return description string
  52884. */
  52885. getDescription(): string;
  52886. /**
  52887. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52888. * @param scene defines the current scene where to apply this optimization
  52889. * @param optimizer defines the current optimizer
  52890. * @returns true if everything that can be done was applied
  52891. */
  52892. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52893. }
  52894. /**
  52895. * Defines an optimization used to turn lens flares off
  52896. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52897. */
  52898. export class LensFlaresOptimization extends SceneOptimization {
  52899. /**
  52900. * Gets a string describing the action executed by the current optimization
  52901. * @return description string
  52902. */
  52903. getDescription(): string;
  52904. /**
  52905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52906. * @param scene defines the current scene where to apply this optimization
  52907. * @param optimizer defines the current optimizer
  52908. * @returns true if everything that can be done was applied
  52909. */
  52910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52911. }
  52912. /**
  52913. * Defines an optimization based on user defined callback.
  52914. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52915. */
  52916. export class CustomOptimization extends SceneOptimization {
  52917. /**
  52918. * Callback called to apply the custom optimization.
  52919. */
  52920. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  52921. /**
  52922. * Callback called to get custom description
  52923. */
  52924. onGetDescription: () => string;
  52925. /**
  52926. * Gets a string describing the action executed by the current optimization
  52927. * @returns description string
  52928. */
  52929. getDescription(): string;
  52930. /**
  52931. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52932. * @param scene defines the current scene where to apply this optimization
  52933. * @param optimizer defines the current optimizer
  52934. * @returns true if everything that can be done was applied
  52935. */
  52936. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52937. }
  52938. /**
  52939. * Defines an optimization used to turn particles off
  52940. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52941. */
  52942. export class ParticlesOptimization extends SceneOptimization {
  52943. /**
  52944. * Gets a string describing the action executed by the current optimization
  52945. * @return description string
  52946. */
  52947. getDescription(): string;
  52948. /**
  52949. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52950. * @param scene defines the current scene where to apply this optimization
  52951. * @param optimizer defines the current optimizer
  52952. * @returns true if everything that can be done was applied
  52953. */
  52954. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52955. }
  52956. /**
  52957. * Defines an optimization used to turn render targets off
  52958. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52959. */
  52960. export class RenderTargetsOptimization extends SceneOptimization {
  52961. /**
  52962. * Gets a string describing the action executed by the current optimization
  52963. * @return description string
  52964. */
  52965. getDescription(): string;
  52966. /**
  52967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52968. * @param scene defines the current scene where to apply this optimization
  52969. * @param optimizer defines the current optimizer
  52970. * @returns true if everything that can be done was applied
  52971. */
  52972. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  52973. }
  52974. /**
  52975. * Defines an optimization used to merge meshes with compatible materials
  52976. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  52977. */
  52978. export class MergeMeshesOptimization extends SceneOptimization {
  52979. private static _UpdateSelectionTree;
  52980. /**
  52981. * Gets or sets a boolean which defines if optimization octree has to be updated
  52982. */
  52983. /**
  52984. * Gets or sets a boolean which defines if optimization octree has to be updated
  52985. */
  52986. static UpdateSelectionTree: boolean;
  52987. /**
  52988. * Gets a string describing the action executed by the current optimization
  52989. * @return description string
  52990. */
  52991. getDescription(): string;
  52992. private _canBeMerged;
  52993. /**
  52994. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  52995. * @param scene defines the current scene where to apply this optimization
  52996. * @param optimizer defines the current optimizer
  52997. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  52998. * @returns true if everything that can be done was applied
  52999. */
  53000. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  53001. }
  53002. /**
  53003. * Defines a list of options used by SceneOptimizer
  53004. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53005. */
  53006. export class SceneOptimizerOptions {
  53007. /**
  53008. * Defines the target frame rate to reach (60 by default)
  53009. */
  53010. targetFrameRate: number;
  53011. /**
  53012. * Defines the interval between two checkes (2000ms by default)
  53013. */
  53014. trackerDuration: number;
  53015. /**
  53016. * Gets the list of optimizations to apply
  53017. */
  53018. optimizations: SceneOptimization[];
  53019. /**
  53020. * Creates a new list of options used by SceneOptimizer
  53021. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  53022. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  53023. */
  53024. constructor(
  53025. /**
  53026. * Defines the target frame rate to reach (60 by default)
  53027. */
  53028. targetFrameRate?: number,
  53029. /**
  53030. * Defines the interval between two checkes (2000ms by default)
  53031. */
  53032. trackerDuration?: number);
  53033. /**
  53034. * Add a new optimization
  53035. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  53036. * @returns the current SceneOptimizerOptions
  53037. */
  53038. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  53039. /**
  53040. * Add a new custom optimization
  53041. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  53042. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  53043. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  53044. * @returns the current SceneOptimizerOptions
  53045. */
  53046. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  53047. /**
  53048. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  53049. * @param targetFrameRate defines the target frame rate (60 by default)
  53050. * @returns a SceneOptimizerOptions object
  53051. */
  53052. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53053. /**
  53054. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  53055. * @param targetFrameRate defines the target frame rate (60 by default)
  53056. * @returns a SceneOptimizerOptions object
  53057. */
  53058. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53059. /**
  53060. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  53061. * @param targetFrameRate defines the target frame rate (60 by default)
  53062. * @returns a SceneOptimizerOptions object
  53063. */
  53064. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  53065. }
  53066. /**
  53067. * Class used to run optimizations in order to reach a target frame rate
  53068. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  53069. */
  53070. export class SceneOptimizer implements IDisposable {
  53071. private _isRunning;
  53072. private _options;
  53073. private _scene;
  53074. private _currentPriorityLevel;
  53075. private _targetFrameRate;
  53076. private _trackerDuration;
  53077. private _currentFrameRate;
  53078. private _sceneDisposeObserver;
  53079. private _improvementMode;
  53080. /**
  53081. * Defines an observable called when the optimizer reaches the target frame rate
  53082. */
  53083. onSuccessObservable: Observable<SceneOptimizer>;
  53084. /**
  53085. * Defines an observable called when the optimizer enables an optimization
  53086. */
  53087. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  53088. /**
  53089. * Defines an observable called when the optimizer is not able to reach the target frame rate
  53090. */
  53091. onFailureObservable: Observable<SceneOptimizer>;
  53092. /**
  53093. * Gets a boolean indicating if the optimizer is in improvement mode
  53094. */
  53095. readonly isInImprovementMode: boolean;
  53096. /**
  53097. * Gets the current priority level (0 at start)
  53098. */
  53099. readonly currentPriorityLevel: number;
  53100. /**
  53101. * Gets the current frame rate checked by the SceneOptimizer
  53102. */
  53103. readonly currentFrameRate: number;
  53104. /**
  53105. * Gets or sets the current target frame rate (60 by default)
  53106. */
  53107. /**
  53108. * Gets or sets the current target frame rate (60 by default)
  53109. */
  53110. targetFrameRate: number;
  53111. /**
  53112. * Gets or sets the current interval between two checks (every 2000ms by default)
  53113. */
  53114. /**
  53115. * Gets or sets the current interval between two checks (every 2000ms by default)
  53116. */
  53117. trackerDuration: number;
  53118. /**
  53119. * Gets the list of active optimizations
  53120. */
  53121. readonly optimizations: SceneOptimization[];
  53122. /**
  53123. * Creates a new SceneOptimizer
  53124. * @param scene defines the scene to work on
  53125. * @param options defines the options to use with the SceneOptimizer
  53126. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  53127. * @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)
  53128. */
  53129. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  53130. /**
  53131. * Stops the current optimizer
  53132. */
  53133. stop(): void;
  53134. /**
  53135. * Reset the optimizer to initial step (current priority level = 0)
  53136. */
  53137. reset(): void;
  53138. /**
  53139. * Start the optimizer. By default it will try to reach a specific framerate
  53140. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  53141. */
  53142. start(): void;
  53143. private _checkCurrentState;
  53144. /**
  53145. * Release all resources
  53146. */
  53147. dispose(): void;
  53148. /**
  53149. * Helper function to create a SceneOptimizer with one single line of code
  53150. * @param scene defines the scene to work on
  53151. * @param options defines the options to use with the SceneOptimizer
  53152. * @param onSuccess defines a callback to call on success
  53153. * @param onFailure defines a callback to call on failure
  53154. * @returns the new SceneOptimizer object
  53155. */
  53156. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  53157. }
  53158. }
  53159. declare module BABYLON {
  53160. /**
  53161. * Class used to serialize a scene into a string
  53162. */
  53163. export class SceneSerializer {
  53164. /**
  53165. * Clear cache used by a previous serialization
  53166. */
  53167. static ClearCache(): void;
  53168. /**
  53169. * Serialize a scene into a JSON compatible object
  53170. * @param scene defines the scene to serialize
  53171. * @returns a JSON compatible object
  53172. */
  53173. static Serialize(scene: Scene): any;
  53174. /**
  53175. * Serialize a mesh into a JSON compatible object
  53176. * @param toSerialize defines the mesh to serialize
  53177. * @param withParents defines if parents must be serialized as well
  53178. * @param withChildren defines if children must be serialized as well
  53179. * @returns a JSON compatible object
  53180. */
  53181. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  53182. }
  53183. }
  53184. declare module BABYLON {
  53185. /**
  53186. * This represents the different options avilable for the video capture.
  53187. */
  53188. export interface VideoRecorderOptions {
  53189. /** Defines the mime type of the video */
  53190. mimeType: string;
  53191. /** Defines the video the video should be recorded at */
  53192. fps: number;
  53193. /** Defines the chunk size for the recording data */
  53194. recordChunckSize: number;
  53195. }
  53196. /**
  53197. * This can helps recording videos from BabylonJS.
  53198. * This is based on the available WebRTC functionalities of the browser.
  53199. *
  53200. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  53201. */
  53202. export class VideoRecorder {
  53203. private static readonly _defaultOptions;
  53204. /**
  53205. * Returns wehther or not the VideoRecorder is available in your browser.
  53206. * @param engine Defines the Babylon Engine to check the support for
  53207. * @returns true if supported otherwise false
  53208. */
  53209. static IsSupported(engine: Engine): boolean;
  53210. private readonly _options;
  53211. private _canvas;
  53212. private _mediaRecorder;
  53213. private _recordedChunks;
  53214. private _fileName;
  53215. private _resolve;
  53216. private _reject;
  53217. /**
  53218. * True wether a recording is already in progress.
  53219. */
  53220. readonly isRecording: boolean;
  53221. /**
  53222. * Create a new VideoCapture object which can help converting what you see in Babylon to
  53223. * a video file.
  53224. * @param engine Defines the BabylonJS Engine you wish to record
  53225. * @param options Defines options that can be used to customized the capture
  53226. */
  53227. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  53228. /**
  53229. * Stops the current recording before the default capture timeout passed in the startRecording
  53230. * functions.
  53231. */
  53232. stopRecording(): void;
  53233. /**
  53234. * Starts recording the canvas for a max duration specified in parameters.
  53235. * @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.
  53236. * @param maxDuration Defines the maximum recording time in seconds.
  53237. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  53238. * @return a promise callback at the end of the recording with the video data in Blob.
  53239. */
  53240. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  53241. /**
  53242. * Releases internal resources used during the recording.
  53243. */
  53244. dispose(): void;
  53245. private _handleDataAvailable;
  53246. private _handleError;
  53247. private _handleStop;
  53248. }
  53249. }
  53250. declare module BABYLON {
  53251. /**
  53252. * Helper class to push actions to a pool of workers.
  53253. */
  53254. export class WorkerPool implements IDisposable {
  53255. private _workerInfos;
  53256. private _pendingActions;
  53257. /**
  53258. * Constructor
  53259. * @param workers Array of workers to use for actions
  53260. */
  53261. constructor(workers: Array<Worker>);
  53262. /**
  53263. * Terminates all workers and clears any pending actions.
  53264. */
  53265. dispose(): void;
  53266. /**
  53267. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53268. * pended until a worker has completed its action.
  53269. * @param action The action to perform. Call onComplete when the action is complete.
  53270. */
  53271. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53272. private _execute;
  53273. }
  53274. }
  53275. declare module BABYLON {
  53276. /**
  53277. * Class containing a set of static utilities functions for screenshots
  53278. */
  53279. export class ScreenshotTools {
  53280. /**
  53281. * Captures a screenshot of the current rendering
  53282. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53283. * @param engine defines the rendering engine
  53284. * @param camera defines the source camera
  53285. * @param size This parameter can be set to a single number or to an object with the
  53286. * following (optional) properties: precision, width, height. If a single number is passed,
  53287. * it will be used for both width and height. If an object is passed, the screenshot size
  53288. * will be derived from the parameters. The precision property is a multiplier allowing
  53289. * rendering at a higher or lower resolution
  53290. * @param successCallback defines the callback receives a single parameter which contains the
  53291. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53292. * src parameter of an <img> to display it
  53293. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  53294. * Check your browser for supported MIME types
  53295. */
  53296. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  53297. /**
  53298. * Generates an image screenshot from the specified camera.
  53299. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  53300. * @param engine The engine to use for rendering
  53301. * @param camera The camera to use for rendering
  53302. * @param size This parameter can be set to a single number or to an object with the
  53303. * following (optional) properties: precision, width, height. If a single number is passed,
  53304. * it will be used for both width and height. If an object is passed, the screenshot size
  53305. * will be derived from the parameters. The precision property is a multiplier allowing
  53306. * rendering at a higher or lower resolution
  53307. * @param successCallback The callback receives a single parameter which contains the
  53308. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  53309. * src parameter of an <img> to display it
  53310. * @param mimeType The MIME type of the screenshot image (default: image/png).
  53311. * Check your browser for supported MIME types
  53312. * @param samples Texture samples (default: 1)
  53313. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  53314. * @param fileName A name for for the downloaded file.
  53315. */
  53316. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  53317. }
  53318. }
  53319. declare module BABYLON {
  53320. /**
  53321. * A cursor which tracks a point on a path
  53322. */
  53323. export class PathCursor {
  53324. private path;
  53325. /**
  53326. * Stores path cursor callbacks for when an onchange event is triggered
  53327. */
  53328. private _onchange;
  53329. /**
  53330. * The value of the path cursor
  53331. */
  53332. value: number;
  53333. /**
  53334. * The animation array of the path cursor
  53335. */
  53336. animations: Animation[];
  53337. /**
  53338. * Initializes the path cursor
  53339. * @param path The path to track
  53340. */
  53341. constructor(path: Path2);
  53342. /**
  53343. * Gets the cursor point on the path
  53344. * @returns A point on the path cursor at the cursor location
  53345. */
  53346. getPoint(): Vector3;
  53347. /**
  53348. * Moves the cursor ahead by the step amount
  53349. * @param step The amount to move the cursor forward
  53350. * @returns This path cursor
  53351. */
  53352. moveAhead(step?: number): PathCursor;
  53353. /**
  53354. * Moves the cursor behind by the step amount
  53355. * @param step The amount to move the cursor back
  53356. * @returns This path cursor
  53357. */
  53358. moveBack(step?: number): PathCursor;
  53359. /**
  53360. * Moves the cursor by the step amount
  53361. * If the step amount is greater than one, an exception is thrown
  53362. * @param step The amount to move the cursor
  53363. * @returns This path cursor
  53364. */
  53365. move(step: number): PathCursor;
  53366. /**
  53367. * Ensures that the value is limited between zero and one
  53368. * @returns This path cursor
  53369. */
  53370. private ensureLimits;
  53371. /**
  53372. * Runs onchange callbacks on change (used by the animation engine)
  53373. * @returns This path cursor
  53374. */
  53375. private raiseOnChange;
  53376. /**
  53377. * Executes a function on change
  53378. * @param f A path cursor onchange callback
  53379. * @returns This path cursor
  53380. */
  53381. onchange(f: (cursor: PathCursor) => void): PathCursor;
  53382. }
  53383. }
  53384. declare module BABYLON {
  53385. /** @hidden */
  53386. export var blurPixelShader: {
  53387. name: string;
  53388. shader: string;
  53389. };
  53390. }
  53391. declare module BABYLON {
  53392. /** @hidden */
  53393. export var bones300Declaration: {
  53394. name: string;
  53395. shader: string;
  53396. };
  53397. }
  53398. declare module BABYLON {
  53399. /** @hidden */
  53400. export var instances300Declaration: {
  53401. name: string;
  53402. shader: string;
  53403. };
  53404. }
  53405. declare module BABYLON {
  53406. /** @hidden */
  53407. export var pointCloudVertexDeclaration: {
  53408. name: string;
  53409. shader: string;
  53410. };
  53411. }
  53412. // Mixins
  53413. interface Window {
  53414. mozIndexedDB: IDBFactory;
  53415. webkitIndexedDB: IDBFactory;
  53416. msIndexedDB: IDBFactory;
  53417. webkitURL: typeof URL;
  53418. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  53419. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  53420. WebGLRenderingContext: WebGLRenderingContext;
  53421. MSGesture: MSGesture;
  53422. CANNON: any;
  53423. AudioContext: AudioContext;
  53424. webkitAudioContext: AudioContext;
  53425. PointerEvent: any;
  53426. Math: Math;
  53427. Uint8Array: Uint8ArrayConstructor;
  53428. Float32Array: Float32ArrayConstructor;
  53429. mozURL: typeof URL;
  53430. msURL: typeof URL;
  53431. VRFrameData: any; // WebVR, from specs 1.1
  53432. DracoDecoderModule: any;
  53433. setImmediate(handler: (...args: any[]) => void): number;
  53434. }
  53435. interface Document {
  53436. mozCancelFullScreen(): void;
  53437. msCancelFullScreen(): void;
  53438. webkitCancelFullScreen(): void;
  53439. requestPointerLock(): void;
  53440. exitPointerLock(): void;
  53441. mozFullScreen: boolean;
  53442. msIsFullScreen: boolean;
  53443. readonly webkitIsFullScreen: boolean;
  53444. readonly pointerLockElement: Element;
  53445. mozPointerLockElement: HTMLElement;
  53446. msPointerLockElement: HTMLElement;
  53447. webkitPointerLockElement: HTMLElement;
  53448. }
  53449. interface HTMLCanvasElement {
  53450. requestPointerLock(): void;
  53451. msRequestPointerLock?(): void;
  53452. mozRequestPointerLock?(): void;
  53453. webkitRequestPointerLock?(): void;
  53454. /** Track wether a record is in progress */
  53455. isRecording: boolean;
  53456. /** Capture Stream method defined by some browsers */
  53457. captureStream(fps?: number): MediaStream;
  53458. }
  53459. interface CanvasRenderingContext2D {
  53460. msImageSmoothingEnabled: boolean;
  53461. }
  53462. interface MouseEvent {
  53463. mozMovementX: number;
  53464. mozMovementY: number;
  53465. webkitMovementX: number;
  53466. webkitMovementY: number;
  53467. msMovementX: number;
  53468. msMovementY: number;
  53469. }
  53470. interface Navigator {
  53471. mozGetVRDevices: (any: any) => any;
  53472. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53473. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53474. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  53475. webkitGetGamepads(): Gamepad[];
  53476. msGetGamepads(): Gamepad[];
  53477. webkitGamepads(): Gamepad[];
  53478. }
  53479. interface HTMLVideoElement {
  53480. mozSrcObject: any;
  53481. }
  53482. interface Math {
  53483. fround(x: number): number;
  53484. imul(a: number, b: number): number;
  53485. }
  53486. interface WebGLProgram {
  53487. context?: WebGLRenderingContext;
  53488. vertexShader?: WebGLShader;
  53489. fragmentShader?: WebGLShader;
  53490. isParallelCompiled: boolean;
  53491. onCompiled?: () => void;
  53492. }
  53493. interface WebGLRenderingContext {
  53494. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  53495. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  53496. vertexAttribDivisor(index: number, divisor: number): void;
  53497. createVertexArray(): any;
  53498. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  53499. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  53500. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  53501. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  53502. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  53503. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  53504. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  53505. // Queries
  53506. createQuery(): WebGLQuery;
  53507. deleteQuery(query: WebGLQuery): void;
  53508. beginQuery(target: number, query: WebGLQuery): void;
  53509. endQuery(target: number): void;
  53510. getQueryParameter(query: WebGLQuery, pname: number): any;
  53511. getQuery(target: number, pname: number): any;
  53512. MAX_SAMPLES: number;
  53513. RGBA8: number;
  53514. READ_FRAMEBUFFER: number;
  53515. DRAW_FRAMEBUFFER: number;
  53516. UNIFORM_BUFFER: number;
  53517. HALF_FLOAT_OES: number;
  53518. RGBA16F: number;
  53519. RGBA32F: number;
  53520. R32F: number;
  53521. RG32F: number;
  53522. RGB32F: number;
  53523. R16F: number;
  53524. RG16F: number;
  53525. RGB16F: number;
  53526. RED: number;
  53527. RG: number;
  53528. R8: number;
  53529. RG8: number;
  53530. UNSIGNED_INT_24_8: number;
  53531. DEPTH24_STENCIL8: number;
  53532. /* Multiple Render Targets */
  53533. drawBuffers(buffers: number[]): void;
  53534. readBuffer(src: number): void;
  53535. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  53536. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  53537. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  53538. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  53539. // Occlusion Query
  53540. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  53541. ANY_SAMPLES_PASSED: number;
  53542. QUERY_RESULT_AVAILABLE: number;
  53543. QUERY_RESULT: number;
  53544. }
  53545. interface WebGLBuffer {
  53546. references: number;
  53547. capacity: number;
  53548. is32Bits: boolean;
  53549. }
  53550. interface WebGLProgram {
  53551. transformFeedback?: WebGLTransformFeedback | null;
  53552. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  53553. }
  53554. interface EXT_disjoint_timer_query {
  53555. QUERY_COUNTER_BITS_EXT: number;
  53556. TIME_ELAPSED_EXT: number;
  53557. TIMESTAMP_EXT: number;
  53558. GPU_DISJOINT_EXT: number;
  53559. QUERY_RESULT_EXT: number;
  53560. QUERY_RESULT_AVAILABLE_EXT: number;
  53561. queryCounterEXT(query: WebGLQuery, target: number): void;
  53562. createQueryEXT(): WebGLQuery;
  53563. beginQueryEXT(target: number, query: WebGLQuery): void;
  53564. endQueryEXT(target: number): void;
  53565. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  53566. deleteQueryEXT(query: WebGLQuery): void;
  53567. }
  53568. interface WebGLUniformLocation {
  53569. _currentState: any;
  53570. }
  53571. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  53572. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  53573. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  53574. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53575. interface WebGLRenderingContext {
  53576. readonly RASTERIZER_DISCARD: number;
  53577. readonly DEPTH_COMPONENT24: number;
  53578. readonly TEXTURE_3D: number;
  53579. readonly TEXTURE_2D_ARRAY: number;
  53580. readonly TEXTURE_COMPARE_FUNC: number;
  53581. readonly TEXTURE_COMPARE_MODE: number;
  53582. readonly COMPARE_REF_TO_TEXTURE: number;
  53583. readonly TEXTURE_WRAP_R: number;
  53584. readonly HALF_FLOAT: number;
  53585. readonly RGB8: number;
  53586. readonly RED_INTEGER: number;
  53587. readonly RG_INTEGER: number;
  53588. readonly RGB_INTEGER: number;
  53589. readonly RGBA_INTEGER: number;
  53590. readonly R8_SNORM: number;
  53591. readonly RG8_SNORM: number;
  53592. readonly RGB8_SNORM: number;
  53593. readonly RGBA8_SNORM: number;
  53594. readonly R8I: number;
  53595. readonly RG8I: number;
  53596. readonly RGB8I: number;
  53597. readonly RGBA8I: number;
  53598. readonly R8UI: number;
  53599. readonly RG8UI: number;
  53600. readonly RGB8UI: number;
  53601. readonly RGBA8UI: number;
  53602. readonly R16I: number;
  53603. readonly RG16I: number;
  53604. readonly RGB16I: number;
  53605. readonly RGBA16I: number;
  53606. readonly R16UI: number;
  53607. readonly RG16UI: number;
  53608. readonly RGB16UI: number;
  53609. readonly RGBA16UI: number;
  53610. readonly R32I: number;
  53611. readonly RG32I: number;
  53612. readonly RGB32I: number;
  53613. readonly RGBA32I: number;
  53614. readonly R32UI: number;
  53615. readonly RG32UI: number;
  53616. readonly RGB32UI: number;
  53617. readonly RGBA32UI: number;
  53618. readonly RGB10_A2UI: number;
  53619. readonly R11F_G11F_B10F: number;
  53620. readonly RGB9_E5: number;
  53621. readonly RGB10_A2: number;
  53622. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  53623. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  53624. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  53625. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  53626. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  53627. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  53628. 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;
  53629. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  53630. readonly TRANSFORM_FEEDBACK: number;
  53631. readonly INTERLEAVED_ATTRIBS: number;
  53632. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  53633. createTransformFeedback(): WebGLTransformFeedback;
  53634. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  53635. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  53636. beginTransformFeedback(primitiveMode: number): void;
  53637. endTransformFeedback(): void;
  53638. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  53639. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53640. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53641. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  53642. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  53643. }
  53644. interface ImageBitmap {
  53645. readonly width: number;
  53646. readonly height: number;
  53647. close(): void;
  53648. }
  53649. interface WebGLQuery extends WebGLObject {
  53650. }
  53651. declare var WebGLQuery: {
  53652. prototype: WebGLQuery;
  53653. new(): WebGLQuery;
  53654. };
  53655. interface WebGLSampler extends WebGLObject {
  53656. }
  53657. declare var WebGLSampler: {
  53658. prototype: WebGLSampler;
  53659. new(): WebGLSampler;
  53660. };
  53661. interface WebGLSync extends WebGLObject {
  53662. }
  53663. declare var WebGLSync: {
  53664. prototype: WebGLSync;
  53665. new(): WebGLSync;
  53666. };
  53667. interface WebGLTransformFeedback extends WebGLObject {
  53668. }
  53669. declare var WebGLTransformFeedback: {
  53670. prototype: WebGLTransformFeedback;
  53671. new(): WebGLTransformFeedback;
  53672. };
  53673. interface WebGLVertexArrayObject extends WebGLObject {
  53674. }
  53675. declare var WebGLVertexArrayObject: {
  53676. prototype: WebGLVertexArrayObject;
  53677. new(): WebGLVertexArrayObject;
  53678. };
  53679. // Type definitions for WebVR API
  53680. // Project: https://w3c.github.io/webvr/
  53681. // Definitions by: six a <https://github.com/lostfictions>
  53682. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  53683. interface VRDisplay extends EventTarget {
  53684. /**
  53685. * Dictionary of capabilities describing the VRDisplay.
  53686. */
  53687. readonly capabilities: VRDisplayCapabilities;
  53688. /**
  53689. * z-depth defining the far plane of the eye view frustum
  53690. * enables mapping of values in the render target depth
  53691. * attachment to scene coordinates. Initially set to 10000.0.
  53692. */
  53693. depthFar: number;
  53694. /**
  53695. * z-depth defining the near plane of the eye view frustum
  53696. * enables mapping of values in the render target depth
  53697. * attachment to scene coordinates. Initially set to 0.01.
  53698. */
  53699. depthNear: number;
  53700. /**
  53701. * An identifier for this distinct VRDisplay. Used as an
  53702. * association point in the Gamepad API.
  53703. */
  53704. readonly displayId: number;
  53705. /**
  53706. * A display name, a user-readable name identifying it.
  53707. */
  53708. readonly displayName: string;
  53709. readonly isConnected: boolean;
  53710. readonly isPresenting: boolean;
  53711. /**
  53712. * If this VRDisplay supports room-scale experiences, the optional
  53713. * stage attribute contains details on the room-scale parameters.
  53714. */
  53715. readonly stageParameters: VRStageParameters | null;
  53716. /**
  53717. * Passing the value returned by `requestAnimationFrame` to
  53718. * `cancelAnimationFrame` will unregister the callback.
  53719. * @param handle Define the hanle of the request to cancel
  53720. */
  53721. cancelAnimationFrame(handle: number): void;
  53722. /**
  53723. * Stops presenting to the VRDisplay.
  53724. * @returns a promise to know when it stopped
  53725. */
  53726. exitPresent(): Promise<void>;
  53727. /**
  53728. * Return the current VREyeParameters for the given eye.
  53729. * @param whichEye Define the eye we want the parameter for
  53730. * @returns the eye parameters
  53731. */
  53732. getEyeParameters(whichEye: string): VREyeParameters;
  53733. /**
  53734. * Populates the passed VRFrameData with the information required to render
  53735. * the current frame.
  53736. * @param frameData Define the data structure to populate
  53737. * @returns true if ok otherwise false
  53738. */
  53739. getFrameData(frameData: VRFrameData): boolean;
  53740. /**
  53741. * Get the layers currently being presented.
  53742. * @returns the list of VR layers
  53743. */
  53744. getLayers(): VRLayer[];
  53745. /**
  53746. * Return a VRPose containing the future predicted pose of the VRDisplay
  53747. * when the current frame will be presented. The value returned will not
  53748. * change until JavaScript has returned control to the browser.
  53749. *
  53750. * The VRPose will contain the position, orientation, velocity,
  53751. * and acceleration of each of these properties.
  53752. * @returns the pose object
  53753. */
  53754. getPose(): VRPose;
  53755. /**
  53756. * Return the current instantaneous pose of the VRDisplay, with no
  53757. * prediction applied.
  53758. * @returns the current instantaneous pose
  53759. */
  53760. getImmediatePose(): VRPose;
  53761. /**
  53762. * The callback passed to `requestAnimationFrame` will be called
  53763. * any time a new frame should be rendered. When the VRDisplay is
  53764. * presenting the callback will be called at the native refresh
  53765. * rate of the HMD. When not presenting this function acts
  53766. * identically to how window.requestAnimationFrame acts. Content should
  53767. * make no assumptions of frame rate or vsync behavior as the HMD runs
  53768. * asynchronously from other displays and at differing refresh rates.
  53769. * @param callback Define the eaction to run next frame
  53770. * @returns the request handle it
  53771. */
  53772. requestAnimationFrame(callback: FrameRequestCallback): number;
  53773. /**
  53774. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  53775. * Repeat calls while already presenting will update the VRLayers being displayed.
  53776. * @param layers Define the list of layer to present
  53777. * @returns a promise to know when the request has been fulfilled
  53778. */
  53779. requestPresent(layers: VRLayer[]): Promise<void>;
  53780. /**
  53781. * Reset the pose for this display, treating its current position and
  53782. * orientation as the "origin/zero" values. VRPose.position,
  53783. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  53784. * updated when calling resetPose(). This should be called in only
  53785. * sitting-space experiences.
  53786. */
  53787. resetPose(): void;
  53788. /**
  53789. * The VRLayer provided to the VRDisplay will be captured and presented
  53790. * in the HMD. Calling this function has the same effect on the source
  53791. * canvas as any other operation that uses its source image, and canvases
  53792. * created without preserveDrawingBuffer set to true will be cleared.
  53793. * @param pose Define the pose to submit
  53794. */
  53795. submitFrame(pose?: VRPose): void;
  53796. }
  53797. declare var VRDisplay: {
  53798. prototype: VRDisplay;
  53799. new(): VRDisplay;
  53800. };
  53801. interface VRLayer {
  53802. leftBounds?: number[] | Float32Array | null;
  53803. rightBounds?: number[] | Float32Array | null;
  53804. source?: HTMLCanvasElement | null;
  53805. }
  53806. interface VRDisplayCapabilities {
  53807. readonly canPresent: boolean;
  53808. readonly hasExternalDisplay: boolean;
  53809. readonly hasOrientation: boolean;
  53810. readonly hasPosition: boolean;
  53811. readonly maxLayers: number;
  53812. }
  53813. interface VREyeParameters {
  53814. /** @deprecated */
  53815. readonly fieldOfView: VRFieldOfView;
  53816. readonly offset: Float32Array;
  53817. readonly renderHeight: number;
  53818. readonly renderWidth: number;
  53819. }
  53820. interface VRFieldOfView {
  53821. readonly downDegrees: number;
  53822. readonly leftDegrees: number;
  53823. readonly rightDegrees: number;
  53824. readonly upDegrees: number;
  53825. }
  53826. interface VRFrameData {
  53827. readonly leftProjectionMatrix: Float32Array;
  53828. readonly leftViewMatrix: Float32Array;
  53829. readonly pose: VRPose;
  53830. readonly rightProjectionMatrix: Float32Array;
  53831. readonly rightViewMatrix: Float32Array;
  53832. readonly timestamp: number;
  53833. }
  53834. interface VRPose {
  53835. readonly angularAcceleration: Float32Array | null;
  53836. readonly angularVelocity: Float32Array | null;
  53837. readonly linearAcceleration: Float32Array | null;
  53838. readonly linearVelocity: Float32Array | null;
  53839. readonly orientation: Float32Array | null;
  53840. readonly position: Float32Array | null;
  53841. readonly timestamp: number;
  53842. }
  53843. interface VRStageParameters {
  53844. sittingToStandingTransform?: Float32Array;
  53845. sizeX?: number;
  53846. sizeY?: number;
  53847. }
  53848. interface Navigator {
  53849. getVRDisplays(): Promise<VRDisplay[]>;
  53850. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  53851. }
  53852. interface Window {
  53853. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  53854. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  53855. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  53856. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53857. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  53858. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  53859. }
  53860. interface Gamepad {
  53861. readonly displayId: number;
  53862. }
  53863. interface XRDevice {
  53864. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  53865. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  53866. }
  53867. interface XRSession {
  53868. getInputSources(): Array<any>;
  53869. baseLayer: XRWebGLLayer;
  53870. requestFrameOfReference(type: string): Promise<void>;
  53871. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  53872. end(): Promise<void>;
  53873. requestAnimationFrame: Function;
  53874. addEventListener: Function;
  53875. }
  53876. interface XRSessionCreationOptions {
  53877. outputContext?: WebGLRenderingContext | null;
  53878. immersive?: boolean;
  53879. environmentIntegration?: boolean;
  53880. }
  53881. interface XRLayer {
  53882. getViewport: Function;
  53883. framebufferWidth: number;
  53884. framebufferHeight: number;
  53885. }
  53886. interface XRView {
  53887. projectionMatrix: Float32Array;
  53888. }
  53889. interface XRFrame {
  53890. getDevicePose: Function;
  53891. getInputPose: Function;
  53892. views: Array<XRView>;
  53893. baseLayer: XRLayer;
  53894. }
  53895. interface XRFrameOfReference {
  53896. }
  53897. interface XRWebGLLayer extends XRLayer {
  53898. framebuffer: WebGLFramebuffer;
  53899. }
  53900. declare var XRWebGLLayer: {
  53901. prototype: XRWebGLLayer;
  53902. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  53903. };