babylon.d.ts 2.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. /**
  6. * Defines how the parser contract is defined.
  7. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  8. */
  9. type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  10. /**
  11. * Defines how the individual parser contract is defined.
  12. * These parser can parse an individual asset
  13. */
  14. type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  15. /**
  16. * Base class of the scene acting as a container for the different elements composing a scene.
  17. * This class is dynamically extended by the different components of the scene increasing
  18. * flexibility and reducing coupling
  19. */
  20. abstract class AbstractScene {
  21. /**
  22. * Stores the list of available parsers in the application.
  23. */
  24. private static _BabylonFileParsers;
  25. /**
  26. * Stores the list of available individual parsers in the application.
  27. */
  28. private static _IndividualBabylonFileParsers;
  29. /**
  30. * Adds a parser in the list of available ones
  31. * @param name Defines the name of the parser
  32. * @param parser Defines the parser to add
  33. */
  34. static AddParser(name: string, parser: BabylonFileParser): void;
  35. /**
  36. * Gets a general parser from the list of avaialble ones
  37. * @param name Defines the name of the parser
  38. * @returns the requested parser or null
  39. */
  40. static GetParser(name: string): Nullable<BabylonFileParser>;
  41. /**
  42. * Adds n individual parser in the list of available ones
  43. * @param name Defines the name of the parser
  44. * @param parser Defines the parser to add
  45. */
  46. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47. /**
  48. * Gets an individual parser from the list of avaialble ones
  49. * @param name Defines the name of the parser
  50. * @returns the requested parser or null
  51. */
  52. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  53. /**
  54. * Parser json data and populate both a scene and its associated container object
  55. * @param jsonData Defines the data to parse
  56. * @param scene Defines the scene to parse the data for
  57. * @param container Defines the container attached to the parsing sequence
  58. * @param rootUrl Defines the root url of the data
  59. */
  60. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  61. /**
  62. * Gets the list of root nodes (ie. nodes with no parent)
  63. */
  64. rootNodes: Node[];
  65. /** All of the cameras added to this scene
  66. * @see http://doc.babylonjs.com/babylon101/cameras
  67. */
  68. cameras: Camera[];
  69. /**
  70. * All of the lights added to this scene
  71. * @see http://doc.babylonjs.com/babylon101/lights
  72. */
  73. lights: Light[];
  74. /**
  75. * All of the (abstract) meshes added to this scene
  76. */
  77. meshes: AbstractMesh[];
  78. /**
  79. * The list of skeletons added to the scene
  80. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81. */
  82. skeletons: Skeleton[];
  83. /**
  84. * All of the particle systems added to this scene
  85. * @see http://doc.babylonjs.com/babylon101/particles
  86. */
  87. particleSystems: IParticleSystem[];
  88. /**
  89. * Gets a list of Animations associated with the scene
  90. */
  91. animations: Animation[];
  92. /**
  93. * All of the animation groups added to this scene
  94. * @see http://doc.babylonjs.com/how_to/group
  95. */
  96. animationGroups: AnimationGroup[];
  97. /**
  98. * All of the multi-materials added to this scene
  99. * @see http://doc.babylonjs.com/how_to/multi_materials
  100. */
  101. multiMaterials: MultiMaterial[];
  102. /**
  103. * All of the materials added to this scene
  104. * In the context of a Scene, it is not supposed to be modified manually.
  105. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  106. * Note also that the order of the Material wihin the array is not significant and might change.
  107. * @see http://doc.babylonjs.com/babylon101/materials
  108. */
  109. materials: Material[];
  110. /**
  111. * The list of morph target managers added to the scene
  112. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  113. */
  114. morphTargetManagers: MorphTargetManager[];
  115. /**
  116. * The list of geometries used in the scene.
  117. */
  118. geometries: Geometry[];
  119. /**
  120. * All of the tranform nodes added to this scene
  121. * In the context of a Scene, it is not supposed to be modified manually.
  122. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  123. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  124. * @see http://doc.babylonjs.com/how_to/transformnode
  125. */
  126. transformNodes: TransformNode[];
  127. /**
  128. * ActionManagers available on the scene.
  129. */
  130. actionManagers: ActionManager[];
  131. /**
  132. * Textures to keep.
  133. */
  134. textures: BaseTexture[];
  135. }
  136. }
  137. declare module BABYLON {
  138. /**
  139. * Set of assets to keep when moving a scene into an asset container.
  140. */
  141. class KeepAssets extends AbstractScene {
  142. }
  143. /**
  144. * Container with a set of assets that can be added or removed from a scene.
  145. */
  146. class AssetContainer extends AbstractScene {
  147. /**
  148. * The scene the AssetContainer belongs to.
  149. */
  150. scene: Scene;
  151. /**
  152. * Instantiates an AssetContainer.
  153. * @param scene The scene the AssetContainer belongs to.
  154. */
  155. constructor(scene: Scene);
  156. /**
  157. * Adds all the assets from the container to the scene.
  158. */
  159. addAllToScene(): void;
  160. /**
  161. * Removes all the assets in the container from the scene
  162. */
  163. removeAllFromScene(): void;
  164. /**
  165. * Disposes all the assets in the container
  166. */
  167. dispose(): void;
  168. private _moveAssets;
  169. /**
  170. * Removes all the assets contained in the scene and adds them to the container.
  171. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  172. */
  173. moveAllFromScene(keepAssets?: KeepAssets): void;
  174. /**
  175. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  176. * @returns the root mesh
  177. */
  178. createRootMesh(): Mesh;
  179. }
  180. }
  181. interface Window {
  182. mozIndexedDB: IDBFactory;
  183. webkitIndexedDB: IDBFactory;
  184. msIndexedDB: IDBFactory;
  185. webkitURL: typeof URL;
  186. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  187. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  188. WebGLRenderingContext: WebGLRenderingContext;
  189. MSGesture: MSGesture;
  190. CANNON: any;
  191. AudioContext: AudioContext;
  192. webkitAudioContext: AudioContext;
  193. PointerEvent: any;
  194. Math: Math;
  195. Uint8Array: Uint8ArrayConstructor;
  196. Float32Array: Float32ArrayConstructor;
  197. mozURL: typeof URL;
  198. msURL: typeof URL;
  199. VRFrameData: any;
  200. DracoDecoderModule: any;
  201. setImmediate(handler: (...args: any[]) => void): number;
  202. }
  203. interface WebGLProgram {
  204. context?: WebGLRenderingContext;
  205. vertexShader?: WebGLShader;
  206. fragmentShader?: WebGLShader;
  207. isParallelCompiled: boolean;
  208. onCompiled?: () => void;
  209. }
  210. interface WebGLRenderingContext {
  211. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  212. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  213. vertexAttribDivisor(index: number, divisor: number): void;
  214. createVertexArray(): any;
  215. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  216. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  217. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  218. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  219. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  220. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  221. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  222. createQuery(): WebGLQuery;
  223. deleteQuery(query: WebGLQuery): void;
  224. beginQuery(target: number, query: WebGLQuery): void;
  225. endQuery(target: number): void;
  226. getQueryParameter(query: WebGLQuery, pname: number): any;
  227. getQuery(target: number, pname: number): any;
  228. MAX_SAMPLES: number;
  229. RGBA8: number;
  230. READ_FRAMEBUFFER: number;
  231. DRAW_FRAMEBUFFER: number;
  232. UNIFORM_BUFFER: number;
  233. HALF_FLOAT_OES: number;
  234. RGBA16F: number;
  235. RGBA32F: number;
  236. R32F: number;
  237. RG32F: number;
  238. RGB32F: number;
  239. R16F: number;
  240. RG16F: number;
  241. RGB16F: number;
  242. RED: number;
  243. RG: number;
  244. R8: number;
  245. RG8: number;
  246. UNSIGNED_INT_24_8: number;
  247. DEPTH24_STENCIL8: number;
  248. drawBuffers(buffers: number[]): void;
  249. readBuffer(src: number): void;
  250. readonly COLOR_ATTACHMENT0: number;
  251. readonly COLOR_ATTACHMENT1: number;
  252. readonly COLOR_ATTACHMENT2: number;
  253. readonly COLOR_ATTACHMENT3: number;
  254. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  255. ANY_SAMPLES_PASSED: number;
  256. QUERY_RESULT_AVAILABLE: number;
  257. QUERY_RESULT: number;
  258. }
  259. interface Document {
  260. mozCancelFullScreen(): void;
  261. msCancelFullScreen(): void;
  262. webkitCancelFullScreen(): void;
  263. requestPointerLock(): void;
  264. exitPointerLock(): void;
  265. mozFullScreen: boolean;
  266. msIsFullScreen: boolean;
  267. readonly webkitIsFullScreen: boolean;
  268. readonly pointerLockElement: Element;
  269. mozPointerLockElement: HTMLElement;
  270. msPointerLockElement: HTMLElement;
  271. webkitPointerLockElement: HTMLElement;
  272. }
  273. interface HTMLCanvasElement {
  274. requestPointerLock(): void;
  275. msRequestPointerLock?(): void;
  276. mozRequestPointerLock?(): void;
  277. webkitRequestPointerLock?(): void;
  278. }
  279. interface CanvasRenderingContext2D {
  280. msImageSmoothingEnabled: boolean;
  281. }
  282. interface WebGLBuffer {
  283. references: number;
  284. capacity: number;
  285. is32Bits: boolean;
  286. }
  287. interface WebGLProgram {
  288. transformFeedback?: WebGLTransformFeedback | null;
  289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  290. }
  291. interface MouseEvent {
  292. mozMovementX: number;
  293. mozMovementY: number;
  294. webkitMovementX: number;
  295. webkitMovementY: number;
  296. msMovementX: number;
  297. msMovementY: number;
  298. }
  299. interface Navigator {
  300. mozGetVRDevices: (any: any) => any;
  301. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  302. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  303. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  304. webkitGetGamepads(): Gamepad[];
  305. msGetGamepads(): Gamepad[];
  306. webkitGamepads(): Gamepad[];
  307. }
  308. interface HTMLVideoElement {
  309. mozSrcObject: any;
  310. }
  311. interface Math {
  312. fround(x: number): number;
  313. imul(a: number, b: number): number;
  314. }
  315. interface EXT_disjoint_timer_query {
  316. QUERY_COUNTER_BITS_EXT: number;
  317. TIME_ELAPSED_EXT: number;
  318. TIMESTAMP_EXT: number;
  319. GPU_DISJOINT_EXT: number;
  320. QUERY_RESULT_EXT: number;
  321. QUERY_RESULT_AVAILABLE_EXT: number;
  322. queryCounterEXT(query: WebGLQuery, target: number): void;
  323. createQueryEXT(): WebGLQuery;
  324. beginQueryEXT(target: number, query: WebGLQuery): void;
  325. endQueryEXT(target: number): void;
  326. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  327. deleteQueryEXT(query: WebGLQuery): void;
  328. }
  329. interface WebGLUniformLocation {
  330. _currentState: any;
  331. }
  332. interface XRDevice {
  333. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  334. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  335. }
  336. interface XRSession {
  337. getInputSources(): Array<any>;
  338. baseLayer: XRWebGLLayer;
  339. requestFrameOfReference(type: string): Promise<void>;
  340. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  341. end(): Promise<void>;
  342. requestAnimationFrame: Function;
  343. addEventListener: Function;
  344. }
  345. interface XRSessionCreationOptions {
  346. outputContext?: WebGLRenderingContext | null;
  347. immersive?: boolean;
  348. environmentIntegration?: boolean;
  349. }
  350. interface XRLayer {
  351. getViewport: Function;
  352. framebufferWidth: number;
  353. framebufferHeight: number;
  354. }
  355. interface XRView {
  356. projectionMatrix: Float32Array;
  357. }
  358. interface XRFrame {
  359. getDevicePose: Function;
  360. getInputPose: Function;
  361. views: Array<XRView>;
  362. baseLayer: XRLayer;
  363. }
  364. interface XRFrameOfReference {
  365. }
  366. interface XRWebGLLayer extends XRLayer {
  367. framebuffer: WebGLFramebuffer;
  368. }
  369. declare var XRWebGLLayer: {
  370. prototype: XRWebGLLayer;
  371. new (session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  372. };
  373. declare module BABYLON {
  374. /**
  375. * Defines how a node can be built from a string name.
  376. */
  377. type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  378. /**
  379. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  380. */
  381. class Node implements IBehaviorAware<Node> {
  382. private static _NodeConstructors;
  383. /**
  384. * Add a new node constructor
  385. * @param type defines the type name of the node to construct
  386. * @param constructorFunc defines the constructor function
  387. */
  388. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  389. /**
  390. * Returns a node constructor based on type name
  391. * @param type defines the type name
  392. * @param name defines the new node name
  393. * @param scene defines the hosting scene
  394. * @param options defines optional options to transmit to constructors
  395. * @returns the new constructor or null
  396. */
  397. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  398. /**
  399. * Gets or sets the name of the node
  400. */
  401. name: string;
  402. /**
  403. * Gets or sets the id of the node
  404. */
  405. id: string;
  406. /**
  407. * Gets or sets the unique id of the node
  408. */
  409. uniqueId: number;
  410. /**
  411. * Gets or sets a string used to store user defined state for the node
  412. */
  413. state: string;
  414. /**
  415. * Gets or sets an object used to store user defined information for the node
  416. */
  417. metadata: any;
  418. /**
  419. * Gets or sets a boolean used to define if the node must be serialized
  420. */
  421. doNotSerialize: boolean;
  422. /** @hidden */
  423. _isDisposed: boolean;
  424. /**
  425. * Gets a list of Animations associated with the node
  426. */
  427. animations: Animation[];
  428. protected _ranges: {
  429. [name: string]: Nullable<AnimationRange>;
  430. };
  431. /**
  432. * Callback raised when the node is ready to be used
  433. */
  434. onReady: (node: Node) => void;
  435. private _isEnabled;
  436. private _isParentEnabled;
  437. private _isReady;
  438. /** @hidden */
  439. _currentRenderId: number;
  440. private _parentRenderId;
  441. protected _childRenderId: number;
  442. /** @hidden */
  443. _waitingParentId: Nullable<string>;
  444. /** @hidden */
  445. _scene: Scene;
  446. /** @hidden */
  447. _cache: any;
  448. private _parentNode;
  449. private _children;
  450. /** @hidden */
  451. _worldMatrix: Matrix;
  452. /** @hidden */
  453. _worldMatrixDeterminant: number;
  454. /** @hidden */
  455. private _sceneRootNodesIndex;
  456. /**
  457. * Gets a boolean indicating if the node has been disposed
  458. * @returns true if the node was disposed
  459. */
  460. isDisposed(): boolean;
  461. /**
  462. * Gets or sets the parent of the node
  463. */
  464. parent: Nullable<Node>;
  465. private addToSceneRootNodes;
  466. private removeFromSceneRootNodes;
  467. private _animationPropertiesOverride;
  468. /**
  469. * Gets or sets the animation properties override
  470. */
  471. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  472. /**
  473. * Gets a string idenfifying the name of the class
  474. * @returns "Node" string
  475. */
  476. getClassName(): string;
  477. /**
  478. * An event triggered when the mesh is disposed
  479. */
  480. onDisposeObservable: Observable<Node>;
  481. private _onDisposeObserver;
  482. /**
  483. * Sets a callback that will be raised when the node will be disposed
  484. */
  485. onDispose: () => void;
  486. /**
  487. * Creates a new Node
  488. * @param name the name and id to be given to this node
  489. * @param scene the scene this node will be added to
  490. * @param addToRootNodes the node will be added to scene.rootNodes
  491. */
  492. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  493. /**
  494. * Gets the scene of the node
  495. * @returns a scene
  496. */
  497. getScene(): Scene;
  498. /**
  499. * Gets the engine of the node
  500. * @returns a Engine
  501. */
  502. getEngine(): Engine;
  503. private _behaviors;
  504. /**
  505. * Attach a behavior to the node
  506. * @see http://doc.babylonjs.com/features/behaviour
  507. * @param behavior defines the behavior to attach
  508. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  509. * @returns the current Node
  510. */
  511. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  512. /**
  513. * Remove an attached behavior
  514. * @see http://doc.babylonjs.com/features/behaviour
  515. * @param behavior defines the behavior to attach
  516. * @returns the current Node
  517. */
  518. removeBehavior(behavior: Behavior<Node>): Node;
  519. /**
  520. * Gets the list of attached behaviors
  521. * @see http://doc.babylonjs.com/features/behaviour
  522. */
  523. readonly behaviors: Behavior<Node>[];
  524. /**
  525. * Gets an attached behavior by name
  526. * @param name defines the name of the behavior to look for
  527. * @see http://doc.babylonjs.com/features/behaviour
  528. * @returns null if behavior was not found else the requested behavior
  529. */
  530. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  531. /**
  532. * Returns the latest update of the World matrix
  533. * @returns a Matrix
  534. */
  535. getWorldMatrix(): Matrix;
  536. /** @hidden */
  537. _getWorldMatrixDeterminant(): number;
  538. /**
  539. * Returns directly the latest state of the mesh World matrix.
  540. * A Matrix is returned.
  541. */
  542. readonly worldMatrixFromCache: Matrix;
  543. /** @hidden */
  544. _initCache(): void;
  545. /** @hidden */
  546. updateCache(force?: boolean): void;
  547. /** @hidden */
  548. _updateCache(ignoreParentClass?: boolean): void;
  549. /** @hidden */
  550. _isSynchronized(): boolean;
  551. /** @hidden */
  552. _markSyncedWithParent(): void;
  553. /** @hidden */
  554. isSynchronizedWithParent(): boolean;
  555. /** @hidden */
  556. isSynchronized(): boolean;
  557. /**
  558. * Is this node ready to be used/rendered
  559. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  560. * @return true if the node is ready
  561. */
  562. isReady(completeCheck?: boolean): boolean;
  563. /**
  564. * Is this node enabled?
  565. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  566. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  567. * @return whether this node (and its parent) is enabled
  568. */
  569. isEnabled(checkAncestors?: boolean): boolean;
  570. /** @hidden */
  571. protected _syncParentEnabledState(): void;
  572. /**
  573. * Set the enabled state of this node
  574. * @param value defines the new enabled state
  575. */
  576. setEnabled(value: boolean): void;
  577. /**
  578. * Is this node a descendant of the given node?
  579. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  580. * @param ancestor defines the parent node to inspect
  581. * @returns a boolean indicating if this node is a descendant of the given node
  582. */
  583. isDescendantOf(ancestor: Node): boolean;
  584. /** @hidden */
  585. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  586. /**
  587. * Will return all nodes that have this node as ascendant
  588. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  589. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  590. * @return all children nodes of all types
  591. */
  592. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  593. /**
  594. * Get all child-meshes of this node
  595. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  596. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  597. * @returns an array of AbstractMesh
  598. */
  599. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  600. /**
  601. * Get all child-transformNodes of this node
  602. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  603. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  604. * @returns an array of TransformNode
  605. */
  606. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  607. /**
  608. * Get all direct children of this node
  609. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  610. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  611. * @returns an array of Node
  612. */
  613. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  614. /** @hidden */
  615. _setReady(state: boolean): void;
  616. /**
  617. * Get an animation by name
  618. * @param name defines the name of the animation to look for
  619. * @returns null if not found else the requested animation
  620. */
  621. getAnimationByName(name: string): Nullable<Animation>;
  622. /**
  623. * Creates an animation range for this node
  624. * @param name defines the name of the range
  625. * @param from defines the starting key
  626. * @param to defines the end key
  627. */
  628. createAnimationRange(name: string, from: number, to: number): void;
  629. /**
  630. * Delete a specific animation range
  631. * @param name defines the name of the range to delete
  632. * @param deleteFrames defines if animation frames from the range must be deleted as well
  633. */
  634. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  635. /**
  636. * Get an animation range by name
  637. * @param name defines the name of the animation range to look for
  638. * @returns null if not found else the requested animation range
  639. */
  640. getAnimationRange(name: string): Nullable<AnimationRange>;
  641. /**
  642. * Will start the animation sequence
  643. * @param name defines the range frames for animation sequence
  644. * @param loop defines if the animation should loop (false by default)
  645. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  646. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  647. * @returns the object created for this animation. If range does not exist, it will return null
  648. */
  649. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  650. /**
  651. * Serialize animation ranges into a JSON compatible object
  652. * @returns serialization object
  653. */
  654. serializeAnimationRanges(): any;
  655. /**
  656. * Computes the world matrix of the node
  657. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  658. * @returns the world matrix
  659. */
  660. computeWorldMatrix(force?: boolean): Matrix;
  661. /**
  662. * Releases resources associated with this node.
  663. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  664. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  665. */
  666. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  667. /**
  668. * Parse animation range data from a serialization object and store them into a given node
  669. * @param node defines where to store the animation ranges
  670. * @param parsedNode defines the serialization object to read data from
  671. * @param scene defines the hosting scene
  672. */
  673. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  674. }
  675. }
  676. declare module BABYLON {
  677. /**
  678. * Define an interface for all classes that will hold resources
  679. */
  680. interface IDisposable {
  681. /**
  682. * Releases all held resources
  683. */
  684. dispose(): void;
  685. }
  686. /**
  687. * This class is used by the onRenderingGroupObservable
  688. */
  689. class RenderingGroupInfo {
  690. /**
  691. * The Scene that being rendered
  692. */
  693. scene: Scene;
  694. /**
  695. * The camera currently used for the rendering pass
  696. */
  697. camera: Nullable<Camera>;
  698. /**
  699. * The ID of the renderingGroup being processed
  700. */
  701. renderingGroupId: number;
  702. }
  703. /** Interface defining initialization parameters for Scene class */
  704. interface SceneOptions {
  705. /**
  706. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by Id
  707. * It will improve performance when the number of geometries becomes important.
  708. */
  709. useGeometryIdsMap?: boolean;
  710. /**
  711. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  712. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  713. */
  714. useMaterialMeshMap?: boolean;
  715. /**
  716. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  717. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  718. */
  719. useClonedMeshhMap?: boolean;
  720. }
  721. /**
  722. * Represents a scene to be rendered by the engine.
  723. * @see http://doc.babylonjs.com/features/scene
  724. */
  725. class Scene extends AbstractScene implements IAnimatable {
  726. private static _uniqueIdCounter;
  727. /** The fog is deactivated */
  728. static readonly FOGMODE_NONE: number;
  729. /** The fog density is following an exponential function */
  730. static readonly FOGMODE_EXP: number;
  731. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  732. static readonly FOGMODE_EXP2: number;
  733. /** The fog density is following a linear function. */
  734. static readonly FOGMODE_LINEAR: number;
  735. /**
  736. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  737. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  738. */
  739. static MinDeltaTime: number;
  740. /**
  741. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  742. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  743. */
  744. static MaxDeltaTime: number;
  745. /**
  746. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  747. */
  748. autoClear: boolean;
  749. /**
  750. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  751. */
  752. autoClearDepthAndStencil: boolean;
  753. /**
  754. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  755. */
  756. clearColor: Color4;
  757. /**
  758. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  759. */
  760. ambientColor: Color3;
  761. /** @hidden */
  762. _environmentBRDFTexture: BaseTexture;
  763. /** @hidden */
  764. protected _environmentTexture: BaseTexture;
  765. /**
  766. * Texture used in all pbr material as the reflection texture.
  767. * As in the majority of the scene they are the same (exception for multi room and so on),
  768. * this is easier to reference from here than from all the materials.
  769. */
  770. /**
  771. * Texture used in all pbr material as the reflection texture.
  772. * As in the majority of the scene they are the same (exception for multi room and so on),
  773. * this is easier to set here than in all the materials.
  774. */
  775. environmentTexture: BaseTexture;
  776. /** @hidden */
  777. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  778. /**
  779. * Default image processing configuration used either in the rendering
  780. * Forward main pass or through the imageProcessingPostProcess if present.
  781. * As in the majority of the scene they are the same (exception for multi camera),
  782. * this is easier to reference from here than from all the materials and post process.
  783. *
  784. * No setter as we it is a shared configuration, you can set the values instead.
  785. */
  786. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  787. private _forceWireframe;
  788. /**
  789. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  790. */
  791. forceWireframe: boolean;
  792. private _forcePointsCloud;
  793. /**
  794. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  795. */
  796. forcePointsCloud: boolean;
  797. /**
  798. * Gets or sets the active clipplane 1
  799. */
  800. clipPlane: Nullable<Plane>;
  801. /**
  802. * Gets or sets the active clipplane 2
  803. */
  804. clipPlane2: Nullable<Plane>;
  805. /**
  806. * Gets or sets the active clipplane 3
  807. */
  808. clipPlane3: Nullable<Plane>;
  809. /**
  810. * Gets or sets the active clipplane 4
  811. */
  812. clipPlane4: Nullable<Plane>;
  813. /**
  814. * Gets or sets a boolean indicating if animations are enabled
  815. */
  816. animationsEnabled: boolean;
  817. private _animationPropertiesOverride;
  818. /**
  819. * Gets or sets the animation properties override
  820. */
  821. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  822. /**
  823. * Gets or sets a boolean indicating if a constant deltatime has to be used
  824. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  825. */
  826. useConstantAnimationDeltaTime: boolean;
  827. /**
  828. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  829. * Please note that it requires to run a ray cast through the scene on every frame
  830. */
  831. constantlyUpdateMeshUnderPointer: boolean;
  832. /**
  833. * Defines the HTML cursor to use when hovering over interactive elements
  834. */
  835. hoverCursor: string;
  836. /**
  837. * Defines the HTML default cursor to use (empty by default)
  838. */
  839. defaultCursor: string;
  840. /**
  841. * This is used to call preventDefault() on pointer down
  842. * in order to block unwanted artifacts like system double clicks
  843. */
  844. preventDefaultOnPointerDown: boolean;
  845. /**
  846. * This is used to call preventDefault() on pointer up
  847. * in order to block unwanted artifacts like system double clicks
  848. */
  849. preventDefaultOnPointerUp: boolean;
  850. /**
  851. * Gets or sets user defined metadata
  852. */
  853. metadata: any;
  854. /**
  855. * Gets the name of the plugin used to load this scene (null by default)
  856. */
  857. loadingPluginName: string;
  858. /**
  859. * Use this array to add regular expressions used to disable offline support for specific urls
  860. */
  861. disableOfflineSupportExceptionRules: RegExp[];
  862. /**
  863. * An event triggered when the scene is disposed.
  864. */
  865. onDisposeObservable: Observable<Scene>;
  866. private _onDisposeObserver;
  867. /** Sets a function to be executed when this scene is disposed. */
  868. onDispose: () => void;
  869. /**
  870. * An event triggered before rendering the scene (right after animations and physics)
  871. */
  872. onBeforeRenderObservable: Observable<Scene>;
  873. private _onBeforeRenderObserver;
  874. /** Sets a function to be executed before rendering this scene */
  875. beforeRender: Nullable<() => void>;
  876. /**
  877. * An event triggered after rendering the scene
  878. */
  879. onAfterRenderObservable: Observable<Scene>;
  880. private _onAfterRenderObserver;
  881. /** Sets a function to be executed after rendering this scene */
  882. afterRender: Nullable<() => void>;
  883. /**
  884. * An event triggered before animating the scene
  885. */
  886. onBeforeAnimationsObservable: Observable<Scene>;
  887. /**
  888. * An event triggered after animations processing
  889. */
  890. onAfterAnimationsObservable: Observable<Scene>;
  891. /**
  892. * An event triggered before draw calls are ready to be sent
  893. */
  894. onBeforeDrawPhaseObservable: Observable<Scene>;
  895. /**
  896. * An event triggered after draw calls have been sent
  897. */
  898. onAfterDrawPhaseObservable: Observable<Scene>;
  899. /**
  900. * An event triggered when the scene is ready
  901. */
  902. onReadyObservable: Observable<Scene>;
  903. /**
  904. * An event triggered before rendering a camera
  905. */
  906. onBeforeCameraRenderObservable: Observable<Camera>;
  907. private _onBeforeCameraRenderObserver;
  908. /** Sets a function to be executed before rendering a camera*/
  909. beforeCameraRender: () => void;
  910. /**
  911. * An event triggered after rendering a camera
  912. */
  913. onAfterCameraRenderObservable: Observable<Camera>;
  914. private _onAfterCameraRenderObserver;
  915. /** Sets a function to be executed after rendering a camera*/
  916. afterCameraRender: () => void;
  917. /**
  918. * An event triggered when active meshes evaluation is about to start
  919. */
  920. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  921. /**
  922. * An event triggered when active meshes evaluation is done
  923. */
  924. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  925. /**
  926. * An event triggered when particles rendering is about to start
  927. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  928. */
  929. onBeforeParticlesRenderingObservable: Observable<Scene>;
  930. /**
  931. * An event triggered when particles rendering is done
  932. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  933. */
  934. onAfterParticlesRenderingObservable: Observable<Scene>;
  935. /**
  936. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  937. */
  938. onDataLoadedObservable: Observable<Scene>;
  939. /**
  940. * An event triggered when a camera is created
  941. */
  942. onNewCameraAddedObservable: Observable<Camera>;
  943. /**
  944. * An event triggered when a camera is removed
  945. */
  946. onCameraRemovedObservable: Observable<Camera>;
  947. /**
  948. * An event triggered when a light is created
  949. */
  950. onNewLightAddedObservable: Observable<Light>;
  951. /**
  952. * An event triggered when a light is removed
  953. */
  954. onLightRemovedObservable: Observable<Light>;
  955. /**
  956. * An event triggered when a geometry is created
  957. */
  958. onNewGeometryAddedObservable: Observable<Geometry>;
  959. /**
  960. * An event triggered when a geometry is removed
  961. */
  962. onGeometryRemovedObservable: Observable<Geometry>;
  963. /**
  964. * An event triggered when a transform node is created
  965. */
  966. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  967. /**
  968. * An event triggered when a transform node is removed
  969. */
  970. onTransformNodeRemovedObservable: Observable<TransformNode>;
  971. /**
  972. * An event triggered when a mesh is created
  973. */
  974. onNewMeshAddedObservable: Observable<AbstractMesh>;
  975. /**
  976. * An event triggered when a mesh is removed
  977. */
  978. onMeshRemovedObservable: Observable<AbstractMesh>;
  979. /**
  980. * An event triggered when a material is created
  981. */
  982. onNewMaterialAddedObservable: Observable<Material>;
  983. /**
  984. * An event triggered when a material is removed
  985. */
  986. onMaterialRemovedObservable: Observable<Material>;
  987. /**
  988. * An event triggered when a texture is created
  989. */
  990. onNewTextureAddedObservable: Observable<BaseTexture>;
  991. /**
  992. * An event triggered when a texture is removed
  993. */
  994. onTextureRemovedObservable: Observable<BaseTexture>;
  995. /**
  996. * An event triggered when render targets are about to be rendered
  997. * Can happen multiple times per frame.
  998. */
  999. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  1000. /**
  1001. * An event triggered when render targets were rendered.
  1002. * Can happen multiple times per frame.
  1003. */
  1004. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  1005. /**
  1006. * An event triggered before calculating deterministic simulation step
  1007. */
  1008. onBeforeStepObservable: Observable<Scene>;
  1009. /**
  1010. * An event triggered after calculating deterministic simulation step
  1011. */
  1012. onAfterStepObservable: Observable<Scene>;
  1013. /**
  1014. * An event triggered when the activeCamera property is updated
  1015. */
  1016. onActiveCameraChanged: Observable<Scene>;
  1017. /**
  1018. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  1019. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1020. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1021. */
  1022. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1023. /**
  1024. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  1025. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  1026. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  1027. */
  1028. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  1029. /**
  1030. * This Observable will when a mesh has been imported into the scene.
  1031. */
  1032. onMeshImportedObservable: Observable<AbstractMesh>;
  1033. private _registeredForLateAnimationBindings;
  1034. /**
  1035. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  1036. */
  1037. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  1038. /**
  1039. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  1040. */
  1041. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  1042. /**
  1043. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  1044. */
  1045. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  1046. private _onPointerMove;
  1047. private _onPointerDown;
  1048. private _onPointerUp;
  1049. /** Callback called when a pointer move is detected */
  1050. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1051. /** Callback called when a pointer down is detected */
  1052. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  1053. /** Callback called when a pointer up is detected */
  1054. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  1055. /** Callback called when a pointer pick is detected */
  1056. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  1057. /**
  1058. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  1059. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  1060. */
  1061. onPrePointerObservable: Observable<PointerInfoPre>;
  1062. /**
  1063. * Observable event triggered each time an input event is received from the rendering canvas
  1064. */
  1065. onPointerObservable: Observable<PointerInfo>;
  1066. /**
  1067. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  1068. */
  1069. readonly unTranslatedPointer: Vector2;
  1070. /** The distance in pixel that you have to move to prevent some events */
  1071. static DragMovementThreshold: number;
  1072. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  1073. static LongPressDelay: number;
  1074. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  1075. static DoubleClickDelay: number;
  1076. /** If you need to check double click without raising a single click at first click, enable this flag */
  1077. static ExclusiveDoubleClickMode: boolean;
  1078. private _initClickEvent;
  1079. private _initActionManager;
  1080. private _delayedSimpleClick;
  1081. private _delayedSimpleClickTimeout;
  1082. private _previousDelayedSimpleClickTimeout;
  1083. private _meshPickProceed;
  1084. private _previousButtonPressed;
  1085. private _currentPickResult;
  1086. private _previousPickResult;
  1087. private _totalPointersPressed;
  1088. private _doubleClickOccured;
  1089. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  1090. cameraToUseForPointers: Nullable<Camera>;
  1091. private _pointerX;
  1092. private _pointerY;
  1093. private _unTranslatedPointerX;
  1094. private _unTranslatedPointerY;
  1095. private _startingPointerPosition;
  1096. private _previousStartingPointerPosition;
  1097. private _startingPointerTime;
  1098. private _previousStartingPointerTime;
  1099. private _pointerCaptures;
  1100. private _timeAccumulator;
  1101. private _currentStepId;
  1102. private _currentInternalStep;
  1103. /** @hidden */
  1104. _mirroredCameraPosition: Nullable<Vector3>;
  1105. /**
  1106. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  1107. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  1108. */
  1109. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  1110. /**
  1111. * Observable event triggered each time an keyboard event is received from the hosting window
  1112. */
  1113. onKeyboardObservable: Observable<KeyboardInfo>;
  1114. private _onKeyDown;
  1115. private _onKeyUp;
  1116. private _onCanvasFocusObserver;
  1117. private _onCanvasBlurObserver;
  1118. private _useRightHandedSystem;
  1119. /**
  1120. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  1121. */
  1122. useRightHandedSystem: boolean;
  1123. /**
  1124. * Sets the step Id used by deterministic lock step
  1125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1126. * @param newStepId defines the step Id
  1127. */
  1128. setStepId(newStepId: number): void;
  1129. /**
  1130. * Gets the step Id used by deterministic lock step
  1131. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1132. * @returns the step Id
  1133. */
  1134. getStepId(): number;
  1135. /**
  1136. * Gets the internal step used by deterministic lock step
  1137. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  1138. * @returns the internal step
  1139. */
  1140. getInternalStep(): number;
  1141. private _fogEnabled;
  1142. /**
  1143. * Gets or sets a boolean indicating if fog is enabled on this scene
  1144. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1145. * (Default is true)
  1146. */
  1147. fogEnabled: boolean;
  1148. private _fogMode;
  1149. /**
  1150. * Gets or sets the fog mode to use
  1151. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1152. * | mode | value |
  1153. * | --- | --- |
  1154. * | FOGMODE_NONE | 0 |
  1155. * | FOGMODE_EXP | 1 |
  1156. * | FOGMODE_EXP2 | 2 |
  1157. * | FOGMODE_LINEAR | 3 |
  1158. */
  1159. fogMode: number;
  1160. /**
  1161. * Gets or sets the fog color to use
  1162. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1163. * (Default is Color3(0.2, 0.2, 0.3))
  1164. */
  1165. fogColor: Color3;
  1166. /**
  1167. * Gets or sets the fog density to use
  1168. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1169. * (Default is 0.1)
  1170. */
  1171. fogDensity: number;
  1172. /**
  1173. * Gets or sets the fog start distance to use
  1174. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1175. * (Default is 0)
  1176. */
  1177. fogStart: number;
  1178. /**
  1179. * Gets or sets the fog end distance to use
  1180. * @see http://doc.babylonjs.com/babylon101/environment#fog
  1181. * (Default is 1000)
  1182. */
  1183. fogEnd: number;
  1184. private _shadowsEnabled;
  1185. /**
  1186. * Gets or sets a boolean indicating if shadows are enabled on this scene
  1187. */
  1188. shadowsEnabled: boolean;
  1189. private _lightsEnabled;
  1190. /**
  1191. * Gets or sets a boolean indicating if lights are enabled on this scene
  1192. */
  1193. lightsEnabled: boolean;
  1194. /** All of the active cameras added to this scene. */
  1195. activeCameras: Camera[];
  1196. private _activeCamera;
  1197. /** Gets or sets the current active camera */
  1198. activeCamera: Nullable<Camera>;
  1199. private _defaultMaterial;
  1200. /** The default material used on meshes when no material is affected */
  1201. /** The default material used on meshes when no material is affected */
  1202. defaultMaterial: Material;
  1203. private _texturesEnabled;
  1204. /**
  1205. * Gets or sets a boolean indicating if textures are enabled on this scene
  1206. */
  1207. texturesEnabled: boolean;
  1208. /**
  1209. * Gets or sets a boolean indicating if particles are enabled on this scene
  1210. */
  1211. particlesEnabled: boolean;
  1212. /**
  1213. * Gets or sets a boolean indicating if sprites are enabled on this scene
  1214. */
  1215. spritesEnabled: boolean;
  1216. private _skeletonsEnabled;
  1217. /**
  1218. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  1219. */
  1220. skeletonsEnabled: boolean;
  1221. /**
  1222. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  1223. */
  1224. lensFlaresEnabled: boolean;
  1225. /**
  1226. * Gets or sets a boolean indicating if collisions are enabled on this scene
  1227. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1228. */
  1229. collisionsEnabled: boolean;
  1230. private _workerCollisions;
  1231. /** @hidden */
  1232. collisionCoordinator: ICollisionCoordinator;
  1233. /**
  1234. * Defines the gravity applied to this scene (used only for collisions)
  1235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  1236. */
  1237. gravity: Vector3;
  1238. /**
  1239. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  1240. */
  1241. postProcessesEnabled: boolean;
  1242. /**
  1243. * The list of postprocesses added to the scene
  1244. */
  1245. postProcesses: PostProcess[];
  1246. /**
  1247. * Gets the current postprocess manager
  1248. */
  1249. postProcessManager: PostProcessManager;
  1250. /**
  1251. * Gets or sets a boolean indicating if render targets are enabled on this scene
  1252. */
  1253. renderTargetsEnabled: boolean;
  1254. /**
  1255. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  1256. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  1257. */
  1258. dumpNextRenderTargets: boolean;
  1259. /**
  1260. * The list of user defined render targets added to the scene
  1261. */
  1262. customRenderTargets: RenderTargetTexture[];
  1263. /**
  1264. * Defines if texture loading must be delayed
  1265. * If true, textures will only be loaded when they need to be rendered
  1266. */
  1267. useDelayedTextureLoading: boolean;
  1268. /**
  1269. * Gets the list of meshes imported to the scene through SceneLoader
  1270. */
  1271. importedMeshesFiles: String[];
  1272. /**
  1273. * Gets or sets a boolean indicating if probes are enabled on this scene
  1274. */
  1275. probesEnabled: boolean;
  1276. /**
  1277. * Gets or sets the current offline provider to use to store scene data
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. offlineProvider: IOfflineProvider;
  1281. /**
  1282. * Gets or sets the action manager associated with the scene
  1283. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1284. */
  1285. actionManager: ActionManager;
  1286. private _meshesForIntersections;
  1287. /**
  1288. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  1289. */
  1290. proceduralTexturesEnabled: boolean;
  1291. private _engine;
  1292. private _totalVertices;
  1293. /** @hidden */
  1294. _activeIndices: PerfCounter;
  1295. /** @hidden */
  1296. _activeParticles: PerfCounter;
  1297. /** @hidden */
  1298. _activeBones: PerfCounter;
  1299. private _animationRatio;
  1300. private _animationTimeLast;
  1301. private _animationTime;
  1302. /**
  1303. * Gets or sets a general scale for animation speed
  1304. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  1305. */
  1306. animationTimeScale: number;
  1307. /** @hidden */
  1308. _cachedMaterial: Nullable<Material>;
  1309. /** @hidden */
  1310. _cachedEffect: Nullable<Effect>;
  1311. /** @hidden */
  1312. _cachedVisibility: Nullable<number>;
  1313. private _renderId;
  1314. private _frameId;
  1315. private _executeWhenReadyTimeoutId;
  1316. private _intermediateRendering;
  1317. private _viewUpdateFlag;
  1318. private _projectionUpdateFlag;
  1319. private _alternateViewUpdateFlag;
  1320. private _alternateProjectionUpdateFlag;
  1321. /** @hidden */
  1322. _toBeDisposed: Nullable<IDisposable>[];
  1323. private _activeRequests;
  1324. private _pendingData;
  1325. private _isDisposed;
  1326. /**
  1327. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  1328. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  1329. */
  1330. dispatchAllSubMeshesOfActiveMeshes: boolean;
  1331. private _activeMeshes;
  1332. private _processedMaterials;
  1333. private _renderTargets;
  1334. /** @hidden */
  1335. _activeParticleSystems: SmartArray<IParticleSystem>;
  1336. private _activeSkeletons;
  1337. private _softwareSkinnedMeshes;
  1338. private _renderingManager;
  1339. /** @hidden */
  1340. _activeAnimatables: Animatable[];
  1341. private _transformMatrix;
  1342. private _sceneUbo;
  1343. private _alternateSceneUbo;
  1344. private _pickWithRayInverseMatrix;
  1345. private _viewMatrix;
  1346. private _projectionMatrix;
  1347. private _alternateViewMatrix;
  1348. private _alternateProjectionMatrix;
  1349. private _alternateTransformMatrix;
  1350. private _useAlternateCameraConfiguration;
  1351. private _alternateRendering;
  1352. private _wheelEventName;
  1353. /** @hidden */
  1354. _forcedViewPosition: Nullable<Vector3>;
  1355. /** @hidden */
  1356. readonly _isAlternateRenderingEnabled: boolean;
  1357. private _frustumPlanes;
  1358. /**
  1359. * Gets the list of frustum planes (built from the active camera)
  1360. */
  1361. readonly frustumPlanes: Plane[];
  1362. /**
  1363. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  1364. * This is useful if there are more lights that the maximum simulteanous authorized
  1365. */
  1366. requireLightSorting: boolean;
  1367. /** @hidden */
  1368. readonly useMaterialMeshMap: boolean;
  1369. /** @hidden */
  1370. readonly useClonedMeshhMap: boolean;
  1371. private _pointerOverMesh;
  1372. private _pickedDownMesh;
  1373. private _pickedUpMesh;
  1374. private _externalData;
  1375. private _uid;
  1376. /**
  1377. * @hidden
  1378. * Backing store of defined scene components.
  1379. */
  1380. _components: ISceneComponent[];
  1381. /**
  1382. * @hidden
  1383. * Backing store of defined scene components.
  1384. */
  1385. _serializableComponents: ISceneSerializableComponent[];
  1386. /**
  1387. * List of components to register on the next registration step.
  1388. */
  1389. private _transientComponents;
  1390. /**
  1391. * Registers the transient components if needed.
  1392. */
  1393. private _registerTransientComponents;
  1394. /**
  1395. * @hidden
  1396. * Add a component to the scene.
  1397. * Note that the ccomponent could be registered on th next frame if this is called after
  1398. * the register component stage.
  1399. * @param component Defines the component to add to the scene
  1400. */
  1401. _addComponent(component: ISceneComponent): void;
  1402. /**
  1403. * @hidden
  1404. * Gets a component from the scene.
  1405. * @param name defines the name of the component to retrieve
  1406. * @returns the component or null if not present
  1407. */
  1408. _getComponent(name: string): Nullable<ISceneComponent>;
  1409. /**
  1410. * @hidden
  1411. * Defines the actions happening before camera updates.
  1412. */
  1413. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  1414. /**
  1415. * @hidden
  1416. * Defines the actions happening before clear the canvas.
  1417. */
  1418. _beforeClearStage: Stage<SimpleStageAction>;
  1419. /**
  1420. * @hidden
  1421. * Defines the actions when collecting render targets for the frame.
  1422. */
  1423. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1424. /**
  1425. * @hidden
  1426. * Defines the actions happening for one camera in the frame.
  1427. */
  1428. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  1429. /**
  1430. * @hidden
  1431. * Defines the actions happening during the per mesh ready checks.
  1432. */
  1433. _isReadyForMeshStage: Stage<MeshStageAction>;
  1434. /**
  1435. * @hidden
  1436. * Defines the actions happening before evaluate active mesh checks.
  1437. */
  1438. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  1439. /**
  1440. * @hidden
  1441. * Defines the actions happening during the evaluate sub mesh checks.
  1442. */
  1443. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  1444. /**
  1445. * @hidden
  1446. * Defines the actions happening during the active mesh stage.
  1447. */
  1448. _activeMeshStage: Stage<ActiveMeshStageAction>;
  1449. /**
  1450. * @hidden
  1451. * Defines the actions happening during the per camera render target step.
  1452. */
  1453. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  1454. /**
  1455. * @hidden
  1456. * Defines the actions happening just before the active camera is drawing.
  1457. */
  1458. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1459. /**
  1460. * @hidden
  1461. * Defines the actions happening just before a render target is drawing.
  1462. */
  1463. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1464. /**
  1465. * @hidden
  1466. * Defines the actions happening just before a rendering group is drawing.
  1467. */
  1468. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1469. /**
  1470. * @hidden
  1471. * Defines the actions happening just before a mesh is drawing.
  1472. */
  1473. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1474. /**
  1475. * @hidden
  1476. * Defines the actions happening just after a mesh has been drawn.
  1477. */
  1478. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1479. /**
  1480. * @hidden
  1481. * Defines the actions happening just after a rendering group has been drawn.
  1482. */
  1483. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1484. /**
  1485. * @hidden
  1486. * Defines the actions happening just after the active camera has been drawn.
  1487. */
  1488. _afterCameraDrawStage: Stage<CameraStageAction>;
  1489. /**
  1490. * @hidden
  1491. * Defines the actions happening just after a render target has been drawn.
  1492. */
  1493. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1494. /**
  1495. * @hidden
  1496. * Defines the actions happening just after rendering all cameras and computing intersections.
  1497. */
  1498. _afterRenderStage: Stage<SimpleStageAction>;
  1499. /**
  1500. * @hidden
  1501. * Defines the actions happening when a pointer move event happens.
  1502. */
  1503. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1504. /**
  1505. * @hidden
  1506. * Defines the actions happening when a pointer down event happens.
  1507. */
  1508. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1509. /**
  1510. * @hidden
  1511. * Defines the actions happening when a pointer up event happens.
  1512. */
  1513. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1514. /**
  1515. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1516. */
  1517. private geometriesById;
  1518. /**
  1519. * Creates a new Scene
  1520. * @param engine defines the engine to use to render this scene
  1521. */
  1522. constructor(engine: Engine, options?: SceneOptions);
  1523. private _defaultMeshCandidates;
  1524. /**
  1525. * @hidden
  1526. */
  1527. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1528. private _defaultSubMeshCandidates;
  1529. /**
  1530. * @hidden
  1531. */
  1532. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1533. /**
  1534. * Sets the default candidate providers for the scene.
  1535. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1536. * and getCollidingSubMeshCandidates to their default function
  1537. */
  1538. setDefaultCandidateProviders(): void;
  1539. /**
  1540. * Gets a boolean indicating if collisions are processed on a web worker
  1541. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#web-worker-based-collision-system-since-21
  1542. */
  1543. workerCollisions: boolean;
  1544. /**
  1545. * Gets the mesh that is currently under the pointer
  1546. */
  1547. readonly meshUnderPointer: Nullable<AbstractMesh>;
  1548. /**
  1549. * Gets the current on-screen X position of the pointer
  1550. */
  1551. readonly pointerX: number;
  1552. /**
  1553. * Gets the current on-screen Y position of the pointer
  1554. */
  1555. readonly pointerY: number;
  1556. /**
  1557. * Gets the cached material (ie. the latest rendered one)
  1558. * @returns the cached material
  1559. */
  1560. getCachedMaterial(): Nullable<Material>;
  1561. /**
  1562. * Gets the cached effect (ie. the latest rendered one)
  1563. * @returns the cached effect
  1564. */
  1565. getCachedEffect(): Nullable<Effect>;
  1566. /**
  1567. * Gets the cached visibility state (ie. the latest rendered one)
  1568. * @returns the cached visibility state
  1569. */
  1570. getCachedVisibility(): Nullable<number>;
  1571. /**
  1572. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1573. * @param material defines the current material
  1574. * @param effect defines the current effect
  1575. * @param visibility defines the current visibility state
  1576. * @returns true if one parameter is not cached
  1577. */
  1578. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1579. /**
  1580. * Gets the engine associated with the scene
  1581. * @returns an Engine
  1582. */
  1583. getEngine(): Engine;
  1584. /**
  1585. * Gets the total number of vertices rendered per frame
  1586. * @returns the total number of vertices rendered per frame
  1587. */
  1588. getTotalVertices(): number;
  1589. /**
  1590. * Gets the performance counter for total vertices
  1591. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1592. */
  1593. readonly totalVerticesPerfCounter: PerfCounter;
  1594. /**
  1595. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1596. * @returns the total number of active indices rendered per frame
  1597. */
  1598. getActiveIndices(): number;
  1599. /**
  1600. * Gets the performance counter for active indices
  1601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1602. */
  1603. readonly totalActiveIndicesPerfCounter: PerfCounter;
  1604. /**
  1605. * Gets the total number of active particles rendered per frame
  1606. * @returns the total number of active particles rendered per frame
  1607. */
  1608. getActiveParticles(): number;
  1609. /**
  1610. * Gets the performance counter for active particles
  1611. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1612. */
  1613. readonly activeParticlesPerfCounter: PerfCounter;
  1614. /**
  1615. * Gets the total number of active bones rendered per frame
  1616. * @returns the total number of active bones rendered per frame
  1617. */
  1618. getActiveBones(): number;
  1619. /**
  1620. * Gets the performance counter for active bones
  1621. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  1622. */
  1623. readonly activeBonesPerfCounter: PerfCounter;
  1624. /**
  1625. * Gets the array of active meshes
  1626. * @returns an array of AbstractMesh
  1627. */
  1628. getActiveMeshes(): SmartArray<AbstractMesh>;
  1629. /**
  1630. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1631. * @returns a number
  1632. */
  1633. getAnimationRatio(): number;
  1634. /**
  1635. * Gets an unique Id for the current render phase
  1636. * @returns a number
  1637. */
  1638. getRenderId(): number;
  1639. /**
  1640. * Gets an unique Id for the current frame
  1641. * @returns a number
  1642. */
  1643. getFrameId(): number;
  1644. /** Call this function if you want to manually increment the render Id*/
  1645. incrementRenderId(): void;
  1646. private _updatePointerPosition;
  1647. private _createUbo;
  1648. private _createAlternateUbo;
  1649. private _setRayOnPointerInfo;
  1650. /**
  1651. * Use this method to simulate a pointer move on a mesh
  1652. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1653. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1654. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1655. * @returns the current scene
  1656. */
  1657. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1658. private _processPointerMove;
  1659. private _checkPrePointerObservable;
  1660. /**
  1661. * Use this method to simulate a pointer down on a mesh
  1662. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1663. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1664. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1665. * @returns the current scene
  1666. */
  1667. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1668. private _processPointerDown;
  1669. /**
  1670. * Use this method to simulate a pointer up on a mesh
  1671. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1672. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1673. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1674. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1675. * @returns the current scene
  1676. */
  1677. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1678. private _processPointerUp;
  1679. /**
  1680. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1681. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1682. * @returns true if the pointer was captured
  1683. */
  1684. isPointerCaptured(pointerId?: number): boolean;
  1685. /** @hidden */
  1686. _isPointerSwiping(): boolean;
  1687. /**
  1688. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1689. * @param attachUp defines if you want to attach events to pointerup
  1690. * @param attachDown defines if you want to attach events to pointerdown
  1691. * @param attachMove defines if you want to attach events to pointermove
  1692. */
  1693. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1694. /** Detaches all event handlers*/
  1695. detachControl(): void;
  1696. /**
  1697. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1698. * Delay loaded resources are not taking in account
  1699. * @return true if all required resources are ready
  1700. */
  1701. isReady(): boolean;
  1702. /** Resets all cached information relative to material (including effect and visibility) */
  1703. resetCachedMaterial(): void;
  1704. /**
  1705. * Registers a function to be called before every frame render
  1706. * @param func defines the function to register
  1707. */
  1708. registerBeforeRender(func: () => void): void;
  1709. /**
  1710. * Unregisters a function called before every frame render
  1711. * @param func defines the function to unregister
  1712. */
  1713. unregisterBeforeRender(func: () => void): void;
  1714. /**
  1715. * Registers a function to be called after every frame render
  1716. * @param func defines the function to register
  1717. */
  1718. registerAfterRender(func: () => void): void;
  1719. /**
  1720. * Unregisters a function called after every frame render
  1721. * @param func defines the function to unregister
  1722. */
  1723. unregisterAfterRender(func: () => void): void;
  1724. private _executeOnceBeforeRender;
  1725. /**
  1726. * The provided function will run before render once and will be disposed afterwards.
  1727. * A timeout delay can be provided so that the function will be executed in N ms.
  1728. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1729. * @param func The function to be executed.
  1730. * @param timeout optional delay in ms
  1731. */
  1732. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1733. /** @hidden */
  1734. _addPendingData(data: any): void;
  1735. /** @hidden */
  1736. _removePendingData(data: any): void;
  1737. /**
  1738. * Returns the number of items waiting to be loaded
  1739. * @returns the number of items waiting to be loaded
  1740. */
  1741. getWaitingItemsCount(): number;
  1742. /**
  1743. * Returns a boolean indicating if the scene is still loading data
  1744. */
  1745. readonly isLoading: boolean;
  1746. /**
  1747. * Registers a function to be executed when the scene is ready
  1748. * @param {Function} func - the function to be executed
  1749. */
  1750. executeWhenReady(func: () => void): void;
  1751. /**
  1752. * Returns a promise that resolves when the scene is ready
  1753. * @returns A promise that resolves when the scene is ready
  1754. */
  1755. whenReadyAsync(): Promise<void>;
  1756. /** @hidden */
  1757. _checkIsReady(): void;
  1758. /**
  1759. * Will start the animation sequence of a given target
  1760. * @param target defines the target
  1761. * @param from defines from which frame should animation start
  1762. * @param to defines until which frame should animation run.
  1763. * @param weight defines the weight to apply to the animation (1.0 by default)
  1764. * @param loop defines if the animation loops
  1765. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1766. * @param onAnimationEnd defines the function to be executed when the animation ends
  1767. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1768. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1769. * @returns the animatable object created for this animation
  1770. */
  1771. beginWeightedAnimation(target: any, from: number, to: number, weight?: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean): Animatable;
  1772. /**
  1773. * Will start the animation sequence of a given target
  1774. * @param target defines the target
  1775. * @param from defines from which frame should animation start
  1776. * @param to defines until which frame should animation run.
  1777. * @param loop defines if the animation loops
  1778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1779. * @param onAnimationEnd defines the function to be executed when the animation ends
  1780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1782. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1783. * @returns the animatable object created for this animation
  1784. */
  1785. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable;
  1786. /**
  1787. * Will start the animation sequence of a given target and its hierarchy
  1788. * @param target defines the target
  1789. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1790. * @param from defines from which frame should animation start
  1791. * @param to defines until which frame should animation run.
  1792. * @param loop defines if the animation loops
  1793. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  1794. * @param onAnimationEnd defines the function to be executed when the animation ends
  1795. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  1796. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  1797. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  1798. * @returns the list of created animatables
  1799. */
  1800. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean): Animatable[];
  1801. /**
  1802. * Begin a new animation on a given node
  1803. * @param target defines the target where the animation will take place
  1804. * @param animations defines the list of animations to start
  1805. * @param from defines the initial value
  1806. * @param to defines the final value
  1807. * @param loop defines if you want animation to loop (off by default)
  1808. * @param speedRatio defines the speed ratio to apply to all animations
  1809. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1810. * @returns the list of created animatables
  1811. */
  1812. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  1813. /**
  1814. * Begin a new animation on a given node and its hierarchy
  1815. * @param target defines the root node where the animation will take place
  1816. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  1817. * @param animations defines the list of animations to start
  1818. * @param from defines the initial value
  1819. * @param to defines the final value
  1820. * @param loop defines if you want animation to loop (off by default)
  1821. * @param speedRatio defines the speed ratio to apply to all animations
  1822. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1823. * @returns the list of animatables created for all nodes
  1824. */
  1825. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  1826. /**
  1827. * Gets the animatable associated with a specific target
  1828. * @param target defines the target of the animatable
  1829. * @returns the required animatable if found
  1830. */
  1831. getAnimatableByTarget(target: any): Nullable<Animatable>;
  1832. /**
  1833. * Gets all animatables associated with a given target
  1834. * @param target defines the target to look animatables for
  1835. * @returns an array of Animatables
  1836. */
  1837. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  1838. /**
  1839. * Gets all animatable attached to the scene
  1840. */
  1841. readonly animatables: Animatable[];
  1842. /**
  1843. * Will stop the animation of the given target
  1844. * @param target - the target
  1845. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1846. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1847. */
  1848. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1849. /**
  1850. * Stops and removes all animations that have been applied to the scene
  1851. */
  1852. stopAllAnimations(): void;
  1853. private _animate;
  1854. /** @hidden */
  1855. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  1856. private _processLateAnimationBindingsForMatrices;
  1857. private _processLateAnimationBindingsForQuaternions;
  1858. private _processLateAnimationBindings;
  1859. /** @hidden */
  1860. _switchToAlternateCameraConfiguration(active: boolean): void;
  1861. /**
  1862. * Gets the current view matrix
  1863. * @returns a Matrix
  1864. */
  1865. getViewMatrix(): Matrix;
  1866. /**
  1867. * Gets the current projection matrix
  1868. * @returns a Matrix
  1869. */
  1870. getProjectionMatrix(): Matrix;
  1871. /**
  1872. * Gets the current transform matrix
  1873. * @returns a Matrix made of View * Projection
  1874. */
  1875. getTransformMatrix(): Matrix;
  1876. /**
  1877. * Sets the current transform matrix
  1878. * @param view defines the View matrix to use
  1879. * @param projection defines the Projection matrix to use
  1880. */
  1881. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1882. /** @hidden */
  1883. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1884. /**
  1885. * Gets the uniform buffer used to store scene data
  1886. * @returns a UniformBuffer
  1887. */
  1888. getSceneUniformBuffer(): UniformBuffer;
  1889. /**
  1890. * Gets an unique (relatively to the current scene) Id
  1891. * @returns an unique number for the scene
  1892. */
  1893. getUniqueId(): number;
  1894. /**
  1895. * Add a mesh to the list of scene's meshes
  1896. * @param newMesh defines the mesh to add
  1897. * @param recursive if all child meshes should also be added to the scene
  1898. */
  1899. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1900. /**
  1901. * Remove a mesh for the list of scene's meshes
  1902. * @param toRemove defines the mesh to remove
  1903. * @param recursive if all child meshes should also be removed from the scene
  1904. * @returns the index where the mesh was in the mesh list
  1905. */
  1906. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1907. /**
  1908. * Add a transform node to the list of scene's transform nodes
  1909. * @param newTransformNode defines the transform node to add
  1910. */
  1911. addTransformNode(newTransformNode: TransformNode): void;
  1912. /**
  1913. * Remove a transform node for the list of scene's transform nodes
  1914. * @param toRemove defines the transform node to remove
  1915. * @returns the index where the transform node was in the transform node list
  1916. */
  1917. removeTransformNode(toRemove: TransformNode): number;
  1918. /**
  1919. * Remove a skeleton for the list of scene's skeletons
  1920. * @param toRemove defines the skeleton to remove
  1921. * @returns the index where the skeleton was in the skeleton list
  1922. */
  1923. removeSkeleton(toRemove: Skeleton): number;
  1924. /**
  1925. * Remove a morph target for the list of scene's morph targets
  1926. * @param toRemove defines the morph target to remove
  1927. * @returns the index where the morph target was in the morph target list
  1928. */
  1929. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1930. /**
  1931. * Remove a light for the list of scene's lights
  1932. * @param toRemove defines the light to remove
  1933. * @returns the index where the light was in the light list
  1934. */
  1935. removeLight(toRemove: Light): number;
  1936. /**
  1937. * Remove a camera for the list of scene's cameras
  1938. * @param toRemove defines the camera to remove
  1939. * @returns the index where the camera was in the camera list
  1940. */
  1941. removeCamera(toRemove: Camera): number;
  1942. /**
  1943. * Remove a particle system for the list of scene's particle systems
  1944. * @param toRemove defines the particle system to remove
  1945. * @returns the index where the particle system was in the particle system list
  1946. */
  1947. removeParticleSystem(toRemove: IParticleSystem): number;
  1948. /**
  1949. * Remove a animation for the list of scene's animations
  1950. * @param toRemove defines the animation to remove
  1951. * @returns the index where the animation was in the animation list
  1952. */
  1953. removeAnimation(toRemove: Animation): number;
  1954. /**
  1955. * Removes the given animation group from this scene.
  1956. * @param toRemove The animation group to remove
  1957. * @returns The index of the removed animation group
  1958. */
  1959. removeAnimationGroup(toRemove: AnimationGroup): number;
  1960. /**
  1961. * Removes the given multi-material from this scene.
  1962. * @param toRemove The multi-material to remove
  1963. * @returns The index of the removed multi-material
  1964. */
  1965. removeMultiMaterial(toRemove: MultiMaterial): number;
  1966. /**
  1967. * Removes the given material from this scene.
  1968. * @param toRemove The material to remove
  1969. * @returns The index of the removed material
  1970. */
  1971. removeMaterial(toRemove: Material): number;
  1972. /**
  1973. * Removes the given action manager from this scene.
  1974. * @param toRemove The action manager to remove
  1975. * @returns The index of the removed action manager
  1976. */
  1977. removeActionManager(toRemove: ActionManager): number;
  1978. /**
  1979. * Removes the given texture from this scene.
  1980. * @param toRemove The texture to remove
  1981. * @returns The index of the removed texture
  1982. */
  1983. removeTexture(toRemove: BaseTexture): number;
  1984. /**
  1985. * Adds the given light to this scene
  1986. * @param newLight The light to add
  1987. */
  1988. addLight(newLight: Light): void;
  1989. /**
  1990. * Sorts the list list based on light priorities
  1991. */
  1992. sortLightsByPriority(): void;
  1993. /**
  1994. * Adds the given camera to this scene
  1995. * @param newCamera The camera to add
  1996. */
  1997. addCamera(newCamera: Camera): void;
  1998. /**
  1999. * Adds the given skeleton to this scene
  2000. * @param newSkeleton The skeleton to add
  2001. */
  2002. addSkeleton(newSkeleton: Skeleton): void;
  2003. /**
  2004. * Adds the given particle system to this scene
  2005. * @param newParticleSystem The particle system to add
  2006. */
  2007. addParticleSystem(newParticleSystem: IParticleSystem): void;
  2008. /**
  2009. * Adds the given animation to this scene
  2010. * @param newAnimation The animation to add
  2011. */
  2012. addAnimation(newAnimation: Animation): void;
  2013. /**
  2014. * Adds the given animation group to this scene.
  2015. * @param newAnimationGroup The animation group to add
  2016. */
  2017. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  2018. /**
  2019. * Adds the given multi-material to this scene
  2020. * @param newMultiMaterial The multi-material to add
  2021. */
  2022. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  2023. /**
  2024. * Adds the given material to this scene
  2025. * @param newMaterial The material to add
  2026. */
  2027. addMaterial(newMaterial: Material): void;
  2028. /**
  2029. * Adds the given morph target to this scene
  2030. * @param newMorphTargetManager The morph target to add
  2031. */
  2032. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  2033. /**
  2034. * Adds the given geometry to this scene
  2035. * @param newGeometry The geometry to add
  2036. */
  2037. addGeometry(newGeometry: Geometry): void;
  2038. /**
  2039. * Adds the given action manager to this scene
  2040. * @param newActionManager The action manager to add
  2041. */
  2042. addActionManager(newActionManager: ActionManager): void;
  2043. /**
  2044. * Adds the given texture to this scene.
  2045. * @param newTexture The texture to add
  2046. */
  2047. addTexture(newTexture: BaseTexture): void;
  2048. /**
  2049. * Switch active camera
  2050. * @param newCamera defines the new active camera
  2051. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  2052. */
  2053. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  2054. /**
  2055. * sets the active camera of the scene using its ID
  2056. * @param id defines the camera's ID
  2057. * @return the new active camera or null if none found.
  2058. */
  2059. setActiveCameraByID(id: string): Nullable<Camera>;
  2060. /**
  2061. * sets the active camera of the scene using its name
  2062. * @param name defines the camera's name
  2063. * @returns the new active camera or null if none found.
  2064. */
  2065. setActiveCameraByName(name: string): Nullable<Camera>;
  2066. /**
  2067. * get an animation group using its name
  2068. * @param name defines the material's name
  2069. * @return the animation group or null if none found.
  2070. */
  2071. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  2072. /**
  2073. * get a material using its id
  2074. * @param id defines the material's ID
  2075. * @return the material or null if none found.
  2076. */
  2077. getMaterialByID(id: string): Nullable<Material>;
  2078. /**
  2079. * Gets a material using its name
  2080. * @param name defines the material's name
  2081. * @return the material or null if none found.
  2082. */
  2083. getMaterialByName(name: string): Nullable<Material>;
  2084. /**
  2085. * Gets a camera using its id
  2086. * @param id defines the id to look for
  2087. * @returns the camera or null if not found
  2088. */
  2089. getCameraByID(id: string): Nullable<Camera>;
  2090. /**
  2091. * Gets a camera using its unique id
  2092. * @param uniqueId defines the unique id to look for
  2093. * @returns the camera or null if not found
  2094. */
  2095. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2096. /**
  2097. * Gets a camera using its name
  2098. * @param name defines the camera's name
  2099. * @return the camera or null if none found.
  2100. */
  2101. getCameraByName(name: string): Nullable<Camera>;
  2102. /**
  2103. * Gets a bone using its id
  2104. * @param id defines the bone's id
  2105. * @return the bone or null if not found
  2106. */
  2107. getBoneByID(id: string): Nullable<Bone>;
  2108. /**
  2109. * Gets a bone using its id
  2110. * @param name defines the bone's name
  2111. * @return the bone or null if not found
  2112. */
  2113. getBoneByName(name: string): Nullable<Bone>;
  2114. /**
  2115. * Gets a light node using its name
  2116. * @param name defines the the light's name
  2117. * @return the light or null if none found.
  2118. */
  2119. getLightByName(name: string): Nullable<Light>;
  2120. /**
  2121. * Gets a light node using its id
  2122. * @param id defines the light's id
  2123. * @return the light or null if none found.
  2124. */
  2125. getLightByID(id: string): Nullable<Light>;
  2126. /**
  2127. * Gets a light node using its scene-generated unique ID
  2128. * @param uniqueId defines the light's unique id
  2129. * @return the light or null if none found.
  2130. */
  2131. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2132. /**
  2133. * Gets a particle system by id
  2134. * @param id defines the particle system id
  2135. * @return the corresponding system or null if none found
  2136. */
  2137. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2138. /**
  2139. * Gets a geometry using its ID
  2140. * @param id defines the geometry's id
  2141. * @return the geometry or null if none found.
  2142. */
  2143. getGeometryByID(id: string): Nullable<Geometry>;
  2144. /**
  2145. * Add a new geometry to this scene
  2146. * @param geometry defines the geometry to be added to the scene.
  2147. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  2148. * @return a boolean defining if the geometry was added or not
  2149. */
  2150. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  2151. /**
  2152. * Removes an existing geometry
  2153. * @param geometry defines the geometry to be removed from the scene
  2154. * @return a boolean defining if the geometry was removed or not
  2155. */
  2156. removeGeometry(geometry: Geometry): boolean;
  2157. /**
  2158. * Gets the list of geometries attached to the scene
  2159. * @returns an array of Geometry
  2160. */
  2161. getGeometries(): Geometry[];
  2162. /**
  2163. * Gets the first added mesh found of a given ID
  2164. * @param id defines the id to search for
  2165. * @return the mesh found or null if not found at all
  2166. */
  2167. getMeshByID(id: string): Nullable<AbstractMesh>;
  2168. /**
  2169. * Gets a list of meshes using their id
  2170. * @param id defines the id to search for
  2171. * @returns a list of meshes
  2172. */
  2173. getMeshesByID(id: string): Array<AbstractMesh>;
  2174. /**
  2175. * Gets the first added transform node found of a given ID
  2176. * @param id defines the id to search for
  2177. * @return the found transform node or null if not found at all.
  2178. */
  2179. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2180. /**
  2181. * Gets a list of transform nodes using their id
  2182. * @param id defines the id to search for
  2183. * @returns a list of transform nodes
  2184. */
  2185. getTransformNodesByID(id: string): Array<TransformNode>;
  2186. /**
  2187. * Gets a mesh with its auto-generated unique id
  2188. * @param uniqueId defines the unique id to search for
  2189. * @return the found mesh or null if not found at all.
  2190. */
  2191. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2192. /**
  2193. * Gets a the last added mesh using a given id
  2194. * @param id defines the id to search for
  2195. * @return the found mesh or null if not found at all.
  2196. */
  2197. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2198. /**
  2199. * Gets a the last added node (Mesh, Camera, Light) using a given id
  2200. * @param id defines the id to search for
  2201. * @return the found node or null if not found at all
  2202. */
  2203. getLastEntryByID(id: string): Nullable<Node>;
  2204. /**
  2205. * Gets a node (Mesh, Camera, Light) using a given id
  2206. * @param id defines the id to search for
  2207. * @return the found node or null if not found at all
  2208. */
  2209. getNodeByID(id: string): Nullable<Node>;
  2210. /**
  2211. * Gets a node (Mesh, Camera, Light) using a given name
  2212. * @param name defines the name to search for
  2213. * @return the found node or null if not found at all.
  2214. */
  2215. getNodeByName(name: string): Nullable<Node>;
  2216. /**
  2217. * Gets a mesh using a given name
  2218. * @param name defines the name to search for
  2219. * @return the found mesh or null if not found at all.
  2220. */
  2221. getMeshByName(name: string): Nullable<AbstractMesh>;
  2222. /**
  2223. * Gets a transform node using a given name
  2224. * @param name defines the name to search for
  2225. * @return the found transform node or null if not found at all.
  2226. */
  2227. getTransformNodeByName(name: string): Nullable<TransformNode>;
  2228. /**
  2229. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  2230. * @param id defines the id to search for
  2231. * @return the found skeleton or null if not found at all.
  2232. */
  2233. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2234. /**
  2235. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  2236. * @param id defines the id to search for
  2237. * @return the found skeleton or null if not found at all.
  2238. */
  2239. getSkeletonById(id: string): Nullable<Skeleton>;
  2240. /**
  2241. * Gets a skeleton using a given name
  2242. * @param name defines the name to search for
  2243. * @return the found skeleton or null if not found at all.
  2244. */
  2245. getSkeletonByName(name: string): Nullable<Skeleton>;
  2246. /**
  2247. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  2248. * @param id defines the id to search for
  2249. * @return the found morph target manager or null if not found at all.
  2250. */
  2251. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  2252. /**
  2253. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  2254. * @param id defines the id to search for
  2255. * @return the found morph target or null if not found at all.
  2256. */
  2257. getMorphTargetById(id: string): Nullable<MorphTarget>;
  2258. /**
  2259. * Gets a boolean indicating if the given mesh is active
  2260. * @param mesh defines the mesh to look for
  2261. * @returns true if the mesh is in the active list
  2262. */
  2263. isActiveMesh(mesh: AbstractMesh): boolean;
  2264. /**
  2265. * Return a unique id as a string which can serve as an identifier for the scene
  2266. */
  2267. readonly uid: string;
  2268. /**
  2269. * Add an externaly attached data from its key.
  2270. * This method call will fail and return false, if such key already exists.
  2271. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  2272. * @param key the unique key that identifies the data
  2273. * @param data the data object to associate to the key for this Engine instance
  2274. * @return true if no such key were already present and the data was added successfully, false otherwise
  2275. */
  2276. addExternalData<T>(key: string, data: T): boolean;
  2277. /**
  2278. * Get an externaly attached data from its key
  2279. * @param key the unique key that identifies the data
  2280. * @return the associated data, if present (can be null), or undefined if not present
  2281. */
  2282. getExternalData<T>(key: string): Nullable<T>;
  2283. /**
  2284. * Get an externaly attached data from its key, create it using a factory if it's not already present
  2285. * @param key the unique key that identifies the data
  2286. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  2287. * @return the associated data, can be null if the factory returned null.
  2288. */
  2289. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  2290. /**
  2291. * Remove an externaly attached data from the Engine instance
  2292. * @param key the unique key that identifies the data
  2293. * @return true if the data was successfully removed, false if it doesn't exist
  2294. */
  2295. removeExternalData(key: string): boolean;
  2296. private _evaluateSubMesh;
  2297. /**
  2298. * Clear the processed materials smart array preventing retention point in material dispose.
  2299. */
  2300. freeProcessedMaterials(): void;
  2301. private _preventFreeActiveMeshesAndRenderingGroups;
  2302. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  2303. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  2304. * when disposing several meshes in a row or a hierarchy of meshes.
  2305. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  2306. */
  2307. blockfreeActiveMeshesAndRenderingGroups: boolean;
  2308. /**
  2309. * Clear the active meshes smart array preventing retention point in mesh dispose.
  2310. */
  2311. freeActiveMeshes(): void;
  2312. /**
  2313. * Clear the info related to rendering groups preventing retention points during dispose.
  2314. */
  2315. freeRenderingGroups(): void;
  2316. /** @hidden */
  2317. _isInIntermediateRendering(): boolean;
  2318. /**
  2319. * Lambda returning the list of potentially active meshes.
  2320. */
  2321. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  2322. /**
  2323. * Lambda returning the list of potentially active sub meshes.
  2324. */
  2325. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  2326. /**
  2327. * Lambda returning the list of potentially intersecting sub meshes.
  2328. */
  2329. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  2330. /**
  2331. * Lambda returning the list of potentially colliding sub meshes.
  2332. */
  2333. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  2334. private _activeMeshesFrozen;
  2335. /**
  2336. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  2337. * @returns the current scene
  2338. */
  2339. freezeActiveMeshes(): Scene;
  2340. /**
  2341. * Use this function to restart evaluating active meshes on every frame
  2342. * @returns the current scene
  2343. */
  2344. unfreezeActiveMeshes(): Scene;
  2345. private _evaluateActiveMeshes;
  2346. private _activeMesh;
  2347. /**
  2348. * Update the transform matrix to update from the current active camera
  2349. * @param force defines a boolean used to force the update even if cache is up to date
  2350. */
  2351. updateTransformMatrix(force?: boolean): void;
  2352. /**
  2353. * 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)
  2354. * @param alternateCamera defines the camera to use
  2355. */
  2356. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  2357. /** @hidden */
  2358. _allowPostProcessClearColor: boolean;
  2359. private _renderForCamera;
  2360. private _processSubCameras;
  2361. private _checkIntersections;
  2362. /** @hidden */
  2363. _advancePhysicsEngineStep(step: number): void;
  2364. /**
  2365. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  2366. */
  2367. getDeterministicFrameTime: () => number;
  2368. /**
  2369. * Render the scene
  2370. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  2371. */
  2372. render(updateCameras?: boolean): void;
  2373. /**
  2374. * Freeze all materials
  2375. * A frozen material will not be updatable but should be faster to render
  2376. */
  2377. freezeMaterials(): void;
  2378. /**
  2379. * Unfreeze all materials
  2380. * A frozen material will not be updatable but should be faster to render
  2381. */
  2382. unfreezeMaterials(): void;
  2383. /**
  2384. * Releases all held ressources
  2385. */
  2386. dispose(): void;
  2387. /**
  2388. * Gets if the scene is already disposed
  2389. */
  2390. readonly isDisposed: boolean;
  2391. /**
  2392. * Call this function to reduce memory footprint of the scene.
  2393. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  2394. */
  2395. clearCachedVertexData(): void;
  2396. /**
  2397. * This function will remove the local cached buffer data from texture.
  2398. * It will save memory but will prevent the texture from being rebuilt
  2399. */
  2400. cleanCachedTextureBuffer(): void;
  2401. /**
  2402. * Get the world extend vectors with an optional filter
  2403. *
  2404. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  2405. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  2406. */
  2407. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  2408. min: Vector3;
  2409. max: Vector3;
  2410. };
  2411. /**
  2412. * Creates a ray that can be used to pick in the scene
  2413. * @param x defines the x coordinate of the origin (on-screen)
  2414. * @param y defines the y coordinate of the origin (on-screen)
  2415. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2416. * @param camera defines the camera to use for the picking
  2417. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2418. * @returns a Ray
  2419. */
  2420. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  2421. /**
  2422. * Creates a ray that can be used to pick in the scene
  2423. * @param x defines the x coordinate of the origin (on-screen)
  2424. * @param y defines the y coordinate of the origin (on-screen)
  2425. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  2426. * @param result defines the ray where to store the picking ray
  2427. * @param camera defines the camera to use for the picking
  2428. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  2429. * @returns the current scene
  2430. */
  2431. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  2432. /**
  2433. * Creates a ray that can be used to pick in the scene
  2434. * @param x defines the x coordinate of the origin (on-screen)
  2435. * @param y defines the y coordinate of the origin (on-screen)
  2436. * @param camera defines the camera to use for the picking
  2437. * @returns a Ray
  2438. */
  2439. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2440. /**
  2441. * Creates a ray that can be used to pick in the scene
  2442. * @param x defines the x coordinate of the origin (on-screen)
  2443. * @param y defines the y coordinate of the origin (on-screen)
  2444. * @param result defines the ray where to store the picking ray
  2445. * @param camera defines the camera to use for the picking
  2446. * @returns the current scene
  2447. */
  2448. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2449. private _internalPick;
  2450. private _internalMultiPick;
  2451. private _tempPickingRay;
  2452. /** Launch a ray to try to pick a mesh in the scene
  2453. * @param x position on screen
  2454. * @param y position on screen
  2455. * @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
  2456. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  2457. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2458. * @returns a PickingInfo
  2459. */
  2460. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2461. private _cachedRayForTransform;
  2462. /** Use the given ray to pick a mesh in the scene
  2463. * @param ray The ray to use to pick meshes
  2464. * @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
  2465. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  2466. * @returns a PickingInfo
  2467. */
  2468. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  2469. /**
  2470. * Launch a ray to try to pick a mesh in the scene
  2471. * @param x X position on screen
  2472. * @param y Y position on screen
  2473. * @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
  2474. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2475. * @returns an array of PickingInfo
  2476. */
  2477. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  2478. /**
  2479. * Launch a ray to try to pick a mesh in the scene
  2480. * @param ray Ray to use
  2481. * @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
  2482. * @returns an array of PickingInfo
  2483. */
  2484. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  2485. /**
  2486. * Force the value of meshUnderPointer
  2487. * @param mesh defines the mesh to use
  2488. */
  2489. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  2490. /**
  2491. * Gets the mesh under the pointer
  2492. * @returns a Mesh or null if no mesh is under the pointer
  2493. */
  2494. getPointerOverMesh(): Nullable<AbstractMesh>;
  2495. /** @hidden */
  2496. _rebuildGeometries(): void;
  2497. /** @hidden */
  2498. _rebuildTextures(): void;
  2499. private _getByTags;
  2500. /**
  2501. * Get a list of meshes by tags
  2502. * @param tagsQuery defines the tags query to use
  2503. * @param forEach defines a predicate used to filter results
  2504. * @returns an array of Mesh
  2505. */
  2506. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  2507. /**
  2508. * Get a list of cameras by tags
  2509. * @param tagsQuery defines the tags query to use
  2510. * @param forEach defines a predicate used to filter results
  2511. * @returns an array of Camera
  2512. */
  2513. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  2514. /**
  2515. * Get a list of lights by tags
  2516. * @param tagsQuery defines the tags query to use
  2517. * @param forEach defines a predicate used to filter results
  2518. * @returns an array of Light
  2519. */
  2520. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  2521. /**
  2522. * Get a list of materials by tags
  2523. * @param tagsQuery defines the tags query to use
  2524. * @param forEach defines a predicate used to filter results
  2525. * @returns an array of Material
  2526. */
  2527. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  2528. /**
  2529. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  2530. * This allowed control for front to back rendering or reversly depending of the special needs.
  2531. *
  2532. * @param renderingGroupId The rendering group id corresponding to its index
  2533. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2534. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2535. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2536. */
  2537. 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;
  2538. /**
  2539. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2540. *
  2541. * @param renderingGroupId The rendering group id corresponding to its index
  2542. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2543. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2544. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2545. */
  2546. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2547. /**
  2548. * Gets the current auto clear configuration for one rendering group of the rendering
  2549. * manager.
  2550. * @param index the rendering group index to get the information for
  2551. * @returns The auto clear setup for the requested rendering group
  2552. */
  2553. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2554. private _blockMaterialDirtyMechanism;
  2555. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2556. blockMaterialDirtyMechanism: boolean;
  2557. /**
  2558. * Will flag all materials as dirty to trigger new shader compilation
  2559. * @param flag defines the flag used to specify which material part must be marked as dirty
  2560. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  2561. */
  2562. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2563. /** @hidden */
  2564. _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;
  2565. /** @hidden */
  2566. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2567. }
  2568. }
  2569. declare module BABYLON {
  2570. /**
  2571. * Groups all the scene component constants in one place to ease maintenance.
  2572. * @hidden
  2573. */
  2574. class SceneComponentConstants {
  2575. static readonly NAME_EFFECTLAYER: string;
  2576. static readonly NAME_LAYER: string;
  2577. static readonly NAME_LENSFLARESYSTEM: string;
  2578. static readonly NAME_BOUNDINGBOXRENDERER: string;
  2579. static readonly NAME_PARTICLESYSTEM: string;
  2580. static readonly NAME_GAMEPAD: string;
  2581. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  2582. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  2583. static readonly NAME_DEPTHRENDERER: string;
  2584. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  2585. static readonly NAME_SPRITE: string;
  2586. static readonly NAME_OUTLINERENDERER: string;
  2587. static readonly NAME_PROCEDURALTEXTURE: string;
  2588. static readonly NAME_SHADOWGENERATOR: string;
  2589. static readonly NAME_OCTREE: string;
  2590. static readonly NAME_PHYSICSENGINE: string;
  2591. static readonly NAME_AUDIO: string;
  2592. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  2593. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2594. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  2595. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  2596. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  2597. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  2598. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  2599. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  2600. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  2601. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  2602. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  2603. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  2604. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  2605. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  2606. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  2607. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  2608. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  2609. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  2610. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  2611. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  2612. static readonly STEP_AFTERRENDER_AUDIO: number;
  2613. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  2614. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  2615. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  2616. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  2617. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  2618. static readonly STEP_POINTERMOVE_SPRITE: number;
  2619. static readonly STEP_POINTERDOWN_SPRITE: number;
  2620. static readonly STEP_POINTERUP_SPRITE: number;
  2621. }
  2622. /**
  2623. * This represents a scene component.
  2624. *
  2625. * This is used to decouple the dependency the scene is having on the different workloads like
  2626. * layers, post processes...
  2627. */
  2628. interface ISceneComponent {
  2629. /**
  2630. * The name of the component. Each component must have a unique name.
  2631. */
  2632. name: string;
  2633. /**
  2634. * The scene the component belongs to.
  2635. */
  2636. scene: Scene;
  2637. /**
  2638. * Register the component to one instance of a scene.
  2639. */
  2640. register(): void;
  2641. /**
  2642. * Rebuilds the elements related to this component in case of
  2643. * context lost for instance.
  2644. */
  2645. rebuild(): void;
  2646. /**
  2647. * Disposes the component and the associated ressources.
  2648. */
  2649. dispose(): void;
  2650. }
  2651. /**
  2652. * This represents a SERIALIZABLE scene component.
  2653. *
  2654. * This extends Scene Component to add Serialization methods on top.
  2655. */
  2656. interface ISceneSerializableComponent extends ISceneComponent {
  2657. /**
  2658. * Adds all the element from the container to the scene
  2659. * @param container the container holding the elements
  2660. */
  2661. addFromContainer(container: AbstractScene): void;
  2662. /**
  2663. * Removes all the elements in the container from the scene
  2664. * @param container contains the elements to remove
  2665. */
  2666. removeFromContainer(container: AbstractScene): void;
  2667. /**
  2668. * Serializes the component data to the specified json object
  2669. * @param serializationObject The object to serialize to
  2670. */
  2671. serialize(serializationObject: any): void;
  2672. }
  2673. /**
  2674. * Strong typing of a Mesh related stage step action
  2675. */
  2676. type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  2677. /**
  2678. * Strong typing of a Evaluate Sub Mesh related stage step action
  2679. */
  2680. type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  2681. /**
  2682. * Strong typing of a Active Mesh related stage step action
  2683. */
  2684. type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  2685. /**
  2686. * Strong typing of a Camera related stage step action
  2687. */
  2688. type CameraStageAction = (camera: Camera) => void;
  2689. /**
  2690. * Strong typing of a Render Target related stage step action
  2691. */
  2692. type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  2693. /**
  2694. * Strong typing of a RenderingGroup related stage step action
  2695. */
  2696. type RenderingGroupStageAction = (renderingGroupId: number) => void;
  2697. /**
  2698. * Strong typing of a Mesh Render related stage step action
  2699. */
  2700. type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  2701. /**
  2702. * Strong typing of a simple stage step action
  2703. */
  2704. type SimpleStageAction = () => void;
  2705. /**
  2706. * Strong typing of a render target action.
  2707. */
  2708. type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  2709. /**
  2710. * Strong typing of a pointer move action.
  2711. */
  2712. type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  2713. /**
  2714. * Strong typing of a pointer up/down action.
  2715. */
  2716. type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  2717. /**
  2718. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  2719. * @hidden
  2720. */
  2721. class Stage<T extends Function> extends Array<{
  2722. index: number;
  2723. component: ISceneComponent;
  2724. action: T;
  2725. }> {
  2726. /**
  2727. * Hide ctor from the rest of the world.
  2728. * @param items The items to add.
  2729. */
  2730. private constructor();
  2731. /**
  2732. * Creates a new Stage.
  2733. * @returns A new instance of a Stage
  2734. */
  2735. static Create<T extends Function>(): Stage<T>;
  2736. /**
  2737. * Registers a step in an ordered way in the targeted stage.
  2738. * @param index Defines the position to register the step in
  2739. * @param component Defines the component attached to the step
  2740. * @param action Defines the action to launch during the step
  2741. */
  2742. registerStep(index: number, component: ISceneComponent, action: T): void;
  2743. /**
  2744. * Clears all the steps from the stage.
  2745. */
  2746. clear(): void;
  2747. }
  2748. }
  2749. declare module BABYLON {
  2750. /** Alias type for value that can be null */
  2751. type Nullable<T> = T | null;
  2752. /**
  2753. * Alias type for number that are floats
  2754. * @ignorenaming
  2755. */
  2756. type float = number;
  2757. /**
  2758. * Alias type for number that are doubles.
  2759. * @ignorenaming
  2760. */
  2761. type double = number;
  2762. /**
  2763. * Alias type for number that are integer
  2764. * @ignorenaming
  2765. */
  2766. type int = number;
  2767. /** Alias type for number array or Float32Array */
  2768. type FloatArray = number[] | Float32Array;
  2769. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  2770. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  2771. /**
  2772. * Alias for types that can be used by a Buffer or VertexBuffer.
  2773. */
  2774. type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  2775. /**
  2776. * Alias type for primitive types
  2777. * @ignorenaming
  2778. */
  2779. type Primitive = undefined | null | boolean | string | number | Function;
  2780. /**
  2781. * Type modifier to make all the properties of an object Readonly
  2782. */
  2783. type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  2784. /**
  2785. * Type modifier to make all the properties of an object Readonly recursively
  2786. */
  2787. type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  2788. /** @hidden */
  2789. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  2790. }
  2791. /** @hidden */
  2792. /** @hidden */
  2793. type DeepImmutableObject<T> = {
  2794. readonly [K in keyof T]: DeepImmutable<T[K]>;
  2795. };
  2796. }
  2797. declare module BABYLON {
  2798. /**
  2799. * The action to be carried out following a trigger
  2800. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  2801. */
  2802. class Action {
  2803. /** the trigger, with or without parameters, for the action */
  2804. triggerOptions: any;
  2805. /**
  2806. * Trigger for the action
  2807. */
  2808. trigger: number;
  2809. /**
  2810. * Internal only - manager for action
  2811. * @hidden
  2812. */
  2813. _actionManager: ActionManager;
  2814. private _nextActiveAction;
  2815. private _child;
  2816. private _condition?;
  2817. private _triggerParameter;
  2818. /**
  2819. * An event triggered prior to action being executed.
  2820. */
  2821. onBeforeExecuteObservable: Observable<Action>;
  2822. /**
  2823. * Creates a new Action
  2824. * @param triggerOptions the trigger, with or without parameters, for the action
  2825. * @param condition an optional determinant of action
  2826. */
  2827. constructor(
  2828. /** the trigger, with or without parameters, for the action */
  2829. triggerOptions: any, condition?: Condition);
  2830. /**
  2831. * Internal only
  2832. * @hidden
  2833. */
  2834. _prepare(): void;
  2835. /**
  2836. * Gets the trigger parameters
  2837. * @returns the trigger parameters
  2838. */
  2839. getTriggerParameter(): any;
  2840. /**
  2841. * Internal only - executes current action event
  2842. * @hidden
  2843. */
  2844. _executeCurrent(evt?: ActionEvent): void;
  2845. /**
  2846. * Execute placeholder for child classes
  2847. * @param evt optional action event
  2848. */
  2849. execute(evt?: ActionEvent): void;
  2850. /**
  2851. * Skips to next active action
  2852. */
  2853. skipToNextActiveAction(): void;
  2854. /**
  2855. * Adds action to chain of actions, may be a DoNothingAction
  2856. * @param action defines the next action to execute
  2857. * @returns The action passed in
  2858. * @see https://www.babylonjs-playground.com/#1T30HR#0
  2859. */
  2860. then(action: Action): Action;
  2861. /**
  2862. * Internal only
  2863. * @hidden
  2864. */
  2865. _getProperty(propertyPath: string): string;
  2866. /**
  2867. * Internal only
  2868. * @hidden
  2869. */
  2870. _getEffectiveTarget(target: any, propertyPath: string): any;
  2871. /**
  2872. * Serialize placeholder for child classes
  2873. * @param parent of child
  2874. * @returns the serialized object
  2875. */
  2876. serialize(parent: any): any;
  2877. /**
  2878. * Internal only called by serialize
  2879. * @hidden
  2880. */
  2881. protected _serialize(serializedAction: any, parent?: any): any;
  2882. /**
  2883. * Internal only
  2884. * @hidden
  2885. */
  2886. static _SerializeValueAsString: (value: any) => string;
  2887. /**
  2888. * Internal only
  2889. * @hidden
  2890. */
  2891. static _GetTargetProperty: (target: Scene | Node) => {
  2892. name: string;
  2893. targetType: string;
  2894. value: string;
  2895. };
  2896. }
  2897. }
  2898. declare module BABYLON {
  2899. /**
  2900. * ActionEvent is the event being sent when an action is triggered.
  2901. */
  2902. class ActionEvent {
  2903. /** The mesh or sprite that triggered the action */
  2904. source: any;
  2905. /** The X mouse cursor position at the time of the event */
  2906. pointerX: number;
  2907. /** The Y mouse cursor position at the time of the event */
  2908. pointerY: number;
  2909. /** The mesh that is currently pointed at (can be null) */
  2910. meshUnderPointer: Nullable<AbstractMesh>;
  2911. /** the original (browser) event that triggered the ActionEvent */
  2912. sourceEvent?: any;
  2913. /** additional data for the event */
  2914. additionalData?: any;
  2915. /**
  2916. * Creates a new ActionEvent
  2917. * @param source The mesh or sprite that triggered the action
  2918. * @param pointerX The X mouse cursor position at the time of the event
  2919. * @param pointerY The Y mouse cursor position at the time of the event
  2920. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  2921. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  2922. * @param additionalData additional data for the event
  2923. */
  2924. constructor(
  2925. /** The mesh or sprite that triggered the action */
  2926. source: any,
  2927. /** The X mouse cursor position at the time of the event */
  2928. pointerX: number,
  2929. /** The Y mouse cursor position at the time of the event */
  2930. pointerY: number,
  2931. /** The mesh that is currently pointed at (can be null) */
  2932. meshUnderPointer: Nullable<AbstractMesh>,
  2933. /** the original (browser) event that triggered the ActionEvent */
  2934. sourceEvent?: any,
  2935. /** additional data for the event */
  2936. additionalData?: any);
  2937. /**
  2938. * Helper function to auto-create an ActionEvent from a source mesh.
  2939. * @param source The source mesh that triggered the event
  2940. * @param evt The original (browser) event
  2941. * @param additionalData additional data for the event
  2942. * @returns the new ActionEvent
  2943. */
  2944. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  2945. /**
  2946. * Helper function to auto-create an ActionEvent from a source sprite
  2947. * @param source The source sprite that triggered the event
  2948. * @param scene Scene associated with the sprite
  2949. * @param evt The original (browser) event
  2950. * @param additionalData additional data for the event
  2951. * @returns the new ActionEvent
  2952. */
  2953. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  2954. /**
  2955. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  2956. * @param scene the scene where the event occurred
  2957. * @param evt The original (browser) event
  2958. * @returns the new ActionEvent
  2959. */
  2960. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  2961. /**
  2962. * Helper function to auto-create an ActionEvent from a primitive
  2963. * @param prim defines the target primitive
  2964. * @param pointerPos defines the pointer position
  2965. * @param evt The original (browser) event
  2966. * @param additionalData additional data for the event
  2967. * @returns the new ActionEvent
  2968. */
  2969. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  2970. }
  2971. /**
  2972. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  2973. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  2974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2975. */
  2976. class ActionManager {
  2977. /**
  2978. * Nothing
  2979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2980. */
  2981. static readonly NothingTrigger: number;
  2982. /**
  2983. * On pick
  2984. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2985. */
  2986. static readonly OnPickTrigger: number;
  2987. /**
  2988. * On left pick
  2989. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2990. */
  2991. static readonly OnLeftPickTrigger: number;
  2992. /**
  2993. * On right pick
  2994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  2995. */
  2996. static readonly OnRightPickTrigger: number;
  2997. /**
  2998. * On center pick
  2999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3000. */
  3001. static readonly OnCenterPickTrigger: number;
  3002. /**
  3003. * On pick down
  3004. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3005. */
  3006. static readonly OnPickDownTrigger: number;
  3007. /**
  3008. * On double pick
  3009. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3010. */
  3011. static readonly OnDoublePickTrigger: number;
  3012. /**
  3013. * On pick up
  3014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3015. */
  3016. static readonly OnPickUpTrigger: number;
  3017. /**
  3018. * On pick out.
  3019. * This trigger will only be raised if you also declared a OnPickDown
  3020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3021. */
  3022. static readonly OnPickOutTrigger: number;
  3023. /**
  3024. * On long press
  3025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3026. */
  3027. static readonly OnLongPressTrigger: number;
  3028. /**
  3029. * On pointer over
  3030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3031. */
  3032. static readonly OnPointerOverTrigger: number;
  3033. /**
  3034. * On pointer out
  3035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3036. */
  3037. static readonly OnPointerOutTrigger: number;
  3038. /**
  3039. * On every frame
  3040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3041. */
  3042. static readonly OnEveryFrameTrigger: number;
  3043. /**
  3044. * On intersection enter
  3045. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3046. */
  3047. static readonly OnIntersectionEnterTrigger: number;
  3048. /**
  3049. * On intersection exit
  3050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3051. */
  3052. static readonly OnIntersectionExitTrigger: number;
  3053. /**
  3054. * On key down
  3055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3056. */
  3057. static readonly OnKeyDownTrigger: number;
  3058. /**
  3059. * On key up
  3060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  3061. */
  3062. static readonly OnKeyUpTrigger: number;
  3063. /** Gets the list of active triggers */
  3064. static Triggers: {
  3065. [key: string]: number;
  3066. };
  3067. /** Gets the list of actions */
  3068. actions: Action[];
  3069. /** Gets the cursor to use when hovering items */
  3070. hoverCursor: string;
  3071. private _scene;
  3072. /**
  3073. * Creates a new action manager
  3074. * @param scene defines the hosting scene
  3075. */
  3076. constructor(scene: Scene);
  3077. /**
  3078. * Releases all associated resources
  3079. */
  3080. dispose(): void;
  3081. /**
  3082. * Gets hosting scene
  3083. * @returns the hosting scene
  3084. */
  3085. getScene(): Scene;
  3086. /**
  3087. * Does this action manager handles actions of any of the given triggers
  3088. * @param triggers defines the triggers to be tested
  3089. * @return a boolean indicating whether one (or more) of the triggers is handled
  3090. */
  3091. hasSpecificTriggers(triggers: number[]): boolean;
  3092. /**
  3093. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  3094. * speed.
  3095. * @param triggerA defines the trigger to be tested
  3096. * @param triggerB defines the trigger to be tested
  3097. * @return a boolean indicating whether one (or more) of the triggers is handled
  3098. */
  3099. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  3100. /**
  3101. * Does this action manager handles actions of a given trigger
  3102. * @param trigger defines the trigger to be tested
  3103. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  3104. * @return whether the trigger is handled
  3105. */
  3106. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  3107. /**
  3108. * Does this action manager has pointer triggers
  3109. */
  3110. readonly hasPointerTriggers: boolean;
  3111. /**
  3112. * Does this action manager has pick triggers
  3113. */
  3114. readonly hasPickTriggers: boolean;
  3115. /**
  3116. * Does exist one action manager with at least one trigger
  3117. **/
  3118. static readonly HasTriggers: boolean;
  3119. /**
  3120. * Does exist one action manager with at least one pick trigger
  3121. **/
  3122. static readonly HasPickTriggers: boolean;
  3123. /**
  3124. * Does exist one action manager that handles actions of a given trigger
  3125. * @param trigger defines the trigger to be tested
  3126. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  3127. **/
  3128. static HasSpecificTrigger(trigger: number): boolean;
  3129. /**
  3130. * Registers an action to this action manager
  3131. * @param action defines the action to be registered
  3132. * @return the action amended (prepared) after registration
  3133. */
  3134. registerAction(action: Action): Nullable<Action>;
  3135. /**
  3136. * Unregisters an action to this action manager
  3137. * @param action defines the action to be unregistered
  3138. * @return a boolean indicating whether the action has been unregistered
  3139. */
  3140. unregisterAction(action: Action): Boolean;
  3141. /**
  3142. * Process a specific trigger
  3143. * @param trigger defines the trigger to process
  3144. * @param evt defines the event details to be processed
  3145. */
  3146. processTrigger(trigger: number, evt?: ActionEvent): void;
  3147. /** @hidden */
  3148. _getEffectiveTarget(target: any, propertyPath: string): any;
  3149. /** @hidden */
  3150. _getProperty(propertyPath: string): string;
  3151. /**
  3152. * Serialize this manager to a JSON object
  3153. * @param name defines the property name to store this manager
  3154. * @returns a JSON representation of this manager
  3155. */
  3156. serialize(name: string): any;
  3157. /**
  3158. * Creates a new ActionManager from a JSON data
  3159. * @param parsedActions defines the JSON data to read from
  3160. * @param object defines the hosting mesh
  3161. * @param scene defines the hosting scene
  3162. */
  3163. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  3164. /**
  3165. * Get a trigger name by index
  3166. * @param trigger defines the trigger index
  3167. * @returns a trigger name
  3168. */
  3169. static GetTriggerName(trigger: number): string;
  3170. }
  3171. }
  3172. declare module BABYLON {
  3173. /**
  3174. * A Condition applied to an Action
  3175. */
  3176. class Condition {
  3177. /**
  3178. * Internal only - manager for action
  3179. * @hidden
  3180. */
  3181. _actionManager: ActionManager;
  3182. /**
  3183. * Internal only
  3184. * @hidden
  3185. */
  3186. _evaluationId: number;
  3187. /**
  3188. * Internal only
  3189. * @hidden
  3190. */
  3191. _currentResult: boolean;
  3192. /**
  3193. * Creates a new Condition
  3194. * @param actionManager the manager of the action the condition is applied to
  3195. */
  3196. constructor(actionManager: ActionManager);
  3197. /**
  3198. * Check if the current condition is valid
  3199. * @returns a boolean
  3200. */
  3201. isValid(): boolean;
  3202. /**
  3203. * Internal only
  3204. * @hidden
  3205. */
  3206. _getProperty(propertyPath: string): string;
  3207. /**
  3208. * Internal only
  3209. * @hidden
  3210. */
  3211. _getEffectiveTarget(target: any, propertyPath: string): any;
  3212. /**
  3213. * Serialize placeholder for child classes
  3214. * @returns the serialized object
  3215. */
  3216. serialize(): any;
  3217. /**
  3218. * Internal only
  3219. * @hidden
  3220. */
  3221. protected _serialize(serializedCondition: any): any;
  3222. }
  3223. /**
  3224. * Defines specific conditional operators as extensions of Condition
  3225. */
  3226. class ValueCondition extends Condition {
  3227. /** path to specify the property of the target the conditional operator uses */
  3228. propertyPath: string;
  3229. /** the value compared by the conditional operator against the current value of the property */
  3230. value: any;
  3231. /** the conditional operator, default ValueCondition.IsEqual */
  3232. operator: number;
  3233. /**
  3234. * Internal only
  3235. * @hidden
  3236. */
  3237. private static _IsEqual;
  3238. /**
  3239. * Internal only
  3240. * @hidden
  3241. */
  3242. private static _IsDifferent;
  3243. /**
  3244. * Internal only
  3245. * @hidden
  3246. */
  3247. private static _IsGreater;
  3248. /**
  3249. * Internal only
  3250. * @hidden
  3251. */
  3252. private static _IsLesser;
  3253. /**
  3254. * returns the number for IsEqual
  3255. */
  3256. static readonly IsEqual: number;
  3257. /**
  3258. * Returns the number for IsDifferent
  3259. */
  3260. static readonly IsDifferent: number;
  3261. /**
  3262. * Returns the number for IsGreater
  3263. */
  3264. static readonly IsGreater: number;
  3265. /**
  3266. * Returns the number for IsLesser
  3267. */
  3268. static readonly IsLesser: number;
  3269. /**
  3270. * Internal only The action manager for the condition
  3271. * @hidden
  3272. */
  3273. _actionManager: ActionManager;
  3274. /**
  3275. * Internal only
  3276. * @hidden
  3277. */
  3278. private _target;
  3279. /**
  3280. * Internal only
  3281. * @hidden
  3282. */
  3283. private _effectiveTarget;
  3284. /**
  3285. * Internal only
  3286. * @hidden
  3287. */
  3288. private _property;
  3289. /**
  3290. * Creates a new ValueCondition
  3291. * @param actionManager manager for the action the condition applies to
  3292. * @param target for the action
  3293. * @param propertyPath path to specify the property of the target the conditional operator uses
  3294. * @param value the value compared by the conditional operator against the current value of the property
  3295. * @param operator the conditional operator, default ValueCondition.IsEqual
  3296. */
  3297. constructor(actionManager: ActionManager, target: any,
  3298. /** path to specify the property of the target the conditional operator uses */
  3299. propertyPath: string,
  3300. /** the value compared by the conditional operator against the current value of the property */
  3301. value: any,
  3302. /** the conditional operator, default ValueCondition.IsEqual */
  3303. operator?: number);
  3304. /**
  3305. * Compares the given value with the property value for the specified conditional operator
  3306. * @returns the result of the comparison
  3307. */
  3308. isValid(): boolean;
  3309. /**
  3310. * Serialize the ValueCondition into a JSON compatible object
  3311. * @returns serialization object
  3312. */
  3313. serialize(): any;
  3314. /**
  3315. * Gets the name of the conditional operator for the ValueCondition
  3316. * @param operator the conditional operator
  3317. * @returns the name
  3318. */
  3319. static GetOperatorName(operator: number): string;
  3320. }
  3321. /**
  3322. * Defines a predicate condition as an extension of Condition
  3323. */
  3324. class PredicateCondition extends Condition {
  3325. /** defines the predicate function used to validate the condition */
  3326. predicate: () => boolean;
  3327. /**
  3328. * Internal only - manager for action
  3329. * @hidden
  3330. */
  3331. _actionManager: ActionManager;
  3332. /**
  3333. * Creates a new PredicateCondition
  3334. * @param actionManager manager for the action the condition applies to
  3335. * @param predicate defines the predicate function used to validate the condition
  3336. */
  3337. constructor(actionManager: ActionManager,
  3338. /** defines the predicate function used to validate the condition */
  3339. predicate: () => boolean);
  3340. /**
  3341. * @returns the validity of the predicate condition
  3342. */
  3343. isValid(): boolean;
  3344. }
  3345. /**
  3346. * Defines a state condition as an extension of Condition
  3347. */
  3348. class StateCondition extends Condition {
  3349. /** Value to compare with target state */
  3350. value: string;
  3351. /**
  3352. * Internal only - manager for action
  3353. * @hidden
  3354. */
  3355. _actionManager: ActionManager;
  3356. /**
  3357. * Internal only
  3358. * @hidden
  3359. */
  3360. private _target;
  3361. /**
  3362. * Creates a new StateCondition
  3363. * @param actionManager manager for the action the condition applies to
  3364. * @param target of the condition
  3365. * @param value to compare with target state
  3366. */
  3367. constructor(actionManager: ActionManager, target: any,
  3368. /** Value to compare with target state */
  3369. value: string);
  3370. /**
  3371. * Gets a boolean indicating if the current condition is met
  3372. * @returns the validity of the state
  3373. */
  3374. isValid(): boolean;
  3375. /**
  3376. * Serialize the StateCondition into a JSON compatible object
  3377. * @returns serialization object
  3378. */
  3379. serialize(): any;
  3380. }
  3381. }
  3382. declare module BABYLON {
  3383. /**
  3384. * This defines an action responsible to toggle a boolean once triggered.
  3385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3386. */
  3387. class SwitchBooleanAction extends Action {
  3388. /**
  3389. * The path to the boolean property in the target object
  3390. */
  3391. propertyPath: string;
  3392. private _target;
  3393. private _effectiveTarget;
  3394. private _property;
  3395. /**
  3396. * Instantiate the action
  3397. * @param triggerOptions defines the trigger options
  3398. * @param target defines the object containing the boolean
  3399. * @param propertyPath defines the path to the boolean property in the target object
  3400. * @param condition defines the trigger related conditions
  3401. */
  3402. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  3403. /** @hidden */
  3404. _prepare(): void;
  3405. /**
  3406. * Execute the action toggle the boolean value.
  3407. */
  3408. execute(): void;
  3409. /**
  3410. * Serializes the actions and its related information.
  3411. * @param parent defines the object to serialize in
  3412. * @returns the serialized object
  3413. */
  3414. serialize(parent: any): any;
  3415. }
  3416. /**
  3417. * This defines an action responsible to set a the state field of the target
  3418. * to a desired value once triggered.
  3419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3420. */
  3421. class SetStateAction extends Action {
  3422. /**
  3423. * The value to store in the state field.
  3424. */
  3425. value: string;
  3426. private _target;
  3427. /**
  3428. * Instantiate the action
  3429. * @param triggerOptions defines the trigger options
  3430. * @param target defines the object containing the state property
  3431. * @param value defines the value to store in the state field
  3432. * @param condition defines the trigger related conditions
  3433. */
  3434. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  3435. /**
  3436. * Execute the action and store the value on the target state property.
  3437. */
  3438. execute(): void;
  3439. /**
  3440. * Serializes the actions and its related information.
  3441. * @param parent defines the object to serialize in
  3442. * @returns the serialized object
  3443. */
  3444. serialize(parent: any): any;
  3445. }
  3446. /**
  3447. * This defines an action responsible to set a property of the target
  3448. * to a desired value once triggered.
  3449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3450. */
  3451. class SetValueAction extends Action {
  3452. /**
  3453. * The path of the property to set in the target.
  3454. */
  3455. propertyPath: string;
  3456. /**
  3457. * The value to set in the property
  3458. */
  3459. value: any;
  3460. private _target;
  3461. private _effectiveTarget;
  3462. private _property;
  3463. /**
  3464. * Instantiate the action
  3465. * @param triggerOptions defines the trigger options
  3466. * @param target defines the object containing the property
  3467. * @param propertyPath defines the path of the property to set in the target
  3468. * @param value defines the value to set in the property
  3469. * @param condition defines the trigger related conditions
  3470. */
  3471. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3472. /** @hidden */
  3473. _prepare(): void;
  3474. /**
  3475. * Execute the action and set the targetted property to the desired value.
  3476. */
  3477. execute(): void;
  3478. /**
  3479. * Serializes the actions and its related information.
  3480. * @param parent defines the object to serialize in
  3481. * @returns the serialized object
  3482. */
  3483. serialize(parent: any): any;
  3484. }
  3485. /**
  3486. * This defines an action responsible to increment the target value
  3487. * to a desired value once triggered.
  3488. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3489. */
  3490. class IncrementValueAction extends Action {
  3491. /**
  3492. * The path of the property to increment in the target.
  3493. */
  3494. propertyPath: string;
  3495. /**
  3496. * The value we should increment the property by.
  3497. */
  3498. value: any;
  3499. private _target;
  3500. private _effectiveTarget;
  3501. private _property;
  3502. /**
  3503. * Instantiate the action
  3504. * @param triggerOptions defines the trigger options
  3505. * @param target defines the object containing the property
  3506. * @param propertyPath defines the path of the property to increment in the target
  3507. * @param value defines the value value we should increment the property by
  3508. * @param condition defines the trigger related conditions
  3509. */
  3510. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  3511. /** @hidden */
  3512. _prepare(): void;
  3513. /**
  3514. * Execute the action and increment the target of the value amount.
  3515. */
  3516. execute(): void;
  3517. /**
  3518. * Serializes the actions and its related information.
  3519. * @param parent defines the object to serialize in
  3520. * @returns the serialized object
  3521. */
  3522. serialize(parent: any): any;
  3523. }
  3524. /**
  3525. * This defines an action responsible to start an animation once triggered.
  3526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3527. */
  3528. class PlayAnimationAction extends Action {
  3529. /**
  3530. * Where the animation should start (animation frame)
  3531. */
  3532. from: number;
  3533. /**
  3534. * Where the animation should stop (animation frame)
  3535. */
  3536. to: number;
  3537. /**
  3538. * Define if the animation should loop or stop after the first play.
  3539. */
  3540. loop?: boolean;
  3541. private _target;
  3542. /**
  3543. * Instantiate the action
  3544. * @param triggerOptions defines the trigger options
  3545. * @param target defines the target animation or animation name
  3546. * @param from defines from where the animation should start (animation frame)
  3547. * @param end defines where the animation should stop (animation frame)
  3548. * @param loop defines if the animation should loop or stop after the first play
  3549. * @param condition defines the trigger related conditions
  3550. */
  3551. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  3552. /** @hidden */
  3553. _prepare(): void;
  3554. /**
  3555. * Execute the action and play the animation.
  3556. */
  3557. execute(): void;
  3558. /**
  3559. * Serializes the actions and its related information.
  3560. * @param parent defines the object to serialize in
  3561. * @returns the serialized object
  3562. */
  3563. serialize(parent: any): any;
  3564. }
  3565. /**
  3566. * This defines an action responsible to stop an animation once triggered.
  3567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3568. */
  3569. class StopAnimationAction extends Action {
  3570. private _target;
  3571. /**
  3572. * Instantiate the action
  3573. * @param triggerOptions defines the trigger options
  3574. * @param target defines the target animation or animation name
  3575. * @param condition defines the trigger related conditions
  3576. */
  3577. constructor(triggerOptions: any, target: any, condition?: Condition);
  3578. /** @hidden */
  3579. _prepare(): void;
  3580. /**
  3581. * Execute the action and stop the animation.
  3582. */
  3583. execute(): void;
  3584. /**
  3585. * Serializes the actions and its related information.
  3586. * @param parent defines the object to serialize in
  3587. * @returns the serialized object
  3588. */
  3589. serialize(parent: any): any;
  3590. }
  3591. /**
  3592. * This defines an action responsible that does nothing once triggered.
  3593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3594. */
  3595. class DoNothingAction extends Action {
  3596. /**
  3597. * Instantiate the action
  3598. * @param triggerOptions defines the trigger options
  3599. * @param condition defines the trigger related conditions
  3600. */
  3601. constructor(triggerOptions?: any, condition?: Condition);
  3602. /**
  3603. * Execute the action and do nothing.
  3604. */
  3605. execute(): void;
  3606. /**
  3607. * Serializes the actions and its related information.
  3608. * @param parent defines the object to serialize in
  3609. * @returns the serialized object
  3610. */
  3611. serialize(parent: any): any;
  3612. }
  3613. /**
  3614. * This defines an action responsible to trigger several actions once triggered.
  3615. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3616. */
  3617. class CombineAction extends Action {
  3618. /**
  3619. * The list of aggregated animations to run.
  3620. */
  3621. children: Action[];
  3622. /**
  3623. * Instantiate the action
  3624. * @param triggerOptions defines the trigger options
  3625. * @param children defines the list of aggregated animations to run
  3626. * @param condition defines the trigger related conditions
  3627. */
  3628. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  3629. /** @hidden */
  3630. _prepare(): void;
  3631. /**
  3632. * Execute the action and executes all the aggregated actions.
  3633. */
  3634. execute(evt: ActionEvent): void;
  3635. /**
  3636. * Serializes the actions and its related information.
  3637. * @param parent defines the object to serialize in
  3638. * @returns the serialized object
  3639. */
  3640. serialize(parent: any): any;
  3641. }
  3642. /**
  3643. * This defines an action responsible to run code (external event) once triggered.
  3644. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3645. */
  3646. class ExecuteCodeAction extends Action {
  3647. /**
  3648. * The callback function to run.
  3649. */
  3650. func: (evt: ActionEvent) => void;
  3651. /**
  3652. * Instantiate the action
  3653. * @param triggerOptions defines the trigger options
  3654. * @param func defines the callback function to run
  3655. * @param condition defines the trigger related conditions
  3656. */
  3657. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  3658. /**
  3659. * Execute the action and run the attached code.
  3660. */
  3661. execute(evt: ActionEvent): void;
  3662. }
  3663. /**
  3664. * This defines an action responsible to set the parent property of the target once triggered.
  3665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3666. */
  3667. class SetParentAction extends Action {
  3668. private _parent;
  3669. private _target;
  3670. /**
  3671. * Instantiate the action
  3672. * @param triggerOptions defines the trigger options
  3673. * @param target defines the target containing the parent property
  3674. * @param parent defines from where the animation should start (animation frame)
  3675. * @param condition defines the trigger related conditions
  3676. */
  3677. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  3678. /** @hidden */
  3679. _prepare(): void;
  3680. /**
  3681. * Execute the action and set the parent property.
  3682. */
  3683. execute(): void;
  3684. /**
  3685. * Serializes the actions and its related information.
  3686. * @param parent defines the object to serialize in
  3687. * @returns the serialized object
  3688. */
  3689. serialize(parent: any): any;
  3690. }
  3691. }
  3692. declare module BABYLON {
  3693. /**
  3694. * This defines an action helpful to play a defined sound on a triggered action.
  3695. */
  3696. class PlaySoundAction extends Action {
  3697. private _sound;
  3698. /**
  3699. * Instantiate the action
  3700. * @param triggerOptions defines the trigger options
  3701. * @param sound defines the sound to play
  3702. * @param condition defines the trigger related conditions
  3703. */
  3704. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3705. /** @hidden */
  3706. _prepare(): void;
  3707. /**
  3708. * Execute the action and play the sound.
  3709. */
  3710. execute(): void;
  3711. /**
  3712. * Serializes the actions and its related information.
  3713. * @param parent defines the object to serialize in
  3714. * @returns the serialized object
  3715. */
  3716. serialize(parent: any): any;
  3717. }
  3718. /**
  3719. * This defines an action helpful to stop a defined sound on a triggered action.
  3720. */
  3721. class StopSoundAction extends Action {
  3722. private _sound;
  3723. /**
  3724. * Instantiate the action
  3725. * @param triggerOptions defines the trigger options
  3726. * @param sound defines the sound to stop
  3727. * @param condition defines the trigger related conditions
  3728. */
  3729. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  3730. /** @hidden */
  3731. _prepare(): void;
  3732. /**
  3733. * Execute the action and stop the sound.
  3734. */
  3735. execute(): void;
  3736. /**
  3737. * Serializes the actions and its related information.
  3738. * @param parent defines the object to serialize in
  3739. * @returns the serialized object
  3740. */
  3741. serialize(parent: any): any;
  3742. }
  3743. }
  3744. declare module BABYLON {
  3745. /**
  3746. * This defines an action responsible to change the value of a property
  3747. * by interpolating between its current value and the newly set one once triggered.
  3748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  3749. */
  3750. class InterpolateValueAction extends Action {
  3751. /**
  3752. * Defines the path of the property where the value should be interpolated
  3753. */
  3754. propertyPath: string;
  3755. /**
  3756. * Defines the target value at the end of the interpolation.
  3757. */
  3758. value: any;
  3759. /**
  3760. * Defines the time it will take for the property to interpolate to the value.
  3761. */
  3762. duration: number;
  3763. /**
  3764. * Defines if the other scene animations should be stopped when the action has been triggered
  3765. */
  3766. stopOtherAnimations?: boolean;
  3767. /**
  3768. * Defines a callback raised once the interpolation animation has been done.
  3769. */
  3770. onInterpolationDone?: () => void;
  3771. /**
  3772. * Observable triggered once the interpolation animation has been done.
  3773. */
  3774. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  3775. private _target;
  3776. private _effectiveTarget;
  3777. private _property;
  3778. /**
  3779. * Instantiate the action
  3780. * @param triggerOptions defines the trigger options
  3781. * @param target defines the object containing the value to interpolate
  3782. * @param propertyPath defines the path to the property in the target object
  3783. * @param value defines the target value at the end of the interpolation
  3784. * @param duration deines the time it will take for the property to interpolate to the value.
  3785. * @param condition defines the trigger related conditions
  3786. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  3787. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  3788. */
  3789. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  3790. /** @hidden */
  3791. _prepare(): void;
  3792. /**
  3793. * Execute the action starts the value interpolation.
  3794. */
  3795. execute(): void;
  3796. /**
  3797. * Serializes the actions and its related information.
  3798. * @param parent defines the object to serialize in
  3799. * @returns the serialized object
  3800. */
  3801. serialize(parent: any): any;
  3802. }
  3803. }
  3804. declare module BABYLON {
  3805. /**
  3806. * Class used to store an actual running animation
  3807. */
  3808. class Animatable {
  3809. /** defines the target object */
  3810. target: any;
  3811. /** defines the starting frame number (default is 0) */
  3812. fromFrame: number;
  3813. /** defines the ending frame number (default is 100) */
  3814. toFrame: number;
  3815. /** defines if the animation must loop (default is false) */
  3816. loopAnimation: boolean;
  3817. /** defines a callback to call when animation ends if it is not looping */
  3818. onAnimationEnd?: (() => void) | null | undefined;
  3819. private _localDelayOffset;
  3820. private _pausedDelay;
  3821. private _runtimeAnimations;
  3822. private _paused;
  3823. private _scene;
  3824. private _speedRatio;
  3825. private _weight;
  3826. private _syncRoot;
  3827. /**
  3828. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  3829. * This will only apply for non looping animation (default is true)
  3830. */
  3831. disposeOnEnd: boolean;
  3832. /**
  3833. * Gets a boolean indicating if the animation has started
  3834. */
  3835. animationStarted: boolean;
  3836. /**
  3837. * Observer raised when the animation ends
  3838. */
  3839. onAnimationEndObservable: Observable<Animatable>;
  3840. /**
  3841. * Gets the root Animatable used to synchronize and normalize animations
  3842. */
  3843. readonly syncRoot: Animatable;
  3844. /**
  3845. * Gets the current frame of the first RuntimeAnimation
  3846. * Used to synchronize Animatables
  3847. */
  3848. readonly masterFrame: number;
  3849. /**
  3850. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  3851. */
  3852. weight: number;
  3853. /**
  3854. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  3855. */
  3856. speedRatio: number;
  3857. /**
  3858. * Creates a new Animatable
  3859. * @param scene defines the hosting scene
  3860. * @param target defines the target object
  3861. * @param fromFrame defines the starting frame number (default is 0)
  3862. * @param toFrame defines the ending frame number (default is 100)
  3863. * @param loopAnimation defines if the animation must loop (default is false)
  3864. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  3865. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  3866. * @param animations defines a group of animation to add to the new Animatable
  3867. */
  3868. constructor(scene: Scene,
  3869. /** defines the target object */
  3870. target: any,
  3871. /** defines the starting frame number (default is 0) */
  3872. fromFrame?: number,
  3873. /** defines the ending frame number (default is 100) */
  3874. toFrame?: number,
  3875. /** defines if the animation must loop (default is false) */
  3876. loopAnimation?: boolean, speedRatio?: number,
  3877. /** defines a callback to call when animation ends if it is not looping */
  3878. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[]);
  3879. /**
  3880. * Synchronize and normalize current Animatable with a source Animatable
  3881. * This is useful when using animation weights and when animations are not of the same length
  3882. * @param root defines the root Animatable to synchronize with
  3883. * @returns the current Animatable
  3884. */
  3885. syncWith(root: Animatable): Animatable;
  3886. /**
  3887. * Gets the list of runtime animations
  3888. * @returns an array of RuntimeAnimation
  3889. */
  3890. getAnimations(): RuntimeAnimation[];
  3891. /**
  3892. * Adds more animations to the current animatable
  3893. * @param target defines the target of the animations
  3894. * @param animations defines the new animations to add
  3895. */
  3896. appendAnimations(target: any, animations: Animation[]): void;
  3897. /**
  3898. * Gets the source animation for a specific property
  3899. * @param property defines the propertyu to look for
  3900. * @returns null or the source animation for the given property
  3901. */
  3902. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  3903. /**
  3904. * Gets the runtime animation for a specific property
  3905. * @param property defines the propertyu to look for
  3906. * @returns null or the runtime animation for the given property
  3907. */
  3908. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  3909. /**
  3910. * Resets the animatable to its original state
  3911. */
  3912. reset(): void;
  3913. /**
  3914. * Allows the animatable to blend with current running animations
  3915. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3916. * @param blendingSpeed defines the blending speed to use
  3917. */
  3918. enableBlending(blendingSpeed: number): void;
  3919. /**
  3920. * Disable animation blending
  3921. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  3922. */
  3923. disableBlending(): void;
  3924. /**
  3925. * Jump directly to a given frame
  3926. * @param frame defines the frame to jump to
  3927. */
  3928. goToFrame(frame: number): void;
  3929. /**
  3930. * Pause the animation
  3931. */
  3932. pause(): void;
  3933. /**
  3934. * Restart the animation
  3935. */
  3936. restart(): void;
  3937. private _raiseOnAnimationEnd;
  3938. /**
  3939. * Stop and delete the current animation
  3940. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  3941. * @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)
  3942. */
  3943. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  3944. /**
  3945. * Wait asynchronously for the animation to end
  3946. * @returns a promise which will be fullfilled when the animation ends
  3947. */
  3948. waitAsync(): Promise<Animatable>;
  3949. /** @hidden */
  3950. _animate(delay: number): boolean;
  3951. }
  3952. }
  3953. declare module BABYLON {
  3954. /**
  3955. * Represents the range of an animation
  3956. */
  3957. class AnimationRange {
  3958. /**The name of the animation range**/
  3959. name: string;
  3960. /**The starting frame of the animation */
  3961. from: number;
  3962. /**The ending frame of the animation*/
  3963. to: number;
  3964. /**
  3965. * Initializes the range of an animation
  3966. * @param name The name of the animation range
  3967. * @param from The starting frame of the animation
  3968. * @param to The ending frame of the animation
  3969. */
  3970. constructor(
  3971. /**The name of the animation range**/
  3972. name: string,
  3973. /**The starting frame of the animation */
  3974. from: number,
  3975. /**The ending frame of the animation*/
  3976. to: number);
  3977. /**
  3978. * Makes a copy of the animation range
  3979. * @returns A copy of the animation range
  3980. */
  3981. clone(): AnimationRange;
  3982. }
  3983. /**
  3984. * Composed of a frame, and an action function
  3985. */
  3986. class AnimationEvent {
  3987. /** The frame for which the event is triggered **/
  3988. frame: number;
  3989. /** The event to perform when triggered **/
  3990. action: (currentFrame: number) => void;
  3991. /** Specifies if the event should be triggered only once**/
  3992. onlyOnce?: boolean | undefined;
  3993. /**
  3994. * Specifies if the animation event is done
  3995. */
  3996. isDone: boolean;
  3997. /**
  3998. * Initializes the animation event
  3999. * @param frame The frame for which the event is triggered
  4000. * @param action The event to perform when triggered
  4001. * @param onlyOnce Specifies if the event should be triggered only once
  4002. */
  4003. constructor(
  4004. /** The frame for which the event is triggered **/
  4005. frame: number,
  4006. /** The event to perform when triggered **/
  4007. action: (currentFrame: number) => void,
  4008. /** Specifies if the event should be triggered only once**/
  4009. onlyOnce?: boolean | undefined);
  4010. /** @hidden */
  4011. _clone(): AnimationEvent;
  4012. }
  4013. /**
  4014. * A cursor which tracks a point on a path
  4015. */
  4016. class PathCursor {
  4017. private path;
  4018. /**
  4019. * Stores path cursor callbacks for when an onchange event is triggered
  4020. */
  4021. private _onchange;
  4022. /**
  4023. * The value of the path cursor
  4024. */
  4025. value: number;
  4026. /**
  4027. * The animation array of the path cursor
  4028. */
  4029. animations: Animation[];
  4030. /**
  4031. * Initializes the path cursor
  4032. * @param path The path to track
  4033. */
  4034. constructor(path: Path2);
  4035. /**
  4036. * Gets the cursor point on the path
  4037. * @returns A point on the path cursor at the cursor location
  4038. */
  4039. getPoint(): Vector3;
  4040. /**
  4041. * Moves the cursor ahead by the step amount
  4042. * @param step The amount to move the cursor forward
  4043. * @returns This path cursor
  4044. */
  4045. moveAhead(step?: number): PathCursor;
  4046. /**
  4047. * Moves the cursor behind by the step amount
  4048. * @param step The amount to move the cursor back
  4049. * @returns This path cursor
  4050. */
  4051. moveBack(step?: number): PathCursor;
  4052. /**
  4053. * Moves the cursor by the step amount
  4054. * If the step amount is greater than one, an exception is thrown
  4055. * @param step The amount to move the cursor
  4056. * @returns This path cursor
  4057. */
  4058. move(step: number): PathCursor;
  4059. /**
  4060. * Ensures that the value is limited between zero and one
  4061. * @returns This path cursor
  4062. */
  4063. private ensureLimits;
  4064. /**
  4065. * Runs onchange callbacks on change (used by the animation engine)
  4066. * @returns This path cursor
  4067. */
  4068. private raiseOnChange;
  4069. /**
  4070. * Executes a function on change
  4071. * @param f A path cursor onchange callback
  4072. * @returns This path cursor
  4073. */
  4074. onchange(f: (cursor: PathCursor) => void): PathCursor;
  4075. }
  4076. /**
  4077. * Defines an interface which represents an animation key frame
  4078. */
  4079. interface IAnimationKey {
  4080. /**
  4081. * Frame of the key frame
  4082. */
  4083. frame: number;
  4084. /**
  4085. * Value at the specifies key frame
  4086. */
  4087. value: any;
  4088. /**
  4089. * The input tangent for the cubic hermite spline
  4090. */
  4091. inTangent?: any;
  4092. /**
  4093. * The output tangent for the cubic hermite spline
  4094. */
  4095. outTangent?: any;
  4096. /**
  4097. * The animation interpolation type
  4098. */
  4099. interpolation?: AnimationKeyInterpolation;
  4100. }
  4101. /**
  4102. * Enum for the animation key frame interpolation type
  4103. */
  4104. enum AnimationKeyInterpolation {
  4105. /**
  4106. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4107. */
  4108. STEP = 1
  4109. }
  4110. /**
  4111. * Class used to store any kind of animation
  4112. */
  4113. class Animation {
  4114. /**Name of the animation */
  4115. name: string;
  4116. /**Property to animate */
  4117. targetProperty: string;
  4118. /**The frames per second of the animation */
  4119. framePerSecond: number;
  4120. /**The data type of the animation */
  4121. dataType: number;
  4122. /**The loop mode of the animation */
  4123. loopMode?: number | undefined;
  4124. /**Specifies if blending should be enabled */
  4125. enableBlending?: boolean | undefined;
  4126. /**
  4127. * Use matrix interpolation instead of using direct key value when animating matrices
  4128. */
  4129. static AllowMatricesInterpolation: boolean;
  4130. /**
  4131. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  4132. */
  4133. static AllowMatrixDecomposeForInterpolation: boolean;
  4134. /**
  4135. * Stores the key frames of the animation
  4136. */
  4137. private _keys;
  4138. /**
  4139. * Stores the easing function of the animation
  4140. */
  4141. private _easingFunction;
  4142. /**
  4143. * @hidden Internal use only
  4144. */
  4145. _runtimeAnimations: RuntimeAnimation[];
  4146. /**
  4147. * The set of event that will be linked to this animation
  4148. */
  4149. private _events;
  4150. /**
  4151. * Stores an array of target property paths
  4152. */
  4153. targetPropertyPath: string[];
  4154. /**
  4155. * Stores the blending speed of the animation
  4156. */
  4157. blendingSpeed: number;
  4158. /**
  4159. * Stores the animation ranges for the animation
  4160. */
  4161. private _ranges;
  4162. /**
  4163. * @hidden Internal use
  4164. */
  4165. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  4166. /**
  4167. * Sets up an animation
  4168. * @param property The property to animate
  4169. * @param animationType The animation type to apply
  4170. * @param framePerSecond The frames per second of the animation
  4171. * @param easingFunction The easing function used in the animation
  4172. * @returns The created animation
  4173. */
  4174. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  4175. /**
  4176. * Create and start an animation on a node
  4177. * @param name defines the name of the global animation that will be run on all nodes
  4178. * @param node defines the root node where the animation will take place
  4179. * @param targetProperty defines property to animate
  4180. * @param framePerSecond defines the number of frame per second yo use
  4181. * @param totalFrame defines the number of frames in total
  4182. * @param from defines the initial value
  4183. * @param to defines the final value
  4184. * @param loopMode defines which loop mode you want to use (off by default)
  4185. * @param easingFunction defines the easing function to use (linear by default)
  4186. * @param onAnimationEnd defines the callback to call when animation end
  4187. * @returns the animatable created for this animation
  4188. */
  4189. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4190. /**
  4191. * Create and start an animation on a node and its descendants
  4192. * @param name defines the name of the global animation that will be run on all nodes
  4193. * @param node defines the root node where the animation will take place
  4194. * @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
  4195. * @param targetProperty defines property to animate
  4196. * @param framePerSecond defines the number of frame per second to use
  4197. * @param totalFrame defines the number of frames in total
  4198. * @param from defines the initial value
  4199. * @param to defines the final value
  4200. * @param loopMode defines which loop mode you want to use (off by default)
  4201. * @param easingFunction defines the easing function to use (linear by default)
  4202. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  4203. * @returns the list of animatables created for all nodes
  4204. * @example https://www.babylonjs-playground.com/#MH0VLI
  4205. */
  4206. 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[]>;
  4207. /**
  4208. * Creates a new animation, merges it with the existing animations and starts it
  4209. * @param name Name of the animation
  4210. * @param node Node which contains the scene that begins the animations
  4211. * @param targetProperty Specifies which property to animate
  4212. * @param framePerSecond The frames per second of the animation
  4213. * @param totalFrame The total number of frames
  4214. * @param from The frame at the beginning of the animation
  4215. * @param to The frame at the end of the animation
  4216. * @param loopMode Specifies the loop mode of the animation
  4217. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  4218. * @param onAnimationEnd Callback to run once the animation is complete
  4219. * @returns Nullable animation
  4220. */
  4221. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  4222. /**
  4223. * Transition property of an host to the target Value
  4224. * @param property The property to transition
  4225. * @param targetValue The target Value of the property
  4226. * @param host The object where the property to animate belongs
  4227. * @param scene Scene used to run the animation
  4228. * @param frameRate Framerate (in frame/s) to use
  4229. * @param transition The transition type we want to use
  4230. * @param duration The duration of the animation, in milliseconds
  4231. * @param onAnimationEnd Callback trigger at the end of the animation
  4232. * @returns Nullable animation
  4233. */
  4234. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  4235. /**
  4236. * Return the array of runtime animations currently using this animation
  4237. */
  4238. readonly runtimeAnimations: RuntimeAnimation[];
  4239. /**
  4240. * Specifies if any of the runtime animations are currently running
  4241. */
  4242. readonly hasRunningRuntimeAnimations: boolean;
  4243. /**
  4244. * Initializes the animation
  4245. * @param name Name of the animation
  4246. * @param targetProperty Property to animate
  4247. * @param framePerSecond The frames per second of the animation
  4248. * @param dataType The data type of the animation
  4249. * @param loopMode The loop mode of the animation
  4250. * @param enableBlendings Specifies if blending should be enabled
  4251. */
  4252. constructor(
  4253. /**Name of the animation */
  4254. name: string,
  4255. /**Property to animate */
  4256. targetProperty: string,
  4257. /**The frames per second of the animation */
  4258. framePerSecond: number,
  4259. /**The data type of the animation */
  4260. dataType: number,
  4261. /**The loop mode of the animation */
  4262. loopMode?: number | undefined,
  4263. /**Specifies if blending should be enabled */
  4264. enableBlending?: boolean | undefined);
  4265. /**
  4266. * Converts the animation to a string
  4267. * @param fullDetails support for multiple levels of logging within scene loading
  4268. * @returns String form of the animation
  4269. */
  4270. toString(fullDetails?: boolean): string;
  4271. /**
  4272. * Add an event to this animation
  4273. * @param event Event to add
  4274. */
  4275. addEvent(event: AnimationEvent): void;
  4276. /**
  4277. * Remove all events found at the given frame
  4278. * @param frame The frame to remove events from
  4279. */
  4280. removeEvents(frame: number): void;
  4281. /**
  4282. * Retrieves all the events from the animation
  4283. * @returns Events from the animation
  4284. */
  4285. getEvents(): AnimationEvent[];
  4286. /**
  4287. * Creates an animation range
  4288. * @param name Name of the animation range
  4289. * @param from Starting frame of the animation range
  4290. * @param to Ending frame of the animation
  4291. */
  4292. createRange(name: string, from: number, to: number): void;
  4293. /**
  4294. * Deletes an animation range by name
  4295. * @param name Name of the animation range to delete
  4296. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  4297. */
  4298. deleteRange(name: string, deleteFrames?: boolean): void;
  4299. /**
  4300. * Gets the animation range by name, or null if not defined
  4301. * @param name Name of the animation range
  4302. * @returns Nullable animation range
  4303. */
  4304. getRange(name: string): Nullable<AnimationRange>;
  4305. /**
  4306. * Gets the key frames from the animation
  4307. * @returns The key frames of the animation
  4308. */
  4309. getKeys(): Array<IAnimationKey>;
  4310. /**
  4311. * Gets the highest frame rate of the animation
  4312. * @returns Highest frame rate of the animation
  4313. */
  4314. getHighestFrame(): number;
  4315. /**
  4316. * Gets the easing function of the animation
  4317. * @returns Easing function of the animation
  4318. */
  4319. getEasingFunction(): IEasingFunction;
  4320. /**
  4321. * Sets the easing function of the animation
  4322. * @param easingFunction A custom mathematical formula for animation
  4323. */
  4324. setEasingFunction(easingFunction: EasingFunction): void;
  4325. /**
  4326. * Interpolates a scalar linearly
  4327. * @param startValue Start value of the animation curve
  4328. * @param endValue End value of the animation curve
  4329. * @param gradient Scalar amount to interpolate
  4330. * @returns Interpolated scalar value
  4331. */
  4332. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  4333. /**
  4334. * Interpolates a scalar cubically
  4335. * @param startValue Start value of the animation curve
  4336. * @param outTangent End tangent of the animation
  4337. * @param endValue End value of the animation curve
  4338. * @param inTangent Start tangent of the animation curve
  4339. * @param gradient Scalar amount to interpolate
  4340. * @returns Interpolated scalar value
  4341. */
  4342. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  4343. /**
  4344. * Interpolates a quaternion using a spherical linear interpolation
  4345. * @param startValue Start value of the animation curve
  4346. * @param endValue End value of the animation curve
  4347. * @param gradient Scalar amount to interpolate
  4348. * @returns Interpolated quaternion value
  4349. */
  4350. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  4351. /**
  4352. * Interpolates a quaternion cubically
  4353. * @param startValue Start value of the animation curve
  4354. * @param outTangent End tangent of the animation curve
  4355. * @param endValue End value of the animation curve
  4356. * @param inTangent Start tangent of the animation curve
  4357. * @param gradient Scalar amount to interpolate
  4358. * @returns Interpolated quaternion value
  4359. */
  4360. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  4361. /**
  4362. * Interpolates a Vector3 linearl
  4363. * @param startValue Start value of the animation curve
  4364. * @param endValue End value of the animation curve
  4365. * @param gradient Scalar amount to interpolate
  4366. * @returns Interpolated scalar value
  4367. */
  4368. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  4369. /**
  4370. * Interpolates a Vector3 cubically
  4371. * @param startValue Start value of the animation curve
  4372. * @param outTangent End tangent of the animation
  4373. * @param endValue End value of the animation curve
  4374. * @param inTangent Start tangent of the animation curve
  4375. * @param gradient Scalar amount to interpolate
  4376. * @returns InterpolatedVector3 value
  4377. */
  4378. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  4379. /**
  4380. * Interpolates a Vector2 linearly
  4381. * @param startValue Start value of the animation curve
  4382. * @param endValue End value of the animation curve
  4383. * @param gradient Scalar amount to interpolate
  4384. * @returns Interpolated Vector2 value
  4385. */
  4386. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  4387. /**
  4388. * Interpolates a Vector2 cubically
  4389. * @param startValue Start value of the animation curve
  4390. * @param outTangent End tangent of the animation
  4391. * @param endValue End value of the animation curve
  4392. * @param inTangent Start tangent of the animation curve
  4393. * @param gradient Scalar amount to interpolate
  4394. * @returns Interpolated Vector2 value
  4395. */
  4396. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  4397. /**
  4398. * Interpolates a size linearly
  4399. * @param startValue Start value of the animation curve
  4400. * @param endValue End value of the animation curve
  4401. * @param gradient Scalar amount to interpolate
  4402. * @returns Interpolated Size value
  4403. */
  4404. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  4405. /**
  4406. * Interpolates a Color3 linearly
  4407. * @param startValue Start value of the animation curve
  4408. * @param endValue End value of the animation curve
  4409. * @param gradient Scalar amount to interpolate
  4410. * @returns Interpolated Color3 value
  4411. */
  4412. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  4413. /**
  4414. * @hidden Internal use only
  4415. */
  4416. _getKeyValue(value: any): any;
  4417. /**
  4418. * @hidden Internal use only
  4419. */
  4420. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  4421. /**
  4422. * Defines the function to use to interpolate matrices
  4423. * @param startValue defines the start matrix
  4424. * @param endValue defines the end matrix
  4425. * @param gradient defines the gradient between both matrices
  4426. * @param result defines an optional target matrix where to store the interpolation
  4427. * @returns the interpolated matrix
  4428. */
  4429. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  4430. /**
  4431. * Makes a copy of the animation
  4432. * @returns Cloned animation
  4433. */
  4434. clone(): Animation;
  4435. /**
  4436. * Sets the key frames of the animation
  4437. * @param values The animation key frames to set
  4438. */
  4439. setKeys(values: Array<IAnimationKey>): void;
  4440. /**
  4441. * Serializes the animation to an object
  4442. * @returns Serialized object
  4443. */
  4444. serialize(): any;
  4445. /**
  4446. * Float animation type
  4447. */
  4448. private static _ANIMATIONTYPE_FLOAT;
  4449. /**
  4450. * Vector3 animation type
  4451. */
  4452. private static _ANIMATIONTYPE_VECTOR3;
  4453. /**
  4454. * Quaternion animation type
  4455. */
  4456. private static _ANIMATIONTYPE_QUATERNION;
  4457. /**
  4458. * Matrix animation type
  4459. */
  4460. private static _ANIMATIONTYPE_MATRIX;
  4461. /**
  4462. * Color3 animation type
  4463. */
  4464. private static _ANIMATIONTYPE_COLOR3;
  4465. /**
  4466. * Vector2 animation type
  4467. */
  4468. private static _ANIMATIONTYPE_VECTOR2;
  4469. /**
  4470. * Size animation type
  4471. */
  4472. private static _ANIMATIONTYPE_SIZE;
  4473. /**
  4474. * Relative Loop Mode
  4475. */
  4476. private static _ANIMATIONLOOPMODE_RELATIVE;
  4477. /**
  4478. * Cycle Loop Mode
  4479. */
  4480. private static _ANIMATIONLOOPMODE_CYCLE;
  4481. /**
  4482. * Constant Loop Mode
  4483. */
  4484. private static _ANIMATIONLOOPMODE_CONSTANT;
  4485. /**
  4486. * Get the float animation type
  4487. */
  4488. static readonly ANIMATIONTYPE_FLOAT: number;
  4489. /**
  4490. * Get the Vector3 animation type
  4491. */
  4492. static readonly ANIMATIONTYPE_VECTOR3: number;
  4493. /**
  4494. * Get the Vector2 animation type
  4495. */
  4496. static readonly ANIMATIONTYPE_VECTOR2: number;
  4497. /**
  4498. * Get the Size animation type
  4499. */
  4500. static readonly ANIMATIONTYPE_SIZE: number;
  4501. /**
  4502. * Get the Quaternion animation type
  4503. */
  4504. static readonly ANIMATIONTYPE_QUATERNION: number;
  4505. /**
  4506. * Get the Matrix animation type
  4507. */
  4508. static readonly ANIMATIONTYPE_MATRIX: number;
  4509. /**
  4510. * Get the Color3 animation type
  4511. */
  4512. static readonly ANIMATIONTYPE_COLOR3: number;
  4513. /**
  4514. * Get the Relative Loop Mode
  4515. */
  4516. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  4517. /**
  4518. * Get the Cycle Loop Mode
  4519. */
  4520. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  4521. /**
  4522. * Get the Constant Loop Mode
  4523. */
  4524. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  4525. /** @hidden */
  4526. static _UniversalLerp(left: any, right: any, amount: number): any;
  4527. /**
  4528. * Parses an animation object and creates an animation
  4529. * @param parsedAnimation Parsed animation object
  4530. * @returns Animation object
  4531. */
  4532. static Parse(parsedAnimation: any): Animation;
  4533. /**
  4534. * Appends the serialized animations from the source animations
  4535. * @param source Source containing the animations
  4536. * @param destination Target to store the animations
  4537. */
  4538. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  4539. }
  4540. }
  4541. declare module BABYLON {
  4542. /**
  4543. * This class defines the direct association between an animation and a target
  4544. */
  4545. class TargetedAnimation {
  4546. /**
  4547. * Animation to perform
  4548. */
  4549. animation: Animation;
  4550. /**
  4551. * Target to animate
  4552. */
  4553. target: any;
  4554. }
  4555. /**
  4556. * Use this class to create coordinated animations on multiple targets
  4557. */
  4558. class AnimationGroup implements IDisposable {
  4559. /** The name of the animation group */
  4560. name: string;
  4561. private _scene;
  4562. private _targetedAnimations;
  4563. private _animatables;
  4564. private _from;
  4565. private _to;
  4566. private _isStarted;
  4567. private _speedRatio;
  4568. /**
  4569. * This observable will notify when one animation have ended.
  4570. */
  4571. onAnimationEndObservable: Observable<TargetedAnimation>;
  4572. /**
  4573. * This observable will notify when all animations have ended.
  4574. */
  4575. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  4576. /**
  4577. * This observable will notify when all animations have paused.
  4578. */
  4579. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  4580. /**
  4581. * Gets the first frame
  4582. */
  4583. readonly from: number;
  4584. /**
  4585. * Gets the last frame
  4586. */
  4587. readonly to: number;
  4588. /**
  4589. * Define if the animations are started
  4590. */
  4591. readonly isStarted: boolean;
  4592. /**
  4593. * Gets or sets the speed ratio to use for all animations
  4594. */
  4595. /**
  4596. * Gets or sets the speed ratio to use for all animations
  4597. */
  4598. speedRatio: number;
  4599. /**
  4600. * Gets the targeted animations for this animation group
  4601. */
  4602. readonly targetedAnimations: Array<TargetedAnimation>;
  4603. /**
  4604. * returning the list of animatables controlled by this animation group.
  4605. */
  4606. readonly animatables: Array<Animatable>;
  4607. /**
  4608. * Instantiates a new Animation Group.
  4609. * This helps managing several animations at once.
  4610. * @see http://doc.babylonjs.com/how_to/group
  4611. * @param name Defines the name of the group
  4612. * @param scene Defines the scene the group belongs to
  4613. */
  4614. constructor(
  4615. /** The name of the animation group */
  4616. name: string, scene?: Nullable<Scene>);
  4617. /**
  4618. * Add an animation (with its target) in the group
  4619. * @param animation defines the animation we want to add
  4620. * @param target defines the target of the animation
  4621. * @returns the TargetedAnimation object
  4622. */
  4623. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  4624. /**
  4625. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4626. * It can add constant keys at begin or end
  4627. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4628. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4629. * @returns the animation group
  4630. */
  4631. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  4632. /**
  4633. * Start all animations on given targets
  4634. * @param loop defines if animations must loop
  4635. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4636. * @param from defines the from key (optional)
  4637. * @param to defines the to key (optional)
  4638. * @returns the current animation group
  4639. */
  4640. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  4641. /**
  4642. * Pause all animations
  4643. * @returns the animation group
  4644. */
  4645. pause(): AnimationGroup;
  4646. /**
  4647. * Play all animations to initial state
  4648. * This function will start() the animations if they were not started or will restart() them if they were paused
  4649. * @param loop defines if animations must loop
  4650. * @returns the animation group
  4651. */
  4652. play(loop?: boolean): AnimationGroup;
  4653. /**
  4654. * Reset all animations to initial state
  4655. * @returns the animation group
  4656. */
  4657. reset(): AnimationGroup;
  4658. /**
  4659. * Restart animations from key 0
  4660. * @returns the animation group
  4661. */
  4662. restart(): AnimationGroup;
  4663. /**
  4664. * Stop all animations
  4665. * @returns the animation group
  4666. */
  4667. stop(): AnimationGroup;
  4668. /**
  4669. * Set animation weight for all animatables
  4670. * @param weight defines the weight to use
  4671. * @return the animationGroup
  4672. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4673. */
  4674. setWeightForAllAnimatables(weight: number): AnimationGroup;
  4675. /**
  4676. * Synchronize and normalize all animatables with a source animatable
  4677. * @param root defines the root animatable to synchronize with
  4678. * @return the animationGroup
  4679. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4680. */
  4681. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  4682. /**
  4683. * Goes to a specific frame in this animation group
  4684. * @param frame the frame number to go to
  4685. * @return the animationGroup
  4686. */
  4687. goToFrame(frame: number): AnimationGroup;
  4688. /**
  4689. * Dispose all associated resources
  4690. */
  4691. dispose(): void;
  4692. private _checkAnimationGroupEnded;
  4693. /**
  4694. * Returns a new AnimationGroup object parsed from the source provided.
  4695. * @param parsedAnimationGroup defines the source
  4696. * @param scene defines the scene that will receive the animationGroup
  4697. * @returns a new AnimationGroup
  4698. */
  4699. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  4700. /**
  4701. * Returns the string "AnimationGroup"
  4702. * @returns "AnimationGroup"
  4703. */
  4704. getClassName(): string;
  4705. /**
  4706. * Creates a detailled string about the object
  4707. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4708. * @returns a string representing the object
  4709. */
  4710. toString(fullDetails?: boolean): string;
  4711. }
  4712. }
  4713. declare module BABYLON {
  4714. /**
  4715. * Class used to override all child animations of a given target
  4716. */
  4717. class AnimationPropertiesOverride {
  4718. /**
  4719. * Gets or sets a value indicating if animation blending must be used
  4720. */
  4721. enableBlending: boolean;
  4722. /**
  4723. * Gets or sets the blending speed to use when enableBlending is true
  4724. */
  4725. blendingSpeed: number;
  4726. /**
  4727. * Gets or sets the default loop mode to use
  4728. */
  4729. loopMode: number;
  4730. }
  4731. }
  4732. declare module BABYLON {
  4733. /**
  4734. * This represents the main contract an easing function should follow.
  4735. * Easing functions are used throughout the animation system.
  4736. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4737. */
  4738. interface IEasingFunction {
  4739. /**
  4740. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4741. * of the easing function.
  4742. * The link below provides some of the most common examples of easing functions.
  4743. * @see https://easings.net/
  4744. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4745. * @returns the corresponding value on the curve defined by the easing function
  4746. */
  4747. ease(gradient: number): number;
  4748. }
  4749. /**
  4750. * Base class used for every default easing function.
  4751. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4752. */
  4753. class EasingFunction implements IEasingFunction {
  4754. /**
  4755. * Interpolation follows the mathematical formula associated with the easing function.
  4756. */
  4757. static readonly EASINGMODE_EASEIN: number;
  4758. /**
  4759. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4760. */
  4761. static readonly EASINGMODE_EASEOUT: number;
  4762. /**
  4763. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4764. */
  4765. static readonly EASINGMODE_EASEINOUT: number;
  4766. private _easingMode;
  4767. /**
  4768. * Sets the easing mode of the current function.
  4769. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4770. */
  4771. setEasingMode(easingMode: number): void;
  4772. /**
  4773. * Gets the current easing mode.
  4774. * @returns the easing mode
  4775. */
  4776. getEasingMode(): number;
  4777. /**
  4778. * @hidden
  4779. */
  4780. easeInCore(gradient: number): number;
  4781. /**
  4782. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4783. * of the easing function.
  4784. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4785. * @returns the corresponding value on the curve defined by the easing function
  4786. */
  4787. ease(gradient: number): number;
  4788. }
  4789. /**
  4790. * Easing function with a circle shape (see link below).
  4791. * @see https://easings.net/#easeInCirc
  4792. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4793. */
  4794. class CircleEase extends EasingFunction implements IEasingFunction {
  4795. /** @hidden */
  4796. easeInCore(gradient: number): number;
  4797. }
  4798. /**
  4799. * Easing function with a ease back shape (see link below).
  4800. * @see https://easings.net/#easeInBack
  4801. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4802. */
  4803. class BackEase extends EasingFunction implements IEasingFunction {
  4804. /** Defines the amplitude of the function */
  4805. amplitude: number;
  4806. /**
  4807. * Instantiates a back ease easing
  4808. * @see https://easings.net/#easeInBack
  4809. * @param amplitude Defines the amplitude of the function
  4810. */
  4811. constructor(
  4812. /** Defines the amplitude of the function */
  4813. amplitude?: number);
  4814. /** @hidden */
  4815. easeInCore(gradient: number): number;
  4816. }
  4817. /**
  4818. * Easing function with a bouncing shape (see link below).
  4819. * @see https://easings.net/#easeInBounce
  4820. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4821. */
  4822. class BounceEase extends EasingFunction implements IEasingFunction {
  4823. /** Defines the number of bounces */
  4824. bounces: number;
  4825. /** Defines the amplitude of the bounce */
  4826. bounciness: number;
  4827. /**
  4828. * Instantiates a bounce easing
  4829. * @see https://easings.net/#easeInBounce
  4830. * @param bounces Defines the number of bounces
  4831. * @param bounciness Defines the amplitude of the bounce
  4832. */
  4833. constructor(
  4834. /** Defines the number of bounces */
  4835. bounces?: number,
  4836. /** Defines the amplitude of the bounce */
  4837. bounciness?: number);
  4838. /** @hidden */
  4839. easeInCore(gradient: number): number;
  4840. }
  4841. /**
  4842. * Easing function with a power of 3 shape (see link below).
  4843. * @see https://easings.net/#easeInCubic
  4844. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4845. */
  4846. class CubicEase extends EasingFunction implements IEasingFunction {
  4847. /** @hidden */
  4848. easeInCore(gradient: number): number;
  4849. }
  4850. /**
  4851. * Easing function with an elastic shape (see link below).
  4852. * @see https://easings.net/#easeInElastic
  4853. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4854. */
  4855. class ElasticEase extends EasingFunction implements IEasingFunction {
  4856. /** Defines the number of oscillations*/
  4857. oscillations: number;
  4858. /** Defines the amplitude of the oscillations*/
  4859. springiness: number;
  4860. /**
  4861. * Instantiates an elastic easing function
  4862. * @see https://easings.net/#easeInElastic
  4863. * @param oscillations Defines the number of oscillations
  4864. * @param springiness Defines the amplitude of the oscillations
  4865. */
  4866. constructor(
  4867. /** Defines the number of oscillations*/
  4868. oscillations?: number,
  4869. /** Defines the amplitude of the oscillations*/
  4870. springiness?: number);
  4871. /** @hidden */
  4872. easeInCore(gradient: number): number;
  4873. }
  4874. /**
  4875. * Easing function with an exponential shape (see link below).
  4876. * @see https://easings.net/#easeInExpo
  4877. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4878. */
  4879. class ExponentialEase extends EasingFunction implements IEasingFunction {
  4880. /** Defines the exponent of the function */
  4881. exponent: number;
  4882. /**
  4883. * Instantiates an exponential easing function
  4884. * @see https://easings.net/#easeInExpo
  4885. * @param exponent Defines the exponent of the function
  4886. */
  4887. constructor(
  4888. /** Defines the exponent of the function */
  4889. exponent?: number);
  4890. /** @hidden */
  4891. easeInCore(gradient: number): number;
  4892. }
  4893. /**
  4894. * Easing function with a power shape (see link below).
  4895. * @see https://easings.net/#easeInQuad
  4896. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4897. */
  4898. class PowerEase extends EasingFunction implements IEasingFunction {
  4899. /** Defines the power of the function */
  4900. power: number;
  4901. /**
  4902. * Instantiates an power base easing function
  4903. * @see https://easings.net/#easeInQuad
  4904. * @param power Defines the power of the function
  4905. */
  4906. constructor(
  4907. /** Defines the power of the function */
  4908. power?: number);
  4909. /** @hidden */
  4910. easeInCore(gradient: number): number;
  4911. }
  4912. /**
  4913. * Easing function with a power of 2 shape (see link below).
  4914. * @see https://easings.net/#easeInQuad
  4915. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4916. */
  4917. class QuadraticEase extends EasingFunction implements IEasingFunction {
  4918. /** @hidden */
  4919. easeInCore(gradient: number): number;
  4920. }
  4921. /**
  4922. * Easing function with a power of 4 shape (see link below).
  4923. * @see https://easings.net/#easeInQuart
  4924. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4925. */
  4926. class QuarticEase extends EasingFunction implements IEasingFunction {
  4927. /** @hidden */
  4928. easeInCore(gradient: number): number;
  4929. }
  4930. /**
  4931. * Easing function with a power of 5 shape (see link below).
  4932. * @see https://easings.net/#easeInQuint
  4933. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4934. */
  4935. class QuinticEase extends EasingFunction implements IEasingFunction {
  4936. /** @hidden */
  4937. easeInCore(gradient: number): number;
  4938. }
  4939. /**
  4940. * Easing function with a sin shape (see link below).
  4941. * @see https://easings.net/#easeInSine
  4942. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4943. */
  4944. class SineEase extends EasingFunction implements IEasingFunction {
  4945. /** @hidden */
  4946. easeInCore(gradient: number): number;
  4947. }
  4948. /**
  4949. * Easing function with a bezier shape (see link below).
  4950. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4951. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4952. */
  4953. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  4954. /** Defines the x component of the start tangent in the bezier curve */
  4955. x1: number;
  4956. /** Defines the y component of the start tangent in the bezier curve */
  4957. y1: number;
  4958. /** Defines the x component of the end tangent in the bezier curve */
  4959. x2: number;
  4960. /** Defines the y component of the end tangent in the bezier curve */
  4961. y2: number;
  4962. /**
  4963. * Instantiates a bezier function
  4964. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4965. * @param x1 Defines the x component of the start tangent in the bezier curve
  4966. * @param y1 Defines the y component of the start tangent in the bezier curve
  4967. * @param x2 Defines the x component of the end tangent in the bezier curve
  4968. * @param y2 Defines the y component of the end tangent in the bezier curve
  4969. */
  4970. constructor(
  4971. /** Defines the x component of the start tangent in the bezier curve */
  4972. x1?: number,
  4973. /** Defines the y component of the start tangent in the bezier curve */
  4974. y1?: number,
  4975. /** Defines the x component of the end tangent in the bezier curve */
  4976. x2?: number,
  4977. /** Defines the y component of the end tangent in the bezier curve */
  4978. y2?: number);
  4979. /** @hidden */
  4980. easeInCore(gradient: number): number;
  4981. }
  4982. }
  4983. declare module BABYLON {
  4984. /**
  4985. * Defines a runtime animation
  4986. */
  4987. class RuntimeAnimation {
  4988. private _events;
  4989. /**
  4990. * The current frame of the runtime animation
  4991. */
  4992. private _currentFrame;
  4993. /**
  4994. * The animation used by the runtime animation
  4995. */
  4996. private _animation;
  4997. /**
  4998. * The target of the runtime animation
  4999. */
  5000. private _target;
  5001. /**
  5002. * The initiating animatable
  5003. */
  5004. private _host;
  5005. /**
  5006. * The original value of the runtime animation
  5007. */
  5008. private _originalValue;
  5009. /**
  5010. * The original blend value of the runtime animation
  5011. */
  5012. private _originalBlendValue;
  5013. /**
  5014. * The offsets cache of the runtime animation
  5015. */
  5016. private _offsetsCache;
  5017. /**
  5018. * The high limits cache of the runtime animation
  5019. */
  5020. private _highLimitsCache;
  5021. /**
  5022. * Specifies if the runtime animation has been stopped
  5023. */
  5024. private _stopped;
  5025. /**
  5026. * The blending factor of the runtime animation
  5027. */
  5028. private _blendingFactor;
  5029. /**
  5030. * The BabylonJS scene
  5031. */
  5032. private _scene;
  5033. /**
  5034. * The current value of the runtime animation
  5035. */
  5036. private _currentValue;
  5037. /** @hidden */
  5038. _workValue: any;
  5039. /**
  5040. * The active target of the runtime animation
  5041. */
  5042. private _activeTarget;
  5043. /**
  5044. * The target path of the runtime animation
  5045. */
  5046. private _targetPath;
  5047. /**
  5048. * The weight of the runtime animation
  5049. */
  5050. private _weight;
  5051. /**
  5052. * The ratio offset of the runtime animation
  5053. */
  5054. private _ratioOffset;
  5055. /**
  5056. * The previous delay of the runtime animation
  5057. */
  5058. private _previousDelay;
  5059. /**
  5060. * The previous ratio of the runtime animation
  5061. */
  5062. private _previousRatio;
  5063. /**
  5064. * Gets the current frame of the runtime animation
  5065. */
  5066. readonly currentFrame: number;
  5067. /**
  5068. * Gets the weight of the runtime animation
  5069. */
  5070. readonly weight: number;
  5071. /**
  5072. * Gets the current value of the runtime animation
  5073. */
  5074. readonly currentValue: any;
  5075. /**
  5076. * Gets the target path of the runtime animation
  5077. */
  5078. readonly targetPath: string;
  5079. /**
  5080. * Gets the actual target of the runtime animation
  5081. */
  5082. readonly target: any;
  5083. /**
  5084. * Create a new RuntimeAnimation object
  5085. * @param target defines the target of the animation
  5086. * @param animation defines the source animation object
  5087. * @param scene defines the hosting scene
  5088. * @param host defines the initiating Animatable
  5089. */
  5090. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  5091. /**
  5092. * Gets the animation from the runtime animation
  5093. */
  5094. readonly animation: Animation;
  5095. /**
  5096. * Resets the runtime animation to the beginning
  5097. * @param restoreOriginal defines whether to restore the target property to the original value
  5098. */
  5099. reset(restoreOriginal?: boolean): void;
  5100. /**
  5101. * Specifies if the runtime animation is stopped
  5102. * @returns Boolean specifying if the runtime animation is stopped
  5103. */
  5104. isStopped(): boolean;
  5105. /**
  5106. * Disposes of the runtime animation
  5107. */
  5108. dispose(): void;
  5109. /**
  5110. * Interpolates the animation from the current frame
  5111. * @param currentFrame The frame to interpolate the animation to
  5112. * @param repeatCount The number of times that the animation should loop
  5113. * @param loopMode The type of looping mode to use
  5114. * @param offsetValue Animation offset value
  5115. * @param highLimitValue The high limit value
  5116. * @returns The interpolated value
  5117. */
  5118. private _interpolate;
  5119. /**
  5120. * Apply the interpolated value to the target
  5121. * @param currentValue defines the value computed by the animation
  5122. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5123. */
  5124. setValue(currentValue: any, weight?: number): void;
  5125. private _setValue;
  5126. /**
  5127. * Gets the loop pmode of the runtime animation
  5128. * @returns Loop Mode
  5129. */
  5130. private _getCorrectLoopMode;
  5131. /**
  5132. * Move the current animation to a given frame
  5133. * @param frame defines the frame to move to
  5134. */
  5135. goToFrame(frame: number): void;
  5136. /**
  5137. * @hidden Internal use only
  5138. */
  5139. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  5140. /**
  5141. * Execute the current animation
  5142. * @param delay defines the delay to add to the current frame
  5143. * @param from defines the lower bound of the animation range
  5144. * @param to defines the upper bound of the animation range
  5145. * @param loop defines if the current animation must loop
  5146. * @param speedRatio defines the current speed ratio
  5147. * @param weight defines the weight of the animation (default is -1 so no weight)
  5148. * @returns a boolean indicating if the animation is running
  5149. */
  5150. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  5151. }
  5152. }
  5153. declare module BABYLON {
  5154. /**
  5155. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5156. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5157. */
  5158. class Analyser {
  5159. /**
  5160. * Gets or sets the smoothing
  5161. * @ignorenaming
  5162. */
  5163. SMOOTHING: number;
  5164. /**
  5165. * Gets or sets the FFT table size
  5166. * @ignorenaming
  5167. */
  5168. FFT_SIZE: number;
  5169. /**
  5170. * Gets or sets the bar graph amplitude
  5171. * @ignorenaming
  5172. */
  5173. BARGRAPHAMPLITUDE: number;
  5174. /**
  5175. * Gets or sets the position of the debug canvas
  5176. * @ignorenaming
  5177. */
  5178. DEBUGCANVASPOS: {
  5179. x: number;
  5180. y: number;
  5181. };
  5182. /**
  5183. * Gets or sets the debug canvas size
  5184. * @ignorenaming
  5185. */
  5186. DEBUGCANVASSIZE: {
  5187. width: number;
  5188. height: number;
  5189. };
  5190. private _byteFreqs;
  5191. private _byteTime;
  5192. private _floatFreqs;
  5193. private _webAudioAnalyser;
  5194. private _debugCanvas;
  5195. private _debugCanvasContext;
  5196. private _scene;
  5197. private _registerFunc;
  5198. private _audioEngine;
  5199. /**
  5200. * Creates a new analyser
  5201. * @param scene defines hosting scene
  5202. */
  5203. constructor(scene: Scene);
  5204. /**
  5205. * Get the number of data values you will have to play with for the visualization
  5206. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5207. * @returns a number
  5208. */
  5209. getFrequencyBinCount(): number;
  5210. /**
  5211. * Gets the current frequency data as a byte array
  5212. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5213. * @returns a Uint8Array
  5214. */
  5215. getByteFrequencyData(): Uint8Array;
  5216. /**
  5217. * Gets the current waveform as a byte array
  5218. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5219. * @returns a Uint8Array
  5220. */
  5221. getByteTimeDomainData(): Uint8Array;
  5222. /**
  5223. * Gets the current frequency data as a float array
  5224. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5225. * @returns a Float32Array
  5226. */
  5227. getFloatFrequencyData(): Float32Array;
  5228. /**
  5229. * Renders the debug canvas
  5230. */
  5231. drawDebugCanvas(): void;
  5232. /**
  5233. * Stops rendering the debug canvas and removes it
  5234. */
  5235. stopDebugCanvas(): void;
  5236. /**
  5237. * Connects two audio nodes
  5238. * @param inputAudioNode defines first node to connect
  5239. * @param outputAudioNode defines second node to connect
  5240. */
  5241. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  5242. /**
  5243. * Releases all associated resources
  5244. */
  5245. dispose(): void;
  5246. }
  5247. }
  5248. declare module BABYLON {
  5249. /**
  5250. * This represents an audio engine and it is responsible
  5251. * to play, synchronize and analyse sounds throughout the application.
  5252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5253. */
  5254. interface IAudioEngine extends IDisposable {
  5255. /**
  5256. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5257. */
  5258. readonly canUseWebAudio: boolean;
  5259. /**
  5260. * Gets the current AudioContext if available.
  5261. */
  5262. readonly audioContext: Nullable<AudioContext>;
  5263. /**
  5264. * The master gain node defines the global audio volume of your audio engine.
  5265. */
  5266. readonly masterGain: GainNode;
  5267. /**
  5268. * Gets whether or not mp3 are supported by your browser.
  5269. */
  5270. readonly isMP3supported: boolean;
  5271. /**
  5272. * Gets whether or not ogg are supported by your browser.
  5273. */
  5274. readonly isOGGsupported: boolean;
  5275. /**
  5276. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5277. * @ignoreNaming
  5278. */
  5279. WarnedWebAudioUnsupported: boolean;
  5280. /**
  5281. * Defines if the audio engine relies on a custom unlocked button.
  5282. * In this case, the embedded button will not be displayed.
  5283. */
  5284. useCustomUnlockedButton: boolean;
  5285. /**
  5286. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  5287. */
  5288. readonly unlocked: boolean;
  5289. /**
  5290. * Event raised when audio has been unlocked on the browser.
  5291. */
  5292. onAudioUnlockedObservable: Observable<AudioEngine>;
  5293. /**
  5294. * Event raised when audio has been locked on the browser.
  5295. */
  5296. onAudioLockedObservable: Observable<AudioEngine>;
  5297. /**
  5298. * Flags the audio engine in Locked state.
  5299. * This happens due to new browser policies preventing audio to autoplay.
  5300. */
  5301. lock(): void;
  5302. /**
  5303. * Unlocks the audio engine once a user action has been done on the dom.
  5304. * This is helpful to resume play once browser policies have been satisfied.
  5305. */
  5306. unlock(): void;
  5307. }
  5308. /**
  5309. * This represents the default audio engine used in babylon.
  5310. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5312. */
  5313. class AudioEngine implements IAudioEngine {
  5314. private _audioContext;
  5315. private _audioContextInitialized;
  5316. private _muteButton;
  5317. private _hostElement;
  5318. /**
  5319. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5320. */
  5321. canUseWebAudio: boolean;
  5322. /**
  5323. * The master gain node defines the global audio volume of your audio engine.
  5324. */
  5325. masterGain: GainNode;
  5326. /**
  5327. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5328. * @ignoreNaming
  5329. */
  5330. WarnedWebAudioUnsupported: boolean;
  5331. /**
  5332. * Gets whether or not mp3 are supported by your browser.
  5333. */
  5334. isMP3supported: boolean;
  5335. /**
  5336. * Gets whether or not ogg are supported by your browser.
  5337. */
  5338. isOGGsupported: boolean;
  5339. /**
  5340. * Gets whether audio has been unlocked on the device.
  5341. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5342. * a user interaction has happened.
  5343. */
  5344. unlocked: boolean;
  5345. /**
  5346. * Defines if the audio engine relies on a custom unlocked button.
  5347. * In this case, the embedded button will not be displayed.
  5348. */
  5349. useCustomUnlockedButton: boolean;
  5350. /**
  5351. * Event raised when audio has been unlocked on the browser.
  5352. */
  5353. onAudioUnlockedObservable: Observable<AudioEngine>;
  5354. /**
  5355. * Event raised when audio has been locked on the browser.
  5356. */
  5357. onAudioLockedObservable: Observable<AudioEngine>;
  5358. /**
  5359. * Gets the current AudioContext if available.
  5360. */
  5361. readonly audioContext: Nullable<AudioContext>;
  5362. private _connectedAnalyser;
  5363. /**
  5364. * Instantiates a new audio engine.
  5365. *
  5366. * There should be only one per page as some browsers restrict the number
  5367. * of audio contexts you can create.
  5368. * @param hostElement defines the host element where to display the mute icon if necessary
  5369. */
  5370. constructor(hostElement?: Nullable<HTMLElement>);
  5371. /**
  5372. * Flags the audio engine in Locked state.
  5373. * This happens due to new browser policies preventing audio to autoplay.
  5374. */
  5375. lock(): void;
  5376. /**
  5377. * Unlocks the audio engine once a user action has been done on the dom.
  5378. * This is helpful to resume play once browser policies have been satisfied.
  5379. */
  5380. unlock(): void;
  5381. private _resumeAudioContext;
  5382. private _initializeAudioContext;
  5383. private _tryToRun;
  5384. private _triggerRunningState;
  5385. private _triggerSuspendedState;
  5386. private _displayMuteButton;
  5387. private _moveButtonToTopLeft;
  5388. private _onResize;
  5389. private _hideMuteButton;
  5390. /**
  5391. * Destroy and release the resources associated with the audio ccontext.
  5392. */
  5393. dispose(): void;
  5394. /**
  5395. * Gets the global volume sets on the master gain.
  5396. * @returns the global volume if set or -1 otherwise
  5397. */
  5398. getGlobalVolume(): number;
  5399. /**
  5400. * Sets the global volume of your experience (sets on the master gain).
  5401. * @param newVolume Defines the new global volume of the application
  5402. */
  5403. setGlobalVolume(newVolume: number): void;
  5404. /**
  5405. * Connect the audio engine to an audio analyser allowing some amazing
  5406. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5408. * @param analyser The analyser to connect to the engine
  5409. */
  5410. connectToAnalyser(analyser: Analyser): void;
  5411. }
  5412. }
  5413. declare module BABYLON {
  5414. interface AbstractScene {
  5415. /**
  5416. * The list of sounds used in the scene.
  5417. */
  5418. sounds: Nullable<Array<Sound>>;
  5419. }
  5420. interface Scene {
  5421. /**
  5422. * @hidden
  5423. * Backing field
  5424. */
  5425. _mainSoundTrack: SoundTrack;
  5426. /**
  5427. * The main sound track played by the scene.
  5428. * It cotains your primary collection of sounds.
  5429. */
  5430. mainSoundTrack: SoundTrack;
  5431. /**
  5432. * The list of sound tracks added to the scene
  5433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5434. */
  5435. soundTracks: Nullable<Array<SoundTrack>>;
  5436. /**
  5437. * Gets a sound using a given name
  5438. * @param name defines the name to search for
  5439. * @return the found sound or null if not found at all.
  5440. */
  5441. getSoundByName(name: string): Nullable<Sound>;
  5442. /**
  5443. * Gets or sets if audio support is enabled
  5444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5445. */
  5446. audioEnabled: boolean;
  5447. /**
  5448. * Gets or sets if audio will be output to headphones
  5449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5450. */
  5451. headphone: boolean;
  5452. }
  5453. /**
  5454. * Defines the sound scene component responsible to manage any sounds
  5455. * in a given scene.
  5456. */
  5457. class AudioSceneComponent implements ISceneSerializableComponent {
  5458. /**
  5459. * The component name helpfull to identify the component in the list of scene components.
  5460. */
  5461. readonly name: string;
  5462. /**
  5463. * The scene the component belongs to.
  5464. */
  5465. scene: Scene;
  5466. private _audioEnabled;
  5467. /**
  5468. * Gets whether audio is enabled or not.
  5469. * Please use related enable/disable method to switch state.
  5470. */
  5471. readonly audioEnabled: boolean;
  5472. private _headphone;
  5473. /**
  5474. * Gets whether audio is outputing to headphone or not.
  5475. * Please use the according Switch methods to change output.
  5476. */
  5477. readonly headphone: boolean;
  5478. /**
  5479. * Creates a new instance of the component for the given scene
  5480. * @param scene Defines the scene to register the component in
  5481. */
  5482. constructor(scene: Scene);
  5483. /**
  5484. * Registers the component in a given scene
  5485. */
  5486. register(): void;
  5487. /**
  5488. * Rebuilds the elements related to this component in case of
  5489. * context lost for instance.
  5490. */
  5491. rebuild(): void;
  5492. /**
  5493. * Serializes the component data to the specified json object
  5494. * @param serializationObject The object to serialize to
  5495. */
  5496. serialize(serializationObject: any): void;
  5497. /**
  5498. * Adds all the element from the container to the scene
  5499. * @param container the container holding the elements
  5500. */
  5501. addFromContainer(container: AbstractScene): void;
  5502. /**
  5503. * Removes all the elements in the container from the scene
  5504. * @param container contains the elements to remove
  5505. */
  5506. removeFromContainer(container: AbstractScene): void;
  5507. /**
  5508. * Disposes the component and the associated ressources.
  5509. */
  5510. dispose(): void;
  5511. /**
  5512. * Disables audio in the associated scene.
  5513. */
  5514. disableAudio(): void;
  5515. /**
  5516. * Enables audio in the associated scene.
  5517. */
  5518. enableAudio(): void;
  5519. /**
  5520. * Switch audio to headphone output.
  5521. */
  5522. switchAudioModeForHeadphones(): void;
  5523. /**
  5524. * Switch audio to normal speakers.
  5525. */
  5526. switchAudioModeForNormalSpeakers(): void;
  5527. private _afterRender;
  5528. }
  5529. }
  5530. declare module BABYLON {
  5531. /**
  5532. * Defines a sound that can be played in the application.
  5533. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  5534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5535. */
  5536. class Sound {
  5537. /**
  5538. * The name of the sound in the scene.
  5539. */
  5540. name: string;
  5541. /**
  5542. * Does the sound autoplay once loaded.
  5543. */
  5544. autoplay: boolean;
  5545. /**
  5546. * Does the sound loop after it finishes playing once.
  5547. */
  5548. loop: boolean;
  5549. /**
  5550. * Does the sound use a custom attenuation curve to simulate the falloff
  5551. * happening when the source gets further away from the camera.
  5552. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5553. */
  5554. useCustomAttenuation: boolean;
  5555. /**
  5556. * The sound track id this sound belongs to.
  5557. */
  5558. soundTrackId: number;
  5559. /**
  5560. * Is this sound currently played.
  5561. */
  5562. isPlaying: boolean;
  5563. /**
  5564. * Is this sound currently paused.
  5565. */
  5566. isPaused: boolean;
  5567. /**
  5568. * Does this sound enables spatial sound.
  5569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5570. */
  5571. spatialSound: boolean;
  5572. /**
  5573. * Define the reference distance the sound should be heard perfectly.
  5574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5575. */
  5576. refDistance: number;
  5577. /**
  5578. * Define the roll off factor of spatial sounds.
  5579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5580. */
  5581. rolloffFactor: number;
  5582. /**
  5583. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  5584. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5585. */
  5586. maxDistance: number;
  5587. /**
  5588. * Define the distance attenuation model the sound will follow.
  5589. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5590. */
  5591. distanceModel: string;
  5592. /**
  5593. * @hidden
  5594. * Back Compat
  5595. **/
  5596. onended: () => any;
  5597. /**
  5598. * Observable event when the current playing sound finishes.
  5599. */
  5600. onEndedObservable: Observable<Sound>;
  5601. private _panningModel;
  5602. private _playbackRate;
  5603. private _streaming;
  5604. private _startTime;
  5605. private _startOffset;
  5606. private _position;
  5607. /** @hidden */
  5608. _positionInEmitterSpace: boolean;
  5609. private _localDirection;
  5610. private _volume;
  5611. private _isReadyToPlay;
  5612. private _isDirectional;
  5613. private _readyToPlayCallback;
  5614. private _audioBuffer;
  5615. private _soundSource;
  5616. private _streamingSource;
  5617. private _soundPanner;
  5618. private _soundGain;
  5619. private _inputAudioNode;
  5620. private _outputAudioNode;
  5621. private _coneInnerAngle;
  5622. private _coneOuterAngle;
  5623. private _coneOuterGain;
  5624. private _scene;
  5625. private _connectedTransformNode;
  5626. private _customAttenuationFunction;
  5627. private _registerFunc;
  5628. private _isOutputConnected;
  5629. private _htmlAudioElement;
  5630. private _urlType;
  5631. /**
  5632. * Create a sound and attach it to a scene
  5633. * @param name Name of your sound
  5634. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  5635. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  5636. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  5637. */
  5638. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  5639. /**
  5640. * Release the sound and its associated resources
  5641. */
  5642. dispose(): void;
  5643. /**
  5644. * Gets if the sounds is ready to be played or not.
  5645. * @returns true if ready, otherwise false
  5646. */
  5647. isReady(): boolean;
  5648. private _soundLoaded;
  5649. /**
  5650. * Sets the data of the sound from an audiobuffer
  5651. * @param audioBuffer The audioBuffer containing the data
  5652. */
  5653. setAudioBuffer(audioBuffer: AudioBuffer): void;
  5654. /**
  5655. * Updates the current sounds options such as maxdistance, loop...
  5656. * @param options A JSON object containing values named as the object properties
  5657. */
  5658. updateOptions(options: any): void;
  5659. private _createSpatialParameters;
  5660. private _updateSpatialParameters;
  5661. /**
  5662. * Switch the panning model to HRTF:
  5663. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5665. */
  5666. switchPanningModelToHRTF(): void;
  5667. /**
  5668. * Switch the panning model to Equal Power:
  5669. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5670. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5671. */
  5672. switchPanningModelToEqualPower(): void;
  5673. private _switchPanningModel;
  5674. /**
  5675. * Connect this sound to a sound track audio node like gain...
  5676. * @param soundTrackAudioNode the sound track audio node to connect to
  5677. */
  5678. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  5679. /**
  5680. * Transform this sound into a directional source
  5681. * @param coneInnerAngle Size of the inner cone in degree
  5682. * @param coneOuterAngle Size of the outer cone in degree
  5683. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  5684. */
  5685. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  5686. /**
  5687. * Gets or sets the inner angle for the directional cone.
  5688. */
  5689. /**
  5690. * Gets or sets the inner angle for the directional cone.
  5691. */
  5692. directionalConeInnerAngle: number;
  5693. /**
  5694. * Gets or sets the outer angle for the directional cone.
  5695. */
  5696. /**
  5697. * Gets or sets the outer angle for the directional cone.
  5698. */
  5699. directionalConeOuterAngle: number;
  5700. /**
  5701. * Sets the position of the emitter if spatial sound is enabled
  5702. * @param newPosition Defines the new posisiton
  5703. */
  5704. setPosition(newPosition: Vector3): void;
  5705. /**
  5706. * Sets the local direction of the emitter if spatial sound is enabled
  5707. * @param newLocalDirection Defines the new local direction
  5708. */
  5709. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  5710. private _updateDirection;
  5711. /** @hidden */
  5712. updateDistanceFromListener(): void;
  5713. /**
  5714. * Sets a new custom attenuation function for the sound.
  5715. * @param callback Defines the function used for the attenuation
  5716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  5717. */
  5718. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  5719. /**
  5720. * Play the sound
  5721. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  5722. * @param offset (optional) Start the sound setting it at a specific time
  5723. */
  5724. play(time?: number, offset?: number): void;
  5725. private _onended;
  5726. /**
  5727. * Stop the sound
  5728. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  5729. */
  5730. stop(time?: number): void;
  5731. /**
  5732. * Put the sound in pause
  5733. */
  5734. pause(): void;
  5735. /**
  5736. * Sets a dedicated volume for this sounds
  5737. * @param newVolume Define the new volume of the sound
  5738. * @param time Define in how long the sound should be at this value
  5739. */
  5740. setVolume(newVolume: number, time?: number): void;
  5741. /**
  5742. * Set the sound play back rate
  5743. * @param newPlaybackRate Define the playback rate the sound should be played at
  5744. */
  5745. setPlaybackRate(newPlaybackRate: number): void;
  5746. /**
  5747. * Gets the volume of the sound.
  5748. * @returns the volume of the sound
  5749. */
  5750. getVolume(): number;
  5751. /**
  5752. * Attach the sound to a dedicated mesh
  5753. * @param transformNode The transform node to connect the sound with
  5754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5755. */
  5756. attachToMesh(transformNode: TransformNode): void;
  5757. /**
  5758. * Detach the sound from the previously attached mesh
  5759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  5760. */
  5761. detachFromMesh(): void;
  5762. private _onRegisterAfterWorldMatrixUpdate;
  5763. /**
  5764. * Clone the current sound in the scene.
  5765. * @returns the new sound clone
  5766. */
  5767. clone(): Nullable<Sound>;
  5768. /**
  5769. * Gets the current underlying audio buffer containing the data
  5770. * @returns the audio buffer
  5771. */
  5772. getAudioBuffer(): Nullable<AudioBuffer>;
  5773. /**
  5774. * Serializes the Sound in a JSON representation
  5775. * @returns the JSON representation of the sound
  5776. */
  5777. serialize(): any;
  5778. /**
  5779. * Parse a JSON representation of a sound to innstantiate in a given scene
  5780. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  5781. * @param scene Define the scene the new parsed sound should be created in
  5782. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  5783. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  5784. * @returns the newly parsed sound
  5785. */
  5786. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  5787. }
  5788. }
  5789. declare module BABYLON {
  5790. /**
  5791. * Options allowed during the creation of a sound track.
  5792. */
  5793. interface ISoundTrackOptions {
  5794. /**
  5795. * The volume the sound track should take during creation
  5796. */
  5797. volume?: number;
  5798. /**
  5799. * Define if the sound track is the main sound track of the scene
  5800. */
  5801. mainTrack?: boolean;
  5802. }
  5803. /**
  5804. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  5805. * It will be also used in a future release to apply effects on a specific track.
  5806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5807. */
  5808. class SoundTrack {
  5809. /**
  5810. * The unique identifier of the sound track in the scene.
  5811. */
  5812. id: number;
  5813. /**
  5814. * The list of sounds included in the sound track.
  5815. */
  5816. soundCollection: Array<Sound>;
  5817. private _outputAudioNode;
  5818. private _scene;
  5819. private _isMainTrack;
  5820. private _connectedAnalyser;
  5821. private _options;
  5822. private _isInitialized;
  5823. /**
  5824. * Creates a new sound track.
  5825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  5826. * @param scene Define the scene the sound track belongs to
  5827. * @param options
  5828. */
  5829. constructor(scene: Scene, options?: ISoundTrackOptions);
  5830. private _initializeSoundTrackAudioGraph;
  5831. /**
  5832. * Release the sound track and its associated resources
  5833. */
  5834. dispose(): void;
  5835. /**
  5836. * Adds a sound to this sound track
  5837. * @param sound define the cound to add
  5838. * @ignoreNaming
  5839. */
  5840. AddSound(sound: Sound): void;
  5841. /**
  5842. * Removes a sound to this sound track
  5843. * @param sound define the cound to remove
  5844. * @ignoreNaming
  5845. */
  5846. RemoveSound(sound: Sound): void;
  5847. /**
  5848. * Set a global volume for the full sound track.
  5849. * @param newVolume Define the new volume of the sound track
  5850. */
  5851. setVolume(newVolume: number): void;
  5852. /**
  5853. * Switch the panning model to HRTF:
  5854. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  5855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5856. */
  5857. switchPanningModelToHRTF(): void;
  5858. /**
  5859. * Switch the panning model to Equal Power:
  5860. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  5861. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  5862. */
  5863. switchPanningModelToEqualPower(): void;
  5864. /**
  5865. * Connect the sound track to an audio analyser allowing some amazing
  5866. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  5867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  5868. * @param analyser The analyser to connect to the engine
  5869. */
  5870. connectToAnalyser(analyser: Analyser): void;
  5871. }
  5872. }
  5873. declare module BABYLON {
  5874. /**
  5875. * Wraps one or more Sound objects and selects one with random weight for playback.
  5876. */
  5877. class WeightedSound {
  5878. /** When true a Sound will be selected and played when the current playing Sound completes. */
  5879. loop: boolean;
  5880. private _coneInnerAngle;
  5881. private _coneOuterAngle;
  5882. private _volume;
  5883. /** A Sound is currently playing. */
  5884. isPlaying: boolean;
  5885. /** A Sound is currently paused. */
  5886. isPaused: boolean;
  5887. private _sounds;
  5888. private _weights;
  5889. private _currentIndex?;
  5890. /**
  5891. * Creates a new WeightedSound from the list of sounds given.
  5892. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  5893. * @param sounds Array of Sounds that will be selected from.
  5894. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  5895. */
  5896. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  5897. /**
  5898. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  5899. */
  5900. /**
  5901. * The size of cone in degress for a directional sound in which there will be no attenuation.
  5902. */
  5903. directionalConeInnerAngle: number;
  5904. /**
  5905. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5906. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5907. */
  5908. /**
  5909. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  5910. * Listener angles between innerAngle and outerAngle will falloff linearly.
  5911. */
  5912. directionalConeOuterAngle: number;
  5913. /**
  5914. * Playback volume.
  5915. */
  5916. /**
  5917. * Playback volume.
  5918. */
  5919. volume: number;
  5920. private _onended;
  5921. /**
  5922. * Suspend playback
  5923. */
  5924. pause(): void;
  5925. /**
  5926. * Stop playback
  5927. */
  5928. stop(): void;
  5929. /**
  5930. * Start playback.
  5931. * @param startOffset Position the clip head at a specific time in seconds.
  5932. */
  5933. play(startOffset?: number): void;
  5934. }
  5935. }
  5936. declare module BABYLON {
  5937. /**
  5938. * Interface used to define a behavior
  5939. */
  5940. interface Behavior<T> {
  5941. /** gets or sets behavior's name */
  5942. name: string;
  5943. /**
  5944. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5945. */
  5946. init(): void;
  5947. /**
  5948. * Called when the behavior is attached to a target
  5949. * @param target defines the target where the behavior is attached to
  5950. */
  5951. attach(target: T): void;
  5952. /**
  5953. * Called when the behavior is detached from its target
  5954. */
  5955. detach(): void;
  5956. }
  5957. /**
  5958. * Interface implemented by classes supporting behaviors
  5959. */
  5960. interface IBehaviorAware<T> {
  5961. /**
  5962. * Attach a behavior
  5963. * @param behavior defines the behavior to attach
  5964. * @returns the current host
  5965. */
  5966. addBehavior(behavior: Behavior<T>): T;
  5967. /**
  5968. * Remove a behavior from the current object
  5969. * @param behavior defines the behavior to detach
  5970. * @returns the current host
  5971. */
  5972. removeBehavior(behavior: Behavior<T>): T;
  5973. /**
  5974. * Gets a behavior using its name to search
  5975. * @param name defines the name to search
  5976. * @returns the behavior or null if not found
  5977. */
  5978. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5979. }
  5980. }
  5981. declare module BABYLON {
  5982. /**
  5983. * Class used to store bone information
  5984. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  5985. */
  5986. class Bone extends Node {
  5987. /**
  5988. * defines the bone name
  5989. */
  5990. name: string;
  5991. private static _tmpVecs;
  5992. private static _tmpQuat;
  5993. private static _tmpMats;
  5994. /**
  5995. * Gets the list of child bones
  5996. */
  5997. children: Bone[];
  5998. /** Gets the animations associated with this bone */
  5999. animations: Animation[];
  6000. /**
  6001. * Gets or sets bone length
  6002. */
  6003. length: number;
  6004. /**
  6005. * @hidden Internal only
  6006. * Set this value to map this bone to a different index in the transform matrices
  6007. * Set this value to -1 to exclude the bone from the transform matrices
  6008. */
  6009. _index: Nullable<number>;
  6010. private _skeleton;
  6011. private _localMatrix;
  6012. private _restPose;
  6013. private _baseMatrix;
  6014. private _absoluteTransform;
  6015. private _invertedAbsoluteTransform;
  6016. private _parent;
  6017. private _scalingDeterminant;
  6018. private _worldTransform;
  6019. private _localScaling;
  6020. private _localRotation;
  6021. private _localPosition;
  6022. private _needToDecompose;
  6023. private _needToCompose;
  6024. /** @hidden */
  6025. /** @hidden */
  6026. _matrix: Matrix;
  6027. /**
  6028. * Create a new bone
  6029. * @param name defines the bone name
  6030. * @param skeleton defines the parent skeleton
  6031. * @param parentBone defines the parent (can be null if the bone is the root)
  6032. * @param localMatrix defines the local matrix
  6033. * @param restPose defines the rest pose matrix
  6034. * @param baseMatrix defines the base matrix
  6035. * @param index defines index of the bone in the hiearchy
  6036. */
  6037. constructor(
  6038. /**
  6039. * defines the bone name
  6040. */
  6041. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  6042. /**
  6043. * Gets the parent skeleton
  6044. * @returns a skeleton
  6045. */
  6046. getSkeleton(): Skeleton;
  6047. /**
  6048. * Gets parent bone
  6049. * @returns a bone or null if the bone is the root of the bone hierarchy
  6050. */
  6051. getParent(): Nullable<Bone>;
  6052. /**
  6053. * Sets the parent bone
  6054. * @param parent defines the parent (can be null if the bone is the root)
  6055. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6056. */
  6057. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  6058. /**
  6059. * Gets the local matrix
  6060. * @returns a matrix
  6061. */
  6062. getLocalMatrix(): Matrix;
  6063. /**
  6064. * Gets the base matrix (initial matrix which remains unchanged)
  6065. * @returns a matrix
  6066. */
  6067. getBaseMatrix(): Matrix;
  6068. /**
  6069. * Gets the rest pose matrix
  6070. * @returns a matrix
  6071. */
  6072. getRestPose(): Matrix;
  6073. /**
  6074. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  6075. */
  6076. getWorldMatrix(): Matrix;
  6077. /**
  6078. * Sets the local matrix to rest pose matrix
  6079. */
  6080. returnToRest(): void;
  6081. /**
  6082. * Gets the inverse of the absolute transform matrix.
  6083. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  6084. * @returns a matrix
  6085. */
  6086. getInvertedAbsoluteTransform(): Matrix;
  6087. /**
  6088. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  6089. * @returns a matrix
  6090. */
  6091. getAbsoluteTransform(): Matrix;
  6092. /** Gets or sets current position (in local space) */
  6093. position: Vector3;
  6094. /** Gets or sets current rotation (in local space) */
  6095. rotation: Vector3;
  6096. /** Gets or sets current rotation quaternion (in local space) */
  6097. rotationQuaternion: Quaternion;
  6098. /** Gets or sets current scaling (in local space) */
  6099. scaling: Vector3;
  6100. /**
  6101. * Gets the animation properties override
  6102. */
  6103. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6104. private _decompose;
  6105. private _compose;
  6106. /**
  6107. * Update the base and local matrices
  6108. * @param matrix defines the new base or local matrix
  6109. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  6110. * @param updateLocalMatrix defines if the local matrix should be updated
  6111. */
  6112. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  6113. /** @hidden */
  6114. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  6115. /**
  6116. * Flag the bone as dirty (Forcing it to update everything)
  6117. */
  6118. markAsDirty(): void;
  6119. private _markAsDirtyAndCompose;
  6120. private _markAsDirtyAndDecompose;
  6121. /**
  6122. * Copy an animation range from another bone
  6123. * @param source defines the source bone
  6124. * @param rangeName defines the range name to copy
  6125. * @param frameOffset defines the frame offset
  6126. * @param rescaleAsRequired defines if rescaling must be applied if required
  6127. * @param skelDimensionsRatio defines the scaling ratio
  6128. * @returns true if operation was successful
  6129. */
  6130. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  6131. /**
  6132. * Translate the bone in local or world space
  6133. * @param vec The amount to translate the bone
  6134. * @param space The space that the translation is in
  6135. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6136. */
  6137. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6138. /**
  6139. * Set the postion of the bone in local or world space
  6140. * @param position The position to set the bone
  6141. * @param space The space that the position is in
  6142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6143. */
  6144. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6145. /**
  6146. * Set the absolute position of the bone (world space)
  6147. * @param position The position to set the bone
  6148. * @param mesh The mesh that this bone is attached to
  6149. */
  6150. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  6151. /**
  6152. * Scale the bone on the x, y and z axes (in local space)
  6153. * @param x The amount to scale the bone on the x axis
  6154. * @param y The amount to scale the bone on the y axis
  6155. * @param z The amount to scale the bone on the z axis
  6156. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  6157. */
  6158. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  6159. /**
  6160. * Set the bone scaling in local space
  6161. * @param scale defines the scaling vector
  6162. */
  6163. setScale(scale: Vector3): void;
  6164. /**
  6165. * Gets the current scaling in local space
  6166. * @returns the current scaling vector
  6167. */
  6168. getScale(): Vector3;
  6169. /**
  6170. * Gets the current scaling in local space and stores it in a target vector
  6171. * @param result defines the target vector
  6172. */
  6173. getScaleToRef(result: Vector3): void;
  6174. /**
  6175. * Set the yaw, pitch, and roll of the bone in local or world space
  6176. * @param yaw The rotation of the bone on the y axis
  6177. * @param pitch The rotation of the bone on the x axis
  6178. * @param roll The rotation of the bone on the z axis
  6179. * @param space The space that the axes of rotation are in
  6180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6181. */
  6182. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  6183. /**
  6184. * Add a rotation to the bone on an axis in local or world space
  6185. * @param axis The axis to rotate the bone on
  6186. * @param amount The amount to rotate the bone
  6187. * @param space The space that the axis is in
  6188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6189. */
  6190. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  6191. /**
  6192. * Set the rotation of the bone to a particular axis angle in local or world space
  6193. * @param axis The axis to rotate the bone on
  6194. * @param angle The angle that the bone should be rotated to
  6195. * @param space The space that the axis is in
  6196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6197. */
  6198. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  6199. /**
  6200. * Set the euler rotation of the bone in local of world space
  6201. * @param rotation The euler rotation that the bone should be set to
  6202. * @param space The space that the rotation is in
  6203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6204. */
  6205. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  6206. /**
  6207. * Set the quaternion rotation of the bone in local of world space
  6208. * @param quat The quaternion rotation that the bone should be set to
  6209. * @param space The space that the rotation is in
  6210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6211. */
  6212. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  6213. /**
  6214. * Set the rotation matrix of the bone in local of world space
  6215. * @param rotMat The rotation matrix that the bone should be set to
  6216. * @param space The space that the rotation is in
  6217. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6218. */
  6219. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  6220. private _rotateWithMatrix;
  6221. private _getNegativeRotationToRef;
  6222. /**
  6223. * Get the position of the bone in local or world space
  6224. * @param space The space that the returned position is in
  6225. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6226. * @returns The position of the bone
  6227. */
  6228. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6229. /**
  6230. * Copy the position of the bone to a vector3 in local or world space
  6231. * @param space The space that the returned position is in
  6232. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6233. * @param result The vector3 to copy the position to
  6234. */
  6235. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  6236. /**
  6237. * Get the absolute position of the bone (world space)
  6238. * @param mesh The mesh that this bone is attached to
  6239. * @returns The absolute position of the bone
  6240. */
  6241. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  6242. /**
  6243. * Copy the absolute position of the bone (world space) to the result param
  6244. * @param mesh The mesh that this bone is attached to
  6245. * @param result The vector3 to copy the absolute position to
  6246. */
  6247. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  6248. /**
  6249. * Compute the absolute transforms of this bone and its children
  6250. */
  6251. computeAbsoluteTransforms(): void;
  6252. /**
  6253. * Get the world direction from an axis that is in the local space of the bone
  6254. * @param localAxis The local direction that is used to compute the world direction
  6255. * @param mesh The mesh that this bone is attached to
  6256. * @returns The world direction
  6257. */
  6258. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6259. /**
  6260. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  6261. * @param localAxis The local direction that is used to compute the world direction
  6262. * @param mesh The mesh that this bone is attached to
  6263. * @param result The vector3 that the world direction will be copied to
  6264. */
  6265. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6266. /**
  6267. * Get the euler rotation of the bone in local or world space
  6268. * @param space The space that the rotation should be in
  6269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6270. * @returns The euler rotation
  6271. */
  6272. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  6273. /**
  6274. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  6275. * @param space The space that the rotation should be in
  6276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6277. * @param result The vector3 that the rotation should be copied to
  6278. */
  6279. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6280. /**
  6281. * Get the quaternion rotation of the bone in either local or world space
  6282. * @param space The space that the rotation should be in
  6283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6284. * @returns The quaternion rotation
  6285. */
  6286. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  6287. /**
  6288. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  6289. * @param space The space that the rotation should be in
  6290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6291. * @param result The quaternion that the rotation should be copied to
  6292. */
  6293. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  6294. /**
  6295. * Get the rotation matrix of the bone in local or world space
  6296. * @param space The space that the rotation should be in
  6297. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6298. * @returns The rotation matrix
  6299. */
  6300. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  6301. /**
  6302. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  6303. * @param space The space that the rotation should be in
  6304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  6305. * @param result The quaternion that the rotation should be copied to
  6306. */
  6307. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  6308. /**
  6309. * Get the world position of a point that is in the local space of the bone
  6310. * @param position The local position
  6311. * @param mesh The mesh that this bone is attached to
  6312. * @returns The world position
  6313. */
  6314. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6315. /**
  6316. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  6317. * @param position The local position
  6318. * @param mesh The mesh that this bone is attached to
  6319. * @param result The vector3 that the world position should be copied to
  6320. */
  6321. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6322. /**
  6323. * Get the local position of a point that is in world space
  6324. * @param position The world position
  6325. * @param mesh The mesh that this bone is attached to
  6326. * @returns The local position
  6327. */
  6328. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  6329. /**
  6330. * Get the local position of a point that is in world space and copy it to the result param
  6331. * @param position The world position
  6332. * @param mesh The mesh that this bone is attached to
  6333. * @param result The vector3 that the local position should be copied to
  6334. */
  6335. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  6336. }
  6337. }
  6338. declare module BABYLON {
  6339. /**
  6340. * Class used to apply inverse kinematics to bones
  6341. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  6342. */
  6343. class BoneIKController {
  6344. private static _tmpVecs;
  6345. private static _tmpQuat;
  6346. private static _tmpMats;
  6347. /**
  6348. * Gets or sets the target mesh
  6349. */
  6350. targetMesh: AbstractMesh;
  6351. /** Gets or sets the mesh used as pole */
  6352. poleTargetMesh: AbstractMesh;
  6353. /**
  6354. * Gets or sets the bone used as pole
  6355. */
  6356. poleTargetBone: Nullable<Bone>;
  6357. /**
  6358. * Gets or sets the target position
  6359. */
  6360. targetPosition: Vector3;
  6361. /**
  6362. * Gets or sets the pole target position
  6363. */
  6364. poleTargetPosition: Vector3;
  6365. /**
  6366. * Gets or sets the pole target local offset
  6367. */
  6368. poleTargetLocalOffset: Vector3;
  6369. /**
  6370. * Gets or sets the pole angle
  6371. */
  6372. poleAngle: number;
  6373. /**
  6374. * Gets or sets the mesh associated with the controller
  6375. */
  6376. mesh: AbstractMesh;
  6377. /**
  6378. * 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)
  6379. */
  6380. slerpAmount: number;
  6381. private _bone1Quat;
  6382. private _bone1Mat;
  6383. private _bone2Ang;
  6384. private _bone1;
  6385. private _bone2;
  6386. private _bone1Length;
  6387. private _bone2Length;
  6388. private _maxAngle;
  6389. private _maxReach;
  6390. private _rightHandedSystem;
  6391. private _bendAxis;
  6392. private _slerping;
  6393. private _adjustRoll;
  6394. /**
  6395. * Gets or sets maximum allowed angle
  6396. */
  6397. maxAngle: number;
  6398. /**
  6399. * Creates a new BoneIKController
  6400. * @param mesh defines the mesh to control
  6401. * @param bone defines the bone to control
  6402. * @param options defines options to set up the controller
  6403. */
  6404. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  6405. targetMesh?: AbstractMesh;
  6406. poleTargetMesh?: AbstractMesh;
  6407. poleTargetBone?: Bone;
  6408. poleTargetLocalOffset?: Vector3;
  6409. poleAngle?: number;
  6410. bendAxis?: Vector3;
  6411. maxAngle?: number;
  6412. slerpAmount?: number;
  6413. });
  6414. private _setMaxAngle;
  6415. /**
  6416. * Force the controller to update the bones
  6417. */
  6418. update(): void;
  6419. }
  6420. }
  6421. declare module BABYLON {
  6422. /**
  6423. * Class used to make a bone look toward a point in space
  6424. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  6425. */
  6426. class BoneLookController {
  6427. private static _tmpVecs;
  6428. private static _tmpQuat;
  6429. private static _tmpMats;
  6430. /**
  6431. * The target Vector3 that the bone will look at
  6432. */
  6433. target: Vector3;
  6434. /**
  6435. * The mesh that the bone is attached to
  6436. */
  6437. mesh: AbstractMesh;
  6438. /**
  6439. * The bone that will be looking to the target
  6440. */
  6441. bone: Bone;
  6442. /**
  6443. * The up axis of the coordinate system that is used when the bone is rotated
  6444. */
  6445. upAxis: Vector3;
  6446. /**
  6447. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD
  6448. */
  6449. upAxisSpace: Space;
  6450. /**
  6451. * Used to make an adjustment to the yaw of the bone
  6452. */
  6453. adjustYaw: number;
  6454. /**
  6455. * Used to make an adjustment to the pitch of the bone
  6456. */
  6457. adjustPitch: number;
  6458. /**
  6459. * Used to make an adjustment to the roll of the bone
  6460. */
  6461. adjustRoll: number;
  6462. /**
  6463. * 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)
  6464. */
  6465. slerpAmount: number;
  6466. private _minYaw;
  6467. private _maxYaw;
  6468. private _minPitch;
  6469. private _maxPitch;
  6470. private _minYawSin;
  6471. private _minYawCos;
  6472. private _maxYawSin;
  6473. private _maxYawCos;
  6474. private _midYawConstraint;
  6475. private _minPitchTan;
  6476. private _maxPitchTan;
  6477. private _boneQuat;
  6478. private _slerping;
  6479. private _transformYawPitch;
  6480. private _transformYawPitchInv;
  6481. private _firstFrameSkipped;
  6482. private _yawRange;
  6483. private _fowardAxis;
  6484. /**
  6485. * Gets or sets the minimum yaw angle that the bone can look to
  6486. */
  6487. minYaw: number;
  6488. /**
  6489. * Gets or sets the maximum yaw angle that the bone can look to
  6490. */
  6491. maxYaw: number;
  6492. /**
  6493. * Gets or sets the minimum pitch angle that the bone can look to
  6494. */
  6495. minPitch: number;
  6496. /**
  6497. * Gets or sets the maximum pitch angle that the bone can look to
  6498. */
  6499. maxPitch: number;
  6500. /**
  6501. * Create a BoneLookController
  6502. * @param mesh the mesh that the bone belongs to
  6503. * @param bone the bone that will be looking to the target
  6504. * @param target the target Vector3 to look at
  6505. * @param settings optional settings:
  6506. * * maxYaw: the maximum angle the bone will yaw to
  6507. * * minYaw: the minimum angle the bone will yaw to
  6508. * * maxPitch: the maximum angle the bone will pitch to
  6509. * * minPitch: the minimum angle the bone will yaw to
  6510. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  6511. * * upAxis: the up axis of the coordinate system
  6512. * * upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  6513. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  6514. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  6515. * * adjustYaw: used to make an adjustment to the yaw of the bone
  6516. * * adjustPitch: used to make an adjustment to the pitch of the bone
  6517. * * adjustRoll: used to make an adjustment to the roll of the bone
  6518. **/
  6519. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  6520. maxYaw?: number;
  6521. minYaw?: number;
  6522. maxPitch?: number;
  6523. minPitch?: number;
  6524. slerpAmount?: number;
  6525. upAxis?: Vector3;
  6526. upAxisSpace?: Space;
  6527. yawAxis?: Vector3;
  6528. pitchAxis?: Vector3;
  6529. adjustYaw?: number;
  6530. adjustPitch?: number;
  6531. adjustRoll?: number;
  6532. });
  6533. /**
  6534. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  6535. */
  6536. update(): void;
  6537. private _getAngleDiff;
  6538. private _getAngleBetween;
  6539. private _isAngleBetween;
  6540. }
  6541. }
  6542. declare module BABYLON {
  6543. /**
  6544. * Class used to handle skinning animations
  6545. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  6546. */
  6547. class Skeleton implements IAnimatable {
  6548. /** defines the skeleton name */
  6549. name: string;
  6550. /** defines the skeleton Id */
  6551. id: string;
  6552. /**
  6553. * Gets the list of child bones
  6554. */
  6555. bones: Bone[];
  6556. /**
  6557. * Gets an estimate of the dimension of the skeleton at rest
  6558. */
  6559. dimensionsAtRest: Vector3;
  6560. /**
  6561. * Gets a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  6562. */
  6563. needInitialSkinMatrix: boolean;
  6564. /**
  6565. * Gets the list of animations attached to this skeleton
  6566. */
  6567. animations: Array<Animation>;
  6568. private _scene;
  6569. private _isDirty;
  6570. private _transformMatrices;
  6571. private _transformMatrixTexture;
  6572. private _meshesWithPoseMatrix;
  6573. private _animatables;
  6574. private _identity;
  6575. private _synchronizedWithMesh;
  6576. private _ranges;
  6577. private _lastAbsoluteTransformsUpdateId;
  6578. private _canUseTextureForBones;
  6579. /**
  6580. * Specifies if the skeleton should be serialized
  6581. */
  6582. doNotSerialize: boolean;
  6583. /**
  6584. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  6585. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  6586. */
  6587. useTextureToStoreBoneMatrices: boolean;
  6588. private _animationPropertiesOverride;
  6589. /**
  6590. * Gets or sets the animation properties override
  6591. */
  6592. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  6593. /**
  6594. * An observable triggered before computing the skeleton's matrices
  6595. */
  6596. onBeforeComputeObservable: Observable<Skeleton>;
  6597. /**
  6598. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  6599. */
  6600. readonly isUsingTextureForMatrices: boolean;
  6601. /**
  6602. * Creates a new skeleton
  6603. * @param name defines the skeleton name
  6604. * @param id defines the skeleton Id
  6605. * @param scene defines the hosting scene
  6606. */
  6607. constructor(
  6608. /** defines the skeleton name */
  6609. name: string,
  6610. /** defines the skeleton Id */
  6611. id: string, scene: Scene);
  6612. /**
  6613. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  6614. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  6615. * @returns a Float32Array containing matrices data
  6616. */
  6617. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  6618. /**
  6619. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  6620. * @returns a raw texture containing the data
  6621. */
  6622. getTransformMatrixTexture(): Nullable<RawTexture>;
  6623. /**
  6624. * Gets the current hosting scene
  6625. * @returns a scene object
  6626. */
  6627. getScene(): Scene;
  6628. /**
  6629. * Gets a string representing the current skeleton data
  6630. * @param fullDetails defines a boolean indicating if we want a verbose version
  6631. * @returns a string representing the current skeleton data
  6632. */
  6633. toString(fullDetails?: boolean): string;
  6634. /**
  6635. * Get bone's index searching by name
  6636. * @param name defines bone's name to search for
  6637. * @return the indice of the bone. Returns -1 if not found
  6638. */
  6639. getBoneIndexByName(name: string): number;
  6640. /**
  6641. * Creater a new animation range
  6642. * @param name defines the name of the range
  6643. * @param from defines the start key
  6644. * @param to defines the end key
  6645. */
  6646. createAnimationRange(name: string, from: number, to: number): void;
  6647. /**
  6648. * Delete a specific animation range
  6649. * @param name defines the name of the range
  6650. * @param deleteFrames defines if frames must be removed as well
  6651. */
  6652. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  6653. /**
  6654. * Gets a specific animation range
  6655. * @param name defines the name of the range to look for
  6656. * @returns the requested animation range or null if not found
  6657. */
  6658. getAnimationRange(name: string): Nullable<AnimationRange>;
  6659. /**
  6660. * Gets the list of all animation ranges defined on this skeleton
  6661. * @returns an array
  6662. */
  6663. getAnimationRanges(): Nullable<AnimationRange>[];
  6664. /**
  6665. * Copy animation range from a source skeleton.
  6666. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  6667. * @param source defines the source skeleton
  6668. * @param name defines the name of the range to copy
  6669. * @param rescaleAsRequired defines if rescaling must be applied if required
  6670. * @returns true if operation was successful
  6671. */
  6672. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  6673. /**
  6674. * Forces the skeleton to go to rest pose
  6675. */
  6676. returnToRest(): void;
  6677. private _getHighestAnimationFrame;
  6678. /**
  6679. * Begin a specific animation range
  6680. * @param name defines the name of the range to start
  6681. * @param loop defines if looping must be turned on (false by default)
  6682. * @param speedRatio defines the speed ratio to apply (1 by default)
  6683. * @param onAnimationEnd defines a callback which will be called when animation will end
  6684. * @returns a new animatable
  6685. */
  6686. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  6687. /** @hidden */
  6688. _markAsDirty(): void;
  6689. /** @hidden */
  6690. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6691. /** @hidden */
  6692. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  6693. private _computeTransformMatrices;
  6694. /**
  6695. * Build all resources required to render a skeleton
  6696. */
  6697. prepare(): void;
  6698. /**
  6699. * Gets the list of animatables currently running for this skeleton
  6700. * @returns an array of animatables
  6701. */
  6702. getAnimatables(): IAnimatable[];
  6703. /**
  6704. * Clone the current skeleton
  6705. * @param name defines the name of the new skeleton
  6706. * @param id defines the id of the enw skeleton
  6707. * @returns the new skeleton
  6708. */
  6709. clone(name: string, id: string): Skeleton;
  6710. /**
  6711. * Enable animation blending for this skeleton
  6712. * @param blendingSpeed defines the blending speed to apply
  6713. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  6714. */
  6715. enableBlending(blendingSpeed?: number): void;
  6716. /**
  6717. * Releases all resources associated with the current skeleton
  6718. */
  6719. dispose(): void;
  6720. /**
  6721. * Serialize the skeleton in a JSON object
  6722. * @returns a JSON object
  6723. */
  6724. serialize(): any;
  6725. /**
  6726. * Creates a new skeleton from serialized data
  6727. * @param parsedSkeleton defines the serialized data
  6728. * @param scene defines the hosting scene
  6729. * @returns a new skeleton
  6730. */
  6731. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  6732. /**
  6733. * Compute all node absolute transforms
  6734. * @param forceUpdate defines if computation must be done even if cache is up to date
  6735. */
  6736. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  6737. /**
  6738. * Gets the root pose matrix
  6739. * @returns a matrix
  6740. */
  6741. getPoseMatrix(): Nullable<Matrix>;
  6742. /**
  6743. * Sorts bones per internal index
  6744. */
  6745. sortBones(): void;
  6746. private _sortBones;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /** @hidden */
  6751. class Collider {
  6752. /** Define if a collision was found */
  6753. collisionFound: boolean;
  6754. /**
  6755. * Define last intersection point in local space
  6756. */
  6757. intersectionPoint: Vector3;
  6758. /**
  6759. * Define last collided mesh
  6760. */
  6761. collidedMesh: Nullable<AbstractMesh>;
  6762. private _collisionPoint;
  6763. private _planeIntersectionPoint;
  6764. private _tempVector;
  6765. private _tempVector2;
  6766. private _tempVector3;
  6767. private _tempVector4;
  6768. private _edge;
  6769. private _baseToVertex;
  6770. private _destinationPoint;
  6771. private _slidePlaneNormal;
  6772. private _displacementVector;
  6773. /** @hidden */
  6774. _radius: Vector3;
  6775. /** @hidden */
  6776. _retry: number;
  6777. private _velocity;
  6778. private _basePoint;
  6779. private _epsilon;
  6780. /** @hidden */
  6781. _velocityWorldLength: number;
  6782. /** @hidden */
  6783. _basePointWorld: Vector3;
  6784. private _velocityWorld;
  6785. private _normalizedVelocity;
  6786. /** @hidden */
  6787. _initialVelocity: Vector3;
  6788. /** @hidden */
  6789. _initialPosition: Vector3;
  6790. private _nearestDistance;
  6791. private _collisionMask;
  6792. collisionMask: number;
  6793. /**
  6794. * Gets the plane normal used to compute the sliding response (in local space)
  6795. */
  6796. readonly slidePlaneNormal: Vector3;
  6797. /** @hidden */
  6798. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6799. /** @hidden */
  6800. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6801. /** @hidden */
  6802. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6803. /** @hidden */
  6804. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  6805. /** @hidden */
  6806. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  6807. /** @hidden */
  6808. _getResponse(pos: Vector3, vel: Vector3): void;
  6809. }
  6810. }
  6811. declare module BABYLON {
  6812. /** @hidden */
  6813. var CollisionWorker: string;
  6814. /** @hidden */
  6815. interface ICollisionCoordinator {
  6816. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6817. init(scene: Scene): void;
  6818. destroy(): void;
  6819. onMeshAdded(mesh: AbstractMesh): void;
  6820. onMeshUpdated(mesh: AbstractMesh): void;
  6821. onMeshRemoved(mesh: AbstractMesh): void;
  6822. onGeometryAdded(geometry: Geometry): void;
  6823. onGeometryUpdated(geometry: Geometry): void;
  6824. onGeometryDeleted(geometry: Geometry): void;
  6825. }
  6826. /** @hidden */
  6827. interface SerializedMesh {
  6828. id: string;
  6829. name: string;
  6830. uniqueId: number;
  6831. geometryId: Nullable<string>;
  6832. sphereCenter: Array<number>;
  6833. sphereRadius: number;
  6834. boxMinimum: Array<number>;
  6835. boxMaximum: Array<number>;
  6836. worldMatrixFromCache: any;
  6837. subMeshes: Array<SerializedSubMesh>;
  6838. checkCollisions: boolean;
  6839. }
  6840. /** @hidden */
  6841. interface SerializedSubMesh {
  6842. position: number;
  6843. verticesStart: number;
  6844. verticesCount: number;
  6845. indexStart: number;
  6846. indexCount: number;
  6847. hasMaterial: boolean;
  6848. sphereCenter: Array<number>;
  6849. sphereRadius: number;
  6850. boxMinimum: Array<number>;
  6851. boxMaximum: Array<number>;
  6852. }
  6853. /**
  6854. * Interface describing the value associated with a geometry.
  6855. * @hidden
  6856. */
  6857. interface SerializedGeometry {
  6858. /**
  6859. * Defines the unique ID of the geometry
  6860. */
  6861. id: string;
  6862. /**
  6863. * Defines the array containing the positions
  6864. */
  6865. positions: Float32Array;
  6866. /**
  6867. * Defines the array containing the indices
  6868. */
  6869. indices: Uint32Array;
  6870. /**
  6871. * Defines the array containing the normals
  6872. */
  6873. normals: Float32Array;
  6874. }
  6875. /** @hidden */
  6876. interface BabylonMessage {
  6877. taskType: WorkerTaskType;
  6878. payload: InitPayload | CollidePayload | UpdatePayload;
  6879. }
  6880. /** @hidden */
  6881. interface SerializedColliderToWorker {
  6882. position: Array<number>;
  6883. velocity: Array<number>;
  6884. radius: Array<number>;
  6885. }
  6886. /** Defines supported task for worker process */
  6887. enum WorkerTaskType {
  6888. /** Initialization */
  6889. INIT = 0,
  6890. /** Update of geometry */
  6891. UPDATE = 1,
  6892. /** Evaluate collision */
  6893. COLLIDE = 2
  6894. }
  6895. /** @hidden */
  6896. interface WorkerReply {
  6897. error: WorkerReplyType;
  6898. taskType: WorkerTaskType;
  6899. payload?: any;
  6900. }
  6901. /** @hidden */
  6902. interface CollisionReplyPayload {
  6903. newPosition: Array<number>;
  6904. collisionId: number;
  6905. collidedMeshUniqueId: number;
  6906. }
  6907. /** @hidden */
  6908. interface InitPayload {
  6909. }
  6910. /** @hidden */
  6911. interface CollidePayload {
  6912. collisionId: number;
  6913. collider: SerializedColliderToWorker;
  6914. maximumRetry: number;
  6915. excludedMeshUniqueId: Nullable<number>;
  6916. }
  6917. /** @hidden */
  6918. interface UpdatePayload {
  6919. updatedMeshes: {
  6920. [n: number]: SerializedMesh;
  6921. };
  6922. updatedGeometries: {
  6923. [s: string]: SerializedGeometry;
  6924. };
  6925. removedMeshes: Array<number>;
  6926. removedGeometries: Array<string>;
  6927. }
  6928. /** Defines kind of replies returned by worker */
  6929. enum WorkerReplyType {
  6930. /** Success */
  6931. SUCCESS = 0,
  6932. /** Unkown error */
  6933. UNKNOWN_ERROR = 1
  6934. }
  6935. /** @hidden */
  6936. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  6937. private _scene;
  6938. private _scaledPosition;
  6939. private _scaledVelocity;
  6940. private _collisionsCallbackArray;
  6941. private _init;
  6942. private _runningUpdated;
  6943. private _worker;
  6944. private _addUpdateMeshesList;
  6945. private _addUpdateGeometriesList;
  6946. private _toRemoveMeshesArray;
  6947. private _toRemoveGeometryArray;
  6948. constructor();
  6949. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  6950. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  6951. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6952. init(scene: Scene): void;
  6953. destroy(): void;
  6954. onMeshAdded(mesh: AbstractMesh): void;
  6955. onMeshUpdated: (transformNode: TransformNode) => void;
  6956. onMeshRemoved(mesh: AbstractMesh): void;
  6957. onGeometryAdded(geometry: Geometry): void;
  6958. onGeometryUpdated: (geometry: Geometry) => void;
  6959. onGeometryDeleted(geometry: Geometry): void;
  6960. private _afterRender;
  6961. private _onMessageFromWorker;
  6962. }
  6963. /** @hidden */
  6964. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  6965. private _scene;
  6966. private _scaledPosition;
  6967. private _scaledVelocity;
  6968. private _finalPosition;
  6969. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  6970. init(scene: Scene): void;
  6971. destroy(): void;
  6972. onMeshAdded(mesh: AbstractMesh): void;
  6973. onMeshUpdated(mesh: AbstractMesh): void;
  6974. onMeshRemoved(mesh: AbstractMesh): void;
  6975. onGeometryAdded(geometry: Geometry): void;
  6976. onGeometryUpdated(geometry: Geometry): void;
  6977. onGeometryDeleted(geometry: Geometry): void;
  6978. private _collideWithWorld;
  6979. }
  6980. }
  6981. declare function importScripts(...urls: string[]): void;
  6982. declare const safePostMessage: any;
  6983. declare module BABYLON {
  6984. /** @hidden */
  6985. var WorkerIncluded: boolean;
  6986. /** @hidden */
  6987. class CollisionCache {
  6988. private _meshes;
  6989. private _geometries;
  6990. getMeshes(): {
  6991. [n: number]: SerializedMesh;
  6992. };
  6993. getGeometries(): {
  6994. [s: number]: SerializedGeometry;
  6995. };
  6996. getMesh(id: any): SerializedMesh;
  6997. addMesh(mesh: SerializedMesh): void;
  6998. removeMesh(uniqueId: number): void;
  6999. getGeometry(id: string): SerializedGeometry;
  7000. addGeometry(geometry: SerializedGeometry): void;
  7001. removeGeometry(id: string): void;
  7002. }
  7003. /** @hidden */
  7004. class CollideWorker {
  7005. collider: Collider;
  7006. private _collisionCache;
  7007. private finalPosition;
  7008. private collisionsScalingMatrix;
  7009. private collisionTranformationMatrix;
  7010. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  7011. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  7012. private checkCollision;
  7013. private processCollisionsForSubMeshes;
  7014. private collideForSubMesh;
  7015. private checkSubmeshCollision;
  7016. }
  7017. /** @hidden */
  7018. interface ICollisionDetector {
  7019. onInit(payload: InitPayload): void;
  7020. onUpdate(payload: UpdatePayload): void;
  7021. onCollision(payload: CollidePayload): void;
  7022. }
  7023. /** @hidden */
  7024. class CollisionDetectorTransferable implements ICollisionDetector {
  7025. private _collisionCache;
  7026. onInit(payload: InitPayload): void;
  7027. onUpdate(payload: UpdatePayload): void;
  7028. onCollision(payload: CollidePayload): void;
  7029. }
  7030. }
  7031. declare module BABYLON {
  7032. /**
  7033. * @hidden
  7034. */
  7035. class IntersectionInfo {
  7036. bu: Nullable<number>;
  7037. bv: Nullable<number>;
  7038. distance: number;
  7039. faceId: number;
  7040. subMeshId: number;
  7041. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7042. }
  7043. /**
  7044. * Information about the result of picking within a scene
  7045. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  7046. */
  7047. class PickingInfo {
  7048. /**
  7049. * If the pick collided with an object
  7050. */
  7051. hit: boolean;
  7052. /**
  7053. * Distance away where the pick collided
  7054. */
  7055. distance: number;
  7056. /**
  7057. * The location of pick collision
  7058. */
  7059. pickedPoint: Nullable<Vector3>;
  7060. /**
  7061. * The mesh corresponding the the pick collision
  7062. */
  7063. pickedMesh: Nullable<AbstractMesh>;
  7064. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  7065. bu: number;
  7066. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  7067. bv: number;
  7068. /** The id of the face on the mesh that was picked */
  7069. faceId: number;
  7070. /** Id of the the submesh that was picked */
  7071. subMeshId: number;
  7072. /** If a sprite was picked, this will be the sprite the pick collided with */
  7073. pickedSprite: Nullable<Sprite>;
  7074. /**
  7075. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  7076. */
  7077. originMesh: Nullable<AbstractMesh>;
  7078. /**
  7079. * The ray that was used to perform the picking.
  7080. */
  7081. ray: Nullable<Ray>;
  7082. /**
  7083. * Gets the normal correspodning to the face the pick collided with
  7084. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  7085. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  7086. * @returns The normal correspodning to the face the pick collided with
  7087. */
  7088. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  7089. /**
  7090. * Gets the texture coordinates of where the pick occured
  7091. * @returns the vector containing the coordnates of the texture
  7092. */
  7093. getTextureCoordinates(): Nullable<Vector2>;
  7094. }
  7095. }
  7096. declare module BABYLON {
  7097. /**
  7098. * Class used to store bounding box information
  7099. */
  7100. class BoundingBox implements ICullable {
  7101. /**
  7102. * Gets the 8 vectors representing the bounding box in local space
  7103. */
  7104. readonly vectors: Vector3[];
  7105. /**
  7106. * Gets the center of the bounding box in local space
  7107. */
  7108. readonly center: Vector3;
  7109. /**
  7110. * Gets the center of the bounding box in world space
  7111. */
  7112. readonly centerWorld: Vector3;
  7113. /**
  7114. * Gets the extend size in local space
  7115. */
  7116. readonly extendSize: Vector3;
  7117. /**
  7118. * Gets the extend size in world space
  7119. */
  7120. readonly extendSizeWorld: Vector3;
  7121. /**
  7122. * Gets the OBB (object bounding box) directions
  7123. */
  7124. readonly directions: Vector3[];
  7125. /**
  7126. * Gets the 8 vectors representing the bounding box in world space
  7127. */
  7128. readonly vectorsWorld: Vector3[];
  7129. /**
  7130. * Gets the minimum vector in world space
  7131. */
  7132. readonly minimumWorld: Vector3;
  7133. /**
  7134. * Gets the maximum vector in world space
  7135. */
  7136. readonly maximumWorld: Vector3;
  7137. /**
  7138. * Gets the minimum vector in local space
  7139. */
  7140. readonly minimum: Vector3;
  7141. /**
  7142. * Gets the maximum vector in local space
  7143. */
  7144. readonly maximum: Vector3;
  7145. private _worldMatrix;
  7146. private static readonly TmpVector3;
  7147. /**
  7148. * @hidden
  7149. */
  7150. _tag: number;
  7151. /**
  7152. * Creates a new bounding box
  7153. * @param min defines the minimum vector (in local space)
  7154. * @param max defines the maximum vector (in local space)
  7155. * @param worldMatrix defines the new world matrix
  7156. */
  7157. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7158. /**
  7159. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7160. * @param min defines the new minimum vector (in local space)
  7161. * @param max defines the new maximum vector (in local space)
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7165. /**
  7166. * Scale the current bounding box by applying a scale factor
  7167. * @param factor defines the scale factor to apply
  7168. * @returns the current bounding box
  7169. */
  7170. scale(factor: number): BoundingBox;
  7171. /**
  7172. * Gets the world matrix of the bounding box
  7173. * @returns a matrix
  7174. */
  7175. getWorldMatrix(): DeepImmutable<Matrix>;
  7176. /** @hidden */
  7177. _update(world: DeepImmutable<Matrix>): void;
  7178. /**
  7179. * Tests if the bounding box is intersecting the frustum planes
  7180. * @param frustumPlanes defines the frustum planes to test
  7181. * @returns true if there is an intersection
  7182. */
  7183. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7184. /**
  7185. * Tests if the bounding box is entirely inside the frustum planes
  7186. * @param frustumPlanes defines the frustum planes to test
  7187. * @returns true if there is an inclusion
  7188. */
  7189. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7190. /**
  7191. * Tests if a point is inside the bounding box
  7192. * @param point defines the point to test
  7193. * @returns true if the point is inside the bounding box
  7194. */
  7195. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7196. /**
  7197. * Tests if the bounding box intersects with a bounding sphere
  7198. * @param sphere defines the sphere to test
  7199. * @returns true if there is an intersection
  7200. */
  7201. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7202. /**
  7203. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7204. * @param min defines the min vector to use
  7205. * @param max defines the max vector to use
  7206. * @returns true if there is an intersection
  7207. */
  7208. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7209. /**
  7210. * Tests if two bounding boxes are intersections
  7211. * @param box0 defines the first box to test
  7212. * @param box1 defines the second box to test
  7213. * @returns true if there is an intersection
  7214. */
  7215. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7216. /**
  7217. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7218. * @param minPoint defines the minimum vector of the bounding box
  7219. * @param maxPoint defines the maximum vector of the bounding box
  7220. * @param sphereCenter defines the sphere center
  7221. * @param sphereRadius defines the sphere radius
  7222. * @returns true if there is an intersection
  7223. */
  7224. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7225. /**
  7226. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7227. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7228. * @param frustumPlanes defines the frustum planes to test
  7229. * @return true if there is an inclusion
  7230. */
  7231. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7232. /**
  7233. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7234. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7235. * @param frustumPlanes defines the frustum planes to test
  7236. * @return true if there is an intersection
  7237. */
  7238. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7239. }
  7240. }
  7241. declare module BABYLON {
  7242. /**
  7243. * Interface for cullable objects
  7244. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7245. */
  7246. interface ICullable {
  7247. /**
  7248. * Checks if the object or part of the object is in the frustum
  7249. * @param frustumPlanes Camera near/planes
  7250. * @returns true if the object is in frustum otherwise false
  7251. */
  7252. isInFrustum(frustumPlanes: Plane[]): boolean;
  7253. /**
  7254. * Checks if a cullable object (mesh...) is in the camera frustum
  7255. * Unlike isInFrustum this cheks the full bounding box
  7256. * @param frustumPlanes Camera near/planes
  7257. * @returns true if the object is in frustum otherwise false
  7258. */
  7259. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7260. }
  7261. /**
  7262. * Info for a bounding data of a mesh
  7263. */
  7264. class BoundingInfo implements ICullable {
  7265. /**
  7266. * Bounding box for the mesh
  7267. */
  7268. readonly boundingBox: BoundingBox;
  7269. /**
  7270. * Bounding sphere for the mesh
  7271. */
  7272. readonly boundingSphere: BoundingSphere;
  7273. private _isLocked;
  7274. private static readonly TmpVector3;
  7275. /**
  7276. * Constructs bounding info
  7277. * @param minimum min vector of the bounding box/sphere
  7278. * @param maximum max vector of the bounding box/sphere
  7279. * @param worldMatrix defines the new world matrix
  7280. */
  7281. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7282. /**
  7283. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7284. * @param min defines the new minimum vector (in local space)
  7285. * @param max defines the new maximum vector (in local space)
  7286. * @param worldMatrix defines the new world matrix
  7287. */
  7288. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7289. /**
  7290. * min vector of the bounding box/sphere
  7291. */
  7292. readonly minimum: Vector3;
  7293. /**
  7294. * max vector of the bounding box/sphere
  7295. */
  7296. readonly maximum: Vector3;
  7297. /**
  7298. * If the info is locked and won't be updated to avoid perf overhead
  7299. */
  7300. isLocked: boolean;
  7301. /**
  7302. * Updates the bounding sphere and box
  7303. * @param world world matrix to be used to update
  7304. */
  7305. update(world: DeepImmutable<Matrix>): void;
  7306. /**
  7307. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7308. * @param center New center of the bounding info
  7309. * @param extend New extend of the bounding info
  7310. * @returns the current bounding info
  7311. */
  7312. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7313. /**
  7314. * Scale the current bounding info by applying a scale factor
  7315. * @param factor defines the scale factor to apply
  7316. * @returns the current bounding info
  7317. */
  7318. scale(factor: number): BoundingInfo;
  7319. /**
  7320. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7321. * @param frustumPlanes defines the frustum to test
  7322. * @param strategy defines the strategy to use for the culling (default is BABYLON.Scene.CULLINGSTRATEGY_STANDARD)
  7323. * @returns true if the bounding info is in the frustum planes
  7324. */
  7325. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7326. /**
  7327. * Gets the world distance between the min and max points of the bounding box
  7328. */
  7329. readonly diagonalLength: number;
  7330. /**
  7331. * Checks if a cullable object (mesh...) is in the camera frustum
  7332. * Unlike isInFrustum this cheks the full bounding box
  7333. * @param frustumPlanes Camera near/planes
  7334. * @returns true if the object is in frustum otherwise false
  7335. */
  7336. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7337. /** @hidden */
  7338. _checkCollision(collider: Collider): boolean;
  7339. /**
  7340. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7341. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7342. * @param point the point to check intersection with
  7343. * @returns if the point intersects
  7344. */
  7345. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7346. /**
  7347. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7348. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7349. * @param boundingInfo the bounding info to check intersection with
  7350. * @param precise if the intersection should be done using OBB
  7351. * @returns if the bounding info intersects
  7352. */
  7353. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7354. }
  7355. }
  7356. declare module BABYLON {
  7357. /**
  7358. * Class used to store bounding sphere information
  7359. */
  7360. class BoundingSphere {
  7361. /**
  7362. * Gets the center of the bounding sphere in local space
  7363. */
  7364. readonly center: Vector3;
  7365. /**
  7366. * Radius of the bounding sphere in local space
  7367. */
  7368. radius: number;
  7369. /**
  7370. * Gets the center of the bounding sphere in world space
  7371. */
  7372. readonly centerWorld: Vector3;
  7373. /**
  7374. * Radius of the bounding sphere in world space
  7375. */
  7376. radiusWorld: number;
  7377. /**
  7378. * Gets the minimum vector in local space
  7379. */
  7380. readonly minimum: Vector3;
  7381. /**
  7382. * Gets the maximum vector in local space
  7383. */
  7384. readonly maximum: Vector3;
  7385. private _worldMatrix;
  7386. private static readonly TmpVector3;
  7387. /**
  7388. * Creates a new bounding sphere
  7389. * @param min defines the minimum vector (in local space)
  7390. * @param max defines the maximum vector (in local space)
  7391. * @param worldMatrix defines the new world matrix
  7392. */
  7393. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7394. /**
  7395. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7396. * @param min defines the new minimum vector (in local space)
  7397. * @param max defines the new maximum vector (in local space)
  7398. * @param worldMatrix defines the new world matrix
  7399. */
  7400. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7401. /**
  7402. * Scale the current bounding sphere by applying a scale factor
  7403. * @param factor defines the scale factor to apply
  7404. * @returns the current bounding box
  7405. */
  7406. scale(factor: number): BoundingSphere;
  7407. /**
  7408. * Gets the world matrix of the bounding box
  7409. * @returns a matrix
  7410. */
  7411. getWorldMatrix(): DeepImmutable<Matrix>;
  7412. /** @hidden */
  7413. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7414. /**
  7415. * Tests if the bounding sphere is intersecting the frustum planes
  7416. * @param frustumPlanes defines the frustum planes to test
  7417. * @returns true if there is an intersection
  7418. */
  7419. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7420. /**
  7421. * Tests if a point is inside the bounding sphere
  7422. * @param point defines the point to test
  7423. * @returns true if the point is inside the bounding sphere
  7424. */
  7425. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7426. /**
  7427. * Checks if two sphere intersct
  7428. * @param sphere0 sphere 0
  7429. * @param sphere1 sphere 1
  7430. * @returns true if the speres intersect
  7431. */
  7432. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7433. }
  7434. }
  7435. declare module BABYLON {
  7436. /**
  7437. * Class representing a ray with position and direction
  7438. */
  7439. class Ray {
  7440. /** origin point */
  7441. origin: Vector3;
  7442. /** direction */
  7443. direction: Vector3;
  7444. /** length of the ray */
  7445. length: number;
  7446. private static readonly TmpVector3;
  7447. private _tmpRay;
  7448. /**
  7449. * Creates a new ray
  7450. * @param origin origin point
  7451. * @param direction direction
  7452. * @param length length of the ray
  7453. */
  7454. constructor(
  7455. /** origin point */
  7456. origin: Vector3,
  7457. /** direction */
  7458. direction: Vector3,
  7459. /** length of the ray */
  7460. length?: number);
  7461. /**
  7462. * Checks if the ray intersects a box
  7463. * @param minimum bound of the box
  7464. * @param maximum bound of the box
  7465. * @param intersectionTreshold extra extend to be added to the box in all direction
  7466. * @returns if the box was hit
  7467. */
  7468. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  7469. /**
  7470. * Checks if the ray intersects a box
  7471. * @param box the bounding box to check
  7472. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  7473. * @returns if the box was hit
  7474. */
  7475. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  7476. /**
  7477. * If the ray hits a sphere
  7478. * @param sphere the bounding sphere to check
  7479. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  7480. * @returns true if it hits the sphere
  7481. */
  7482. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  7483. /**
  7484. * If the ray hits a triange
  7485. * @param vertex0 triangle vertex
  7486. * @param vertex1 triangle vertex
  7487. * @param vertex2 triangle vertex
  7488. * @returns intersection information if hit
  7489. */
  7490. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  7491. /**
  7492. * Checks if ray intersects a plane
  7493. * @param plane the plane to check
  7494. * @returns the distance away it was hit
  7495. */
  7496. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  7497. /**
  7498. * Checks if ray intersects a mesh
  7499. * @param mesh the mesh to check
  7500. * @param fastCheck if only the bounding box should checked
  7501. * @returns picking info of the intersecton
  7502. */
  7503. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  7504. /**
  7505. * Checks if ray intersects a mesh
  7506. * @param meshes the meshes to check
  7507. * @param fastCheck if only the bounding box should checked
  7508. * @param results array to store result in
  7509. * @returns Array of picking infos
  7510. */
  7511. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  7512. private _comparePickingInfo;
  7513. private static smallnum;
  7514. private static rayl;
  7515. /**
  7516. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  7517. * @param sega the first point of the segment to test the intersection against
  7518. * @param segb the second point of the segment to test the intersection against
  7519. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  7520. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  7521. */
  7522. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  7523. /**
  7524. * Update the ray from viewport position
  7525. * @param x position
  7526. * @param y y position
  7527. * @param viewportWidth viewport width
  7528. * @param viewportHeight viewport height
  7529. * @param world world matrix
  7530. * @param view view matrix
  7531. * @param projection projection matrix
  7532. * @returns this ray updated
  7533. */
  7534. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7535. /**
  7536. * Creates a ray with origin and direction of 0,0,0
  7537. * @returns the new ray
  7538. */
  7539. static Zero(): Ray;
  7540. /**
  7541. * Creates a new ray from screen space and viewport
  7542. * @param x position
  7543. * @param y y position
  7544. * @param viewportWidth viewport width
  7545. * @param viewportHeight viewport height
  7546. * @param world world matrix
  7547. * @param view view matrix
  7548. * @param projection projection matrix
  7549. * @returns new ray
  7550. */
  7551. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  7552. /**
  7553. * 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
  7554. * transformed to the given world matrix.
  7555. * @param origin The origin point
  7556. * @param end The end point
  7557. * @param world a matrix to transform the ray to. Default is the identity matrix.
  7558. * @returns the new ray
  7559. */
  7560. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  7561. /**
  7562. * Transforms a ray by a matrix
  7563. * @param ray ray to transform
  7564. * @param matrix matrix to apply
  7565. * @returns the resulting new ray
  7566. */
  7567. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  7568. /**
  7569. * Transforms a ray by a matrix
  7570. * @param ray ray to transform
  7571. * @param matrix matrix to apply
  7572. * @param result ray to store result in
  7573. */
  7574. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  7575. }
  7576. }
  7577. declare module BABYLON {
  7578. /**
  7579. * This represents an orbital type of camera.
  7580. *
  7581. * 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.
  7582. * 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.
  7583. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  7584. */
  7585. class ArcRotateCamera extends TargetCamera {
  7586. /**
  7587. * Defines the rotation angle of the camera along the longitudinal axis.
  7588. */
  7589. alpha: number;
  7590. /**
  7591. * Defines the rotation angle of the camera along the latitudinal axis.
  7592. */
  7593. beta: number;
  7594. /**
  7595. * Defines the radius of the camera from it s target point.
  7596. */
  7597. radius: number;
  7598. protected _target: Vector3;
  7599. protected _targetHost: Nullable<AbstractMesh>;
  7600. /**
  7601. * Defines the target point of the camera.
  7602. * The camera looks towards it form the radius distance.
  7603. */
  7604. target: Vector3;
  7605. /**
  7606. * Current inertia value on the longitudinal axis.
  7607. * The bigger this number the longer it will take for the camera to stop.
  7608. */
  7609. inertialAlphaOffset: number;
  7610. /**
  7611. * Current inertia value on the latitudinal axis.
  7612. * The bigger this number the longer it will take for the camera to stop.
  7613. */
  7614. inertialBetaOffset: number;
  7615. /**
  7616. * Current inertia value on the radius axis.
  7617. * The bigger this number the longer it will take for the camera to stop.
  7618. */
  7619. inertialRadiusOffset: number;
  7620. /**
  7621. * Minimum allowed angle on the longitudinal axis.
  7622. * This can help limiting how the Camera is able to move in the scene.
  7623. */
  7624. lowerAlphaLimit: Nullable<number>;
  7625. /**
  7626. * Maximum allowed angle on the longitudinal axis.
  7627. * This can help limiting how the Camera is able to move in the scene.
  7628. */
  7629. upperAlphaLimit: Nullable<number>;
  7630. /**
  7631. * Minimum allowed angle on the latitudinal axis.
  7632. * This can help limiting how the Camera is able to move in the scene.
  7633. */
  7634. lowerBetaLimit: number;
  7635. /**
  7636. * Maximum allowed angle on the latitudinal axis.
  7637. * This can help limiting how the Camera is able to move in the scene.
  7638. */
  7639. upperBetaLimit: number;
  7640. /**
  7641. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  7642. * This can help limiting how the Camera is able to move in the scene.
  7643. */
  7644. lowerRadiusLimit: Nullable<number>;
  7645. /**
  7646. * Maximum allowed distance of the camera to the target (The camera can not get further).
  7647. * This can help limiting how the Camera is able to move in the scene.
  7648. */
  7649. upperRadiusLimit: Nullable<number>;
  7650. /**
  7651. * Defines the current inertia value used during panning of the camera along the X axis.
  7652. */
  7653. inertialPanningX: number;
  7654. /**
  7655. * Defines the current inertia value used during panning of the camera along the Y axis.
  7656. */
  7657. inertialPanningY: number;
  7658. /**
  7659. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  7660. * Basically if your fingers moves away from more than this distance you will be considered
  7661. * in pinch mode.
  7662. */
  7663. pinchToPanMaxDistance: number;
  7664. /**
  7665. * Defines the maximum distance the camera can pan.
  7666. * This could help keeping the cammera always in your scene.
  7667. */
  7668. panningDistanceLimit: Nullable<number>;
  7669. /**
  7670. * Defines the target of the camera before paning.
  7671. */
  7672. panningOriginTarget: Vector3;
  7673. /**
  7674. * Defines the value of the inertia used during panning.
  7675. * 0 would mean stop inertia and one would mean no decelleration at all.
  7676. */
  7677. panningInertia: number;
  7678. /**
  7679. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  7680. */
  7681. angularSensibilityX: number;
  7682. /**
  7683. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  7684. */
  7685. angularSensibilityY: number;
  7686. /**
  7687. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  7688. */
  7689. pinchPrecision: number;
  7690. /**
  7691. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  7692. * It will be used instead of pinchDeltaPrecision if different from 0.
  7693. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7694. */
  7695. pinchDeltaPercentage: number;
  7696. /**
  7697. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  7698. */
  7699. panningSensibility: number;
  7700. /**
  7701. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  7702. */
  7703. keysUp: number[];
  7704. /**
  7705. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  7706. */
  7707. keysDown: number[];
  7708. /**
  7709. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  7710. */
  7711. keysLeft: number[];
  7712. /**
  7713. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  7714. */
  7715. keysRight: number[];
  7716. /**
  7717. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  7718. */
  7719. wheelPrecision: number;
  7720. /**
  7721. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  7722. * It will be used instead of pinchDeltaPrecision if different from 0.
  7723. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  7724. */
  7725. wheelDeltaPercentage: number;
  7726. /**
  7727. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  7728. */
  7729. zoomOnFactor: number;
  7730. /**
  7731. * Defines a screen offset for the camera position.
  7732. */
  7733. targetScreenOffset: Vector2;
  7734. /**
  7735. * Allows the camera to be completely reversed.
  7736. * If false the camera can not arrive upside down.
  7737. */
  7738. allowUpsideDown: boolean;
  7739. /**
  7740. * Define if double tap/click is used to restore the previously saved state of the camera.
  7741. */
  7742. useInputToRestoreState: boolean;
  7743. /** @hidden */
  7744. _viewMatrix: Matrix;
  7745. /** @hidden */
  7746. _useCtrlForPanning: boolean;
  7747. /** @hidden */
  7748. _panningMouseButton: number;
  7749. /**
  7750. * Defines the inpute associated to the camera.
  7751. */
  7752. inputs: ArcRotateCameraInputsManager;
  7753. /** @hidden */
  7754. _reset: () => void;
  7755. /**
  7756. * Defines the allowed panning axis.
  7757. */
  7758. panningAxis: Vector3;
  7759. protected _localDirection: Vector3;
  7760. protected _transformedDirection: Vector3;
  7761. private _bouncingBehavior;
  7762. /**
  7763. * Gets the bouncing behavior of the camera if it has been enabled.
  7764. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7765. */
  7766. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  7767. /**
  7768. * Defines if the bouncing behavior of the camera is enabled on the camera.
  7769. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7770. */
  7771. useBouncingBehavior: boolean;
  7772. private _framingBehavior;
  7773. /**
  7774. * Gets the framing behavior of the camera if it has been enabled.
  7775. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7776. */
  7777. readonly framingBehavior: Nullable<FramingBehavior>;
  7778. /**
  7779. * Defines if the framing behavior of the camera is enabled on the camera.
  7780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  7781. */
  7782. useFramingBehavior: boolean;
  7783. private _autoRotationBehavior;
  7784. /**
  7785. * Gets the auto rotation behavior of the camera if it has been enabled.
  7786. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7787. */
  7788. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  7789. /**
  7790. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  7791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7792. */
  7793. useAutoRotationBehavior: boolean;
  7794. /**
  7795. * Observable triggered when the mesh target has been changed on the camera.
  7796. */
  7797. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  7798. /**
  7799. * Event raised when the camera is colliding with a mesh.
  7800. */
  7801. onCollide: (collidedMesh: AbstractMesh) => void;
  7802. /**
  7803. * Defines whether the camera should check collision with the objects oh the scene.
  7804. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  7805. */
  7806. checkCollisions: boolean;
  7807. /**
  7808. * Defines the collision radius of the camera.
  7809. * This simulates a sphere around the camera.
  7810. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  7811. */
  7812. collisionRadius: Vector3;
  7813. protected _collider: Collider;
  7814. protected _previousPosition: Vector3;
  7815. protected _collisionVelocity: Vector3;
  7816. protected _newPosition: Vector3;
  7817. protected _previousAlpha: number;
  7818. protected _previousBeta: number;
  7819. protected _previousRadius: number;
  7820. protected _collisionTriggered: boolean;
  7821. protected _targetBoundingCenter: Nullable<Vector3>;
  7822. private _computationVector;
  7823. /**
  7824. * Instantiates a new ArcRotateCamera in a given scene
  7825. * @param name Defines the name of the camera
  7826. * @param alpha Defines the camera rotation along the logitudinal axis
  7827. * @param beta Defines the camera rotation along the latitudinal axis
  7828. * @param radius Defines the camera distance from its target
  7829. * @param target Defines the camera target
  7830. * @param scene Defines the scene the camera belongs to
  7831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7832. */
  7833. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7834. /** @hidden */
  7835. _initCache(): void;
  7836. /** @hidden */
  7837. _updateCache(ignoreParentClass?: boolean): void;
  7838. protected _getTargetPosition(): Vector3;
  7839. private _storedAlpha;
  7840. private _storedBeta;
  7841. private _storedRadius;
  7842. private _storedTarget;
  7843. /**
  7844. * Stores the current state of the camera (alpha, beta, radius and target)
  7845. * @returns the camera itself
  7846. */
  7847. storeState(): Camera;
  7848. /**
  7849. * @hidden
  7850. * Restored camera state. You must call storeState() first
  7851. */
  7852. _restoreStateValues(): boolean;
  7853. /** @hidden */
  7854. _isSynchronizedViewMatrix(): boolean;
  7855. /**
  7856. * Attached controls to the current camera.
  7857. * @param element Defines the element the controls should be listened from
  7858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7859. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  7860. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  7861. */
  7862. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  7863. /**
  7864. * Detach the current controls from the camera.
  7865. * The camera will stop reacting to inputs.
  7866. * @param element Defines the element to stop listening the inputs from
  7867. */
  7868. detachControl(element: HTMLElement): void;
  7869. /** @hidden */
  7870. _checkInputs(): void;
  7871. protected _checkLimits(): void;
  7872. /**
  7873. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  7874. */
  7875. rebuildAnglesAndRadius(): void;
  7876. /**
  7877. * Use a position to define the current camera related information like aplha, beta and radius
  7878. * @param position Defines the position to set the camera at
  7879. */
  7880. setPosition(position: Vector3): void;
  7881. /**
  7882. * Defines the target the camera should look at.
  7883. * This will automatically adapt alpha beta and radius to fit within the new target.
  7884. * @param target Defines the new target as a Vector or a mesh
  7885. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  7886. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  7887. */
  7888. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  7889. /** @hidden */
  7890. _getViewMatrix(): Matrix;
  7891. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  7892. /**
  7893. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  7894. * @param meshes Defines the mesh to zoom on
  7895. * @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)
  7896. */
  7897. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  7898. /**
  7899. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  7900. * The target will be changed but the radius
  7901. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  7902. * @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)
  7903. */
  7904. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  7905. min: Vector3;
  7906. max: Vector3;
  7907. distance: number;
  7908. }, doNotUpdateMaxZ?: boolean): void;
  7909. /**
  7910. * @override
  7911. * Override Camera.createRigCamera
  7912. */
  7913. createRigCamera(name: string, cameraIndex: number): Camera;
  7914. /**
  7915. * @hidden
  7916. * @override
  7917. * Override Camera._updateRigCameras
  7918. */
  7919. _updateRigCameras(): void;
  7920. /**
  7921. * Destroy the camera and release the current resources hold by it.
  7922. */
  7923. dispose(): void;
  7924. /**
  7925. * Gets the current object class name.
  7926. * @return the class name
  7927. */
  7928. getClassName(): string;
  7929. }
  7930. }
  7931. declare module BABYLON {
  7932. /**
  7933. * Default Inputs manager for the ArcRotateCamera.
  7934. * It groups all the default supported inputs for ease of use.
  7935. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7936. */
  7937. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  7938. /**
  7939. * Instantiates a new ArcRotateCameraInputsManager.
  7940. * @param camera Defines the camera the inputs belong to
  7941. */
  7942. constructor(camera: ArcRotateCamera);
  7943. /**
  7944. * Add mouse wheel input support to the input manager.
  7945. * @returns the current input manager
  7946. */
  7947. addMouseWheel(): ArcRotateCameraInputsManager;
  7948. /**
  7949. * Add pointers input support to the input manager.
  7950. * @returns the current input manager
  7951. */
  7952. addPointers(): ArcRotateCameraInputsManager;
  7953. /**
  7954. * Add keyboard input support to the input manager.
  7955. * @returns the current input manager
  7956. */
  7957. addKeyboard(): ArcRotateCameraInputsManager;
  7958. /**
  7959. * Add orientation input support to the input manager.
  7960. * @returns the current input manager
  7961. */
  7962. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  7963. }
  7964. }
  7965. declare module BABYLON {
  7966. /**
  7967. * This is the base class of all the camera used in the application.
  7968. * @see http://doc.babylonjs.com/features/cameras
  7969. */
  7970. class Camera extends Node {
  7971. /**
  7972. * This is the default projection mode used by the cameras.
  7973. * It helps recreating a feeling of perspective and better appreciate depth.
  7974. * This is the best way to simulate real life cameras.
  7975. */
  7976. static readonly PERSPECTIVE_CAMERA: number;
  7977. /**
  7978. * This helps creating camera with an orthographic mode.
  7979. * 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.
  7980. */
  7981. static readonly ORTHOGRAPHIC_CAMERA: number;
  7982. /**
  7983. * This is the default FOV mode for perspective cameras.
  7984. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  7985. */
  7986. static readonly FOVMODE_VERTICAL_FIXED: number;
  7987. /**
  7988. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  7989. */
  7990. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  7991. /**
  7992. * This specifies ther is no need for a camera rig.
  7993. * Basically only one eye is rendered corresponding to the camera.
  7994. */
  7995. static readonly RIG_MODE_NONE: number;
  7996. /**
  7997. * Simulates a camera Rig with one blue eye and one red eye.
  7998. * This can be use with 3d blue and red glasses.
  7999. */
  8000. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  8001. /**
  8002. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  8003. */
  8004. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  8005. /**
  8006. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  8007. */
  8008. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  8009. /**
  8010. * Defines that both eyes of the camera will be rendered over under each other.
  8011. */
  8012. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  8013. /**
  8014. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  8015. */
  8016. static readonly RIG_MODE_VR: number;
  8017. /**
  8018. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  8019. */
  8020. static readonly RIG_MODE_WEBVR: number;
  8021. /**
  8022. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  8023. */
  8024. static readonly RIG_MODE_CUSTOM: number;
  8025. /**
  8026. * Defines if by default attaching controls should prevent the default javascript event to continue.
  8027. */
  8028. static ForceAttachControlToAlwaysPreventDefault: boolean;
  8029. /**
  8030. * @hidden
  8031. * Might be removed once multiview will be a thing
  8032. */
  8033. static UseAlternateWebVRRendering: boolean;
  8034. /**
  8035. * Define the input manager associated with the camera.
  8036. */
  8037. inputs: CameraInputsManager<Camera>;
  8038. /**
  8039. * Define the current local position of the camera in the scene
  8040. */
  8041. position: Vector3;
  8042. /**
  8043. * The vector the camera should consider as up.
  8044. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  8045. */
  8046. upVector: Vector3;
  8047. /**
  8048. * Define the current limit on the left side for an orthographic camera
  8049. * In scene unit
  8050. */
  8051. orthoLeft: Nullable<number>;
  8052. /**
  8053. * Define the current limit on the right side for an orthographic camera
  8054. * In scene unit
  8055. */
  8056. orthoRight: Nullable<number>;
  8057. /**
  8058. * Define the current limit on the bottom side for an orthographic camera
  8059. * In scene unit
  8060. */
  8061. orthoBottom: Nullable<number>;
  8062. /**
  8063. * Define the current limit on the top side for an orthographic camera
  8064. * In scene unit
  8065. */
  8066. orthoTop: Nullable<number>;
  8067. /**
  8068. * Field Of View is set in Radians. (default is 0.8)
  8069. */
  8070. fov: number;
  8071. /**
  8072. * Define the minimum distance the camera can see from.
  8073. * This is important to note that the depth buffer are not infinite and the closer it starts
  8074. * the more your scene might encounter depth fighting issue.
  8075. */
  8076. minZ: number;
  8077. /**
  8078. * Define the maximum distance the camera can see to.
  8079. * This is important to note that the depth buffer are not infinite and the further it end
  8080. * the more your scene might encounter depth fighting issue.
  8081. */
  8082. maxZ: number;
  8083. /**
  8084. * Define the default inertia of the camera.
  8085. * This helps giving a smooth feeling to the camera movement.
  8086. */
  8087. inertia: number;
  8088. /**
  8089. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  8090. */
  8091. mode: number;
  8092. /**
  8093. * Define wether the camera is intermediate.
  8094. * This is usefull to not present the output directly to the screen in case of rig without post process for instance
  8095. */
  8096. isIntermediate: boolean;
  8097. /**
  8098. * Define the viewport of the camera.
  8099. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  8100. */
  8101. viewport: Viewport;
  8102. /**
  8103. * Restricts the camera to viewing objects with the same layerMask.
  8104. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  8105. */
  8106. layerMask: number;
  8107. /**
  8108. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  8109. */
  8110. fovMode: number;
  8111. /**
  8112. * Rig mode of the camera.
  8113. * This is usefull to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  8114. * This is normally controlled byt the camera themselves as internal use.
  8115. */
  8116. cameraRigMode: number;
  8117. /**
  8118. * Defines the distance between both "eyes" in case of a RIG
  8119. */
  8120. interaxialDistance: number;
  8121. /**
  8122. * Defines if stereoscopic rendering is done side by side or over under.
  8123. */
  8124. isStereoscopicSideBySide: boolean;
  8125. /**
  8126. * 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
  8127. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  8128. * else in the scene.
  8129. */
  8130. customRenderTargets: RenderTargetTexture[];
  8131. /**
  8132. * When set, the camera will render to this render target instead of the default canvas
  8133. */
  8134. outputRenderTarget: Nullable<RenderTargetTexture>;
  8135. /**
  8136. * Observable triggered when the camera view matrix has changed.
  8137. */
  8138. onViewMatrixChangedObservable: Observable<Camera>;
  8139. /**
  8140. * Observable triggered when the camera Projection matrix has changed.
  8141. */
  8142. onProjectionMatrixChangedObservable: Observable<Camera>;
  8143. /**
  8144. * Observable triggered when the inputs have been processed.
  8145. */
  8146. onAfterCheckInputsObservable: Observable<Camera>;
  8147. /**
  8148. * Observable triggered when reset has been called and applied to the camera.
  8149. */
  8150. onRestoreStateObservable: Observable<Camera>;
  8151. /** @hidden */
  8152. _cameraRigParams: any;
  8153. /** @hidden */
  8154. _rigCameras: Camera[];
  8155. /** @hidden */
  8156. _rigPostProcess: Nullable<PostProcess>;
  8157. protected _webvrViewMatrix: Matrix;
  8158. /** @hidden */
  8159. _skipRendering: boolean;
  8160. /** @hidden */
  8161. _alternateCamera: Camera;
  8162. /** @hidden */
  8163. _projectionMatrix: Matrix;
  8164. /** @hidden */
  8165. _postProcesses: Nullable<PostProcess>[];
  8166. /** @hidden */
  8167. _activeMeshes: SmartArray<AbstractMesh>;
  8168. protected _globalPosition: Vector3;
  8169. /** hidden */
  8170. _computedViewMatrix: Matrix;
  8171. private _doNotComputeProjectionMatrix;
  8172. private _transformMatrix;
  8173. private _frustumPlanes;
  8174. private _refreshFrustumPlanes;
  8175. private _storedFov;
  8176. private _stateStored;
  8177. /**
  8178. * Instantiates a new camera object.
  8179. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  8180. * @see http://doc.babylonjs.com/features/cameras
  8181. * @param name Defines the name of the camera in the scene
  8182. * @param position Defines the position of the camera
  8183. * @param scene Defines the scene the camera belongs too
  8184. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  8185. */
  8186. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8187. /**
  8188. * Store current camera state (fov, position, etc..)
  8189. * @returns the camera
  8190. */
  8191. storeState(): Camera;
  8192. /**
  8193. * Restores the camera state values if it has been stored. You must call storeState() first
  8194. */
  8195. protected _restoreStateValues(): boolean;
  8196. /**
  8197. * Restored camera state. You must call storeState() first.
  8198. * @returns true if restored and false otherwise
  8199. */
  8200. restoreState(): boolean;
  8201. /**
  8202. * Gets the class name of the camera.
  8203. * @returns the class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Gets a string representation of the camera usefull for debug purpose.
  8208. * @param fullDetails Defines that a more verboe level of logging is required
  8209. * @returns the string representation
  8210. */
  8211. toString(fullDetails?: boolean): string;
  8212. /**
  8213. * Gets the current world space position of the camera.
  8214. */
  8215. readonly globalPosition: Vector3;
  8216. /**
  8217. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  8218. * @returns the active meshe list
  8219. */
  8220. getActiveMeshes(): SmartArray<AbstractMesh>;
  8221. /**
  8222. * Check wether a mesh is part of the current active mesh list of the camera
  8223. * @param mesh Defines the mesh to check
  8224. * @returns true if active, false otherwise
  8225. */
  8226. isActiveMesh(mesh: Mesh): boolean;
  8227. /**
  8228. * Is this camera ready to be used/rendered
  8229. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  8230. * @return true if the camera is ready
  8231. */
  8232. isReady(completeCheck?: boolean): boolean;
  8233. /** @hidden */
  8234. _initCache(): void;
  8235. /** @hidden */
  8236. _updateCache(ignoreParentClass?: boolean): void;
  8237. /** @hidden */
  8238. _isSynchronized(): boolean;
  8239. /** @hidden */
  8240. _isSynchronizedViewMatrix(): boolean;
  8241. /** @hidden */
  8242. _isSynchronizedProjectionMatrix(): boolean;
  8243. /**
  8244. * Attach the input controls to a specific dom element to get the input from.
  8245. * @param element Defines the element the controls should be listened from
  8246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8247. */
  8248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8249. /**
  8250. * Detach the current controls from the specified dom element.
  8251. * @param element Defines the element to stop listening the inputs from
  8252. */
  8253. detachControl(element: HTMLElement): void;
  8254. /**
  8255. * Update the camera state according to the different inputs gathered during the frame.
  8256. */
  8257. update(): void;
  8258. /** @hidden */
  8259. _checkInputs(): void;
  8260. /** @hidden */
  8261. readonly rigCameras: Camera[];
  8262. /**
  8263. * Gets the post process used by the rig cameras
  8264. */
  8265. readonly rigPostProcess: Nullable<PostProcess>;
  8266. /**
  8267. * Internal, gets the first post proces.
  8268. * @returns the first post process to be run on this camera.
  8269. */
  8270. _getFirstPostProcess(): Nullable<PostProcess>;
  8271. private _cascadePostProcessesToRigCams;
  8272. /**
  8273. * Attach a post process to the camera.
  8274. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8275. * @param postProcess The post process to attach to the camera
  8276. * @param insertAt The position of the post process in case several of them are in use in the scene
  8277. * @returns the position the post process has been inserted at
  8278. */
  8279. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  8280. /**
  8281. * Detach a post process to the camera.
  8282. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  8283. * @param postProcess The post process to detach from the camera
  8284. */
  8285. detachPostProcess(postProcess: PostProcess): void;
  8286. /**
  8287. * Gets the current world matrix of the camera
  8288. */
  8289. getWorldMatrix(): Matrix;
  8290. /** @hidden */
  8291. protected _getViewMatrix(): Matrix;
  8292. /**
  8293. * Gets the current view matrix of the camera.
  8294. * @param force forces the camera to recompute the matrix without looking at the cached state
  8295. * @returns the view matrix
  8296. */
  8297. getViewMatrix(force?: boolean): Matrix;
  8298. /**
  8299. * Freeze the projection matrix.
  8300. * It will prevent the cache check of the camera projection compute and can speed up perf
  8301. * if no parameter of the camera are meant to change
  8302. * @param projection Defines manually a projection if necessary
  8303. */
  8304. freezeProjectionMatrix(projection?: Matrix): void;
  8305. /**
  8306. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  8307. */
  8308. unfreezeProjectionMatrix(): void;
  8309. /**
  8310. * Gets the current projection matrix of the camera.
  8311. * @param force forces the camera to recompute the matrix without looking at the cached state
  8312. * @returns the projection matrix
  8313. */
  8314. getProjectionMatrix(force?: boolean): Matrix;
  8315. /**
  8316. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  8317. * @returns a Matrix
  8318. */
  8319. getTransformationMatrix(): Matrix;
  8320. private _updateFrustumPlanes;
  8321. /**
  8322. * Checks if a cullable object (mesh...) is in the camera frustum
  8323. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  8324. * @param target The object to check
  8325. * @returns true if the object is in frustum otherwise false
  8326. */
  8327. isInFrustum(target: ICullable): boolean;
  8328. /**
  8329. * Checks if a cullable object (mesh...) is in the camera frustum
  8330. * Unlike isInFrustum this cheks the full bounding box
  8331. * @param target The object to check
  8332. * @returns true if the object is in frustum otherwise false
  8333. */
  8334. isCompletelyInFrustum(target: ICullable): boolean;
  8335. /**
  8336. * Gets a ray in the forward direction from the camera.
  8337. * @param length Defines the length of the ray to create
  8338. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  8339. * @param origin Defines the start point of the ray which defaults to the camera position
  8340. * @returns the forward ray
  8341. */
  8342. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  8343. /**
  8344. * Releases resources associated with this node.
  8345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8347. */
  8348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8349. /**
  8350. * Gets the left camera of a rig setup in case of Rigged Camera
  8351. */
  8352. readonly leftCamera: Nullable<FreeCamera>;
  8353. /**
  8354. * Gets the right camera of a rig setup in case of Rigged Camera
  8355. */
  8356. readonly rightCamera: Nullable<FreeCamera>;
  8357. /**
  8358. * Gets the left camera target of a rig setup in case of Rigged Camera
  8359. * @returns the target position
  8360. */
  8361. getLeftTarget(): Nullable<Vector3>;
  8362. /**
  8363. * Gets the right camera target of a rig setup in case of Rigged Camera
  8364. * @returns the target position
  8365. */
  8366. getRightTarget(): Nullable<Vector3>;
  8367. /**
  8368. * @hidden
  8369. */
  8370. setCameraRigMode(mode: number, rigParams: any): void;
  8371. private _getVRProjectionMatrix;
  8372. protected _updateCameraRotationMatrix(): void;
  8373. protected _updateWebVRCameraRotationMatrix(): void;
  8374. /**
  8375. * This function MUST be overwritten by the different WebVR cameras available.
  8376. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8377. */
  8378. protected _getWebVRProjectionMatrix(): Matrix;
  8379. /**
  8380. * This function MUST be overwritten by the different WebVR cameras available.
  8381. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  8382. */
  8383. protected _getWebVRViewMatrix(): Matrix;
  8384. /** @hidden */
  8385. setCameraRigParameter(name: string, value: any): void;
  8386. /**
  8387. * needs to be overridden by children so sub has required properties to be copied
  8388. * @hidden
  8389. */
  8390. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8391. /**
  8392. * May need to be overridden by children
  8393. * @hidden
  8394. */
  8395. _updateRigCameras(): void;
  8396. /** @hidden */
  8397. _setupInputs(): void;
  8398. /**
  8399. * Serialiaze the camera setup to a json represention
  8400. * @returns the JSON representation
  8401. */
  8402. serialize(): any;
  8403. /**
  8404. * Clones the current camera.
  8405. * @param name The cloned camera name
  8406. * @returns the cloned camera
  8407. */
  8408. clone(name: string): Camera;
  8409. /**
  8410. * Gets the direction of the camera relative to a given local axis.
  8411. * @param localAxis Defines the reference axis to provide a relative direction.
  8412. * @return the direction
  8413. */
  8414. getDirection(localAxis: Vector3): Vector3;
  8415. /**
  8416. * Gets the direction of the camera relative to a given local axis into a passed vector.
  8417. * @param localAxis Defines the reference axis to provide a relative direction.
  8418. * @param result Defines the vector to store the result in
  8419. */
  8420. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  8421. /**
  8422. * Gets a camera constructor for a given camera type
  8423. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  8424. * @param name The name of the camera the result will be able to instantiate
  8425. * @param scene The scene the result will construct the camera in
  8426. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  8427. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  8428. * @returns a factory method to construc the camera
  8429. */
  8430. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  8431. /**
  8432. * Compute the world matrix of the camera.
  8433. * @returns the camera workd matrix
  8434. */
  8435. computeWorldMatrix(): Matrix;
  8436. /**
  8437. * Parse a JSON and creates the camera from the parsed information
  8438. * @param parsedCamera The JSON to parse
  8439. * @param scene The scene to instantiate the camera in
  8440. * @returns the newly constructed camera
  8441. */
  8442. static Parse(parsedCamera: any, scene: Scene): Camera;
  8443. }
  8444. }
  8445. declare module BABYLON {
  8446. /**
  8447. * @ignore
  8448. * This is a list of all the different input types that are available in the application.
  8449. * Fo instance: ArcRotateCameraGamepadInput...
  8450. */
  8451. var CameraInputTypes: {};
  8452. /**
  8453. * This is the contract to implement in order to create a new input class.
  8454. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8455. */
  8456. interface ICameraInput<TCamera extends Camera> {
  8457. /**
  8458. * Defines the camera the input is attached to.
  8459. */
  8460. camera: Nullable<TCamera>;
  8461. /**
  8462. * Gets the class name of the current intput.
  8463. * @returns the class name
  8464. */
  8465. getClassName(): string;
  8466. /**
  8467. * Get the friendly name associated with the input class.
  8468. * @returns the input friendly name
  8469. */
  8470. getSimpleName(): string;
  8471. /**
  8472. * Attach the input controls to a specific dom element to get the input from.
  8473. * @param element Defines the element the controls should be listened from
  8474. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8475. */
  8476. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8477. /**
  8478. * Detach the current controls from the specified dom element.
  8479. * @param element Defines the element to stop listening the inputs from
  8480. */
  8481. detachControl(element: Nullable<HTMLElement>): void;
  8482. /**
  8483. * Update the current camera state depending on the inputs that have been used this frame.
  8484. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8485. */
  8486. checkInputs?: () => void;
  8487. }
  8488. /**
  8489. * Represents a map of input types to input instance or input index to input instance.
  8490. */
  8491. interface CameraInputsMap<TCamera extends Camera> {
  8492. /**
  8493. * Accessor to the input by input type.
  8494. */
  8495. [name: string]: ICameraInput<TCamera>;
  8496. /**
  8497. * Accessor to the input by input index.
  8498. */
  8499. [idx: number]: ICameraInput<TCamera>;
  8500. }
  8501. /**
  8502. * This represents the input manager used within a camera.
  8503. * It helps dealing with all the different kind of input attached to a camera.
  8504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8505. */
  8506. class CameraInputsManager<TCamera extends Camera> {
  8507. /**
  8508. * Defines the list of inputs attahed to the camera.
  8509. */
  8510. attached: CameraInputsMap<TCamera>;
  8511. /**
  8512. * Defines the dom element the camera is collecting inputs from.
  8513. * This is null if the controls have not been attached.
  8514. */
  8515. attachedElement: Nullable<HTMLElement>;
  8516. /**
  8517. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8518. */
  8519. noPreventDefault: boolean;
  8520. /**
  8521. * Defined the camera the input manager belongs to.
  8522. */
  8523. camera: TCamera;
  8524. /**
  8525. * Update the current camera state depending on the inputs that have been used this frame.
  8526. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8527. */
  8528. checkInputs: () => void;
  8529. /**
  8530. * Instantiate a new Camera Input Manager.
  8531. * @param camera Defines the camera the input manager blongs to
  8532. */
  8533. constructor(camera: TCamera);
  8534. /**
  8535. * Add an input method to a camera
  8536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8537. * @param input camera input method
  8538. */
  8539. add(input: ICameraInput<TCamera>): void;
  8540. /**
  8541. * Remove a specific input method from a camera
  8542. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8543. * @param inputToRemove camera input method
  8544. */
  8545. remove(inputToRemove: ICameraInput<TCamera>): void;
  8546. /**
  8547. * Remove a specific input type from a camera
  8548. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8549. * @param inputType the type of the input to remove
  8550. */
  8551. removeByType(inputType: string): void;
  8552. private _addCheckInputs;
  8553. /**
  8554. * Attach the input controls to the currently attached dom element to listen the events from.
  8555. * @param input Defines the input to attach
  8556. */
  8557. attachInput(input: ICameraInput<TCamera>): void;
  8558. /**
  8559. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8560. * @param element Defines the dom element to collect the events from
  8561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8562. */
  8563. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8564. /**
  8565. * Detach the current manager inputs controls from a specific dom element.
  8566. * @param element Defines the dom element to collect the events from
  8567. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8568. */
  8569. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8570. /**
  8571. * Rebuild the dynamic inputCheck function from the current list of
  8572. * defined inputs in the manager.
  8573. */
  8574. rebuildInputCheck(): void;
  8575. /**
  8576. * Remove all attached input methods from a camera
  8577. */
  8578. clear(): void;
  8579. /**
  8580. * Serialize the current input manager attached to a camera.
  8581. * This ensures than once parsed,
  8582. * the input associated to the camera will be identical to the current ones
  8583. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8584. */
  8585. serialize(serializedCamera: any): void;
  8586. /**
  8587. * Parses an input manager serialized JSON to restore the previous list of inputs
  8588. * and states associated to a camera.
  8589. * @param parsedCamera Defines the JSON to parse
  8590. */
  8591. parse(parsedCamera: any): void;
  8592. }
  8593. }
  8594. declare module BABYLON {
  8595. /**
  8596. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  8597. * being tilted forward or back and left or right.
  8598. */
  8599. class DeviceOrientationCamera extends FreeCamera {
  8600. private _initialQuaternion;
  8601. private _quaternionCache;
  8602. /**
  8603. * Creates a new device orientation camera
  8604. * @param name The name of the camera
  8605. * @param position The start position camera
  8606. * @param scene The scene the camera belongs to
  8607. */
  8608. constructor(name: string, position: Vector3, scene: Scene);
  8609. /**
  8610. * Gets the current instance class name ("DeviceOrientationCamera").
  8611. * This helps avoiding instanceof at run time.
  8612. * @returns the class name
  8613. */
  8614. getClassName(): string;
  8615. /**
  8616. * @hidden
  8617. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  8618. */
  8619. _checkInputs(): void;
  8620. /**
  8621. * Reset the camera to its default orientation on the specified axis only.
  8622. * @param axis The axis to reset
  8623. */
  8624. resetToCurrentRotation(axis?: Axis): void;
  8625. }
  8626. }
  8627. declare module BABYLON {
  8628. /**
  8629. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8630. * such as in a 3D Space Shooter or a Flight Simulator.
  8631. */
  8632. class FlyCamera extends TargetCamera {
  8633. /**
  8634. * Define the collision ellipsoid of the camera.
  8635. * This is helpful for simulating a camera body, like a player's body.
  8636. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8637. */
  8638. ellipsoid: Vector3;
  8639. /**
  8640. * Define an offset for the position of the ellipsoid around the camera.
  8641. * This can be helpful if the camera is attached away from the player's body center,
  8642. * such as at its head.
  8643. */
  8644. ellipsoidOffset: Vector3;
  8645. /**
  8646. * Enable or disable collisions of the camera with the rest of the scene objects.
  8647. */
  8648. checkCollisions: boolean;
  8649. /**
  8650. * Enable or disable gravity on the camera.
  8651. */
  8652. applyGravity: boolean;
  8653. /**
  8654. * Define the current direction the camera is moving to.
  8655. */
  8656. cameraDirection: Vector3;
  8657. /**
  8658. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  8659. * This overrides and empties cameraRotation.
  8660. */
  8661. rotationQuaternion: BABYLON.Quaternion;
  8662. /**
  8663. * Track Roll to maintain the wanted Rolling when looking around.
  8664. */
  8665. _trackRoll: number;
  8666. /**
  8667. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  8668. */
  8669. rollCorrect: number;
  8670. /**
  8671. * Mimic a banked turn, Rolling the camera when Yawing.
  8672. * It's recommended to use rollCorrect = 10 for faster banking correction.
  8673. */
  8674. bankedTurn: boolean;
  8675. /**
  8676. * Limit in radians for how much Roll banking will add. (Default: 90°)
  8677. */
  8678. bankedTurnLimit: number;
  8679. /**
  8680. * Value of 0 disables the banked Roll.
  8681. * Value of 1 is equal to the Yaw angle in radians.
  8682. */
  8683. bankedTurnMultiplier: number;
  8684. /**
  8685. * The inputs manager loads all the input sources, such as keyboard and mouse.
  8686. */
  8687. inputs: FlyCameraInputsManager;
  8688. /**
  8689. * Gets the input sensibility for mouse input.
  8690. * Higher values reduce sensitivity.
  8691. */
  8692. /**
  8693. * Sets the input sensibility for a mouse input.
  8694. * Higher values reduce sensitivity.
  8695. */
  8696. angularSensibility: number;
  8697. /**
  8698. * Get the keys for camera movement forward.
  8699. */
  8700. /**
  8701. * Set the keys for camera movement forward.
  8702. */
  8703. keysForward: number[];
  8704. /**
  8705. * Get the keys for camera movement backward.
  8706. */
  8707. keysBackward: number[];
  8708. /**
  8709. * Get the keys for camera movement up.
  8710. */
  8711. /**
  8712. * Set the keys for camera movement up.
  8713. */
  8714. keysUp: number[];
  8715. /**
  8716. * Get the keys for camera movement down.
  8717. */
  8718. /**
  8719. * Set the keys for camera movement down.
  8720. */
  8721. keysDown: number[];
  8722. /**
  8723. * Get the keys for camera movement left.
  8724. */
  8725. /**
  8726. * Set the keys for camera movement left.
  8727. */
  8728. keysLeft: number[];
  8729. /**
  8730. * Set the keys for camera movement right.
  8731. */
  8732. /**
  8733. * Set the keys for camera movement right.
  8734. */
  8735. keysRight: number[];
  8736. /**
  8737. * Event raised when the camera collides with a mesh in the scene.
  8738. */
  8739. onCollide: (collidedMesh: AbstractMesh) => void;
  8740. private _collider;
  8741. private _needMoveForGravity;
  8742. private _oldPosition;
  8743. private _diffPosition;
  8744. private _newPosition;
  8745. /** @hidden */
  8746. _localDirection: Vector3;
  8747. /** @hidden */
  8748. _transformedDirection: Vector3;
  8749. /**
  8750. * Instantiates a FlyCamera.
  8751. * This is a flying camera, designed for 3D movement and rotation in all directions,
  8752. * such as in a 3D Space Shooter or a Flight Simulator.
  8753. * @param name Define the name of the camera in the scene.
  8754. * @param position Define the starting position of the camera in the scene.
  8755. * @param scene Define the scene the camera belongs to.
  8756. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  8757. */
  8758. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8759. /**
  8760. * Attach a control to the HTML DOM element.
  8761. * @param element Defines the element that listens to the input events.
  8762. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  8763. */
  8764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8765. /**
  8766. * Detach a control from the HTML DOM element.
  8767. * The camera will stop reacting to that input.
  8768. * @param element Defines the element that listens to the input events.
  8769. */
  8770. detachControl(element: HTMLElement): void;
  8771. private _collisionMask;
  8772. /**
  8773. * Get the mask that the camera ignores in collision events.
  8774. */
  8775. /**
  8776. * Set the mask that the camera ignores in collision events.
  8777. */
  8778. collisionMask: number;
  8779. /** @hidden */
  8780. _collideWithWorld(displacement: Vector3): void;
  8781. /** @hidden */
  8782. private _onCollisionPositionChange;
  8783. /** @hidden */
  8784. _checkInputs(): void;
  8785. /** @hidden */
  8786. _decideIfNeedsToMove(): boolean;
  8787. /** @hidden */
  8788. _updatePosition(): void;
  8789. /**
  8790. * Restore the Roll to its target value at the rate specified.
  8791. * @param rate - Higher means slower restoring.
  8792. * @hidden
  8793. */
  8794. restoreRoll(rate: number): void;
  8795. /**
  8796. * Destroy the camera and release the current resources held by it.
  8797. */
  8798. dispose(): void;
  8799. /**
  8800. * Get the current object class name.
  8801. * @returns the class name.
  8802. */
  8803. getClassName(): string;
  8804. }
  8805. }
  8806. declare module BABYLON {
  8807. /**
  8808. * Default Inputs manager for the FlyCamera.
  8809. * It groups all the default supported inputs for ease of use.
  8810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8811. */
  8812. class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  8813. /**
  8814. * Instantiates a new FlyCameraInputsManager.
  8815. * @param camera Defines the camera the inputs belong to.
  8816. */
  8817. constructor(camera: FlyCamera);
  8818. /**
  8819. * Add keyboard input support to the input manager.
  8820. * @returns the new FlyCameraKeyboardMoveInput().
  8821. */
  8822. addKeyboard(): FlyCameraInputsManager;
  8823. /**
  8824. * Add mouse input support to the input manager.
  8825. * @param touchEnabled Enable touch screen support.
  8826. * @returns the new FlyCameraMouseInput().
  8827. */
  8828. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  8829. }
  8830. }
  8831. declare module BABYLON {
  8832. /**
  8833. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  8834. * an arc rotate version arcFollowCamera are available.
  8835. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8836. */
  8837. class FollowCamera extends TargetCamera {
  8838. /**
  8839. * Distance the follow camera should follow an object at
  8840. */
  8841. radius: number;
  8842. /**
  8843. * Define a rotation offset between the camera and the object it follows
  8844. */
  8845. rotationOffset: number;
  8846. /**
  8847. * Define a height offset between the camera and the object it follows.
  8848. * It can help following an object from the top (like a car chaing a plane)
  8849. */
  8850. heightOffset: number;
  8851. /**
  8852. * Define how fast the camera can accelerate to follow it s target.
  8853. */
  8854. cameraAcceleration: number;
  8855. /**
  8856. * Define the speed limit of the camera following an object.
  8857. */
  8858. maxCameraSpeed: number;
  8859. /**
  8860. * Define the target of the camera.
  8861. */
  8862. lockedTarget: Nullable<AbstractMesh>;
  8863. /**
  8864. * Instantiates the follow camera.
  8865. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8866. * @param name Define the name of the camera in the scene
  8867. * @param position Define the position of the camera
  8868. * @param scene Define the scene the camera belong to
  8869. * @param lockedTarget Define the target of the camera
  8870. */
  8871. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  8872. private _follow;
  8873. /** @hidden */
  8874. _checkInputs(): void;
  8875. /**
  8876. * Gets the camera class name.
  8877. * @returns the class name
  8878. */
  8879. getClassName(): string;
  8880. }
  8881. /**
  8882. * Arc Rotate version of the follow camera.
  8883. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  8884. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8885. */
  8886. class ArcFollowCamera extends TargetCamera {
  8887. /** The longitudinal angle of the camera */
  8888. alpha: number;
  8889. /** The latitudinal angle of the camera */
  8890. beta: number;
  8891. /** The radius of the camera from its target */
  8892. radius: number;
  8893. /** Define the camera target (the messh it should follow) */
  8894. target: Nullable<AbstractMesh>;
  8895. private _cartesianCoordinates;
  8896. /**
  8897. * Instantiates a new ArcFollowCamera
  8898. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  8899. * @param name Define the name of the camera
  8900. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  8901. * @param beta Define the rotation angle of the camera around the elevation axis
  8902. * @param radius Define the radius of the camera from its target point
  8903. * @param target Define the target of the camera
  8904. * @param scene Define the scene the camera belongs to
  8905. */
  8906. constructor(name: string,
  8907. /** The longitudinal angle of the camera */
  8908. alpha: number,
  8909. /** The latitudinal angle of the camera */
  8910. beta: number,
  8911. /** The radius of the camera from its target */
  8912. radius: number,
  8913. /** Define the camera target (the messh it should follow) */
  8914. target: Nullable<AbstractMesh>, scene: Scene);
  8915. private _follow;
  8916. /** @hidden */
  8917. _checkInputs(): void;
  8918. /**
  8919. * Returns the class name of the object.
  8920. * It is mostly used internally for serialization purposes.
  8921. */
  8922. getClassName(): string;
  8923. }
  8924. }
  8925. declare module BABYLON {
  8926. /**
  8927. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8928. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8929. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8930. */
  8931. class FreeCamera extends TargetCamera {
  8932. /**
  8933. * Define the collision ellipsoid of the camera.
  8934. * This is helpful to simulate a camera body like the player body around the camera
  8935. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8936. */
  8937. ellipsoid: Vector3;
  8938. /**
  8939. * Define an offset for the position of the ellipsoid around the camera.
  8940. * This can be helpful to determine the center of the body near the gravity center of the body
  8941. * instead of its head.
  8942. */
  8943. ellipsoidOffset: Vector3;
  8944. /**
  8945. * Enable or disable collisions of the camera with the rest of the scene objects.
  8946. */
  8947. checkCollisions: boolean;
  8948. /**
  8949. * Enable or disable gravity on the camera.
  8950. */
  8951. applyGravity: boolean;
  8952. /**
  8953. * Define the input manager associated to the camera.
  8954. */
  8955. inputs: FreeCameraInputsManager;
  8956. /**
  8957. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8958. * Higher values reduce sensitivity.
  8959. */
  8960. /**
  8961. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8962. * Higher values reduce sensitivity.
  8963. */
  8964. angularSensibility: number;
  8965. /**
  8966. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8967. */
  8968. keysUp: number[];
  8969. /**
  8970. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8971. */
  8972. keysDown: number[];
  8973. /**
  8974. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8975. */
  8976. keysLeft: number[];
  8977. /**
  8978. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8979. */
  8980. keysRight: number[];
  8981. /**
  8982. * Event raised when the camera collide with a mesh in the scene.
  8983. */
  8984. onCollide: (collidedMesh: AbstractMesh) => void;
  8985. private _collider;
  8986. private _needMoveForGravity;
  8987. private _oldPosition;
  8988. private _diffPosition;
  8989. private _newPosition;
  8990. /** @hidden */
  8991. _localDirection: Vector3;
  8992. /** @hidden */
  8993. _transformedDirection: Vector3;
  8994. /**
  8995. * Instantiates a Free Camera.
  8996. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  8997. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8998. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8999. * @param name Define the name of the camera in the scene
  9000. * @param position Define the start position of the camera in the scene
  9001. * @param scene Define the scene the camera belongs to
  9002. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9003. */
  9004. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9005. /**
  9006. * Attached controls to the current camera.
  9007. * @param element Defines the element the controls should be listened from
  9008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9009. */
  9010. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9011. /**
  9012. * Detach the current controls from the camera.
  9013. * The camera will stop reacting to inputs.
  9014. * @param element Defines the element to stop listening the inputs from
  9015. */
  9016. detachControl(element: HTMLElement): void;
  9017. private _collisionMask;
  9018. /**
  9019. * Define a collision mask to limit the list of object the camera can collide with
  9020. */
  9021. collisionMask: number;
  9022. /** @hidden */
  9023. _collideWithWorld(displacement: Vector3): void;
  9024. private _onCollisionPositionChange;
  9025. /** @hidden */
  9026. _checkInputs(): void;
  9027. /** @hidden */
  9028. _decideIfNeedsToMove(): boolean;
  9029. /** @hidden */
  9030. _updatePosition(): void;
  9031. /**
  9032. * Destroy the camera and release the current resources hold by it.
  9033. */
  9034. dispose(): void;
  9035. /**
  9036. * Gets the current object class name.
  9037. * @return the class name
  9038. */
  9039. getClassName(): string;
  9040. }
  9041. }
  9042. declare module BABYLON {
  9043. /**
  9044. * Default Inputs manager for the FreeCamera.
  9045. * It groups all the default supported inputs for ease of use.
  9046. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9047. */
  9048. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  9049. /**
  9050. * Instantiates a new FreeCameraInputsManager.
  9051. * @param camera Defines the camera the inputs belong to
  9052. */
  9053. constructor(camera: FreeCamera);
  9054. /**
  9055. * Add keyboard input support to the input manager.
  9056. * @returns the current input manager
  9057. */
  9058. addKeyboard(): FreeCameraInputsManager;
  9059. /**
  9060. * Add mouse input support to the input manager.
  9061. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  9062. * @returns the current input manager
  9063. */
  9064. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  9065. /**
  9066. * Add orientation input support to the input manager.
  9067. * @returns the current input manager
  9068. */
  9069. addDeviceOrientation(): FreeCameraInputsManager;
  9070. /**
  9071. * Add touch input support to the input manager.
  9072. * @returns the current input manager
  9073. */
  9074. addTouch(): FreeCameraInputsManager;
  9075. /**
  9076. * Add virtual joystick input support to the input manager.
  9077. * @returns the current input manager
  9078. */
  9079. addVirtualJoystick(): FreeCameraInputsManager;
  9080. }
  9081. }
  9082. declare module BABYLON {
  9083. /**
  9084. * This represents a FPS type of camera. This is only here for back compat purpose.
  9085. * Please use the UniversalCamera instead as both are identical.
  9086. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9087. */
  9088. class GamepadCamera extends UniversalCamera {
  9089. /**
  9090. * Instantiates a new Gamepad Camera
  9091. * This represents a FPS type of camera. This is only here for back compat purpose.
  9092. * Please use the UniversalCamera instead as both are identical.
  9093. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9094. * @param name Define the name of the camera in the scene
  9095. * @param position Define the start position of the camera in the scene
  9096. * @param scene Define the scene the camera belongs to
  9097. */
  9098. constructor(name: string, position: Vector3, scene: Scene);
  9099. /**
  9100. * Gets the current object class name.
  9101. * @return the class name
  9102. */
  9103. getClassName(): string;
  9104. }
  9105. }
  9106. declare module BABYLON {
  9107. /**
  9108. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9109. * This is the base of the follow, arc rotate cameras and Free camera
  9110. * @see http://doc.babylonjs.com/features/cameras
  9111. */
  9112. class TargetCamera extends Camera {
  9113. private static _RigCamTransformMatrix;
  9114. private static _TargetTransformMatrix;
  9115. /**
  9116. * Define the current direction the camera is moving to
  9117. */
  9118. cameraDirection: Vector3;
  9119. /**
  9120. * Define the current rotation the camera is rotating to
  9121. */
  9122. cameraRotation: Vector2;
  9123. /**
  9124. * When set, the up vector of the camera will be updated by the rotation of the camera
  9125. */
  9126. updateUpVectorFromRotation: boolean;
  9127. private _tmpQuaternion;
  9128. /**
  9129. * Define the current rotation of the camera
  9130. */
  9131. rotation: Vector3;
  9132. /**
  9133. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9134. */
  9135. rotationQuaternion: Quaternion;
  9136. /**
  9137. * Define the current speed of the camera
  9138. */
  9139. speed: number;
  9140. /**
  9141. * Add cconstraint to the camera to prevent it to move freely in all directions and
  9142. * around all axis.
  9143. */
  9144. noRotationConstraint: boolean;
  9145. /**
  9146. * Define the current target of the camera as an object or a position.
  9147. */
  9148. lockedTarget: any;
  9149. /** @hidden */
  9150. _currentTarget: Vector3;
  9151. /** @hidden */
  9152. _viewMatrix: Matrix;
  9153. /** @hidden */
  9154. _camMatrix: Matrix;
  9155. /** @hidden */
  9156. _cameraTransformMatrix: Matrix;
  9157. /** @hidden */
  9158. _cameraRotationMatrix: Matrix;
  9159. /** @hidden */
  9160. _referencePoint: Vector3;
  9161. /** @hidden */
  9162. _transformedReferencePoint: Vector3;
  9163. protected _globalCurrentTarget: Vector3;
  9164. protected _globalCurrentUpVector: Vector3;
  9165. /** @hidden */
  9166. _reset: () => void;
  9167. private _defaultUp;
  9168. /**
  9169. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  9170. * This is the base of the follow, arc rotate cameras and Free camera
  9171. * @see http://doc.babylonjs.com/features/cameras
  9172. * @param name Defines the name of the camera in the scene
  9173. * @param position Defines the start position of the camera in the scene
  9174. * @param scene Defines the scene the camera belongs to
  9175. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9176. */
  9177. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9178. /**
  9179. * Gets the position in front of the camera at a given distance.
  9180. * @param distance The distance from the camera we want the position to be
  9181. * @returns the position
  9182. */
  9183. getFrontPosition(distance: number): Vector3;
  9184. /** @hidden */
  9185. _getLockedTargetPosition(): Nullable<Vector3>;
  9186. private _storedPosition;
  9187. private _storedRotation;
  9188. private _storedRotationQuaternion;
  9189. /**
  9190. * Store current camera state of the camera (fov, position, rotation, etc..)
  9191. * @returns the camera
  9192. */
  9193. storeState(): Camera;
  9194. /**
  9195. * Restored camera state. You must call storeState() first
  9196. * @returns whether it was successful or not
  9197. * @hidden
  9198. */
  9199. _restoreStateValues(): boolean;
  9200. /** @hidden */
  9201. _initCache(): void;
  9202. /** @hidden */
  9203. _updateCache(ignoreParentClass?: boolean): void;
  9204. /** @hidden */
  9205. _isSynchronizedViewMatrix(): boolean;
  9206. /** @hidden */
  9207. _computeLocalCameraSpeed(): number;
  9208. /** @hidden */
  9209. setTarget(target: Vector3): void;
  9210. /**
  9211. * Return the current target position of the camera. This value is expressed in local space.
  9212. * @returns the target position
  9213. */
  9214. getTarget(): Vector3;
  9215. /** @hidden */
  9216. _decideIfNeedsToMove(): boolean;
  9217. /** @hidden */
  9218. _updatePosition(): void;
  9219. /** @hidden */
  9220. _checkInputs(): void;
  9221. protected _updateCameraRotationMatrix(): void;
  9222. /**
  9223. * 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)
  9224. * @returns the current camera
  9225. */
  9226. private _rotateUpVectorWithCameraRotationMatrix;
  9227. private _cachedRotationZ;
  9228. private _cachedQuaternionRotationZ;
  9229. /** @hidden */
  9230. _getViewMatrix(): Matrix;
  9231. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9232. /**
  9233. * @hidden
  9234. */
  9235. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9236. /**
  9237. * @hidden
  9238. */
  9239. _updateRigCameras(): void;
  9240. private _getRigCamPosition;
  9241. /**
  9242. * Gets the current object class name.
  9243. * @return the class name
  9244. */
  9245. getClassName(): string;
  9246. }
  9247. }
  9248. declare module BABYLON {
  9249. /**
  9250. * This represents a FPS type of camera controlled by touch.
  9251. * This is like a universal camera minus the Gamepad controls.
  9252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9253. */
  9254. class TouchCamera extends FreeCamera {
  9255. /**
  9256. * Defines the touch sensibility for rotation.
  9257. * The higher the faster.
  9258. */
  9259. touchAngularSensibility: number;
  9260. /**
  9261. * Defines the touch sensibility for move.
  9262. * The higher the faster.
  9263. */
  9264. touchMoveSensibility: number;
  9265. /**
  9266. * Instantiates a new touch camera.
  9267. * This represents a FPS type of camera controlled by touch.
  9268. * This is like a universal camera minus the Gamepad controls.
  9269. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9270. * @param name Define the name of the camera in the scene
  9271. * @param position Define the start position of the camera in the scene
  9272. * @param scene Define the scene the camera belongs to
  9273. */
  9274. constructor(name: string, position: Vector3, scene: Scene);
  9275. /**
  9276. * Gets the current object class name.
  9277. * @return the class name
  9278. */
  9279. getClassName(): string;
  9280. /** @hidden */
  9281. _setupInputs(): void;
  9282. }
  9283. }
  9284. declare module BABYLON {
  9285. /**
  9286. * 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,
  9287. * which still works and will still be found in many Playgrounds.
  9288. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9289. */
  9290. class UniversalCamera extends TouchCamera {
  9291. /**
  9292. * Defines the gamepad rotation sensiblity.
  9293. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  9294. */
  9295. gamepadAngularSensibility: number;
  9296. /**
  9297. * Defines the gamepad move sensiblity.
  9298. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  9299. */
  9300. gamepadMoveSensibility: number;
  9301. /**
  9302. * 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,
  9303. * which still works and will still be found in many Playgrounds.
  9304. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  9305. * @param name Define the name of the camera in the scene
  9306. * @param position Define the start position of the camera in the scene
  9307. * @param scene Define the scene the camera belongs to
  9308. */
  9309. constructor(name: string, position: Vector3, scene: Scene);
  9310. /**
  9311. * Gets the current object class name.
  9312. * @return the class name
  9313. */
  9314. getClassName(): string;
  9315. }
  9316. }
  9317. declare module BABYLON {
  9318. /**
  9319. * This represents a free type of camera. It can be usefull in First Person Shooter game for instance.
  9320. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9321. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9322. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9323. */
  9324. class VirtualJoysticksCamera extends FreeCamera {
  9325. /**
  9326. * Intantiates a VirtualJoysticksCamera. It can be usefull in First Person Shooter game for instance.
  9327. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  9328. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  9329. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  9330. * @param name Define the name of the camera in the scene
  9331. * @param position Define the start position of the camera in the scene
  9332. * @param scene Define the scene the camera belongs to
  9333. */
  9334. constructor(name: string, position: Vector3, scene: Scene);
  9335. /**
  9336. * Gets the current object class name.
  9337. * @return the class name
  9338. */
  9339. getClassName(): string;
  9340. }
  9341. }
  9342. interface VRDisplay extends EventTarget {
  9343. /**
  9344. * Dictionary of capabilities describing the VRDisplay.
  9345. */
  9346. readonly capabilities: VRDisplayCapabilities;
  9347. /**
  9348. * z-depth defining the far plane of the eye view frustum
  9349. * enables mapping of values in the render target depth
  9350. * attachment to scene coordinates. Initially set to 10000.0.
  9351. */
  9352. depthFar: number;
  9353. /**
  9354. * z-depth defining the near plane of the eye view frustum
  9355. * enables mapping of values in the render target depth
  9356. * attachment to scene coordinates. Initially set to 0.01.
  9357. */
  9358. depthNear: number;
  9359. /**
  9360. * An identifier for this distinct VRDisplay. Used as an
  9361. * association point in the Gamepad API.
  9362. */
  9363. readonly displayId: number;
  9364. /**
  9365. * A display name, a user-readable name identifying it.
  9366. */
  9367. readonly displayName: string;
  9368. readonly isConnected: boolean;
  9369. readonly isPresenting: boolean;
  9370. /**
  9371. * If this VRDisplay supports room-scale experiences, the optional
  9372. * stage attribute contains details on the room-scale parameters.
  9373. */
  9374. readonly stageParameters: VRStageParameters | null;
  9375. /**
  9376. * Passing the value returned by `requestAnimationFrame` to
  9377. * `cancelAnimationFrame` will unregister the callback.
  9378. * @param handle Define the hanle of the request to cancel
  9379. */
  9380. cancelAnimationFrame(handle: number): void;
  9381. /**
  9382. * Stops presenting to the VRDisplay.
  9383. * @returns a promise to know when it stopped
  9384. */
  9385. exitPresent(): Promise<void>;
  9386. /**
  9387. * Return the current VREyeParameters for the given eye.
  9388. * @param whichEye Define the eye we want the parameter for
  9389. * @returns the eye parameters
  9390. */
  9391. getEyeParameters(whichEye: string): VREyeParameters;
  9392. /**
  9393. * Populates the passed VRFrameData with the information required to render
  9394. * the current frame.
  9395. * @param frameData Define the data structure to populate
  9396. * @returns true if ok otherwise false
  9397. */
  9398. getFrameData(frameData: VRFrameData): boolean;
  9399. /**
  9400. * Get the layers currently being presented.
  9401. * @returns the list of VR layers
  9402. */
  9403. getLayers(): VRLayer[];
  9404. /**
  9405. * Return a VRPose containing the future predicted pose of the VRDisplay
  9406. * when the current frame will be presented. The value returned will not
  9407. * change until JavaScript has returned control to the browser.
  9408. *
  9409. * The VRPose will contain the position, orientation, velocity,
  9410. * and acceleration of each of these properties.
  9411. * @returns the pose object
  9412. */
  9413. getPose(): VRPose;
  9414. /**
  9415. * Return the current instantaneous pose of the VRDisplay, with no
  9416. * prediction applied.
  9417. * @returns the current instantaneous pose
  9418. */
  9419. getImmediatePose(): VRPose;
  9420. /**
  9421. * The callback passed to `requestAnimationFrame` will be called
  9422. * any time a new frame should be rendered. When the VRDisplay is
  9423. * presenting the callback will be called at the native refresh
  9424. * rate of the HMD. When not presenting this function acts
  9425. * identically to how window.requestAnimationFrame acts. Content should
  9426. * make no assumptions of frame rate or vsync behavior as the HMD runs
  9427. * asynchronously from other displays and at differing refresh rates.
  9428. * @param callback Define the eaction to run next frame
  9429. * @returns the request handle it
  9430. */
  9431. requestAnimationFrame(callback: FrameRequestCallback): number;
  9432. /**
  9433. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  9434. * Repeat calls while already presenting will update the VRLayers being displayed.
  9435. * @param layers Define the list of layer to present
  9436. * @returns a promise to know when the request has been fulfilled
  9437. */
  9438. requestPresent(layers: VRLayer[]): Promise<void>;
  9439. /**
  9440. * Reset the pose for this display, treating its current position and
  9441. * orientation as the "origin/zero" values. VRPose.position,
  9442. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  9443. * updated when calling resetPose(). This should be called in only
  9444. * sitting-space experiences.
  9445. */
  9446. resetPose(): void;
  9447. /**
  9448. * The VRLayer provided to the VRDisplay will be captured and presented
  9449. * in the HMD. Calling this function has the same effect on the source
  9450. * canvas as any other operation that uses its source image, and canvases
  9451. * created without preserveDrawingBuffer set to true will be cleared.
  9452. * @param pose Define the pose to submit
  9453. */
  9454. submitFrame(pose?: VRPose): void;
  9455. }
  9456. declare var VRDisplay: {
  9457. prototype: VRDisplay;
  9458. new (): VRDisplay;
  9459. };
  9460. interface VRLayer {
  9461. leftBounds?: number[] | Float32Array | null;
  9462. rightBounds?: number[] | Float32Array | null;
  9463. source?: HTMLCanvasElement | null;
  9464. }
  9465. interface VRDisplayCapabilities {
  9466. readonly canPresent: boolean;
  9467. readonly hasExternalDisplay: boolean;
  9468. readonly hasOrientation: boolean;
  9469. readonly hasPosition: boolean;
  9470. readonly maxLayers: number;
  9471. }
  9472. interface VREyeParameters {
  9473. /** @deprecated */
  9474. readonly fieldOfView: VRFieldOfView;
  9475. readonly offset: Float32Array;
  9476. readonly renderHeight: number;
  9477. readonly renderWidth: number;
  9478. }
  9479. interface VRFieldOfView {
  9480. readonly downDegrees: number;
  9481. readonly leftDegrees: number;
  9482. readonly rightDegrees: number;
  9483. readonly upDegrees: number;
  9484. }
  9485. interface VRFrameData {
  9486. readonly leftProjectionMatrix: Float32Array;
  9487. readonly leftViewMatrix: Float32Array;
  9488. readonly pose: VRPose;
  9489. readonly rightProjectionMatrix: Float32Array;
  9490. readonly rightViewMatrix: Float32Array;
  9491. readonly timestamp: number;
  9492. }
  9493. interface VRPose {
  9494. readonly angularAcceleration: Float32Array | null;
  9495. readonly angularVelocity: Float32Array | null;
  9496. readonly linearAcceleration: Float32Array | null;
  9497. readonly linearVelocity: Float32Array | null;
  9498. readonly orientation: Float32Array | null;
  9499. readonly position: Float32Array | null;
  9500. readonly timestamp: number;
  9501. }
  9502. interface VRStageParameters {
  9503. sittingToStandingTransform?: Float32Array;
  9504. sizeX?: number;
  9505. sizeY?: number;
  9506. }
  9507. interface Navigator {
  9508. getVRDisplays(): Promise<VRDisplay[]>;
  9509. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  9510. }
  9511. interface Window {
  9512. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  9513. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  9514. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  9515. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9516. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  9517. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  9518. }
  9519. interface Gamepad {
  9520. readonly displayId: number;
  9521. }
  9522. /**
  9523. * Module Debug contains the (visual) components to debug a scene correctly
  9524. */
  9525. declare module BABYLON.Debug {
  9526. /**
  9527. * The Axes viewer will show 3 axes in a specific point in space
  9528. */
  9529. class AxesViewer {
  9530. private _xline;
  9531. private _yline;
  9532. private _zline;
  9533. private _xmesh;
  9534. private _ymesh;
  9535. private _zmesh;
  9536. /**
  9537. * Gets the hosting scene
  9538. */
  9539. scene: Nullable<Scene>;
  9540. /**
  9541. * Gets or sets a number used to scale line length
  9542. */
  9543. scaleLines: number;
  9544. /**
  9545. * Creates a new AxesViewer
  9546. * @param scene defines the hosting scene
  9547. * @param scaleLines defines a number used to scale line length (1 by default)
  9548. */
  9549. constructor(scene: Scene, scaleLines?: number);
  9550. /**
  9551. * Force the viewer to update
  9552. * @param position defines the position of the viewer
  9553. * @param xaxis defines the x axis of the viewer
  9554. * @param yaxis defines the y axis of the viewer
  9555. * @param zaxis defines the z axis of the viewer
  9556. */
  9557. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  9558. /** Releases resources */
  9559. dispose(): void;
  9560. }
  9561. }
  9562. declare module BABYLON.Debug {
  9563. /**
  9564. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  9565. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  9566. */
  9567. class BoneAxesViewer extends AxesViewer {
  9568. /**
  9569. * Gets or sets the target mesh where to display the axes viewer
  9570. */
  9571. mesh: Nullable<Mesh>;
  9572. /**
  9573. * Gets or sets the target bone where to display the axes viewer
  9574. */
  9575. bone: Nullable<Bone>;
  9576. /** Gets current position */
  9577. pos: Vector3;
  9578. /** Gets direction of X axis */
  9579. xaxis: Vector3;
  9580. /** Gets direction of Y axis */
  9581. yaxis: Vector3;
  9582. /** Gets direction of Z axis */
  9583. zaxis: Vector3;
  9584. /**
  9585. * Creates a new BoneAxesViewer
  9586. * @param scene defines the hosting scene
  9587. * @param bone defines the target bone
  9588. * @param mesh defines the target mesh
  9589. * @param scaleLines defines a scaling factor for line length (1 by default)
  9590. */
  9591. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  9592. /**
  9593. * Force the viewer to update
  9594. */
  9595. update(): void;
  9596. /** Releases resources */
  9597. dispose(): void;
  9598. }
  9599. }
  9600. declare module BABYLON {
  9601. interface Scene {
  9602. /**
  9603. * @hidden
  9604. * Backing field
  9605. */
  9606. _debugLayer: DebugLayer;
  9607. /**
  9608. * Gets the debug layer (aka Inspector) associated with the scene
  9609. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9610. */
  9611. debugLayer: DebugLayer;
  9612. }
  9613. /**
  9614. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9615. * what is happening in your scene
  9616. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9617. */
  9618. class DebugLayer {
  9619. /**
  9620. * Define the url to get the inspector script from.
  9621. * By default it uses the babylonjs CDN.
  9622. * @ignoreNaming
  9623. */
  9624. static InspectorURL: string;
  9625. private _scene;
  9626. private _inspector;
  9627. private BJSINSPECTOR;
  9628. /**
  9629. * Observable triggered when a property is changed through the inspector.
  9630. */
  9631. onPropertyChangedObservable: Observable<{
  9632. object: any;
  9633. property: string;
  9634. value: any;
  9635. initialValue: any;
  9636. }>;
  9637. /**
  9638. * Instantiates a new debug layer.
  9639. * The debug layer (aka Inspector) is the go to tool in order to better understand
  9640. * what is happening in your scene
  9641. * @see http://doc.babylonjs.com/features/playground_debuglayer
  9642. * @param scene Defines the scene to inspect
  9643. */
  9644. constructor(scene: Scene);
  9645. /** Creates the inspector window. */
  9646. private _createInspector;
  9647. /**
  9648. * Get if the inspector is visible or not.
  9649. * @returns true if visible otherwise, false
  9650. */
  9651. isVisible(): boolean;
  9652. /**
  9653. * Hide the inspector and close its window.
  9654. */
  9655. hide(): void;
  9656. /**
  9657. *
  9658. * Launch the debugLayer.
  9659. *
  9660. * initialTab:
  9661. * | Value | Tab Name |
  9662. * | --- | --- |
  9663. * | 0 | Scene |
  9664. * | 1 | Console |
  9665. * | 2 | Stats |
  9666. * | 3 | Textures |
  9667. * | 4 | Mesh |
  9668. * | 5 | Light |
  9669. * | 6 | Material |
  9670. * | 7 | GLTF |
  9671. * | 8 | GUI |
  9672. * | 9 | Physics |
  9673. * | 10 | Camera |
  9674. * | 11 | Audio |
  9675. *
  9676. * @param config Define the configuration of the inspector
  9677. */
  9678. show(config?: {
  9679. popup?: boolean;
  9680. initialTab?: number | string;
  9681. parentElement?: HTMLElement;
  9682. newColors?: {
  9683. backgroundColor?: string;
  9684. backgroundColorLighter?: string;
  9685. backgroundColorLighter2?: string;
  9686. backgroundColorLighter3?: string;
  9687. color?: string;
  9688. colorTop?: string;
  9689. colorBot?: string;
  9690. };
  9691. }): void;
  9692. /**
  9693. * Gets the active tab
  9694. * @return the index of the active tab or -1 if the inspector is hidden
  9695. */
  9696. getActiveTab(): number;
  9697. }
  9698. }
  9699. declare module BABYLON.Debug {
  9700. /**
  9701. * Used to show the physics impostor around the specific mesh
  9702. */
  9703. class PhysicsViewer {
  9704. /** @hidden */
  9705. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  9706. /** @hidden */
  9707. protected _meshes: Array<Nullable<AbstractMesh>>;
  9708. /** @hidden */
  9709. protected _scene: Nullable<Scene>;
  9710. /** @hidden */
  9711. protected _numMeshes: number;
  9712. /** @hidden */
  9713. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  9714. private _renderFunction;
  9715. private _debugBoxMesh;
  9716. private _debugSphereMesh;
  9717. private _debugMaterial;
  9718. /**
  9719. * Creates a new PhysicsViewer
  9720. * @param scene defines the hosting scene
  9721. */
  9722. constructor(scene: Scene);
  9723. /** @hidden */
  9724. protected _updateDebugMeshes(): void;
  9725. /**
  9726. * Renders a specified physic impostor
  9727. * @param impostor defines the impostor to render
  9728. */
  9729. showImpostor(impostor: PhysicsImpostor): void;
  9730. /**
  9731. * Hides a specified physic impostor
  9732. * @param impostor defines the impostor to hide
  9733. */
  9734. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  9735. private _getDebugMaterial;
  9736. private _getDebugBoxMesh;
  9737. private _getDebugSphereMesh;
  9738. private _getDebugMesh;
  9739. /** Releases all resources */
  9740. dispose(): void;
  9741. }
  9742. }
  9743. declare module BABYLON {
  9744. /**
  9745. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9746. * in order to better appreciate the issue one might have.
  9747. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9748. */
  9749. class RayHelper {
  9750. /**
  9751. * Defines the ray we are currently tryin to visualize.
  9752. */
  9753. ray: Nullable<Ray>;
  9754. private _renderPoints;
  9755. private _renderLine;
  9756. private _renderFunction;
  9757. private _scene;
  9758. private _updateToMeshFunction;
  9759. private _attachedToMesh;
  9760. private _meshSpaceDirection;
  9761. private _meshSpaceOrigin;
  9762. /**
  9763. * Helper function to create a colored helper in a scene in one line.
  9764. * @param ray Defines the ray we are currently tryin to visualize
  9765. * @param scene Defines the scene the ray is used in
  9766. * @param color Defines the color we want to see the ray in
  9767. * @returns The newly created ray helper.
  9768. */
  9769. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  9770. /**
  9771. * Instantiate a new ray helper.
  9772. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  9773. * in order to better appreciate the issue one might have.
  9774. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  9775. * @param ray Defines the ray we are currently tryin to visualize
  9776. */
  9777. constructor(ray: Ray);
  9778. /**
  9779. * Shows the ray we are willing to debug.
  9780. * @param scene Defines the scene the ray needs to be rendered in
  9781. * @param color Defines the color the ray needs to be rendered in
  9782. */
  9783. show(scene: Scene, color?: Color3): void;
  9784. /**
  9785. * Hides the ray we are debugging.
  9786. */
  9787. hide(): void;
  9788. private _render;
  9789. /**
  9790. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  9791. * @param mesh Defines the mesh we want the helper attached to
  9792. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  9793. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  9794. * @param length Defines the length of the ray
  9795. */
  9796. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  9797. /**
  9798. * Detach the ray helper from the mesh it has previously been attached to.
  9799. */
  9800. detachFromMesh(): void;
  9801. private _updateToMesh;
  9802. /**
  9803. * Dispose the helper and release its associated resources.
  9804. */
  9805. dispose(): void;
  9806. }
  9807. }
  9808. declare module BABYLON.Debug {
  9809. /**
  9810. * Class used to render a debug view of a given skeleton
  9811. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  9812. */
  9813. class SkeletonViewer {
  9814. /** defines the skeleton to render */
  9815. skeleton: Skeleton;
  9816. /** defines the mesh attached to the skeleton */
  9817. mesh: AbstractMesh;
  9818. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9819. autoUpdateBonesMatrices: boolean;
  9820. /** defines the rendering group id to use with the viewer */
  9821. renderingGroupId: number;
  9822. /** defines an optional utility layer to render the helper on */
  9823. utilityLayerRenderer?: UtilityLayerRenderer | undefined;
  9824. /** Gets or sets the color used to render the skeleton */
  9825. color: Color3;
  9826. private _scene;
  9827. private _debugLines;
  9828. private _debugMesh;
  9829. private _isEnabled;
  9830. private _renderFunction;
  9831. /**
  9832. * Returns the mesh used to render the bones
  9833. */
  9834. readonly debugMesh: Nullable<LinesMesh>;
  9835. /**
  9836. * Creates a new SkeletonViewer
  9837. * @param skeleton defines the skeleton to render
  9838. * @param mesh defines the mesh attached to the skeleton
  9839. * @param scene defines the hosting scene
  9840. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  9841. * @param renderingGroupId defines the rendering group id to use with the viewer
  9842. * @param utilityLayerRenderer defines an optional utility layer to render the helper on
  9843. */
  9844. constructor(
  9845. /** defines the skeleton to render */
  9846. skeleton: Skeleton,
  9847. /** defines the mesh attached to the skeleton */
  9848. mesh: AbstractMesh, scene: Scene,
  9849. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  9850. autoUpdateBonesMatrices?: boolean,
  9851. /** defines the rendering group id to use with the viewer */
  9852. renderingGroupId?: number,
  9853. /** defines an optional utility layer to render the helper on */
  9854. utilityLayerRenderer?: UtilityLayerRenderer | undefined);
  9855. /** Gets or sets a boolean indicating if the viewer is enabled */
  9856. isEnabled: boolean;
  9857. private _getBonePosition;
  9858. private _getLinesForBonesWithLength;
  9859. private _getLinesForBonesNoLength;
  9860. /** Update the viewer to sync with current skeleton state */
  9861. update(): void;
  9862. /** Release associated resources */
  9863. dispose(): void;
  9864. }
  9865. }
  9866. declare module BABYLON {
  9867. /**
  9868. * Interface for attribute information associated with buffer instanciation
  9869. */
  9870. class InstancingAttributeInfo {
  9871. /**
  9872. * Index/offset of the attribute in the vertex shader
  9873. */
  9874. index: number;
  9875. /**
  9876. * size of the attribute, 1, 2, 3 or 4
  9877. */
  9878. attributeSize: number;
  9879. /**
  9880. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  9881. * default is FLOAT
  9882. */
  9883. attribyteType: number;
  9884. /**
  9885. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  9886. */
  9887. normalized: boolean;
  9888. /**
  9889. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  9890. */
  9891. offset: number;
  9892. /**
  9893. * Name of the GLSL attribute, for debugging purpose only
  9894. */
  9895. attributeName: string;
  9896. }
  9897. /**
  9898. * Define options used to create a render target texture
  9899. */
  9900. class RenderTargetCreationOptions {
  9901. /**
  9902. * Specifies is mipmaps must be generated
  9903. */
  9904. generateMipMaps?: boolean;
  9905. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  9906. generateDepthBuffer?: boolean;
  9907. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  9908. generateStencilBuffer?: boolean;
  9909. /** Defines texture type (int by default) */
  9910. type?: number;
  9911. /** Defines sampling mode (trilinear by default) */
  9912. samplingMode?: number;
  9913. /** Defines format (RGBA by default) */
  9914. format?: number;
  9915. }
  9916. /**
  9917. * Define options used to create a depth texture
  9918. */
  9919. class DepthTextureCreationOptions {
  9920. /** Specifies whether or not a stencil should be allocated in the texture */
  9921. generateStencil?: boolean;
  9922. /** Specifies whether or not bilinear filtering is enable on the texture */
  9923. bilinearFiltering?: boolean;
  9924. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  9925. comparisonFunction?: number;
  9926. /** Specifies if the created texture is a cube texture */
  9927. isCube?: boolean;
  9928. }
  9929. /**
  9930. * Class used to describe the capabilities of the engine relatively to the current browser
  9931. */
  9932. class EngineCapabilities {
  9933. /** Maximum textures units per fragment shader */
  9934. maxTexturesImageUnits: number;
  9935. /** Maximum texture units per vertex shader */
  9936. maxVertexTextureImageUnits: number;
  9937. /** Maximum textures units in the entire pipeline */
  9938. maxCombinedTexturesImageUnits: number;
  9939. /** Maximum texture size */
  9940. maxTextureSize: number;
  9941. /** Maximum cube texture size */
  9942. maxCubemapTextureSize: number;
  9943. /** Maximum render texture size */
  9944. maxRenderTextureSize: number;
  9945. /** Maximum number of vertex attributes */
  9946. maxVertexAttribs: number;
  9947. /** Maximum number of varyings */
  9948. maxVaryingVectors: number;
  9949. /** Maximum number of uniforms per vertex shader */
  9950. maxVertexUniformVectors: number;
  9951. /** Maximum number of uniforms per fragment shader */
  9952. maxFragmentUniformVectors: number;
  9953. /** Defines if standard derivates (dx/dy) are supported */
  9954. standardDerivatives: boolean;
  9955. /** Defines if s3tc texture compression is supported */
  9956. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  9957. /** Defines if pvrtc texture compression is supported */
  9958. pvrtc: any;
  9959. /** Defines if etc1 texture compression is supported */
  9960. etc1: any;
  9961. /** Defines if etc2 texture compression is supported */
  9962. etc2: any;
  9963. /** Defines if astc texture compression is supported */
  9964. astc: any;
  9965. /** Defines if float textures are supported */
  9966. textureFloat: boolean;
  9967. /** Defines if vertex array objects are supported */
  9968. vertexArrayObject: boolean;
  9969. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  9970. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  9971. /** Gets the maximum level of anisotropy supported */
  9972. maxAnisotropy: number;
  9973. /** Defines if instancing is supported */
  9974. instancedArrays: boolean;
  9975. /** Defines if 32 bits indices are supported */
  9976. uintIndices: boolean;
  9977. /** Defines if high precision shaders are supported */
  9978. highPrecisionShaderSupported: boolean;
  9979. /** Defines if depth reading in the fragment shader is supported */
  9980. fragmentDepthSupported: boolean;
  9981. /** Defines if float texture linear filtering is supported*/
  9982. textureFloatLinearFiltering: boolean;
  9983. /** Defines if rendering to float textures is supported */
  9984. textureFloatRender: boolean;
  9985. /** Defines if half float textures are supported*/
  9986. textureHalfFloat: boolean;
  9987. /** Defines if half float texture linear filtering is supported*/
  9988. textureHalfFloatLinearFiltering: boolean;
  9989. /** Defines if rendering to half float textures is supported */
  9990. textureHalfFloatRender: boolean;
  9991. /** Defines if textureLOD shader command is supported */
  9992. textureLOD: boolean;
  9993. /** Defines if draw buffers extension is supported */
  9994. drawBuffersExtension: boolean;
  9995. /** Defines if depth textures are supported */
  9996. depthTextureExtension: boolean;
  9997. /** Defines if float color buffer are supported */
  9998. colorBufferFloat: boolean;
  9999. /** Gets disjoint timer query extension (null if not supported) */
  10000. timerQuery: EXT_disjoint_timer_query;
  10001. /** Defines if timestamp can be used with timer query */
  10002. canUseTimestampForTimerQuery: boolean;
  10003. /** Function used to let the system compiles shaders in background */
  10004. parallelShaderCompile: {
  10005. MAX_SHADER_COMPILER_THREADS_KHR: number;
  10006. maxShaderCompilerThreadsKHR: (thread: number) => void;
  10007. COMPLETION_STATUS_KHR: number;
  10008. };
  10009. }
  10010. /** Interface defining initialization parameters for Engine class */
  10011. interface EngineOptions extends WebGLContextAttributes {
  10012. /**
  10013. * Defines if the engine should no exceed a specified device ratio
  10014. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  10015. */
  10016. limitDeviceRatio?: number;
  10017. /**
  10018. * Defines if webvr should be enabled automatically
  10019. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10020. */
  10021. autoEnableWebVR?: boolean;
  10022. /**
  10023. * Defines if webgl2 should be turned off even if supported
  10024. * @see http://doc.babylonjs.com/features/webgl2
  10025. */
  10026. disableWebGL2Support?: boolean;
  10027. /**
  10028. * Defines if webaudio should be initialized as well
  10029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10030. */
  10031. audioEngine?: boolean;
  10032. /**
  10033. * Defines if animations should run using a deterministic lock step
  10034. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10035. */
  10036. deterministicLockstep?: boolean;
  10037. /** Defines the maximum steps to use with deterministic lock step mode */
  10038. lockstepMaxSteps?: number;
  10039. /**
  10040. * Defines that engine should ignore context lost events
  10041. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  10042. */
  10043. doNotHandleContextLost?: boolean;
  10044. }
  10045. /**
  10046. * Defines the interface used by display changed events
  10047. */
  10048. interface IDisplayChangedEventArgs {
  10049. /** Gets the vrDisplay object (if any) */
  10050. vrDisplay: Nullable<any>;
  10051. /** Gets a boolean indicating if webVR is supported */
  10052. vrSupported: boolean;
  10053. }
  10054. /**
  10055. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  10056. */
  10057. class Engine {
  10058. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  10059. static ExceptionList: ({
  10060. key: string;
  10061. capture: string;
  10062. captureConstraint: number;
  10063. targets: string[];
  10064. } | {
  10065. key: string;
  10066. capture: null;
  10067. captureConstraint: null;
  10068. targets: string[];
  10069. })[];
  10070. /** Gets the list of created engines */
  10071. static Instances: Engine[];
  10072. /**
  10073. * Gets the latest created engine
  10074. */
  10075. static readonly LastCreatedEngine: Nullable<Engine>;
  10076. /**
  10077. * Gets the latest created scene
  10078. */
  10079. static readonly LastCreatedScene: Nullable<Scene>;
  10080. /**
  10081. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  10082. * @param flag defines which part of the materials must be marked as dirty
  10083. * @param predicate defines a predicate used to filter which materials should be affected
  10084. */
  10085. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  10086. /**
  10087. * Hidden
  10088. */
  10089. static _TextureLoaders: IInternalTextureLoader[];
  10090. /** Defines that alpha blending is disabled */
  10091. static readonly ALPHA_DISABLE: number;
  10092. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  10093. static readonly ALPHA_ADD: number;
  10094. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  10095. static readonly ALPHA_COMBINE: number;
  10096. /** Defines that alpha blending to DEST - SRC * DEST */
  10097. static readonly ALPHA_SUBTRACT: number;
  10098. /** Defines that alpha blending to SRC * DEST */
  10099. static readonly ALPHA_MULTIPLY: number;
  10100. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  10101. static readonly ALPHA_MAXIMIZED: number;
  10102. /** Defines that alpha blending to SRC + DEST */
  10103. static readonly ALPHA_ONEONE: number;
  10104. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  10105. static readonly ALPHA_PREMULTIPLIED: number;
  10106. /**
  10107. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  10108. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  10109. */
  10110. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  10111. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  10112. static readonly ALPHA_INTERPOLATE: number;
  10113. /**
  10114. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  10115. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  10116. */
  10117. static readonly ALPHA_SCREENMODE: number;
  10118. /** Defines that the ressource is not delayed*/
  10119. static readonly DELAYLOADSTATE_NONE: number;
  10120. /** Defines that the ressource was successfully delay loaded */
  10121. static readonly DELAYLOADSTATE_LOADED: number;
  10122. /** Defines that the ressource is currently delay loading */
  10123. static readonly DELAYLOADSTATE_LOADING: number;
  10124. /** Defines that the ressource is delayed and has not started loading */
  10125. static readonly DELAYLOADSTATE_NOTLOADED: number;
  10126. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  10127. static readonly NEVER: number;
  10128. /** 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 */
  10129. static readonly ALWAYS: number;
  10130. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  10131. static readonly LESS: number;
  10132. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  10133. static readonly EQUAL: number;
  10134. /** 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 */
  10135. static readonly LEQUAL: number;
  10136. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  10137. static readonly GREATER: number;
  10138. /** 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 */
  10139. static readonly GEQUAL: number;
  10140. /** 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 */
  10141. static readonly NOTEQUAL: number;
  10142. /** Passed to stencilOperation to specify that stencil value must be kept */
  10143. static readonly KEEP: number;
  10144. /** Passed to stencilOperation to specify that stencil value must be replaced */
  10145. static readonly REPLACE: number;
  10146. /** Passed to stencilOperation to specify that stencil value must be incremented */
  10147. static readonly INCR: number;
  10148. /** Passed to stencilOperation to specify that stencil value must be decremented */
  10149. static readonly DECR: number;
  10150. /** Passed to stencilOperation to specify that stencil value must be inverted */
  10151. static readonly INVERT: number;
  10152. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  10153. static readonly INCR_WRAP: number;
  10154. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  10155. static readonly DECR_WRAP: number;
  10156. /** Texture is not repeating outside of 0..1 UVs */
  10157. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  10158. /** Texture is repeating outside of 0..1 UVs */
  10159. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  10160. /** Texture is repeating and mirrored */
  10161. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  10162. /** ALPHA */
  10163. static readonly TEXTUREFORMAT_ALPHA: number;
  10164. /** LUMINANCE */
  10165. static readonly TEXTUREFORMAT_LUMINANCE: number;
  10166. /** LUMINANCE_ALPHA */
  10167. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  10168. /** RGB */
  10169. static readonly TEXTUREFORMAT_RGB: number;
  10170. /** RGBA */
  10171. static readonly TEXTUREFORMAT_RGBA: number;
  10172. /** RED */
  10173. static readonly TEXTUREFORMAT_RED: number;
  10174. /** RED (2nd reference) */
  10175. static readonly TEXTUREFORMAT_R: number;
  10176. /** RG */
  10177. static readonly TEXTUREFORMAT_RG: number;
  10178. /** RED_INTEGER */
  10179. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  10180. /** RED_INTEGER (2nd reference) */
  10181. static readonly TEXTUREFORMAT_R_INTEGER: number;
  10182. /** RG_INTEGER */
  10183. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  10184. /** RGB_INTEGER */
  10185. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  10186. /** RGBA_INTEGER */
  10187. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  10188. /** UNSIGNED_BYTE */
  10189. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  10190. /** UNSIGNED_BYTE (2nd reference) */
  10191. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  10192. /** FLOAT */
  10193. static readonly TEXTURETYPE_FLOAT: number;
  10194. /** HALF_FLOAT */
  10195. static readonly TEXTURETYPE_HALF_FLOAT: number;
  10196. /** BYTE */
  10197. static readonly TEXTURETYPE_BYTE: number;
  10198. /** SHORT */
  10199. static readonly TEXTURETYPE_SHORT: number;
  10200. /** UNSIGNED_SHORT */
  10201. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  10202. /** INT */
  10203. static readonly TEXTURETYPE_INT: number;
  10204. /** UNSIGNED_INT */
  10205. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  10206. /** UNSIGNED_SHORT_4_4_4_4 */
  10207. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  10208. /** UNSIGNED_SHORT_5_5_5_1 */
  10209. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  10210. /** UNSIGNED_SHORT_5_6_5 */
  10211. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  10212. /** UNSIGNED_INT_2_10_10_10_REV */
  10213. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  10214. /** UNSIGNED_INT_24_8 */
  10215. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  10216. /** UNSIGNED_INT_10F_11F_11F_REV */
  10217. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  10218. /** UNSIGNED_INT_5_9_9_9_REV */
  10219. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  10220. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  10221. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  10222. /** nearest is mag = nearest and min = nearest and mip = linear */
  10223. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  10224. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10225. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  10226. /** Trilinear is mag = linear and min = linear and mip = linear */
  10227. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  10228. /** nearest is mag = nearest and min = nearest and mip = linear */
  10229. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  10230. /** Bilinear is mag = linear and min = linear and mip = nearest */
  10231. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  10232. /** Trilinear is mag = linear and min = linear and mip = linear */
  10233. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  10234. /** mag = nearest and min = nearest and mip = nearest */
  10235. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  10236. /** mag = nearest and min = linear and mip = nearest */
  10237. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  10238. /** mag = nearest and min = linear and mip = linear */
  10239. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  10240. /** mag = nearest and min = linear and mip = none */
  10241. static readonly TEXTURE_NEAREST_LINEAR: number;
  10242. /** mag = nearest and min = nearest and mip = none */
  10243. static readonly TEXTURE_NEAREST_NEAREST: number;
  10244. /** mag = linear and min = nearest and mip = nearest */
  10245. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  10246. /** mag = linear and min = nearest and mip = linear */
  10247. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  10248. /** mag = linear and min = linear and mip = none */
  10249. static readonly TEXTURE_LINEAR_LINEAR: number;
  10250. /** mag = linear and min = nearest and mip = none */
  10251. static readonly TEXTURE_LINEAR_NEAREST: number;
  10252. /** Explicit coordinates mode */
  10253. static readonly TEXTURE_EXPLICIT_MODE: number;
  10254. /** Spherical coordinates mode */
  10255. static readonly TEXTURE_SPHERICAL_MODE: number;
  10256. /** Planar coordinates mode */
  10257. static readonly TEXTURE_PLANAR_MODE: number;
  10258. /** Cubic coordinates mode */
  10259. static readonly TEXTURE_CUBIC_MODE: number;
  10260. /** Projection coordinates mode */
  10261. static readonly TEXTURE_PROJECTION_MODE: number;
  10262. /** Skybox coordinates mode */
  10263. static readonly TEXTURE_SKYBOX_MODE: number;
  10264. /** Inverse Cubic coordinates mode */
  10265. static readonly TEXTURE_INVCUBIC_MODE: number;
  10266. /** Equirectangular coordinates mode */
  10267. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  10268. /** Equirectangular Fixed coordinates mode */
  10269. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  10270. /** Equirectangular Fixed Mirrored coordinates mode */
  10271. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  10272. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  10273. static readonly SCALEMODE_FLOOR: number;
  10274. /** Defines that texture rescaling will look for the nearest power of 2 size */
  10275. static readonly SCALEMODE_NEAREST: number;
  10276. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  10277. static readonly SCALEMODE_CEILING: number;
  10278. /**
  10279. * Returns the current version of the framework
  10280. */
  10281. static readonly Version: string;
  10282. /**
  10283. * Returns a string describing the current engine
  10284. */
  10285. readonly description: string;
  10286. /**
  10287. * Gets or sets the epsilon value used by collision engine
  10288. */
  10289. static CollisionsEpsilon: number;
  10290. /**
  10291. * Gets or sets the relative url used to load code if using the engine in non-minified mode
  10292. */
  10293. static CodeRepository: string;
  10294. /**
  10295. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  10296. */
  10297. static ShadersRepository: string;
  10298. /**
  10299. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  10300. */
  10301. forcePOTTextures: boolean;
  10302. /**
  10303. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  10304. */
  10305. isFullscreen: boolean;
  10306. /**
  10307. * Gets a boolean indicating if the pointer is currently locked
  10308. */
  10309. isPointerLock: boolean;
  10310. /**
  10311. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  10312. */
  10313. cullBackFaces: boolean;
  10314. /**
  10315. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  10316. */
  10317. renderEvenInBackground: boolean;
  10318. /**
  10319. * Gets or sets a boolean indicating that cache can be kept between frames
  10320. */
  10321. preventCacheWipeBetweenFrames: boolean;
  10322. /**
  10323. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  10324. **/
  10325. enableOfflineSupport: boolean;
  10326. /**
  10327. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (Babylon.js will always consider the database is up to date)
  10328. **/
  10329. disableManifestCheck: boolean;
  10330. /**
  10331. * Gets the list of created scenes
  10332. */
  10333. scenes: Scene[];
  10334. /**
  10335. * Event raised when a new scene is created
  10336. */
  10337. onNewSceneAddedObservable: Observable<Scene>;
  10338. /**
  10339. * Gets the list of created postprocesses
  10340. */
  10341. postProcesses: PostProcess[];
  10342. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  10343. validateShaderPrograms: boolean;
  10344. /**
  10345. * Observable event triggered each time the rendering canvas is resized
  10346. */
  10347. onResizeObservable: Observable<Engine>;
  10348. /**
  10349. * Observable event triggered each time the canvas loses focus
  10350. */
  10351. onCanvasBlurObservable: Observable<Engine>;
  10352. /**
  10353. * Observable event triggered each time the canvas gains focus
  10354. */
  10355. onCanvasFocusObservable: Observable<Engine>;
  10356. /**
  10357. * Observable event triggered each time the canvas receives pointerout event
  10358. */
  10359. onCanvasPointerOutObservable: Observable<PointerEvent>;
  10360. /**
  10361. * Observable event triggered before each texture is initialized
  10362. */
  10363. onBeforeTextureInitObservable: Observable<Texture>;
  10364. private _vrDisplay;
  10365. private _vrSupported;
  10366. private _oldSize;
  10367. private _oldHardwareScaleFactor;
  10368. private _vrExclusivePointerMode;
  10369. private _webVRInitPromise;
  10370. /**
  10371. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  10372. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  10373. */
  10374. readonly isInVRExclusivePointerMode: boolean;
  10375. /**
  10376. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  10377. */
  10378. disableUniformBuffers: boolean;
  10379. /** @hidden */
  10380. _uniformBuffers: UniformBuffer[];
  10381. /**
  10382. * Gets a boolean indicating that the engine supports uniform buffers
  10383. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10384. */
  10385. readonly supportsUniformBuffers: boolean;
  10386. /**
  10387. * Observable raised when the engine begins a new frame
  10388. */
  10389. onBeginFrameObservable: Observable<Engine>;
  10390. /**
  10391. * If set, will be used to request the next animation frame for the render loop
  10392. */
  10393. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  10394. /**
  10395. * Observable raised when the engine ends the current frame
  10396. */
  10397. onEndFrameObservable: Observable<Engine>;
  10398. /**
  10399. * Observable raised when the engine is about to compile a shader
  10400. */
  10401. onBeforeShaderCompilationObservable: Observable<Engine>;
  10402. /**
  10403. * Observable raised when the engine has jsut compiled a shader
  10404. */
  10405. onAfterShaderCompilationObservable: Observable<Engine>;
  10406. /** @hidden */
  10407. _gl: WebGLRenderingContext;
  10408. private _renderingCanvas;
  10409. private _windowIsBackground;
  10410. private _webGLVersion;
  10411. /**
  10412. * Gets a boolean indicating that only power of 2 textures are supported
  10413. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  10414. */
  10415. readonly needPOTTextures: boolean;
  10416. /** @hidden */
  10417. _badOS: boolean;
  10418. /** @hidden */
  10419. _badDesktopOS: boolean;
  10420. /**
  10421. * Gets or sets a value indicating if we want to disable texture binding optimization.
  10422. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  10423. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  10424. */
  10425. disableTextureBindingOptimization: boolean;
  10426. /**
  10427. * Gets the audio engine
  10428. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  10429. * @ignorenaming
  10430. */
  10431. static audioEngine: IAudioEngine;
  10432. /**
  10433. * Default AudioEngine factory responsible of creating the Audio Engine.
  10434. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  10435. */
  10436. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  10437. /**
  10438. * Default offline support factory responsible of creating a tool used to store data locally.
  10439. * By default, this will create a Database object if the workload has been embedded.
  10440. */
  10441. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  10442. private _onFocus;
  10443. private _onBlur;
  10444. private _onCanvasPointerOut;
  10445. private _onCanvasBlur;
  10446. private _onCanvasFocus;
  10447. private _onFullscreenChange;
  10448. private _onPointerLockChange;
  10449. private _onVRDisplayPointerRestricted;
  10450. private _onVRDisplayPointerUnrestricted;
  10451. private _onVrDisplayConnect;
  10452. private _onVrDisplayDisconnect;
  10453. private _onVrDisplayPresentChange;
  10454. /**
  10455. * Observable signaled when VR display mode changes
  10456. */
  10457. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  10458. /**
  10459. * Observable signaled when VR request present is complete
  10460. */
  10461. onVRRequestPresentComplete: Observable<boolean>;
  10462. /**
  10463. * Observable signaled when VR request present starts
  10464. */
  10465. onVRRequestPresentStart: Observable<Engine>;
  10466. private _hardwareScalingLevel;
  10467. /** @hidden */
  10468. protected _caps: EngineCapabilities;
  10469. private _pointerLockRequested;
  10470. private _isStencilEnable;
  10471. private _colorWrite;
  10472. private _loadingScreen;
  10473. /** @hidden */
  10474. _drawCalls: PerfCounter;
  10475. /** @hidden */
  10476. _textureCollisions: PerfCounter;
  10477. private _glVersion;
  10478. private _glRenderer;
  10479. private _glVendor;
  10480. private _videoTextureSupported;
  10481. private _renderingQueueLaunched;
  10482. private _activeRenderLoops;
  10483. private _deterministicLockstep;
  10484. private _lockstepMaxSteps;
  10485. /**
  10486. * Observable signaled when a context lost event is raised
  10487. */
  10488. onContextLostObservable: Observable<Engine>;
  10489. /**
  10490. * Observable signaled when a context restored event is raised
  10491. */
  10492. onContextRestoredObservable: Observable<Engine>;
  10493. private _onContextLost;
  10494. private _onContextRestored;
  10495. private _contextWasLost;
  10496. private _doNotHandleContextLost;
  10497. /**
  10498. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  10499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  10500. */
  10501. doNotHandleContextLost: boolean;
  10502. private _performanceMonitor;
  10503. private _fps;
  10504. private _deltaTime;
  10505. /**
  10506. * Turn this value on if you want to pause FPS computation when in background
  10507. */
  10508. disablePerformanceMonitorInBackground: boolean;
  10509. /**
  10510. * Gets the performance monitor attached to this engine
  10511. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  10512. */
  10513. readonly performanceMonitor: PerformanceMonitor;
  10514. /** @hidden */
  10515. protected _depthCullingState: _DepthCullingState;
  10516. /** @hidden */
  10517. protected _stencilState: _StencilState;
  10518. /** @hidden */
  10519. protected _alphaState: _AlphaState;
  10520. /** @hidden */
  10521. protected _alphaMode: number;
  10522. protected _internalTexturesCache: InternalTexture[];
  10523. /** @hidden */
  10524. protected _activeChannel: number;
  10525. private _currentTextureChannel;
  10526. /** @hidden */
  10527. protected _boundTexturesCache: {
  10528. [key: string]: Nullable<InternalTexture>;
  10529. };
  10530. /** @hidden */
  10531. protected _currentEffect: Nullable<Effect>;
  10532. /** @hidden */
  10533. protected _currentProgram: Nullable<WebGLProgram>;
  10534. private _compiledEffects;
  10535. private _vertexAttribArraysEnabled;
  10536. /** @hidden */
  10537. protected _cachedViewport: Nullable<Viewport>;
  10538. private _cachedVertexArrayObject;
  10539. /** @hidden */
  10540. protected _cachedVertexBuffers: any;
  10541. /** @hidden */
  10542. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  10543. /** @hidden */
  10544. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  10545. /** @hidden */
  10546. protected _currentRenderTarget: Nullable<InternalTexture>;
  10547. private _uintIndicesCurrentlySet;
  10548. private _currentBoundBuffer;
  10549. /** @hidden */
  10550. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  10551. private _currentBufferPointers;
  10552. private _currentInstanceLocations;
  10553. private _currentInstanceBuffers;
  10554. private _textureUnits;
  10555. private _firstBoundInternalTextureTracker;
  10556. private _lastBoundInternalTextureTracker;
  10557. private _workingCanvas;
  10558. private _workingContext;
  10559. private _rescalePostProcess;
  10560. private _dummyFramebuffer;
  10561. private _externalData;
  10562. private _bindedRenderFunction;
  10563. private _vaoRecordInProgress;
  10564. private _mustWipeVertexAttributes;
  10565. private _emptyTexture;
  10566. private _emptyCubeTexture;
  10567. private _emptyTexture3D;
  10568. /** @hidden */
  10569. _frameHandler: number;
  10570. private _nextFreeTextureSlots;
  10571. private _maxSimultaneousTextures;
  10572. private _activeRequests;
  10573. private _texturesSupported;
  10574. private _textureFormatInUse;
  10575. /**
  10576. * Gets the list of texture formats supported
  10577. */
  10578. readonly texturesSupported: Array<string>;
  10579. /**
  10580. * Gets the list of texture formats in use
  10581. */
  10582. readonly textureFormatInUse: Nullable<string>;
  10583. /**
  10584. * Gets the current viewport
  10585. */
  10586. readonly currentViewport: Nullable<Viewport>;
  10587. /**
  10588. * Gets the default empty texture
  10589. */
  10590. readonly emptyTexture: InternalTexture;
  10591. /**
  10592. * Gets the default empty 3D texture
  10593. */
  10594. readonly emptyTexture3D: InternalTexture;
  10595. /**
  10596. * Gets the default empty cube texture
  10597. */
  10598. readonly emptyCubeTexture: InternalTexture;
  10599. /**
  10600. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  10601. */
  10602. readonly premultipliedAlpha: boolean;
  10603. /**
  10604. * Creates a new engine
  10605. * @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
  10606. * @param antialias defines enable antialiasing (default: false)
  10607. * @param options defines further options to be sent to the getContext() function
  10608. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  10609. */
  10610. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  10611. private _rebuildInternalTextures;
  10612. private _rebuildEffects;
  10613. /**
  10614. * Gets a boolean indicating if all created effects are ready
  10615. * @returns true if all effects are ready
  10616. */
  10617. areAllEffectsReady(): boolean;
  10618. private _rebuildBuffers;
  10619. private _initGLContext;
  10620. /**
  10621. * Gets version of the current webGL context
  10622. */
  10623. readonly webGLVersion: number;
  10624. /**
  10625. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  10626. */
  10627. readonly isStencilEnable: boolean;
  10628. private _prepareWorkingCanvas;
  10629. /**
  10630. * Reset the texture cache to empty state
  10631. */
  10632. resetTextureCache(): void;
  10633. /**
  10634. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  10635. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10636. * @returns true if engine is in deterministic lock step mode
  10637. */
  10638. isDeterministicLockStep(): boolean;
  10639. /**
  10640. * Gets the max steps when engine is running in deterministic lock step
  10641. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  10642. * @returns the max steps
  10643. */
  10644. getLockstepMaxSteps(): number;
  10645. /**
  10646. * Gets an object containing information about the current webGL context
  10647. * @returns an object containing the vender, the renderer and the version of the current webGL context
  10648. */
  10649. getGlInfo(): {
  10650. vendor: string;
  10651. renderer: string;
  10652. version: string;
  10653. };
  10654. /**
  10655. * Gets current aspect ratio
  10656. * @param camera defines the camera to use to get the aspect ratio
  10657. * @param useScreen defines if screen size must be used (or the current render target if any)
  10658. * @returns a number defining the aspect ratio
  10659. */
  10660. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  10661. /**
  10662. * Gets current screen aspect ratio
  10663. * @returns a number defining the aspect ratio
  10664. */
  10665. getScreenAspectRatio(): number;
  10666. /**
  10667. * Gets the current render width
  10668. * @param useScreen defines if screen size must be used (or the current render target if any)
  10669. * @returns a number defining the current render width
  10670. */
  10671. getRenderWidth(useScreen?: boolean): number;
  10672. /**
  10673. * Gets the current render height
  10674. * @param useScreen defines if screen size must be used (or the current render target if any)
  10675. * @returns a number defining the current render height
  10676. */
  10677. getRenderHeight(useScreen?: boolean): number;
  10678. /**
  10679. * Gets the HTML canvas attached with the current webGL context
  10680. * @returns a HTML canvas
  10681. */
  10682. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  10683. /**
  10684. * Gets the client rect of the HTML canvas attached with the current webGL context
  10685. * @returns a client rectanglee
  10686. */
  10687. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  10688. /**
  10689. * Defines the hardware scaling level.
  10690. * By default the hardware scaling level is computed from the window device ratio.
  10691. * 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.
  10692. * @param level defines the level to use
  10693. */
  10694. setHardwareScalingLevel(level: number): void;
  10695. /**
  10696. * Gets the current hardware scaling level.
  10697. * By default the hardware scaling level is computed from the window device ratio.
  10698. * 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.
  10699. * @returns a number indicating the current hardware scaling level
  10700. */
  10701. getHardwareScalingLevel(): number;
  10702. /**
  10703. * Gets the list of loaded textures
  10704. * @returns an array containing all loaded textures
  10705. */
  10706. getLoadedTexturesCache(): InternalTexture[];
  10707. /**
  10708. * Gets the object containing all engine capabilities
  10709. * @returns the EngineCapabilities object
  10710. */
  10711. getCaps(): EngineCapabilities;
  10712. /**
  10713. * Gets the current depth function
  10714. * @returns a number defining the depth function
  10715. */
  10716. getDepthFunction(): Nullable<number>;
  10717. /**
  10718. * Sets the current depth function
  10719. * @param depthFunc defines the function to use
  10720. */
  10721. setDepthFunction(depthFunc: number): void;
  10722. /**
  10723. * Sets the current depth function to GREATER
  10724. */
  10725. setDepthFunctionToGreater(): void;
  10726. /**
  10727. * Sets the current depth function to GEQUAL
  10728. */
  10729. setDepthFunctionToGreaterOrEqual(): void;
  10730. /**
  10731. * Sets the current depth function to LESS
  10732. */
  10733. setDepthFunctionToLess(): void;
  10734. /**
  10735. * Sets the current depth function to LEQUAL
  10736. */
  10737. setDepthFunctionToLessOrEqual(): void;
  10738. /**
  10739. * Gets a boolean indicating if stencil buffer is enabled
  10740. * @returns the current stencil buffer state
  10741. */
  10742. getStencilBuffer(): boolean;
  10743. /**
  10744. * Enable or disable the stencil buffer
  10745. * @param enable defines if the stencil buffer must be enabled or disabled
  10746. */
  10747. setStencilBuffer(enable: boolean): void;
  10748. /**
  10749. * Gets the current stencil mask
  10750. * @returns a number defining the new stencil mask to use
  10751. */
  10752. getStencilMask(): number;
  10753. /**
  10754. * Sets the current stencil mask
  10755. * @param mask defines the new stencil mask to use
  10756. */
  10757. setStencilMask(mask: number): void;
  10758. /**
  10759. * Gets the current stencil function
  10760. * @returns a number defining the stencil function to use
  10761. */
  10762. getStencilFunction(): number;
  10763. /**
  10764. * Gets the current stencil reference value
  10765. * @returns a number defining the stencil reference value to use
  10766. */
  10767. getStencilFunctionReference(): number;
  10768. /**
  10769. * Gets the current stencil mask
  10770. * @returns a number defining the stencil mask to use
  10771. */
  10772. getStencilFunctionMask(): number;
  10773. /**
  10774. * Sets the current stencil function
  10775. * @param stencilFunc defines the new stencil function to use
  10776. */
  10777. setStencilFunction(stencilFunc: number): void;
  10778. /**
  10779. * Sets the current stencil reference
  10780. * @param reference defines the new stencil reference to use
  10781. */
  10782. setStencilFunctionReference(reference: number): void;
  10783. /**
  10784. * Sets the current stencil mask
  10785. * @param mask defines the new stencil mask to use
  10786. */
  10787. setStencilFunctionMask(mask: number): void;
  10788. /**
  10789. * Gets the current stencil operation when stencil fails
  10790. * @returns a number defining stencil operation to use when stencil fails
  10791. */
  10792. getStencilOperationFail(): number;
  10793. /**
  10794. * Gets the current stencil operation when depth fails
  10795. * @returns a number defining stencil operation to use when depth fails
  10796. */
  10797. getStencilOperationDepthFail(): number;
  10798. /**
  10799. * Gets the current stencil operation when stencil passes
  10800. * @returns a number defining stencil operation to use when stencil passes
  10801. */
  10802. getStencilOperationPass(): number;
  10803. /**
  10804. * Sets the stencil operation to use when stencil fails
  10805. * @param operation defines the stencil operation to use when stencil fails
  10806. */
  10807. setStencilOperationFail(operation: number): void;
  10808. /**
  10809. * Sets the stencil operation to use when depth fails
  10810. * @param operation defines the stencil operation to use when depth fails
  10811. */
  10812. setStencilOperationDepthFail(operation: number): void;
  10813. /**
  10814. * Sets the stencil operation to use when stencil passes
  10815. * @param operation defines the stencil operation to use when stencil passes
  10816. */
  10817. setStencilOperationPass(operation: number): void;
  10818. /**
  10819. * Sets a boolean indicating if the dithering state is enabled or disabled
  10820. * @param value defines the dithering state
  10821. */
  10822. setDitheringState(value: boolean): void;
  10823. /**
  10824. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  10825. * @param value defines the rasterizer state
  10826. */
  10827. setRasterizerState(value: boolean): void;
  10828. /**
  10829. * stop executing a render loop function and remove it from the execution array
  10830. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  10831. */
  10832. stopRenderLoop(renderFunction?: () => void): void;
  10833. /** @hidden */
  10834. _renderLoop(): void;
  10835. /**
  10836. * Register and execute a render loop. The engine can have more than one render function
  10837. * @param renderFunction defines the function to continuously execute
  10838. */
  10839. runRenderLoop(renderFunction: () => void): void;
  10840. /**
  10841. * Toggle full screen mode
  10842. * @param requestPointerLock defines if a pointer lock should be requested from the user
  10843. */
  10844. switchFullscreen(requestPointerLock: boolean): void;
  10845. /**
  10846. * Clear the current render buffer or the current render target (if any is set up)
  10847. * @param color defines the color to use
  10848. * @param backBuffer defines if the back buffer must be cleared
  10849. * @param depth defines if the depth buffer must be cleared
  10850. * @param stencil defines if the stencil buffer must be cleared
  10851. */
  10852. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  10853. /**
  10854. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  10855. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  10856. * @param y defines the y-coordinate of the corner of the clear rectangle
  10857. * @param width defines the width of the clear rectangle
  10858. * @param height defines the height of the clear rectangle
  10859. * @param clearColor defines the clear color
  10860. */
  10861. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  10862. private _viewportCached;
  10863. /** @hidden */
  10864. _viewport(x: number, y: number, width: number, height: number): void;
  10865. /**
  10866. * Set the WebGL's viewport
  10867. * @param viewport defines the viewport element to be used
  10868. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  10869. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  10870. */
  10871. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  10872. /**
  10873. * Directly set the WebGL Viewport
  10874. * @param x defines the x coordinate of the viewport (in screen space)
  10875. * @param y defines the y coordinate of the viewport (in screen space)
  10876. * @param width defines the width of the viewport (in screen space)
  10877. * @param height defines the height of the viewport (in screen space)
  10878. * @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
  10879. */
  10880. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  10881. /**
  10882. * Begin a new frame
  10883. */
  10884. beginFrame(): void;
  10885. /**
  10886. * Enf the current frame
  10887. */
  10888. endFrame(): void;
  10889. /**
  10890. * Resize the view according to the canvas' size
  10891. */
  10892. resize(): void;
  10893. /**
  10894. * Force a specific size of the canvas
  10895. * @param width defines the new canvas' width
  10896. * @param height defines the new canvas' height
  10897. */
  10898. setSize(width: number, height: number): void;
  10899. /**
  10900. * Gets a boolean indicating if a webVR device was detected
  10901. * @returns true if a webVR device was detected
  10902. */
  10903. isVRDevicePresent(): boolean;
  10904. /**
  10905. * Gets the current webVR device
  10906. * @returns the current webVR device (or null)
  10907. */
  10908. getVRDevice(): any;
  10909. /**
  10910. * Initializes a webVR display and starts listening to display change events
  10911. * The onVRDisplayChangedObservable will be notified upon these changes
  10912. * @returns The onVRDisplayChangedObservable
  10913. */
  10914. initWebVR(): Observable<IDisplayChangedEventArgs>;
  10915. /**
  10916. * Initializes a webVR display and starts listening to display change events
  10917. * The onVRDisplayChangedObservable will be notified upon these changes
  10918. * @returns A promise containing a VRDisplay and if vr is supported
  10919. */
  10920. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  10921. /**
  10922. * Call this function to switch to webVR mode
  10923. * Will do nothing if webVR is not supported or if there is no webVR device
  10924. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10925. */
  10926. enableVR(): void;
  10927. /**
  10928. * Call this function to leave webVR mode
  10929. * Will do nothing if webVR is not supported or if there is no webVR device
  10930. * @see http://doc.babylonjs.com/how_to/webvr_camera
  10931. */
  10932. disableVR(): void;
  10933. private _onVRFullScreenTriggered;
  10934. private _getVRDisplaysAsync;
  10935. /**
  10936. * Binds the frame buffer to the specified texture.
  10937. * @param texture The texture to render to or null for the default canvas
  10938. * @param faceIndex The face of the texture to render to in case of cube texture
  10939. * @param requiredWidth The width of the target to render to
  10940. * @param requiredHeight The height of the target to render to
  10941. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  10942. * @param depthStencilTexture The depth stencil texture to use to render
  10943. * @param lodLevel defines le lod level to bind to the frame buffer
  10944. */
  10945. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  10946. private bindUnboundFramebuffer;
  10947. /**
  10948. * Unbind the current render target texture from the webGL context
  10949. * @param texture defines the render target texture to unbind
  10950. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10951. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10952. */
  10953. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10954. /**
  10955. * Unbind a list of render target textures from the webGL context
  10956. * This is used only when drawBuffer extension or webGL2 are active
  10957. * @param textures defines the render target textures to unbind
  10958. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  10959. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  10960. */
  10961. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  10962. /**
  10963. * Force the mipmap generation for the given render target texture
  10964. * @param texture defines the render target texture to use
  10965. */
  10966. generateMipMapsForCubemap(texture: InternalTexture): void;
  10967. /**
  10968. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  10969. */
  10970. flushFramebuffer(): void;
  10971. /**
  10972. * Unbind the current render target and bind the default framebuffer
  10973. */
  10974. restoreDefaultFramebuffer(): void;
  10975. /**
  10976. * Create an uniform buffer
  10977. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10978. * @param elements defines the content of the uniform buffer
  10979. * @returns the webGL uniform buffer
  10980. */
  10981. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  10982. /**
  10983. * Create a dynamic uniform buffer
  10984. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10985. * @param elements defines the content of the uniform buffer
  10986. * @returns the webGL uniform buffer
  10987. */
  10988. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  10989. /**
  10990. * Update an existing uniform buffer
  10991. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  10992. * @param uniformBuffer defines the target uniform buffer
  10993. * @param elements defines the content to update
  10994. * @param offset defines the offset in the uniform buffer where update should start
  10995. * @param count defines the size of the data to update
  10996. */
  10997. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  10998. private _resetVertexBufferBinding;
  10999. /**
  11000. * Creates a vertex buffer
  11001. * @param data the data for the vertex buffer
  11002. * @returns the new WebGL static buffer
  11003. */
  11004. createVertexBuffer(data: DataArray): WebGLBuffer;
  11005. /**
  11006. * Creates a dynamic vertex buffer
  11007. * @param data the data for the dynamic vertex buffer
  11008. * @returns the new WebGL dynamic buffer
  11009. */
  11010. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  11011. /**
  11012. * Update a dynamic index buffer
  11013. * @param indexBuffer defines the target index buffer
  11014. * @param indices defines the data to update
  11015. * @param offset defines the offset in the target index buffer where update should start
  11016. */
  11017. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  11018. /**
  11019. * Updates a dynamic vertex buffer.
  11020. * @param vertexBuffer the vertex buffer to update
  11021. * @param data the data used to update the vertex buffer
  11022. * @param byteOffset the byte offset of the data
  11023. * @param byteLength the byte length of the data
  11024. */
  11025. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11026. private _resetIndexBufferBinding;
  11027. /**
  11028. * Creates a new index buffer
  11029. * @param indices defines the content of the index buffer
  11030. * @param updatable defines if the index buffer must be updatable
  11031. * @returns a new webGL buffer
  11032. */
  11033. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  11034. /**
  11035. * Bind a webGL buffer to the webGL context
  11036. * @param buffer defines the buffer to bind
  11037. */
  11038. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  11039. /**
  11040. * Bind an uniform buffer to the current webGL context
  11041. * @param buffer defines the buffer to bind
  11042. */
  11043. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  11044. /**
  11045. * Bind a buffer to the current webGL context at a given location
  11046. * @param buffer defines the buffer to bind
  11047. * @param location defines the index where to bind the buffer
  11048. */
  11049. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  11050. /**
  11051. * Bind a specific block at a given index in a specific shader program
  11052. * @param shaderProgram defines the shader program
  11053. * @param blockName defines the block name
  11054. * @param index defines the index where to bind the block
  11055. */
  11056. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  11057. private bindIndexBuffer;
  11058. private bindBuffer;
  11059. /**
  11060. * update the bound buffer with the given data
  11061. * @param data defines the data to update
  11062. */
  11063. updateArrayBuffer(data: Float32Array): void;
  11064. private _vertexAttribPointer;
  11065. private _bindIndexBufferWithCache;
  11066. private _bindVertexBuffersAttributes;
  11067. /**
  11068. * Records a vertex array object
  11069. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11070. * @param vertexBuffers defines the list of vertex buffers to store
  11071. * @param indexBuffer defines the index buffer to store
  11072. * @param effect defines the effect to store
  11073. * @returns the new vertex array object
  11074. */
  11075. recordVertexArrayObject(vertexBuffers: {
  11076. [key: string]: VertexBuffer;
  11077. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  11078. /**
  11079. * Bind a specific vertex array object
  11080. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  11081. * @param vertexArrayObject defines the vertex array object to bind
  11082. * @param indexBuffer defines the index buffer to bind
  11083. */
  11084. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  11085. /**
  11086. * Bind webGl buffers directly to the webGL context
  11087. * @param vertexBuffer defines the vertex buffer to bind
  11088. * @param indexBuffer defines the index buffer to bind
  11089. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  11090. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  11091. * @param effect defines the effect associated with the vertex buffer
  11092. */
  11093. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  11094. private _unbindVertexArrayObject;
  11095. /**
  11096. * Bind a list of vertex buffers to the webGL context
  11097. * @param vertexBuffers defines the list of vertex buffers to bind
  11098. * @param indexBuffer defines the index buffer to bind
  11099. * @param effect defines the effect associated with the vertex buffers
  11100. */
  11101. bindBuffers(vertexBuffers: {
  11102. [key: string]: Nullable<VertexBuffer>;
  11103. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  11104. /**
  11105. * Unbind all instance attributes
  11106. */
  11107. unbindInstanceAttributes(): void;
  11108. /**
  11109. * Release and free the memory of a vertex array object
  11110. * @param vao defines the vertex array object to delete
  11111. */
  11112. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  11113. /** @hidden */
  11114. _releaseBuffer(buffer: WebGLBuffer): boolean;
  11115. /**
  11116. * Creates a webGL buffer to use with instanciation
  11117. * @param capacity defines the size of the buffer
  11118. * @returns the webGL buffer
  11119. */
  11120. createInstancesBuffer(capacity: number): WebGLBuffer;
  11121. /**
  11122. * Delete a webGL buffer used with instanciation
  11123. * @param buffer defines the webGL buffer to delete
  11124. */
  11125. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  11126. /**
  11127. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  11128. * @param instancesBuffer defines the webGL buffer to update and bind
  11129. * @param data defines the data to store in the buffer
  11130. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  11131. */
  11132. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  11133. /**
  11134. * Apply all cached states (depth, culling, stencil and alpha)
  11135. */
  11136. applyStates(): void;
  11137. /**
  11138. * Send a draw order
  11139. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11140. * @param indexStart defines the starting index
  11141. * @param indexCount defines the number of index to draw
  11142. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11143. */
  11144. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  11145. /**
  11146. * Draw a list of points
  11147. * @param verticesStart defines the index of first vertex to draw
  11148. * @param verticesCount defines the count of vertices to draw
  11149. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11150. */
  11151. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11152. /**
  11153. * Draw a list of unindexed primitives
  11154. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  11155. * @param verticesStart defines the index of first vertex to draw
  11156. * @param verticesCount defines the count of vertices to draw
  11157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11158. */
  11159. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11160. /**
  11161. * Draw a list of indexed primitives
  11162. * @param fillMode defines the primitive to use
  11163. * @param indexStart defines the starting index
  11164. * @param indexCount defines the number of index to draw
  11165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11166. */
  11167. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  11168. /**
  11169. * Draw a list of unindexed primitives
  11170. * @param fillMode defines the primitive to use
  11171. * @param verticesStart defines the index of first vertex to draw
  11172. * @param verticesCount defines the count of vertices to draw
  11173. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  11174. */
  11175. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  11176. private _drawMode;
  11177. /** @hidden */
  11178. _releaseEffect(effect: Effect): void;
  11179. /** @hidden */
  11180. _deleteProgram(program: WebGLProgram): void;
  11181. /**
  11182. * Create a new effect (used to store vertex/fragment shaders)
  11183. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  11184. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  11185. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  11186. * @param samplers defines an array of string used to represent textures
  11187. * @param defines defines the string containing the defines to use to compile the shaders
  11188. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  11189. * @param onCompiled defines a function to call when the effect creation is successful
  11190. * @param onError defines a function to call when the effect creation has failed
  11191. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  11192. * @returns the new Effect
  11193. */
  11194. 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;
  11195. private _compileShader;
  11196. private _compileRawShader;
  11197. /**
  11198. * Directly creates a webGL program
  11199. * @param vertexCode defines the vertex shader code to use
  11200. * @param fragmentCode defines the fragment shader code to use
  11201. * @param context defines the webGL context to use (if not set, the current one will be used)
  11202. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11203. * @returns the new webGL program
  11204. */
  11205. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11206. /**
  11207. * Creates a webGL program
  11208. * @param vertexCode defines the vertex shader code to use
  11209. * @param fragmentCode defines the fragment shader code to use
  11210. * @param defines defines the string containing the defines to use to compile the shaders
  11211. * @param context defines the webGL context to use (if not set, the current one will be used)
  11212. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  11213. * @returns the new webGL program
  11214. */
  11215. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  11216. private _createShaderProgram;
  11217. private _finalizeProgram;
  11218. /** @hidden */
  11219. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  11220. /** @hidden */
  11221. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  11222. /**
  11223. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  11224. * @param shaderProgram defines the webGL program to use
  11225. * @param uniformsNames defines the list of uniform names
  11226. * @returns an array of webGL uniform locations
  11227. */
  11228. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  11229. /**
  11230. * Gets the lsit of active attributes for a given webGL program
  11231. * @param shaderProgram defines the webGL program to use
  11232. * @param attributesNames defines the list of attribute names to get
  11233. * @returns an array of indices indicating the offset of each attribute
  11234. */
  11235. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  11236. /**
  11237. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  11238. * @param effect defines the effect to activate
  11239. */
  11240. enableEffect(effect: Nullable<Effect>): void;
  11241. /**
  11242. * Set the value of an uniform to an array of int32
  11243. * @param uniform defines the webGL uniform location where to store the value
  11244. * @param array defines the array of int32 to store
  11245. */
  11246. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11247. /**
  11248. * Set the value of an uniform to an array of int32 (stored as vec2)
  11249. * @param uniform defines the webGL uniform location where to store the value
  11250. * @param array defines the array of int32 to store
  11251. */
  11252. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11253. /**
  11254. * Set the value of an uniform to an array of int32 (stored as vec3)
  11255. * @param uniform defines the webGL uniform location where to store the value
  11256. * @param array defines the array of int32 to store
  11257. */
  11258. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11259. /**
  11260. * Set the value of an uniform to an array of int32 (stored as vec4)
  11261. * @param uniform defines the webGL uniform location where to store the value
  11262. * @param array defines the array of int32 to store
  11263. */
  11264. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  11265. /**
  11266. * Set the value of an uniform to an array of float32
  11267. * @param uniform defines the webGL uniform location where to store the value
  11268. * @param array defines the array of float32 to store
  11269. */
  11270. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11271. /**
  11272. * Set the value of an uniform to an array of float32 (stored as vec2)
  11273. * @param uniform defines the webGL uniform location where to store the value
  11274. * @param array defines the array of float32 to store
  11275. */
  11276. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11277. /**
  11278. * Set the value of an uniform to an array of float32 (stored as vec3)
  11279. * @param uniform defines the webGL uniform location where to store the value
  11280. * @param array defines the array of float32 to store
  11281. */
  11282. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11283. /**
  11284. * Set the value of an uniform to an array of float32 (stored as vec4)
  11285. * @param uniform defines the webGL uniform location where to store the value
  11286. * @param array defines the array of float32 to store
  11287. */
  11288. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  11289. /**
  11290. * Set the value of an uniform to an array of number
  11291. * @param uniform defines the webGL uniform location where to store the value
  11292. * @param array defines the array of number to store
  11293. */
  11294. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11295. /**
  11296. * Set the value of an uniform to an array of number (stored as vec2)
  11297. * @param uniform defines the webGL uniform location where to store the value
  11298. * @param array defines the array of number to store
  11299. */
  11300. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11301. /**
  11302. * Set the value of an uniform to an array of number (stored as vec3)
  11303. * @param uniform defines the webGL uniform location where to store the value
  11304. * @param array defines the array of number to store
  11305. */
  11306. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11307. /**
  11308. * Set the value of an uniform to an array of number (stored as vec4)
  11309. * @param uniform defines the webGL uniform location where to store the value
  11310. * @param array defines the array of number to store
  11311. */
  11312. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  11313. /**
  11314. * Set the value of an uniform to an array of float32 (stored as matrices)
  11315. * @param uniform defines the webGL uniform location where to store the value
  11316. * @param matrices defines the array of float32 to store
  11317. */
  11318. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  11319. /**
  11320. * Set the value of an uniform to a matrix
  11321. * @param uniform defines the webGL uniform location where to store the value
  11322. * @param matrix defines the matrix to store
  11323. */
  11324. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  11325. /**
  11326. * Set the value of an uniform to a matrix (3x3)
  11327. * @param uniform defines the webGL uniform location where to store the value
  11328. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  11329. */
  11330. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11331. /**
  11332. * Set the value of an uniform to a matrix (2x2)
  11333. * @param uniform defines the webGL uniform location where to store the value
  11334. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  11335. */
  11336. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  11337. /**
  11338. * Set the value of an uniform to a number (int)
  11339. * @param uniform defines the webGL uniform location where to store the value
  11340. * @param value defines the int number to store
  11341. */
  11342. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11343. /**
  11344. * Set the value of an uniform to a number (float)
  11345. * @param uniform defines the webGL uniform location where to store the value
  11346. * @param value defines the float number to store
  11347. */
  11348. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  11349. /**
  11350. * Set the value of an uniform to a vec2
  11351. * @param uniform defines the webGL uniform location where to store the value
  11352. * @param x defines the 1st component of the value
  11353. * @param y defines the 2nd component of the value
  11354. */
  11355. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  11356. /**
  11357. * Set the value of an uniform to a vec3
  11358. * @param uniform defines the webGL uniform location where to store the value
  11359. * @param x defines the 1st component of the value
  11360. * @param y defines the 2nd component of the value
  11361. * @param z defines the 3rd component of the value
  11362. */
  11363. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  11364. /**
  11365. * Set the value of an uniform to a boolean
  11366. * @param uniform defines the webGL uniform location where to store the value
  11367. * @param bool defines the boolean to store
  11368. */
  11369. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  11370. /**
  11371. * Set the value of an uniform to a vec4
  11372. * @param uniform defines the webGL uniform location where to store the value
  11373. * @param x defines the 1st component of the value
  11374. * @param y defines the 2nd component of the value
  11375. * @param z defines the 3rd component of the value
  11376. * @param w defines the 4th component of the value
  11377. */
  11378. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  11379. /**
  11380. * Set the value of an uniform to a Color3
  11381. * @param uniform defines the webGL uniform location where to store the value
  11382. * @param color3 defines the color to store
  11383. */
  11384. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  11385. /**
  11386. * Set the value of an uniform to a Color3 and an alpha value
  11387. * @param uniform defines the webGL uniform location where to store the value
  11388. * @param color3 defines the color to store
  11389. * @param alpha defines the alpha component to store
  11390. */
  11391. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  11392. /**
  11393. * Sets a Color4 on a uniform variable
  11394. * @param uniform defines the uniform location
  11395. * @param color4 defines the value to be set
  11396. */
  11397. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  11398. /**
  11399. * Set various states to the webGL context
  11400. * @param culling defines backface culling state
  11401. * @param zOffset defines the value to apply to zOffset (0 by default)
  11402. * @param force defines if states must be applied even if cache is up to date
  11403. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  11404. */
  11405. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  11406. /**
  11407. * Set the z offset to apply to current rendering
  11408. * @param value defines the offset to apply
  11409. */
  11410. setZOffset(value: number): void;
  11411. /**
  11412. * Gets the current value of the zOffset
  11413. * @returns the current zOffset state
  11414. */
  11415. getZOffset(): number;
  11416. /**
  11417. * Enable or disable depth buffering
  11418. * @param enable defines the state to set
  11419. */
  11420. setDepthBuffer(enable: boolean): void;
  11421. /**
  11422. * Gets a boolean indicating if depth writing is enabled
  11423. * @returns the current depth writing state
  11424. */
  11425. getDepthWrite(): boolean;
  11426. /**
  11427. * Enable or disable depth writing
  11428. * @param enable defines the state to set
  11429. */
  11430. setDepthWrite(enable: boolean): void;
  11431. /**
  11432. * Enable or disable color writing
  11433. * @param enable defines the state to set
  11434. */
  11435. setColorWrite(enable: boolean): void;
  11436. /**
  11437. * Gets a boolean indicating if color writing is enabled
  11438. * @returns the current color writing state
  11439. */
  11440. getColorWrite(): boolean;
  11441. /**
  11442. * Sets alpha constants used by some alpha blending modes
  11443. * @param r defines the red component
  11444. * @param g defines the green component
  11445. * @param b defines the blue component
  11446. * @param a defines the alpha component
  11447. */
  11448. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  11449. /**
  11450. * Sets the current alpha mode
  11451. * @param mode defines the mode to use (one of the BABYLON.Engine.ALPHA_XXX)
  11452. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  11453. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11454. */
  11455. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  11456. /**
  11457. * Gets the current alpha mode
  11458. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  11459. * @returns the current alpha mode
  11460. */
  11461. getAlphaMode(): number;
  11462. /**
  11463. * Clears the list of texture accessible through engine.
  11464. * This can help preventing texture load conflict due to name collision.
  11465. */
  11466. clearInternalTexturesCache(): void;
  11467. /**
  11468. * Force the entire cache to be cleared
  11469. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  11470. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  11471. */
  11472. wipeCaches(bruteForce?: boolean): void;
  11473. /**
  11474. * Set the compressed texture format to use, based on the formats you have, and the formats
  11475. * supported by the hardware / browser.
  11476. *
  11477. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  11478. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  11479. * to API arguments needed to compressed textures. This puts the burden on the container
  11480. * generator to house the arcane code for determining these for current & future formats.
  11481. *
  11482. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  11483. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  11484. *
  11485. * Note: The result of this call is not taken into account when a texture is base64.
  11486. *
  11487. * @param formatsAvailable defines the list of those format families you have created
  11488. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  11489. *
  11490. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  11491. * @returns The extension selected.
  11492. */
  11493. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  11494. private _getSamplingParameters;
  11495. private _partialLoadImg;
  11496. private _cascadeLoadImgs;
  11497. /** @hidden */
  11498. _createTexture(): WebGLTexture;
  11499. /**
  11500. * Usually called from BABYLON.Texture.ts.
  11501. * Passed information to create a WebGLTexture
  11502. * @param urlArg defines a value which contains one of the following:
  11503. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  11504. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  11505. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  11506. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  11507. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  11508. * @param scene needed for loading to the correct scene
  11509. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  11510. * @param onLoad optional callback to be called upon successful completion
  11511. * @param onError optional callback to be called upon failure
  11512. * @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
  11513. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  11514. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  11515. * @param forcedExtension defines the extension to use to pick the right loader
  11516. * @returns a InternalTexture for assignment back into BABYLON.Texture
  11517. */
  11518. 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>): InternalTexture;
  11519. private _rescaleTexture;
  11520. /**
  11521. * Update a raw texture
  11522. * @param texture defines the texture to update
  11523. * @param data defines the data to store in the texture
  11524. * @param format defines the format of the data
  11525. * @param invertY defines if data must be stored with Y axis inverted
  11526. * @param compression defines the compression used (null by default)
  11527. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11528. */
  11529. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  11530. /**
  11531. * Creates a raw texture
  11532. * @param data defines the data to store in the texture
  11533. * @param width defines the width of the texture
  11534. * @param height defines the height of the texture
  11535. * @param format defines the format of the data
  11536. * @param generateMipMaps defines if the engine should generate the mip levels
  11537. * @param invertY defines if data must be stored with Y axis inverted
  11538. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11539. * @param compression defines the compression used (null by default)
  11540. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11541. * @returns the raw texture inside an InternalTexture
  11542. */
  11543. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  11544. private _unpackFlipYCached;
  11545. /**
  11546. * In case you are sharing the context with other applications, it might
  11547. * be interested to not cache the unpack flip y state to ensure a consistent
  11548. * value would be set.
  11549. */
  11550. enableUnpackFlipYCached: boolean;
  11551. /** @hidden */
  11552. _unpackFlipY(value: boolean): void;
  11553. /** @hidden */
  11554. _getUnpackAlignement(): number;
  11555. /**
  11556. * Creates a dynamic texture
  11557. * @param width defines the width of the texture
  11558. * @param height defines the height of the texture
  11559. * @param generateMipMaps defines if the engine should generate the mip levels
  11560. * @param samplingMode defines the required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  11561. * @returns the dynamic texture inside an InternalTexture
  11562. */
  11563. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  11564. /**
  11565. * Update the sampling mode of a given texture
  11566. * @param samplingMode defines the required sampling mode
  11567. * @param texture defines the texture to update
  11568. */
  11569. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  11570. /**
  11571. * Update the content of a dynamic texture
  11572. * @param texture defines the texture to update
  11573. * @param canvas defines the canvas containing the source
  11574. * @param invertY defines if data must be stored with Y axis inverted
  11575. * @param premulAlpha defines if alpha is stored as premultiplied
  11576. * @param format defines the format of the data
  11577. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  11578. */
  11579. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  11580. /**
  11581. * Update a video texture
  11582. * @param texture defines the texture to update
  11583. * @param video defines the video element to use
  11584. * @param invertY defines if data must be stored with Y axis inverted
  11585. */
  11586. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  11587. /**
  11588. * Updates a depth texture Comparison Mode and Function.
  11589. * If the comparison Function is equal to 0, the mode will be set to none.
  11590. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  11591. * @param texture The texture to set the comparison function for
  11592. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  11593. */
  11594. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  11595. private _setupDepthStencilTexture;
  11596. /**
  11597. * Creates a depth stencil texture.
  11598. * This is only available in WebGL 2 or with the depth texture extension available.
  11599. * @param size The size of face edge in the texture.
  11600. * @param options The options defining the texture.
  11601. * @returns The texture
  11602. */
  11603. createDepthStencilTexture(size: number | {
  11604. width: number;
  11605. height: number;
  11606. }, options: DepthTextureCreationOptions): InternalTexture;
  11607. /**
  11608. * Creates a depth stencil texture.
  11609. * This is only available in WebGL 2 or with the depth texture extension available.
  11610. * @param size The size of face edge in the texture.
  11611. * @param options The options defining the texture.
  11612. * @returns The texture
  11613. */
  11614. private _createDepthStencilTexture;
  11615. /**
  11616. * Creates a depth stencil cube texture.
  11617. * This is only available in WebGL 2.
  11618. * @param size The size of face edge in the cube texture.
  11619. * @param options The options defining the cube texture.
  11620. * @returns The cube texture
  11621. */
  11622. private _createDepthStencilCubeTexture;
  11623. /**
  11624. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  11625. * @param renderTarget The render target to set the frame buffer for
  11626. */
  11627. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  11628. /**
  11629. * Creates a new render target texture
  11630. * @param size defines the size of the texture
  11631. * @param options defines the options used to create the texture
  11632. * @returns a new render target texture stored in an InternalTexture
  11633. */
  11634. createRenderTargetTexture(size: number | {
  11635. width: number;
  11636. height: number;
  11637. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  11638. /**
  11639. * Create a multi render target texture
  11640. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  11641. * @param size defines the size of the texture
  11642. * @param options defines the creation options
  11643. * @returns the cube texture as an InternalTexture
  11644. */
  11645. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  11646. private _setupFramebufferDepthAttachments;
  11647. /**
  11648. * Updates the sample count of a render target texture
  11649. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11650. * @param texture defines the texture to update
  11651. * @param samples defines the sample count to set
  11652. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11653. */
  11654. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  11655. /**
  11656. * Update the sample count for a given multiple render target texture
  11657. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  11658. * @param textures defines the textures to update
  11659. * @param samples defines the sample count to set
  11660. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  11661. */
  11662. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  11663. /** @hidden */
  11664. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11665. /** @hidden */
  11666. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11667. /** @hidden */
  11668. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  11669. /** @hidden */
  11670. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  11671. /**
  11672. * Creates a new render target cube texture
  11673. * @param size defines the size of the texture
  11674. * @param options defines the options used to create the texture
  11675. * @returns a new render target cube texture stored in an InternalTexture
  11676. */
  11677. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11678. /**
  11679. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  11680. * @param rootUrl defines the url where the file to load is located
  11681. * @param scene defines the current scene
  11682. * @param lodScale defines scale to apply to the mip map selection
  11683. * @param lodOffset defines offset to apply to the mip map selection
  11684. * @param onLoad defines an optional callback raised when the texture is loaded
  11685. * @param onError defines an optional callback raised if there is an issue to load the texture
  11686. * @param format defines the format of the data
  11687. * @param forcedExtension defines the extension to use to pick the right loader
  11688. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  11689. * @returns the cube texture as an InternalTexture
  11690. */
  11691. 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;
  11692. /**
  11693. * Creates a cube texture
  11694. * @param rootUrl defines the url where the files to load is located
  11695. * @param scene defines the current scene
  11696. * @param files defines the list of files to load (1 per face)
  11697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11698. * @param onLoad defines an optional callback raised when the texture is loaded
  11699. * @param onError defines an optional callback raised if there is an issue to load the texture
  11700. * @param format defines the format of the data
  11701. * @param forcedExtension defines the extension to use to pick the right loader
  11702. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11703. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11704. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11705. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11706. * @returns the cube texture as an InternalTexture
  11707. */
  11708. 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>): InternalTexture;
  11709. /**
  11710. * @hidden
  11711. */
  11712. _setCubeMapTextureParams(loadMipmap: boolean): void;
  11713. /**
  11714. * Update a raw cube texture
  11715. * @param texture defines the texture to udpdate
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11719. * @param invertY defines if data must be stored with Y axis inverted
  11720. * @param compression defines the compression used (null by default)
  11721. * @param level defines which level of the texture to update
  11722. */
  11723. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  11724. /**
  11725. * Creates a new raw cube texture
  11726. * @param data defines the array of data to use to create each face
  11727. * @param size defines the size of the textures
  11728. * @param format defines the format of the data
  11729. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11730. * @param generateMipMaps defines if the engine should generate the mip levels
  11731. * @param invertY defines if data must be stored with Y axis inverted
  11732. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11733. * @param compression defines the compression used (null by default)
  11734. * @returns the cube texture as an InternalTexture
  11735. */
  11736. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  11737. /**
  11738. * Creates a new raw cube texture from a specified url
  11739. * @param url defines the url where the data is located
  11740. * @param scene defines the current scene
  11741. * @param size defines the size of the textures
  11742. * @param format defines the format of the data
  11743. * @param type defines the type fo the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  11744. * @param noMipmap defines if the engine should avoid generating the mip levels
  11745. * @param callback defines a callback used to extract texture data from loaded data
  11746. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11747. * @param onLoad defines a callback called when texture is loaded
  11748. * @param onError defines a callback called if there is an error
  11749. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11750. * @param invertY defines if data must be stored with Y axis inverted
  11751. * @returns the cube texture as an InternalTexture
  11752. */
  11753. 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;
  11754. /**
  11755. * Update a raw 3D texture
  11756. * @param texture defines the texture to update
  11757. * @param data defines the data to store
  11758. * @param format defines the data format
  11759. * @param invertY defines if data must be stored with Y axis inverted
  11760. * @param compression defines the used compression (can be null)
  11761. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11762. */
  11763. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  11764. /**
  11765. * Creates a new raw 3D texture
  11766. * @param data defines the data used to create the texture
  11767. * @param width defines the width of the texture
  11768. * @param height defines the height of the texture
  11769. * @param depth defines the depth of the texture
  11770. * @param format defines the format of the texture
  11771. * @param generateMipMaps defines if the engine must generate mip levels
  11772. * @param invertY defines if data must be stored with Y axis inverted
  11773. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  11774. * @param compression defines the compressed used (can be null)
  11775. * @param textureType defines the compressed used (can be null)
  11776. * @returns a new raw 3D texture (stored in an InternalTexture)
  11777. */
  11778. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  11779. private _prepareWebGLTextureContinuation;
  11780. private _prepareWebGLTexture;
  11781. private _convertRGBtoRGBATextureData;
  11782. /** @hidden */
  11783. _releaseFramebufferObjects(texture: InternalTexture): void;
  11784. /** @hidden */
  11785. _releaseTexture(texture: InternalTexture): void;
  11786. private setProgram;
  11787. private _boundUniforms;
  11788. /**
  11789. * Binds an effect to the webGL context
  11790. * @param effect defines the effect to bind
  11791. */
  11792. bindSamplers(effect: Effect): void;
  11793. private _moveBoundTextureOnTop;
  11794. private _getCorrectTextureChannel;
  11795. private _linkTrackers;
  11796. private _removeDesignatedSlot;
  11797. private _activateCurrentTexture;
  11798. /** @hidden */
  11799. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  11800. /** @hidden */
  11801. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  11802. /**
  11803. * Sets a texture to the webGL context from a postprocess
  11804. * @param channel defines the channel to use
  11805. * @param postProcess defines the source postprocess
  11806. */
  11807. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  11808. /**
  11809. * Binds the output of the passed in post process to the texture channel specified
  11810. * @param channel The channel the texture should be bound to
  11811. * @param postProcess The post process which's output should be bound
  11812. */
  11813. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  11814. /**
  11815. * Unbind all textures from the webGL context
  11816. */
  11817. unbindAllTextures(): void;
  11818. /**
  11819. * Sets a texture to the according uniform.
  11820. * @param channel The texture channel
  11821. * @param uniform The uniform to set
  11822. * @param texture The texture to apply
  11823. */
  11824. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  11825. /**
  11826. * Sets a depth stencil texture from a render target to the according uniform.
  11827. * @param channel The texture channel
  11828. * @param uniform The uniform to set
  11829. * @param texture The render target texture containing the depth stencil texture to apply
  11830. */
  11831. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  11832. private _bindSamplerUniformToChannel;
  11833. private _getTextureWrapMode;
  11834. private _setTexture;
  11835. /**
  11836. * Sets an array of texture to the webGL context
  11837. * @param channel defines the channel where the texture array must be set
  11838. * @param uniform defines the associated uniform location
  11839. * @param textures defines the array of textures to bind
  11840. */
  11841. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  11842. /** @hidden */
  11843. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  11844. private _setTextureParameterFloat;
  11845. private _setTextureParameterInteger;
  11846. /**
  11847. * Reads pixels from the current frame buffer. Please note that this function can be slow
  11848. * @param x defines the x coordinate of the rectangle where pixels must be read
  11849. * @param y defines the y coordinate of the rectangle where pixels must be read
  11850. * @param width defines the width of the rectangle where pixels must be read
  11851. * @param height defines the height of the rectangle where pixels must be read
  11852. * @returns a Uint8Array containing RGBA colors
  11853. */
  11854. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  11855. /**
  11856. * Add an externaly attached data from its key.
  11857. * This method call will fail and return false, if such key already exists.
  11858. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  11859. * @param key the unique key that identifies the data
  11860. * @param data the data object to associate to the key for this Engine instance
  11861. * @return true if no such key were already present and the data was added successfully, false otherwise
  11862. */
  11863. addExternalData<T>(key: string, data: T): boolean;
  11864. /**
  11865. * Get an externaly attached data from its key
  11866. * @param key the unique key that identifies the data
  11867. * @return the associated data, if present (can be null), or undefined if not present
  11868. */
  11869. getExternalData<T>(key: string): T;
  11870. /**
  11871. * Get an externaly attached data from its key, create it using a factory if it's not already present
  11872. * @param key the unique key that identifies the data
  11873. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  11874. * @return the associated data, can be null if the factory returned null.
  11875. */
  11876. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  11877. /**
  11878. * Remove an externaly attached data from the Engine instance
  11879. * @param key the unique key that identifies the data
  11880. * @return true if the data was successfully removed, false if it doesn't exist
  11881. */
  11882. removeExternalData(key: string): boolean;
  11883. /**
  11884. * Unbind all vertex attributes from the webGL context
  11885. */
  11886. unbindAllAttributes(): void;
  11887. /**
  11888. * 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
  11889. */
  11890. releaseEffects(): void;
  11891. /**
  11892. * Dispose and release all associated resources
  11893. */
  11894. dispose(): void;
  11895. /**
  11896. * Display the loading screen
  11897. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11898. */
  11899. displayLoadingUI(): void;
  11900. /**
  11901. * Hide the loading screen
  11902. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11903. */
  11904. hideLoadingUI(): void;
  11905. /**
  11906. * Gets the current loading screen object
  11907. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11908. */
  11909. /**
  11910. * Sets the current loading screen object
  11911. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11912. */
  11913. loadingScreen: ILoadingScreen;
  11914. /**
  11915. * Sets the current loading screen text
  11916. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11917. */
  11918. loadingUIText: string;
  11919. /**
  11920. * Sets the current loading screen background color
  11921. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  11922. */
  11923. loadingUIBackgroundColor: string;
  11924. /**
  11925. * Attach a new callback raised when context lost event is fired
  11926. * @param callback defines the callback to call
  11927. */
  11928. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11929. /**
  11930. * Attach a new callback raised when context restored event is fired
  11931. * @param callback defines the callback to call
  11932. */
  11933. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  11934. /**
  11935. * Gets the source code of the vertex shader associated with a specific webGL program
  11936. * @param program defines the program to use
  11937. * @returns a string containing the source code of the vertex shader associated with the program
  11938. */
  11939. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  11940. /**
  11941. * Gets the source code of the fragment shader associated with a specific webGL program
  11942. * @param program defines the program to use
  11943. * @returns a string containing the source code of the fragment shader associated with the program
  11944. */
  11945. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  11946. /**
  11947. * Get the current error code of the webGL context
  11948. * @returns the error code
  11949. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  11950. */
  11951. getError(): number;
  11952. /**
  11953. * Gets the current framerate
  11954. * @returns a number representing the framerate
  11955. */
  11956. getFps(): number;
  11957. /**
  11958. * Gets the time spent between current and previous frame
  11959. * @returns a number representing the delta time in ms
  11960. */
  11961. getDeltaTime(): number;
  11962. private _measureFps;
  11963. /** @hidden */
  11964. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  11965. private _canRenderToFloatFramebuffer;
  11966. private _canRenderToHalfFloatFramebuffer;
  11967. private _canRenderToFramebuffer;
  11968. /** @hidden */
  11969. _getWebGLTextureType(type: number): number;
  11970. private _getInternalFormat;
  11971. /** @hidden */
  11972. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  11973. /** @hidden */
  11974. _getRGBAMultiSampleBufferFormat(type: number): number;
  11975. /** @hidden */
  11976. _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;
  11977. /** @hidden */
  11978. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  11979. private _partialLoadFile;
  11980. private _cascadeLoadFiles;
  11981. /**
  11982. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  11983. * @returns true if the engine can be created
  11984. * @ignorenaming
  11985. */
  11986. static isSupported(): boolean;
  11987. }
  11988. }
  11989. declare module BABYLON {
  11990. /**
  11991. * Options to create the null engine
  11992. */
  11993. class NullEngineOptions {
  11994. /**
  11995. * Render width (Default: 512)
  11996. */
  11997. renderWidth: number;
  11998. /**
  11999. * Render height (Default: 256)
  12000. */
  12001. renderHeight: number;
  12002. /**
  12003. * Texture size (Default: 512)
  12004. */
  12005. textureSize: number;
  12006. /**
  12007. * If delta time between frames should be constant
  12008. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12009. */
  12010. deterministicLockstep: boolean;
  12011. /**
  12012. * Maximum about of steps between frames (Default: 4)
  12013. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12014. */
  12015. lockstepMaxSteps: number;
  12016. }
  12017. /**
  12018. * The null engine class provides support for headless version of babylon.js.
  12019. * This can be used in server side scenario or for testing purposes
  12020. */
  12021. class NullEngine extends Engine {
  12022. private _options;
  12023. /**
  12024. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  12025. */
  12026. isDeterministicLockStep(): boolean;
  12027. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  12028. getLockstepMaxSteps(): number;
  12029. /**
  12030. * Sets hardware scaling, used to save performance if needed
  12031. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  12032. */
  12033. getHardwareScalingLevel(): number;
  12034. constructor(options?: NullEngineOptions);
  12035. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12036. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  12037. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  12038. getRenderWidth(useScreen?: boolean): number;
  12039. getRenderHeight(useScreen?: boolean): number;
  12040. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  12041. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  12042. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  12043. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  12044. bindSamplers(effect: Effect): void;
  12045. enableEffect(effect: Effect): void;
  12046. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  12047. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  12048. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  12049. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  12050. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  12051. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  12052. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  12053. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  12054. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  12055. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  12056. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  12057. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  12058. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  12059. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  12060. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  12061. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12062. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  12063. setFloat(uniform: WebGLUniformLocation, value: number): void;
  12064. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  12065. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  12066. setBool(uniform: WebGLUniformLocation, bool: number): void;
  12067. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  12068. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  12069. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  12070. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12071. bindBuffers(vertexBuffers: {
  12072. [key: string]: VertexBuffer;
  12073. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  12074. wipeCaches(bruteForce?: boolean): void;
  12075. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  12076. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  12077. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  12078. /** @hidden */
  12079. _createTexture(): WebGLTexture;
  12080. /** @hidden */
  12081. _releaseTexture(texture: InternalTexture): void;
  12082. 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;
  12083. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12084. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  12085. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  12086. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  12087. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  12088. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  12089. areAllEffectsReady(): boolean;
  12090. /**
  12091. * @hidden
  12092. * Get the current error code of the webGL context
  12093. * @returns the error code
  12094. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  12095. */
  12096. getError(): number;
  12097. /** @hidden */
  12098. _getUnpackAlignement(): number;
  12099. /** @hidden */
  12100. _unpackFlipY(value: boolean): void;
  12101. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  12102. /**
  12103. * Updates a dynamic vertex buffer.
  12104. * @param vertexBuffer the vertex buffer to update
  12105. * @param data the data used to update the vertex buffer
  12106. * @param byteOffset the byte offset of the data (optional)
  12107. * @param byteLength the byte length of the data (optional)
  12108. */
  12109. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  12110. protected _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  12111. /** @hidden */
  12112. _bindTexture(channel: number, texture: InternalTexture): void;
  12113. /** @hidden */
  12114. _releaseBuffer(buffer: WebGLBuffer): boolean;
  12115. releaseEffects(): void;
  12116. displayLoadingUI(): void;
  12117. hideLoadingUI(): void;
  12118. /** @hidden */
  12119. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12120. /** @hidden */
  12121. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12122. /** @hidden */
  12123. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  12124. /** @hidden */
  12125. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  12126. }
  12127. }
  12128. interface WebGLRenderingContext {
  12129. readonly RASTERIZER_DISCARD: number;
  12130. readonly DEPTH_COMPONENT24: number;
  12131. readonly TEXTURE_3D: number;
  12132. readonly TEXTURE_2D_ARRAY: number;
  12133. readonly TEXTURE_COMPARE_FUNC: number;
  12134. readonly TEXTURE_COMPARE_MODE: number;
  12135. readonly COMPARE_REF_TO_TEXTURE: number;
  12136. readonly TEXTURE_WRAP_R: number;
  12137. readonly HALF_FLOAT: number;
  12138. readonly RGB8: number;
  12139. readonly RED_INTEGER: number;
  12140. readonly RG_INTEGER: number;
  12141. readonly RGB_INTEGER: number;
  12142. readonly RGBA_INTEGER: number;
  12143. readonly R8_SNORM: number;
  12144. readonly RG8_SNORM: number;
  12145. readonly RGB8_SNORM: number;
  12146. readonly RGBA8_SNORM: number;
  12147. readonly R8I: number;
  12148. readonly RG8I: number;
  12149. readonly RGB8I: number;
  12150. readonly RGBA8I: number;
  12151. readonly R8UI: number;
  12152. readonly RG8UI: number;
  12153. readonly RGB8UI: number;
  12154. readonly RGBA8UI: number;
  12155. readonly R16I: number;
  12156. readonly RG16I: number;
  12157. readonly RGB16I: number;
  12158. readonly RGBA16I: number;
  12159. readonly R16UI: number;
  12160. readonly RG16UI: number;
  12161. readonly RGB16UI: number;
  12162. readonly RGBA16UI: number;
  12163. readonly R32I: number;
  12164. readonly RG32I: number;
  12165. readonly RGB32I: number;
  12166. readonly RGBA32I: number;
  12167. readonly R32UI: number;
  12168. readonly RG32UI: number;
  12169. readonly RGB32UI: number;
  12170. readonly RGBA32UI: number;
  12171. readonly RGB10_A2UI: number;
  12172. readonly R11F_G11F_B10F: number;
  12173. readonly RGB9_E5: number;
  12174. readonly RGB10_A2: number;
  12175. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  12176. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  12177. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  12178. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  12179. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  12180. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  12181. 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;
  12182. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  12183. readonly TRANSFORM_FEEDBACK: number;
  12184. readonly INTERLEAVED_ATTRIBS: number;
  12185. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  12186. createTransformFeedback(): WebGLTransformFeedback;
  12187. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  12188. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  12189. beginTransformFeedback(primitiveMode: number): void;
  12190. endTransformFeedback(): void;
  12191. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  12192. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12193. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12194. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  12195. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  12196. }
  12197. interface ImageBitmap {
  12198. readonly width: number;
  12199. readonly height: number;
  12200. close(): void;
  12201. }
  12202. interface WebGLQuery extends WebGLObject {
  12203. }
  12204. declare var WebGLQuery: {
  12205. prototype: WebGLQuery;
  12206. new (): WebGLQuery;
  12207. };
  12208. interface WebGLSampler extends WebGLObject {
  12209. }
  12210. declare var WebGLSampler: {
  12211. prototype: WebGLSampler;
  12212. new (): WebGLSampler;
  12213. };
  12214. interface WebGLSync extends WebGLObject {
  12215. }
  12216. declare var WebGLSync: {
  12217. prototype: WebGLSync;
  12218. new (): WebGLSync;
  12219. };
  12220. interface WebGLTransformFeedback extends WebGLObject {
  12221. }
  12222. declare var WebGLTransformFeedback: {
  12223. prototype: WebGLTransformFeedback;
  12224. new (): WebGLTransformFeedback;
  12225. };
  12226. interface WebGLVertexArrayObject extends WebGLObject {
  12227. }
  12228. declare var WebGLVertexArrayObject: {
  12229. prototype: WebGLVertexArrayObject;
  12230. new (): WebGLVertexArrayObject;
  12231. };
  12232. declare module BABYLON {
  12233. /**
  12234. * Gather the list of clipboard event types as constants.
  12235. */
  12236. class ClipboardEventTypes {
  12237. /**
  12238. * The clipboard event is fired when a copy command is active (pressed).
  12239. */
  12240. static readonly COPY: number;
  12241. /**
  12242. * The clipboard event is fired when a cut command is active (pressed).
  12243. */
  12244. static readonly CUT: number;
  12245. /**
  12246. * The clipboard event is fired when a paste command is active (pressed).
  12247. */
  12248. static readonly PASTE: number;
  12249. }
  12250. /**
  12251. * This class is used to store clipboard related info for the onClipboardObservable event.
  12252. */
  12253. class ClipboardInfo {
  12254. /**
  12255. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12256. */
  12257. type: number;
  12258. /**
  12259. * Defines the related dom event
  12260. */
  12261. event: ClipboardEvent;
  12262. /**
  12263. *Creates an instance of ClipboardInfo.
  12264. * @param {number} type
  12265. * @param {ClipboardEvent} event
  12266. */
  12267. constructor(
  12268. /**
  12269. * Defines the type of event (BABYLON.ClipboardEventTypes)
  12270. */
  12271. type: number,
  12272. /**
  12273. * Defines the related dom event
  12274. */
  12275. event: ClipboardEvent);
  12276. /**
  12277. * Get the clipboard event's type from the keycode.
  12278. * @param keyCode Defines the keyCode for the current keyboard event.
  12279. * @return {number}
  12280. */
  12281. static GetTypeFromCharacter(keyCode: number): number;
  12282. }
  12283. }
  12284. declare module BABYLON {
  12285. /**
  12286. * Gather the list of keyboard event types as constants.
  12287. */
  12288. class KeyboardEventTypes {
  12289. /**
  12290. * The keydown event is fired when a key becomes active (pressed).
  12291. */
  12292. static readonly KEYDOWN: number;
  12293. /**
  12294. * The keyup event is fired when a key has been released.
  12295. */
  12296. static readonly KEYUP: number;
  12297. }
  12298. /**
  12299. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12300. */
  12301. class KeyboardInfo {
  12302. /**
  12303. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12304. */
  12305. type: number;
  12306. /**
  12307. * Defines the related dom event
  12308. */
  12309. event: KeyboardEvent;
  12310. /**
  12311. * Instantiates a new keyboard info.
  12312. * This class is used to store keyboard related info for the onKeyboardObservable event.
  12313. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12314. * @param event Defines the related dom event
  12315. */
  12316. constructor(
  12317. /**
  12318. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12319. */
  12320. type: number,
  12321. /**
  12322. * Defines the related dom event
  12323. */
  12324. event: KeyboardEvent);
  12325. }
  12326. /**
  12327. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12328. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  12329. */
  12330. class KeyboardInfoPre extends KeyboardInfo {
  12331. /**
  12332. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12333. */
  12334. type: number;
  12335. /**
  12336. * Defines the related dom event
  12337. */
  12338. event: KeyboardEvent;
  12339. /**
  12340. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  12341. */
  12342. skipOnPointerObservable: boolean;
  12343. /**
  12344. * Instantiates a new keyboard pre info.
  12345. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  12346. * @param type Defines the type of event (BABYLON.KeyboardEventTypes)
  12347. * @param event Defines the related dom event
  12348. */
  12349. constructor(
  12350. /**
  12351. * Defines the type of event (BABYLON.KeyboardEventTypes)
  12352. */
  12353. type: number,
  12354. /**
  12355. * Defines the related dom event
  12356. */
  12357. event: KeyboardEvent);
  12358. }
  12359. }
  12360. declare module BABYLON {
  12361. /**
  12362. * Gather the list of pointer event types as constants.
  12363. */
  12364. class PointerEventTypes {
  12365. /**
  12366. * 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.
  12367. */
  12368. static readonly POINTERDOWN: number;
  12369. /**
  12370. * The pointerup event is fired when a pointer is no longer active.
  12371. */
  12372. static readonly POINTERUP: number;
  12373. /**
  12374. * The pointermove event is fired when a pointer changes coordinates.
  12375. */
  12376. static readonly POINTERMOVE: number;
  12377. /**
  12378. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12379. */
  12380. static readonly POINTERWHEEL: number;
  12381. /**
  12382. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12383. */
  12384. static readonly POINTERPICK: number;
  12385. /**
  12386. * The pointertap event is fired when a the object has been touched and released without drag.
  12387. */
  12388. static readonly POINTERTAP: number;
  12389. /**
  12390. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12391. */
  12392. static readonly POINTERDOUBLETAP: number;
  12393. }
  12394. /**
  12395. * Base class of pointer info types.
  12396. */
  12397. class PointerInfoBase {
  12398. /**
  12399. * Defines the type of event (BABYLON.PointerEventTypes)
  12400. */
  12401. type: number;
  12402. /**
  12403. * Defines the related dom event
  12404. */
  12405. event: PointerEvent | MouseWheelEvent;
  12406. /**
  12407. * Instantiates the base class of pointers info.
  12408. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12409. * @param event Defines the related dom event
  12410. */
  12411. constructor(
  12412. /**
  12413. * Defines the type of event (BABYLON.PointerEventTypes)
  12414. */
  12415. type: number,
  12416. /**
  12417. * Defines the related dom event
  12418. */
  12419. event: PointerEvent | MouseWheelEvent);
  12420. }
  12421. /**
  12422. * This class is used to store pointer related info for the onPrePointerObservable event.
  12423. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12424. */
  12425. class PointerInfoPre extends PointerInfoBase {
  12426. /**
  12427. * Ray from a pointer if availible (eg. 6dof controller)
  12428. */
  12429. ray: Nullable<Ray>;
  12430. /**
  12431. * Defines the local position of the pointer on the canvas.
  12432. */
  12433. localPosition: Vector2;
  12434. /**
  12435. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12436. */
  12437. skipOnPointerObservable: boolean;
  12438. /**
  12439. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12440. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12441. * @param event Defines the related dom event
  12442. * @param localX Defines the local x coordinates of the pointer when the event occured
  12443. * @param localY Defines the local y coordinates of the pointer when the event occured
  12444. */
  12445. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12446. }
  12447. /**
  12448. * This type contains all the data related to a pointer event in Babylon.js.
  12449. * 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.
  12450. */
  12451. class PointerInfo extends PointerInfoBase {
  12452. /**
  12453. * Defines the picking info associated to the info (if any)\
  12454. */
  12455. pickInfo: Nullable<PickingInfo>;
  12456. /**
  12457. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12458. * @param type Defines the type of event (BABYLON.PointerEventTypes)
  12459. * @param event Defines the related dom event
  12460. * @param pickInfo Defines the picking info associated to the info (if any)\
  12461. */
  12462. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12463. /**
  12464. * Defines the picking info associated to the info (if any)\
  12465. */
  12466. pickInfo: Nullable<PickingInfo>);
  12467. }
  12468. }
  12469. declare module BABYLON {
  12470. /**
  12471. * Represents a gamepad control stick position
  12472. */
  12473. class StickValues {
  12474. /**
  12475. * The x component of the control stick
  12476. */
  12477. x: number;
  12478. /**
  12479. * The y component of the control stick
  12480. */
  12481. y: number;
  12482. /**
  12483. * Initializes the gamepad x and y control stick values
  12484. * @param x The x component of the gamepad control stick value
  12485. * @param y The y component of the gamepad control stick value
  12486. */
  12487. constructor(
  12488. /**
  12489. * The x component of the control stick
  12490. */
  12491. x: number,
  12492. /**
  12493. * The y component of the control stick
  12494. */
  12495. y: number);
  12496. }
  12497. /**
  12498. * An interface which manages callbacks for gamepad button changes
  12499. */
  12500. interface GamepadButtonChanges {
  12501. /**
  12502. * Called when a gamepad has been changed
  12503. */
  12504. changed: boolean;
  12505. /**
  12506. * Called when a gamepad press event has been triggered
  12507. */
  12508. pressChanged: boolean;
  12509. /**
  12510. * Called when a touch event has been triggered
  12511. */
  12512. touchChanged: boolean;
  12513. /**
  12514. * Called when a value has changed
  12515. */
  12516. valueChanged: boolean;
  12517. }
  12518. /**
  12519. * Represents a gamepad
  12520. */
  12521. class Gamepad {
  12522. /**
  12523. * The id of the gamepad
  12524. */
  12525. id: string;
  12526. /**
  12527. * The index of the gamepad
  12528. */
  12529. index: number;
  12530. /**
  12531. * The browser gamepad
  12532. */
  12533. browserGamepad: any;
  12534. /**
  12535. * Specifies what type of gamepad this represents
  12536. */
  12537. type: number;
  12538. private _leftStick;
  12539. private _rightStick;
  12540. /** @hidden */
  12541. _isConnected: boolean;
  12542. private _leftStickAxisX;
  12543. private _leftStickAxisY;
  12544. private _rightStickAxisX;
  12545. private _rightStickAxisY;
  12546. /**
  12547. * Triggered when the left control stick has been changed
  12548. */
  12549. private _onleftstickchanged;
  12550. /**
  12551. * Triggered when the right control stick has been changed
  12552. */
  12553. private _onrightstickchanged;
  12554. /**
  12555. * Represents a gamepad controller
  12556. */
  12557. static GAMEPAD: number;
  12558. /**
  12559. * Represents a generic controller
  12560. */
  12561. static GENERIC: number;
  12562. /**
  12563. * Represents an XBox controller
  12564. */
  12565. static XBOX: number;
  12566. /**
  12567. * Represents a pose-enabled controller
  12568. */
  12569. static POSE_ENABLED: number;
  12570. /**
  12571. * Specifies whether the left control stick should be Y-inverted
  12572. */
  12573. protected _invertLeftStickY: boolean;
  12574. /**
  12575. * Specifies if the gamepad has been connected
  12576. */
  12577. readonly isConnected: boolean;
  12578. /**
  12579. * Initializes the gamepad
  12580. * @param id The id of the gamepad
  12581. * @param index The index of the gamepad
  12582. * @param browserGamepad The browser gamepad
  12583. * @param leftStickX The x component of the left joystick
  12584. * @param leftStickY The y component of the left joystick
  12585. * @param rightStickX The x component of the right joystick
  12586. * @param rightStickY The y component of the right joystick
  12587. */
  12588. constructor(
  12589. /**
  12590. * The id of the gamepad
  12591. */
  12592. id: string,
  12593. /**
  12594. * The index of the gamepad
  12595. */
  12596. index: number,
  12597. /**
  12598. * The browser gamepad
  12599. */
  12600. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12601. /**
  12602. * Callback triggered when the left joystick has changed
  12603. * @param callback
  12604. */
  12605. onleftstickchanged(callback: (values: StickValues) => void): void;
  12606. /**
  12607. * Callback triggered when the right joystick has changed
  12608. * @param callback
  12609. */
  12610. onrightstickchanged(callback: (values: StickValues) => void): void;
  12611. /**
  12612. * Gets the left joystick
  12613. */
  12614. /**
  12615. * Sets the left joystick values
  12616. */
  12617. leftStick: StickValues;
  12618. /**
  12619. * Gets the right joystick
  12620. */
  12621. /**
  12622. * Sets the right joystick value
  12623. */
  12624. rightStick: StickValues;
  12625. /**
  12626. * Updates the gamepad joystick positions
  12627. */
  12628. update(): void;
  12629. /**
  12630. * Disposes the gamepad
  12631. */
  12632. dispose(): void;
  12633. }
  12634. /**
  12635. * Represents a generic gamepad
  12636. */
  12637. class GenericPad extends Gamepad {
  12638. private _buttons;
  12639. private _onbuttondown;
  12640. private _onbuttonup;
  12641. /**
  12642. * Observable triggered when a button has been pressed
  12643. */
  12644. onButtonDownObservable: Observable<number>;
  12645. /**
  12646. * Observable triggered when a button has been released
  12647. */
  12648. onButtonUpObservable: Observable<number>;
  12649. /**
  12650. * Callback triggered when a button has been pressed
  12651. * @param callback Called when a button has been pressed
  12652. */
  12653. onbuttondown(callback: (buttonPressed: number) => void): void;
  12654. /**
  12655. * Callback triggered when a button has been released
  12656. * @param callback Called when a button has been released
  12657. */
  12658. onbuttonup(callback: (buttonReleased: number) => void): void;
  12659. /**
  12660. * Initializes the generic gamepad
  12661. * @param id The id of the generic gamepad
  12662. * @param index The index of the generic gamepad
  12663. * @param browserGamepad The browser gamepad
  12664. */
  12665. constructor(id: string, index: number, browserGamepad: any);
  12666. private _setButtonValue;
  12667. /**
  12668. * Updates the generic gamepad
  12669. */
  12670. update(): void;
  12671. /**
  12672. * Disposes the generic gamepad
  12673. */
  12674. dispose(): void;
  12675. }
  12676. }
  12677. declare module BABYLON {
  12678. /**
  12679. * Manager for handling gamepads
  12680. */
  12681. class GamepadManager {
  12682. private _scene?;
  12683. private _babylonGamepads;
  12684. private _oneGamepadConnected;
  12685. /** @hidden */
  12686. _isMonitoring: boolean;
  12687. private _gamepadEventSupported;
  12688. private _gamepadSupport;
  12689. /**
  12690. * observable to be triggered when the gamepad controller has been connected
  12691. */
  12692. onGamepadConnectedObservable: Observable<Gamepad>;
  12693. /**
  12694. * observable to be triggered when the gamepad controller has been disconnected
  12695. */
  12696. onGamepadDisconnectedObservable: Observable<Gamepad>;
  12697. private _onGamepadConnectedEvent;
  12698. private _onGamepadDisconnectedEvent;
  12699. /**
  12700. * Initializes the gamepad manager
  12701. * @param _scene BabylonJS scene
  12702. */
  12703. constructor(_scene?: Scene | undefined);
  12704. /**
  12705. * The gamepads in the game pad manager
  12706. */
  12707. readonly gamepads: Gamepad[];
  12708. /**
  12709. * Get the gamepad controllers based on type
  12710. * @param type The type of gamepad controller
  12711. * @returns Nullable gamepad
  12712. */
  12713. getGamepadByType(type?: number): Nullable<Gamepad>;
  12714. /**
  12715. * Disposes the gamepad manager
  12716. */
  12717. dispose(): void;
  12718. private _addNewGamepad;
  12719. private _startMonitoringGamepads;
  12720. private _stopMonitoringGamepads;
  12721. /** @hidden */
  12722. _checkGamepadsStatus(): void;
  12723. private _updateGamepadObjects;
  12724. }
  12725. }
  12726. declare module BABYLON {
  12727. interface Scene {
  12728. /** @hidden */
  12729. _gamepadManager: Nullable<GamepadManager>;
  12730. /**
  12731. * Gets the gamepad manager associated with the scene
  12732. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  12733. */
  12734. gamepadManager: GamepadManager;
  12735. }
  12736. /**
  12737. * Interface representing a free camera inputs manager
  12738. */
  12739. interface FreeCameraInputsManager {
  12740. /**
  12741. * Adds gamepad input support to the FreeCameraInputsManager.
  12742. * @returns the FreeCameraInputsManager
  12743. */
  12744. addGamepad(): FreeCameraInputsManager;
  12745. }
  12746. /**
  12747. * Interface representing an arc rotate camera inputs manager
  12748. */
  12749. interface ArcRotateCameraInputsManager {
  12750. /**
  12751. * Adds gamepad input support to the ArcRotateCamera InputManager.
  12752. * @returns the camera inputs manager
  12753. */
  12754. addGamepad(): ArcRotateCameraInputsManager;
  12755. }
  12756. /**
  12757. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  12758. */
  12759. class GamepadSystemSceneComponent implements ISceneComponent {
  12760. /**
  12761. * The component name helpfull to identify the component in the list of scene components.
  12762. */
  12763. readonly name: string;
  12764. /**
  12765. * The scene the component belongs to.
  12766. */
  12767. scene: Scene;
  12768. /**
  12769. * Creates a new instance of the component for the given scene
  12770. * @param scene Defines the scene to register the component in
  12771. */
  12772. constructor(scene: Scene);
  12773. /**
  12774. * Registers the component in a given scene
  12775. */
  12776. register(): void;
  12777. /**
  12778. * Rebuilds the elements related to this component in case of
  12779. * context lost for instance.
  12780. */
  12781. rebuild(): void;
  12782. /**
  12783. * Disposes the component and the associated ressources
  12784. */
  12785. dispose(): void;
  12786. private _beforeCameraUpdate;
  12787. }
  12788. }
  12789. declare module BABYLON {
  12790. /**
  12791. * Defines supported buttons for XBox360 compatible gamepads
  12792. */
  12793. enum Xbox360Button {
  12794. /** A */
  12795. A = 0,
  12796. /** B */
  12797. B = 1,
  12798. /** X */
  12799. X = 2,
  12800. /** Y */
  12801. Y = 3,
  12802. /** Start */
  12803. Start = 4,
  12804. /** Back */
  12805. Back = 5,
  12806. /** Left button */
  12807. LB = 6,
  12808. /** Right button */
  12809. RB = 7,
  12810. /** Left stick */
  12811. LeftStick = 8,
  12812. /** Right stick */
  12813. RightStick = 9
  12814. }
  12815. /** Defines values for XBox360 DPad */
  12816. enum Xbox360Dpad {
  12817. /** Up */
  12818. Up = 0,
  12819. /** Down */
  12820. Down = 1,
  12821. /** Left */
  12822. Left = 2,
  12823. /** Right */
  12824. Right = 3
  12825. }
  12826. /**
  12827. * Defines a XBox360 gamepad
  12828. */
  12829. class Xbox360Pad extends Gamepad {
  12830. private _leftTrigger;
  12831. private _rightTrigger;
  12832. private _onlefttriggerchanged;
  12833. private _onrighttriggerchanged;
  12834. private _onbuttondown;
  12835. private _onbuttonup;
  12836. private _ondpaddown;
  12837. private _ondpadup;
  12838. /** Observable raised when a button is pressed */
  12839. onButtonDownObservable: Observable<Xbox360Button>;
  12840. /** Observable raised when a button is released */
  12841. onButtonUpObservable: Observable<Xbox360Button>;
  12842. /** Observable raised when a pad is pressed */
  12843. onPadDownObservable: Observable<Xbox360Dpad>;
  12844. /** Observable raised when a pad is released */
  12845. onPadUpObservable: Observable<Xbox360Dpad>;
  12846. private _buttonA;
  12847. private _buttonB;
  12848. private _buttonX;
  12849. private _buttonY;
  12850. private _buttonBack;
  12851. private _buttonStart;
  12852. private _buttonLB;
  12853. private _buttonRB;
  12854. private _buttonLeftStick;
  12855. private _buttonRightStick;
  12856. private _dPadUp;
  12857. private _dPadDown;
  12858. private _dPadLeft;
  12859. private _dPadRight;
  12860. private _isXboxOnePad;
  12861. /**
  12862. * Creates a new XBox360 gamepad object
  12863. * @param id defines the id of this gamepad
  12864. * @param index defines its index
  12865. * @param gamepad defines the internal HTML gamepad object
  12866. * @param xboxOne defines if it is a XBox One gamepad
  12867. */
  12868. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  12869. /**
  12870. * Defines the callback to call when left trigger is pressed
  12871. * @param callback defines the callback to use
  12872. */
  12873. onlefttriggerchanged(callback: (value: number) => void): void;
  12874. /**
  12875. * Defines the callback to call when right trigger is pressed
  12876. * @param callback defines the callback to use
  12877. */
  12878. onrighttriggerchanged(callback: (value: number) => void): void;
  12879. /**
  12880. * Gets the left trigger value
  12881. */
  12882. /**
  12883. * Sets the left trigger value
  12884. */
  12885. leftTrigger: number;
  12886. /**
  12887. * Gets the right trigger value
  12888. */
  12889. /**
  12890. * Sets the right trigger value
  12891. */
  12892. rightTrigger: number;
  12893. /**
  12894. * Defines the callback to call when a button is pressed
  12895. * @param callback defines the callback to use
  12896. */
  12897. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  12898. /**
  12899. * Defines the callback to call when a button is released
  12900. * @param callback defines the callback to use
  12901. */
  12902. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  12903. /**
  12904. * Defines the callback to call when a pad is pressed
  12905. * @param callback defines the callback to use
  12906. */
  12907. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  12908. /**
  12909. * Defines the callback to call when a pad is released
  12910. * @param callback defines the callback to use
  12911. */
  12912. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  12913. private _setButtonValue;
  12914. private _setDPadValue;
  12915. /**
  12916. * Gets the value of the `A` button
  12917. */
  12918. /**
  12919. * Sets the value of the `A` button
  12920. */
  12921. buttonA: number;
  12922. /**
  12923. * Gets the value of the `B` button
  12924. */
  12925. /**
  12926. * Sets the value of the `B` button
  12927. */
  12928. buttonB: number;
  12929. /**
  12930. * Gets the value of the `X` button
  12931. */
  12932. /**
  12933. * Sets the value of the `X` button
  12934. */
  12935. buttonX: number;
  12936. /**
  12937. * Gets the value of the `Y` button
  12938. */
  12939. /**
  12940. * Sets the value of the `Y` button
  12941. */
  12942. buttonY: number;
  12943. /**
  12944. * Gets the value of the `Start` button
  12945. */
  12946. /**
  12947. * Sets the value of the `Start` button
  12948. */
  12949. buttonStart: number;
  12950. /**
  12951. * Gets the value of the `Back` button
  12952. */
  12953. /**
  12954. * Sets the value of the `Back` button
  12955. */
  12956. buttonBack: number;
  12957. /**
  12958. * Gets the value of the `Left` button
  12959. */
  12960. /**
  12961. * Sets the value of the `Left` button
  12962. */
  12963. buttonLB: number;
  12964. /**
  12965. * Gets the value of the `Right` button
  12966. */
  12967. /**
  12968. * Sets the value of the `Right` button
  12969. */
  12970. buttonRB: number;
  12971. /**
  12972. * Gets the value of the Left joystick
  12973. */
  12974. /**
  12975. * Sets the value of the Left joystick
  12976. */
  12977. buttonLeftStick: number;
  12978. /**
  12979. * Gets the value of the Right joystick
  12980. */
  12981. /**
  12982. * Sets the value of the Right joystick
  12983. */
  12984. buttonRightStick: number;
  12985. /**
  12986. * Gets the value of D-pad up
  12987. */
  12988. /**
  12989. * Sets the value of D-pad up
  12990. */
  12991. dPadUp: number;
  12992. /**
  12993. * Gets the value of D-pad down
  12994. */
  12995. /**
  12996. * Sets the value of D-pad down
  12997. */
  12998. dPadDown: number;
  12999. /**
  13000. * Gets the value of D-pad left
  13001. */
  13002. /**
  13003. * Sets the value of D-pad left
  13004. */
  13005. dPadLeft: number;
  13006. /**
  13007. * Gets the value of D-pad right
  13008. */
  13009. /**
  13010. * Sets the value of D-pad right
  13011. */
  13012. dPadRight: number;
  13013. /**
  13014. * Force the gamepad to synchronize with device values
  13015. */
  13016. update(): void;
  13017. /**
  13018. * Disposes the gamepad
  13019. */
  13020. dispose(): void;
  13021. }
  13022. }
  13023. declare module BABYLON {
  13024. /**
  13025. * Single axis drag gizmo
  13026. */
  13027. class AxisDragGizmo extends Gizmo {
  13028. /**
  13029. * Drag behavior responsible for the gizmos dragging interactions
  13030. */
  13031. dragBehavior: PointerDragBehavior;
  13032. private _pointerObserver;
  13033. /**
  13034. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13035. */
  13036. snapDistance: number;
  13037. /**
  13038. * Event that fires each time the gizmo snaps to a new location.
  13039. * * snapDistance is the the change in distance
  13040. */
  13041. onSnapObservable: Observable<{
  13042. snapDistance: number;
  13043. }>;
  13044. /**
  13045. * Creates an AxisDragGizmo
  13046. * @param gizmoLayer The utility layer the gizmo will be added to
  13047. * @param dragAxis The axis which the gizmo will be able to drag on
  13048. * @param color The color of the gizmo
  13049. */
  13050. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13051. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13052. /**
  13053. * Disposes of the gizmo
  13054. */
  13055. dispose(): void;
  13056. }
  13057. }
  13058. declare module BABYLON {
  13059. /**
  13060. * Single axis scale gizmo
  13061. */
  13062. class AxisScaleGizmo extends Gizmo {
  13063. private _coloredMaterial;
  13064. /**
  13065. * Drag behavior responsible for the gizmos dragging interactions
  13066. */
  13067. dragBehavior: PointerDragBehavior;
  13068. private _pointerObserver;
  13069. /**
  13070. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13071. */
  13072. snapDistance: number;
  13073. /**
  13074. * Event that fires each time the gizmo snaps to a new location.
  13075. * * snapDistance is the the change in distance
  13076. */
  13077. onSnapObservable: Observable<{
  13078. snapDistance: number;
  13079. }>;
  13080. /**
  13081. * If the scaling operation should be done on all axis (default: false)
  13082. */
  13083. uniformScaling: boolean;
  13084. /**
  13085. * Creates an AxisScaleGizmo
  13086. * @param gizmoLayer The utility layer the gizmo will be added to
  13087. * @param dragAxis The axis which the gizmo will be able to scale on
  13088. * @param color The color of the gizmo
  13089. */
  13090. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13091. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13092. /**
  13093. * Disposes of the gizmo
  13094. */
  13095. dispose(): void;
  13096. /**
  13097. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13098. * @param mesh The mesh to replace the default mesh of the gizmo
  13099. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  13100. */
  13101. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  13102. }
  13103. }
  13104. declare module BABYLON {
  13105. /**
  13106. * Bounding box gizmo
  13107. */
  13108. class BoundingBoxGizmo extends Gizmo {
  13109. private _lineBoundingBox;
  13110. private _rotateSpheresParent;
  13111. private _scaleBoxesParent;
  13112. private _boundingDimensions;
  13113. private _renderObserver;
  13114. private _pointerObserver;
  13115. private _scaleDragSpeed;
  13116. private _tmpQuaternion;
  13117. private _tmpVector;
  13118. private _tmpRotationMatrix;
  13119. /**
  13120. * 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)
  13121. */
  13122. ignoreChildren: boolean;
  13123. /**
  13124. * 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)
  13125. */
  13126. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  13127. /**
  13128. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  13129. */
  13130. rotationSphereSize: number;
  13131. /**
  13132. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  13133. */
  13134. scaleBoxSize: number;
  13135. /**
  13136. * 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)
  13137. */
  13138. fixedDragMeshScreenSize: boolean;
  13139. /**
  13140. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  13141. */
  13142. fixedDragMeshScreenSizeDistanceFactor: number;
  13143. /**
  13144. * Fired when a rotation sphere or scale box is dragged
  13145. */
  13146. onDragStartObservable: Observable<{}>;
  13147. /**
  13148. * Fired when a scale box is dragged
  13149. */
  13150. onScaleBoxDragObservable: Observable<{}>;
  13151. /**
  13152. * Fired when a scale box drag is ended
  13153. */
  13154. onScaleBoxDragEndObservable: Observable<{}>;
  13155. /**
  13156. * Fired when a rotation sphere is dragged
  13157. */
  13158. onRotationSphereDragObservable: Observable<{}>;
  13159. /**
  13160. * Fired when a rotation sphere drag is ended
  13161. */
  13162. onRotationSphereDragEndObservable: Observable<{}>;
  13163. /**
  13164. * 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)
  13165. */
  13166. scalePivot: Nullable<Vector3>;
  13167. private _anchorMesh;
  13168. private _existingMeshScale;
  13169. private static _PivotCached;
  13170. private static _OldPivotPoint;
  13171. private static _PivotTranslation;
  13172. private static _PivotTmpVector;
  13173. /** @hidden */
  13174. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  13175. /** @hidden */
  13176. static _RestorePivotPoint(mesh: AbstractMesh): void;
  13177. /**
  13178. * Creates an BoundingBoxGizmo
  13179. * @param gizmoLayer The utility layer the gizmo will be added to
  13180. * @param color The color of the gizmo
  13181. */
  13182. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  13183. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13184. private _selectNode;
  13185. /**
  13186. * Updates the bounding box information for the Gizmo
  13187. */
  13188. updateBoundingBox(): void;
  13189. private _updateRotationSpheres;
  13190. private _updateScaleBoxes;
  13191. /**
  13192. * Enables rotation on the specified axis and disables rotation on the others
  13193. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  13194. */
  13195. setEnabledRotationAxis(axis: string): void;
  13196. /**
  13197. * Disposes of the gizmo
  13198. */
  13199. dispose(): void;
  13200. /**
  13201. * 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)
  13202. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  13203. * @returns the bounding box mesh with the passed in mesh as a child
  13204. */
  13205. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  13206. /**
  13207. * CustomMeshes are not supported by this gizmo
  13208. * @param mesh The mesh to replace the default mesh of the gizmo
  13209. */
  13210. setCustomMesh(mesh: Mesh): void;
  13211. }
  13212. }
  13213. declare module BABYLON {
  13214. /**
  13215. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  13216. */
  13217. class Gizmo implements IDisposable {
  13218. /** The utility layer the gizmo will be added to */
  13219. gizmoLayer: UtilityLayerRenderer;
  13220. /**
  13221. * The root mesh of the gizmo
  13222. */
  13223. protected _rootMesh: Mesh;
  13224. private _attachedMesh;
  13225. /**
  13226. * Ratio for the scale of the gizmo (Default: 1)
  13227. */
  13228. scaleRatio: number;
  13229. private _tmpMatrix;
  13230. /**
  13231. * If a custom mesh has been set (Default: false)
  13232. */
  13233. protected _customMeshSet: boolean;
  13234. /**
  13235. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  13236. * * When set, interactions will be enabled
  13237. */
  13238. attachedMesh: Nullable<AbstractMesh>;
  13239. /**
  13240. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  13241. * @param mesh The mesh to replace the default mesh of the gizmo
  13242. */
  13243. setCustomMesh(mesh: Mesh): void;
  13244. /**
  13245. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  13246. */
  13247. updateGizmoRotationToMatchAttachedMesh: boolean;
  13248. /**
  13249. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  13250. */
  13251. updateGizmoPositionToMatchAttachedMesh: boolean;
  13252. /**
  13253. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  13254. */
  13255. protected _updateScale: boolean;
  13256. protected _interactionsEnabled: boolean;
  13257. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13258. private _beforeRenderObserver;
  13259. /**
  13260. * Creates a gizmo
  13261. * @param gizmoLayer The utility layer the gizmo will be added to
  13262. */
  13263. constructor(
  13264. /** The utility layer the gizmo will be added to */
  13265. gizmoLayer?: UtilityLayerRenderer);
  13266. private _tempVector;
  13267. /**
  13268. * @hidden
  13269. * Updates the gizmo to match the attached mesh's position/rotation
  13270. */
  13271. protected _update(): void;
  13272. /**
  13273. * Disposes of the gizmo
  13274. */
  13275. dispose(): void;
  13276. }
  13277. }
  13278. declare module BABYLON {
  13279. /**
  13280. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  13281. */
  13282. class GizmoManager implements IDisposable {
  13283. private scene;
  13284. /**
  13285. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  13286. */
  13287. gizmos: {
  13288. positionGizmo: Nullable<PositionGizmo>;
  13289. rotationGizmo: Nullable<RotationGizmo>;
  13290. scaleGizmo: Nullable<ScaleGizmo>;
  13291. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  13292. };
  13293. private _gizmosEnabled;
  13294. private _pointerObserver;
  13295. private _attachedMesh;
  13296. private _boundingBoxColor;
  13297. private _defaultUtilityLayer;
  13298. private _defaultKeepDepthUtilityLayer;
  13299. /**
  13300. * When bounding box gizmo is enabled, this can be used to track drag/end events
  13301. */
  13302. boundingBoxDragBehavior: SixDofDragBehavior;
  13303. /**
  13304. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  13305. */
  13306. attachableMeshes: Nullable<Array<AbstractMesh>>;
  13307. /**
  13308. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  13309. */
  13310. usePointerToAttachGizmos: boolean;
  13311. /**
  13312. * Instatiates a gizmo manager
  13313. * @param scene the scene to overlay the gizmos on top of
  13314. */
  13315. constructor(scene: Scene);
  13316. /**
  13317. * Attaches a set of gizmos to the specified mesh
  13318. * @param mesh The mesh the gizmo's should be attached to
  13319. */
  13320. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  13321. /**
  13322. * If the position gizmo is enabled
  13323. */
  13324. positionGizmoEnabled: boolean;
  13325. /**
  13326. * If the rotation gizmo is enabled
  13327. */
  13328. rotationGizmoEnabled: boolean;
  13329. /**
  13330. * If the scale gizmo is enabled
  13331. */
  13332. scaleGizmoEnabled: boolean;
  13333. /**
  13334. * If the boundingBox gizmo is enabled
  13335. */
  13336. boundingBoxGizmoEnabled: boolean;
  13337. /**
  13338. * Disposes of the gizmo manager
  13339. */
  13340. dispose(): void;
  13341. }
  13342. }
  13343. declare module BABYLON {
  13344. /**
  13345. * Single plane rotation gizmo
  13346. */
  13347. class PlaneRotationGizmo extends Gizmo {
  13348. /**
  13349. * Drag behavior responsible for the gizmos dragging interactions
  13350. */
  13351. dragBehavior: PointerDragBehavior;
  13352. private _pointerObserver;
  13353. /**
  13354. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  13355. */
  13356. snapDistance: number;
  13357. /**
  13358. * Event that fires each time the gizmo snaps to a new location.
  13359. * * snapDistance is the the change in distance
  13360. */
  13361. onSnapObservable: Observable<{
  13362. snapDistance: number;
  13363. }>;
  13364. /**
  13365. * Creates a PlaneRotationGizmo
  13366. * @param gizmoLayer The utility layer the gizmo will be added to
  13367. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  13368. * @param color The color of the gizmo
  13369. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13370. */
  13371. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13372. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  13373. /**
  13374. * Disposes of the gizmo
  13375. */
  13376. dispose(): void;
  13377. }
  13378. }
  13379. declare module BABYLON {
  13380. /**
  13381. * Gizmo that enables dragging a mesh along 3 axis
  13382. */
  13383. class PositionGizmo extends Gizmo {
  13384. /**
  13385. * Internal gizmo used for interactions on the x axis
  13386. */
  13387. xGizmo: AxisDragGizmo;
  13388. /**
  13389. * Internal gizmo used for interactions on the y axis
  13390. */
  13391. yGizmo: AxisDragGizmo;
  13392. /**
  13393. * Internal gizmo used for interactions on the z axis
  13394. */
  13395. zGizmo: AxisDragGizmo;
  13396. /** Fires an event when any of it's sub gizmos are dragged */
  13397. onDragStartObservable: Observable<{}>;
  13398. /** Fires an event when any of it's sub gizmos are released from dragging */
  13399. onDragEndObservable: Observable<{}>;
  13400. attachedMesh: Nullable<AbstractMesh>;
  13401. /**
  13402. * Creates a PositionGizmo
  13403. * @param gizmoLayer The utility layer the gizmo will be added to
  13404. */
  13405. constructor(gizmoLayer?: UtilityLayerRenderer);
  13406. updateGizmoRotationToMatchAttachedMesh: boolean;
  13407. /**
  13408. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13409. */
  13410. snapDistance: number;
  13411. /**
  13412. * Ratio for the scale of the gizmo (Default: 1)
  13413. */
  13414. scaleRatio: number;
  13415. /**
  13416. * Disposes of the gizmo
  13417. */
  13418. dispose(): void;
  13419. /**
  13420. * CustomMeshes are not supported by this gizmo
  13421. * @param mesh The mesh to replace the default mesh of the gizmo
  13422. */
  13423. setCustomMesh(mesh: Mesh): void;
  13424. }
  13425. }
  13426. declare module BABYLON {
  13427. /**
  13428. * Gizmo that enables rotating a mesh along 3 axis
  13429. */
  13430. class RotationGizmo extends Gizmo {
  13431. /**
  13432. * Internal gizmo used for interactions on the x axis
  13433. */
  13434. xGizmo: PlaneRotationGizmo;
  13435. /**
  13436. * Internal gizmo used for interactions on the y axis
  13437. */
  13438. yGizmo: PlaneRotationGizmo;
  13439. /**
  13440. * Internal gizmo used for interactions on the z axis
  13441. */
  13442. zGizmo: PlaneRotationGizmo;
  13443. /** Fires an event when any of it's sub gizmos are dragged */
  13444. onDragStartObservable: Observable<{}>;
  13445. /** Fires an event when any of it's sub gizmos are released from dragging */
  13446. onDragEndObservable: Observable<{}>;
  13447. attachedMesh: Nullable<AbstractMesh>;
  13448. /**
  13449. * Creates a RotationGizmo
  13450. * @param gizmoLayer The utility layer the gizmo will be added to
  13451. * @param tessellation Amount of tessellation to be used when creating rotation circles
  13452. */
  13453. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  13454. updateGizmoRotationToMatchAttachedMesh: boolean;
  13455. /**
  13456. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13457. */
  13458. snapDistance: number;
  13459. /**
  13460. * Ratio for the scale of the gizmo (Default: 1)
  13461. */
  13462. scaleRatio: number;
  13463. /**
  13464. * Disposes of the gizmo
  13465. */
  13466. dispose(): void;
  13467. /**
  13468. * CustomMeshes are not supported by this gizmo
  13469. * @param mesh The mesh to replace the default mesh of the gizmo
  13470. */
  13471. setCustomMesh(mesh: Mesh): void;
  13472. }
  13473. }
  13474. declare module BABYLON {
  13475. /**
  13476. * Gizmo that enables scaling a mesh along 3 axis
  13477. */
  13478. class ScaleGizmo extends Gizmo {
  13479. /**
  13480. * Internal gizmo used for interactions on the x axis
  13481. */
  13482. xGizmo: AxisScaleGizmo;
  13483. /**
  13484. * Internal gizmo used for interactions on the y axis
  13485. */
  13486. yGizmo: AxisScaleGizmo;
  13487. /**
  13488. * Internal gizmo used for interactions on the z axis
  13489. */
  13490. zGizmo: AxisScaleGizmo;
  13491. /**
  13492. * Internal gizmo used to scale all axis equally
  13493. */
  13494. uniformScaleGizmo: AxisScaleGizmo;
  13495. /** Fires an event when any of it's sub gizmos are dragged */
  13496. onDragStartObservable: Observable<{}>;
  13497. /** Fires an event when any of it's sub gizmos are released from dragging */
  13498. onDragEndObservable: Observable<{}>;
  13499. attachedMesh: Nullable<AbstractMesh>;
  13500. /**
  13501. * Creates a ScaleGizmo
  13502. * @param gizmoLayer The utility layer the gizmo will be added to
  13503. */
  13504. constructor(gizmoLayer?: UtilityLayerRenderer);
  13505. updateGizmoRotationToMatchAttachedMesh: boolean;
  13506. /**
  13507. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  13508. */
  13509. snapDistance: number;
  13510. /**
  13511. * Ratio for the scale of the gizmo (Default: 1)
  13512. */
  13513. scaleRatio: number;
  13514. /**
  13515. * Disposes of the gizmo
  13516. */
  13517. dispose(): void;
  13518. }
  13519. }
  13520. declare module BABYLON {
  13521. /**
  13522. * Represents the different options available during the creation of
  13523. * a Environment helper.
  13524. *
  13525. * This can control the default ground, skybox and image processing setup of your scene.
  13526. */
  13527. interface IEnvironmentHelperOptions {
  13528. /**
  13529. * Specifies wether or not to create a ground.
  13530. * True by default.
  13531. */
  13532. createGround: boolean;
  13533. /**
  13534. * Specifies the ground size.
  13535. * 15 by default.
  13536. */
  13537. groundSize: number;
  13538. /**
  13539. * The texture used on the ground for the main color.
  13540. * Comes from the BabylonJS CDN by default.
  13541. *
  13542. * Remarks: Can be either a texture or a url.
  13543. */
  13544. groundTexture: string | BaseTexture;
  13545. /**
  13546. * The color mixed in the ground texture by default.
  13547. * BabylonJS clearColor by default.
  13548. */
  13549. groundColor: Color3;
  13550. /**
  13551. * Specifies the ground opacity.
  13552. * 1 by default.
  13553. */
  13554. groundOpacity: number;
  13555. /**
  13556. * Enables the ground to receive shadows.
  13557. * True by default.
  13558. */
  13559. enableGroundShadow: boolean;
  13560. /**
  13561. * Helps preventing the shadow to be fully black on the ground.
  13562. * 0.5 by default.
  13563. */
  13564. groundShadowLevel: number;
  13565. /**
  13566. * Creates a mirror texture attach to the ground.
  13567. * false by default.
  13568. */
  13569. enableGroundMirror: boolean;
  13570. /**
  13571. * Specifies the ground mirror size ratio.
  13572. * 0.3 by default as the default kernel is 64.
  13573. */
  13574. groundMirrorSizeRatio: number;
  13575. /**
  13576. * Specifies the ground mirror blur kernel size.
  13577. * 64 by default.
  13578. */
  13579. groundMirrorBlurKernel: number;
  13580. /**
  13581. * Specifies the ground mirror visibility amount.
  13582. * 1 by default
  13583. */
  13584. groundMirrorAmount: number;
  13585. /**
  13586. * Specifies the ground mirror reflectance weight.
  13587. * This uses the standard weight of the background material to setup the fresnel effect
  13588. * of the mirror.
  13589. * 1 by default.
  13590. */
  13591. groundMirrorFresnelWeight: number;
  13592. /**
  13593. * Specifies the ground mirror Falloff distance.
  13594. * This can helps reducing the size of the reflection.
  13595. * 0 by Default.
  13596. */
  13597. groundMirrorFallOffDistance: number;
  13598. /**
  13599. * Specifies the ground mirror texture type.
  13600. * Unsigned Int by Default.
  13601. */
  13602. groundMirrorTextureType: number;
  13603. /**
  13604. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  13605. * the shown objects.
  13606. */
  13607. groundYBias: number;
  13608. /**
  13609. * Specifies wether or not to create a skybox.
  13610. * True by default.
  13611. */
  13612. createSkybox: boolean;
  13613. /**
  13614. * Specifies the skybox size.
  13615. * 20 by default.
  13616. */
  13617. skyboxSize: number;
  13618. /**
  13619. * The texture used on the skybox for the main color.
  13620. * Comes from the BabylonJS CDN by default.
  13621. *
  13622. * Remarks: Can be either a texture or a url.
  13623. */
  13624. skyboxTexture: string | BaseTexture;
  13625. /**
  13626. * The color mixed in the skybox texture by default.
  13627. * BabylonJS clearColor by default.
  13628. */
  13629. skyboxColor: Color3;
  13630. /**
  13631. * The background rotation around the Y axis of the scene.
  13632. * This helps aligning the key lights of your scene with the background.
  13633. * 0 by default.
  13634. */
  13635. backgroundYRotation: number;
  13636. /**
  13637. * Compute automatically the size of the elements to best fit with the scene.
  13638. */
  13639. sizeAuto: boolean;
  13640. /**
  13641. * Default position of the rootMesh if autoSize is not true.
  13642. */
  13643. rootPosition: Vector3;
  13644. /**
  13645. * Sets up the image processing in the scene.
  13646. * true by default.
  13647. */
  13648. setupImageProcessing: boolean;
  13649. /**
  13650. * The texture used as your environment texture in the scene.
  13651. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  13652. *
  13653. * Remarks: Can be either a texture or a url.
  13654. */
  13655. environmentTexture: string | BaseTexture;
  13656. /**
  13657. * The value of the exposure to apply to the scene.
  13658. * 0.6 by default if setupImageProcessing is true.
  13659. */
  13660. cameraExposure: number;
  13661. /**
  13662. * The value of the contrast to apply to the scene.
  13663. * 1.6 by default if setupImageProcessing is true.
  13664. */
  13665. cameraContrast: number;
  13666. /**
  13667. * Specifies wether or not tonemapping should be enabled in the scene.
  13668. * true by default if setupImageProcessing is true.
  13669. */
  13670. toneMappingEnabled: boolean;
  13671. }
  13672. /**
  13673. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  13674. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  13675. * It also helps with the default setup of your imageProcessing configuration.
  13676. */
  13677. class EnvironmentHelper {
  13678. /**
  13679. * Default ground texture URL.
  13680. */
  13681. private static _groundTextureCDNUrl;
  13682. /**
  13683. * Default skybox texture URL.
  13684. */
  13685. private static _skyboxTextureCDNUrl;
  13686. /**
  13687. * Default environment texture URL.
  13688. */
  13689. private static _environmentTextureCDNUrl;
  13690. /**
  13691. * Creates the default options for the helper.
  13692. */
  13693. private static _getDefaultOptions;
  13694. private _rootMesh;
  13695. /**
  13696. * Gets the root mesh created by the helper.
  13697. */
  13698. readonly rootMesh: Mesh;
  13699. private _skybox;
  13700. /**
  13701. * Gets the skybox created by the helper.
  13702. */
  13703. readonly skybox: Nullable<Mesh>;
  13704. private _skyboxTexture;
  13705. /**
  13706. * Gets the skybox texture created by the helper.
  13707. */
  13708. readonly skyboxTexture: Nullable<BaseTexture>;
  13709. private _skyboxMaterial;
  13710. /**
  13711. * Gets the skybox material created by the helper.
  13712. */
  13713. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  13714. private _ground;
  13715. /**
  13716. * Gets the ground mesh created by the helper.
  13717. */
  13718. readonly ground: Nullable<Mesh>;
  13719. private _groundTexture;
  13720. /**
  13721. * Gets the ground texture created by the helper.
  13722. */
  13723. readonly groundTexture: Nullable<BaseTexture>;
  13724. private _groundMirror;
  13725. /**
  13726. * Gets the ground mirror created by the helper.
  13727. */
  13728. readonly groundMirror: Nullable<MirrorTexture>;
  13729. /**
  13730. * Gets the ground mirror render list to helps pushing the meshes
  13731. * you wish in the ground reflection.
  13732. */
  13733. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  13734. private _groundMaterial;
  13735. /**
  13736. * Gets the ground material created by the helper.
  13737. */
  13738. readonly groundMaterial: Nullable<BackgroundMaterial>;
  13739. /**
  13740. * Stores the creation options.
  13741. */
  13742. private readonly _scene;
  13743. private _options;
  13744. /**
  13745. * This observable will be notified with any error during the creation of the environment,
  13746. * mainly texture creation errors.
  13747. */
  13748. onErrorObservable: Observable<{
  13749. message?: string;
  13750. exception?: any;
  13751. }>;
  13752. /**
  13753. * constructor
  13754. * @param options
  13755. * @param scene The scene to add the material to
  13756. */
  13757. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  13758. /**
  13759. * Updates the background according to the new options
  13760. * @param options
  13761. */
  13762. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  13763. /**
  13764. * Sets the primary color of all the available elements.
  13765. * @param color the main color to affect to the ground and the background
  13766. */
  13767. setMainColor(color: Color3): void;
  13768. /**
  13769. * Setup the image processing according to the specified options.
  13770. */
  13771. private _setupImageProcessing;
  13772. /**
  13773. * Setup the environment texture according to the specified options.
  13774. */
  13775. private _setupEnvironmentTexture;
  13776. /**
  13777. * Setup the background according to the specified options.
  13778. */
  13779. private _setupBackground;
  13780. /**
  13781. * Get the scene sizes according to the setup.
  13782. */
  13783. private _getSceneSize;
  13784. /**
  13785. * Setup the ground according to the specified options.
  13786. */
  13787. private _setupGround;
  13788. /**
  13789. * Setup the ground material according to the specified options.
  13790. */
  13791. private _setupGroundMaterial;
  13792. /**
  13793. * Setup the ground diffuse texture according to the specified options.
  13794. */
  13795. private _setupGroundDiffuseTexture;
  13796. /**
  13797. * Setup the ground mirror texture according to the specified options.
  13798. */
  13799. private _setupGroundMirrorTexture;
  13800. /**
  13801. * Setup the ground to receive the mirror texture.
  13802. */
  13803. private _setupMirrorInGroundMaterial;
  13804. /**
  13805. * Setup the skybox according to the specified options.
  13806. */
  13807. private _setupSkybox;
  13808. /**
  13809. * Setup the skybox material according to the specified options.
  13810. */
  13811. private _setupSkyboxMaterial;
  13812. /**
  13813. * Setup the skybox reflection texture according to the specified options.
  13814. */
  13815. private _setupSkyboxReflectionTexture;
  13816. private _errorHandler;
  13817. /**
  13818. * Dispose all the elements created by the Helper.
  13819. */
  13820. dispose(): void;
  13821. }
  13822. }
  13823. declare module BABYLON {
  13824. /**
  13825. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  13826. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  13827. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  13828. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13829. */
  13830. class PhotoDome extends TransformNode {
  13831. private _useDirectMapping;
  13832. /**
  13833. * The texture being displayed on the sphere
  13834. */
  13835. protected _photoTexture: Texture;
  13836. /**
  13837. * Gets or sets the texture being displayed on the sphere
  13838. */
  13839. photoTexture: Texture;
  13840. /**
  13841. * Observable raised when an error occured while loading the 360 image
  13842. */
  13843. onLoadErrorObservable: Observable<string>;
  13844. /**
  13845. * The skybox material
  13846. */
  13847. protected _material: BackgroundMaterial;
  13848. /**
  13849. * The surface used for the skybox
  13850. */
  13851. protected _mesh: Mesh;
  13852. /**
  13853. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13854. * Also see the options.resolution property.
  13855. */
  13856. fovMultiplier: number;
  13857. /**
  13858. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  13859. * @param name Element's name, child elements will append suffixes for their own names.
  13860. * @param urlsOfPhoto defines the url of the photo to display
  13861. * @param options defines an object containing optional or exposed sub element properties
  13862. * @param onError defines a callback called when an error occured while loading the texture
  13863. */
  13864. constructor(name: string, urlOfPhoto: string, options: {
  13865. resolution?: number;
  13866. size?: number;
  13867. useDirectMapping?: boolean;
  13868. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  13869. /**
  13870. * Releases resources associated with this node.
  13871. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13872. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13873. */
  13874. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13875. }
  13876. }
  13877. declare module BABYLON {
  13878. interface Scene {
  13879. /**
  13880. * Creates a default light for the scene.
  13881. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  13882. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  13883. */
  13884. createDefaultLight(replace?: boolean): void;
  13885. /**
  13886. * Creates a default camera for the scene.
  13887. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  13888. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13889. * @param replace has default false, when true replaces the active camera in the scene
  13890. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  13891. */
  13892. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13893. /**
  13894. * Creates a default camera and a default light.
  13895. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  13896. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  13897. * @param replace has the default false, when true replaces the active camera/light in the scene
  13898. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  13899. */
  13900. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  13901. /**
  13902. * Creates a new sky box
  13903. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  13904. * @param environmentTexture defines the texture to use as environment texture
  13905. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  13906. * @param scale defines the overall scale of the skybox
  13907. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  13908. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  13909. * @returns a new mesh holding the sky box
  13910. */
  13911. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  13912. /**
  13913. * Creates a new environment
  13914. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  13915. * @param options defines the options you can use to configure the environment
  13916. * @returns the new EnvironmentHelper
  13917. */
  13918. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  13919. /**
  13920. * Creates a new VREXperienceHelper
  13921. * @see http://doc.babylonjs.com/how_to/webvr_helper
  13922. * @param webVROptions defines the options used to create the new VREXperienceHelper
  13923. * @returns a new VREXperienceHelper
  13924. */
  13925. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  13926. /**
  13927. * Creates a new XREXperienceHelper
  13928. * @see http://doc.babylonjs.com/how_to/webxr
  13929. * @returns a promise for a new XREXperienceHelper
  13930. */
  13931. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  13932. }
  13933. }
  13934. declare module BABYLON {
  13935. /**
  13936. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  13937. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  13938. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  13939. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  13940. */
  13941. class VideoDome extends TransformNode {
  13942. private _useDirectMapping;
  13943. /**
  13944. * The video texture being displayed on the sphere
  13945. */
  13946. protected _videoTexture: VideoTexture;
  13947. /**
  13948. * Gets the video texture being displayed on the sphere
  13949. */
  13950. readonly videoTexture: VideoTexture;
  13951. /**
  13952. * The skybox material
  13953. */
  13954. protected _material: BackgroundMaterial;
  13955. /**
  13956. * The surface used for the skybox
  13957. */
  13958. protected _mesh: Mesh;
  13959. /**
  13960. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  13961. * Also see the options.resolution property.
  13962. */
  13963. fovMultiplier: number;
  13964. /**
  13965. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  13966. * @param name Element's name, child elements will append suffixes for their own names.
  13967. * @param urlsOrVideo defines the url(s) or the video element to use
  13968. * @param options An object containing optional or exposed sub element properties
  13969. */
  13970. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  13971. resolution?: number;
  13972. clickToPlay?: boolean;
  13973. autoPlay?: boolean;
  13974. loop?: boolean;
  13975. size?: number;
  13976. poster?: string;
  13977. useDirectMapping?: boolean;
  13978. }, scene: Scene);
  13979. /**
  13980. * Releases resources associated with this node.
  13981. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13982. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13983. */
  13984. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13985. }
  13986. }
  13987. declare module BABYLON {
  13988. /**
  13989. * This class can be used to get instrumentation data from a Babylon engine
  13990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  13991. */
  13992. class EngineInstrumentation implements IDisposable {
  13993. /**
  13994. * Define the instrumented engine.
  13995. */
  13996. engine: Engine;
  13997. private _captureGPUFrameTime;
  13998. private _gpuFrameTimeToken;
  13999. private _gpuFrameTime;
  14000. private _captureShaderCompilationTime;
  14001. private _shaderCompilationTime;
  14002. private _onBeginFrameObserver;
  14003. private _onEndFrameObserver;
  14004. private _onBeforeShaderCompilationObserver;
  14005. private _onAfterShaderCompilationObserver;
  14006. /**
  14007. * Gets the perf counter used for GPU frame time
  14008. */
  14009. readonly gpuFrameTimeCounter: PerfCounter;
  14010. /**
  14011. * Gets the GPU frame time capture status
  14012. */
  14013. /**
  14014. * Enable or disable the GPU frame time capture
  14015. */
  14016. captureGPUFrameTime: boolean;
  14017. /**
  14018. * Gets the perf counter used for shader compilation time
  14019. */
  14020. readonly shaderCompilationTimeCounter: PerfCounter;
  14021. /**
  14022. * Gets the shader compilation time capture status
  14023. */
  14024. /**
  14025. * Enable or disable the shader compilation time capture
  14026. */
  14027. captureShaderCompilationTime: boolean;
  14028. /**
  14029. * Instantiates a new engine instrumentation.
  14030. * This class can be used to get instrumentation data from a Babylon engine
  14031. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  14032. * @param engine Defines the engine to instrument
  14033. */
  14034. constructor(
  14035. /**
  14036. * Define the instrumented engine.
  14037. */
  14038. engine: Engine);
  14039. /**
  14040. * Dispose and release associated resources.
  14041. */
  14042. dispose(): void;
  14043. }
  14044. }
  14045. declare module BABYLON {
  14046. /**
  14047. * This class can be used to get instrumentation data from a Babylon engine
  14048. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14049. */
  14050. class SceneInstrumentation implements IDisposable {
  14051. /**
  14052. * Defines the scene to instrument
  14053. */
  14054. scene: Scene;
  14055. private _captureActiveMeshesEvaluationTime;
  14056. private _activeMeshesEvaluationTime;
  14057. private _captureRenderTargetsRenderTime;
  14058. private _renderTargetsRenderTime;
  14059. private _captureFrameTime;
  14060. private _frameTime;
  14061. private _captureRenderTime;
  14062. private _renderTime;
  14063. private _captureInterFrameTime;
  14064. private _interFrameTime;
  14065. private _captureParticlesRenderTime;
  14066. private _particlesRenderTime;
  14067. private _captureSpritesRenderTime;
  14068. private _spritesRenderTime;
  14069. private _capturePhysicsTime;
  14070. private _physicsTime;
  14071. private _captureAnimationsTime;
  14072. private _animationsTime;
  14073. private _captureCameraRenderTime;
  14074. private _cameraRenderTime;
  14075. private _onBeforeActiveMeshesEvaluationObserver;
  14076. private _onAfterActiveMeshesEvaluationObserver;
  14077. private _onBeforeRenderTargetsRenderObserver;
  14078. private _onAfterRenderTargetsRenderObserver;
  14079. private _onAfterRenderObserver;
  14080. private _onBeforeDrawPhaseObserver;
  14081. private _onAfterDrawPhaseObserver;
  14082. private _onBeforeAnimationsObserver;
  14083. private _onBeforeParticlesRenderingObserver;
  14084. private _onAfterParticlesRenderingObserver;
  14085. private _onBeforeSpritesRenderingObserver;
  14086. private _onAfterSpritesRenderingObserver;
  14087. private _onBeforePhysicsObserver;
  14088. private _onAfterPhysicsObserver;
  14089. private _onAfterAnimationsObserver;
  14090. private _onBeforeCameraRenderObserver;
  14091. private _onAfterCameraRenderObserver;
  14092. /**
  14093. * Gets the perf counter used for active meshes evaluation time
  14094. */
  14095. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  14096. /**
  14097. * Gets the active meshes evaluation time capture status
  14098. */
  14099. /**
  14100. * Enable or disable the active meshes evaluation time capture
  14101. */
  14102. captureActiveMeshesEvaluationTime: boolean;
  14103. /**
  14104. * Gets the perf counter used for render targets render time
  14105. */
  14106. readonly renderTargetsRenderTimeCounter: PerfCounter;
  14107. /**
  14108. * Gets the render targets render time capture status
  14109. */
  14110. /**
  14111. * Enable or disable the render targets render time capture
  14112. */
  14113. captureRenderTargetsRenderTime: boolean;
  14114. /**
  14115. * Gets the perf counter used for particles render time
  14116. */
  14117. readonly particlesRenderTimeCounter: PerfCounter;
  14118. /**
  14119. * Gets the particles render time capture status
  14120. */
  14121. /**
  14122. * Enable or disable the particles render time capture
  14123. */
  14124. captureParticlesRenderTime: boolean;
  14125. /**
  14126. * Gets the perf counter used for sprites render time
  14127. */
  14128. readonly spritesRenderTimeCounter: PerfCounter;
  14129. /**
  14130. * Gets the sprites render time capture status
  14131. */
  14132. /**
  14133. * Enable or disable the sprites render time capture
  14134. */
  14135. captureSpritesRenderTime: boolean;
  14136. /**
  14137. * Gets the perf counter used for physics time
  14138. */
  14139. readonly physicsTimeCounter: PerfCounter;
  14140. /**
  14141. * Gets the physics time capture status
  14142. */
  14143. /**
  14144. * Enable or disable the physics time capture
  14145. */
  14146. capturePhysicsTime: boolean;
  14147. /**
  14148. * Gets the perf counter used for animations time
  14149. */
  14150. readonly animationsTimeCounter: PerfCounter;
  14151. /**
  14152. * Gets the animations time capture status
  14153. */
  14154. /**
  14155. * Enable or disable the animations time capture
  14156. */
  14157. captureAnimationsTime: boolean;
  14158. /**
  14159. * Gets the perf counter used for frame time capture
  14160. */
  14161. readonly frameTimeCounter: PerfCounter;
  14162. /**
  14163. * Gets the frame time capture status
  14164. */
  14165. /**
  14166. * Enable or disable the frame time capture
  14167. */
  14168. captureFrameTime: boolean;
  14169. /**
  14170. * Gets the perf counter used for inter-frames time capture
  14171. */
  14172. readonly interFrameTimeCounter: PerfCounter;
  14173. /**
  14174. * Gets the inter-frames time capture status
  14175. */
  14176. /**
  14177. * Enable or disable the inter-frames time capture
  14178. */
  14179. captureInterFrameTime: boolean;
  14180. /**
  14181. * Gets the perf counter used for render time capture
  14182. */
  14183. readonly renderTimeCounter: PerfCounter;
  14184. /**
  14185. * Gets the render time capture status
  14186. */
  14187. /**
  14188. * Enable or disable the render time capture
  14189. */
  14190. captureRenderTime: boolean;
  14191. /**
  14192. * Gets the perf counter used for camera render time capture
  14193. */
  14194. readonly cameraRenderTimeCounter: PerfCounter;
  14195. /**
  14196. * Gets the camera render time capture status
  14197. */
  14198. /**
  14199. * Enable or disable the camera render time capture
  14200. */
  14201. captureCameraRenderTime: boolean;
  14202. /**
  14203. * Gets the perf counter used for draw calls
  14204. */
  14205. readonly drawCallsCounter: PerfCounter;
  14206. /**
  14207. * Gets the perf counter used for texture collisions
  14208. */
  14209. readonly textureCollisionsCounter: PerfCounter;
  14210. /**
  14211. * Instantiates a new scene instrumentation.
  14212. * This class can be used to get instrumentation data from a Babylon engine
  14213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  14214. * @param scene Defines the scene to instrument
  14215. */
  14216. constructor(
  14217. /**
  14218. * Defines the scene to instrument
  14219. */
  14220. scene: Scene);
  14221. /**
  14222. * Dispose and release associated resources.
  14223. */
  14224. dispose(): void;
  14225. }
  14226. }
  14227. declare module BABYLON {
  14228. /**
  14229. * @hidden
  14230. **/
  14231. class _TimeToken {
  14232. _startTimeQuery: Nullable<WebGLQuery>;
  14233. _endTimeQuery: Nullable<WebGLQuery>;
  14234. _timeElapsedQuery: Nullable<WebGLQuery>;
  14235. _timeElapsedQueryEnded: boolean;
  14236. }
  14237. }
  14238. declare module BABYLON {
  14239. /**
  14240. * Effect layer options. This helps customizing the behaviour
  14241. * of the effect layer.
  14242. */
  14243. interface IEffectLayerOptions {
  14244. /**
  14245. * Multiplication factor apply to the canvas size to compute the render target size
  14246. * used to generated the objects (the smaller the faster).
  14247. */
  14248. mainTextureRatio: number;
  14249. /**
  14250. * Enforces a fixed size texture to ensure effect stability across devices.
  14251. */
  14252. mainTextureFixedSize?: number;
  14253. /**
  14254. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  14255. */
  14256. alphaBlendingMode: number;
  14257. /**
  14258. * The camera attached to the layer.
  14259. */
  14260. camera: Nullable<Camera>;
  14261. /**
  14262. * The rendering group to draw the layer in.
  14263. */
  14264. renderingGroupId: number;
  14265. }
  14266. /**
  14267. * The effect layer Helps adding post process effect blended with the main pass.
  14268. *
  14269. * This can be for instance use to generate glow or higlight effects on the scene.
  14270. *
  14271. * The effect layer class can not be used directly and is intented to inherited from to be
  14272. * customized per effects.
  14273. */
  14274. abstract class EffectLayer {
  14275. private _vertexBuffers;
  14276. private _indexBuffer;
  14277. private _cachedDefines;
  14278. private _effectLayerMapGenerationEffect;
  14279. private _effectLayerOptions;
  14280. private _mergeEffect;
  14281. protected _scene: Scene;
  14282. protected _engine: Engine;
  14283. protected _maxSize: number;
  14284. protected _mainTextureDesiredSize: ISize;
  14285. protected _mainTexture: RenderTargetTexture;
  14286. protected _shouldRender: boolean;
  14287. protected _postProcesses: PostProcess[];
  14288. protected _textures: BaseTexture[];
  14289. protected _emissiveTextureAndColor: {
  14290. texture: Nullable<BaseTexture>;
  14291. color: Color4;
  14292. };
  14293. /**
  14294. * The name of the layer
  14295. */
  14296. name: string;
  14297. /**
  14298. * The clear color of the texture used to generate the glow map.
  14299. */
  14300. neutralColor: Color4;
  14301. /**
  14302. * Specifies wether the highlight layer is enabled or not.
  14303. */
  14304. isEnabled: boolean;
  14305. /**
  14306. * Gets the camera attached to the layer.
  14307. */
  14308. readonly camera: Nullable<Camera>;
  14309. /**
  14310. * Gets the rendering group id the layer should render in.
  14311. */
  14312. readonly renderingGroupId: number;
  14313. /**
  14314. * An event triggered when the effect layer has been disposed.
  14315. */
  14316. onDisposeObservable: Observable<EffectLayer>;
  14317. /**
  14318. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  14319. */
  14320. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  14321. /**
  14322. * An event triggered when the generated texture is being merged in the scene.
  14323. */
  14324. onBeforeComposeObservable: Observable<EffectLayer>;
  14325. /**
  14326. * An event triggered when the generated texture has been merged in the scene.
  14327. */
  14328. onAfterComposeObservable: Observable<EffectLayer>;
  14329. /**
  14330. * An event triggered when the efffect layer changes its size.
  14331. */
  14332. onSizeChangedObservable: Observable<EffectLayer>;
  14333. /**
  14334. * Instantiates a new effect Layer and references it in the scene.
  14335. * @param name The name of the layer
  14336. * @param scene The scene to use the layer in
  14337. */
  14338. constructor(
  14339. /** The Friendly of the effect in the scene */
  14340. name: string, scene: Scene);
  14341. /**
  14342. * Get the effect name of the layer.
  14343. * @return The effect name
  14344. */
  14345. abstract getEffectName(): string;
  14346. /**
  14347. * Checks for the readiness of the element composing the layer.
  14348. * @param subMesh the mesh to check for
  14349. * @param useInstances specify wether or not to use instances to render the mesh
  14350. * @return true if ready otherwise, false
  14351. */
  14352. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14353. /**
  14354. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14355. * @returns true if the effect requires stencil during the main canvas render pass.
  14356. */
  14357. abstract needStencil(): boolean;
  14358. /**
  14359. * Create the merge effect. This is the shader use to blit the information back
  14360. * to the main canvas at the end of the scene rendering.
  14361. * @returns The effect containing the shader used to merge the effect on the main canvas
  14362. */
  14363. protected abstract _createMergeEffect(): Effect;
  14364. /**
  14365. * Creates the render target textures and post processes used in the effect layer.
  14366. */
  14367. protected abstract _createTextureAndPostProcesses(): void;
  14368. /**
  14369. * Implementation specific of rendering the generating effect on the main canvas.
  14370. * @param effect The effect used to render through
  14371. */
  14372. protected abstract _internalRender(effect: Effect): void;
  14373. /**
  14374. * Sets the required values for both the emissive texture and and the main color.
  14375. */
  14376. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14377. /**
  14378. * Free any resources and references associated to a mesh.
  14379. * Internal use
  14380. * @param mesh The mesh to free.
  14381. */
  14382. abstract _disposeMesh(mesh: Mesh): void;
  14383. /**
  14384. * Serializes this layer (Glow or Highlight for example)
  14385. * @returns a serialized layer object
  14386. */
  14387. abstract serialize?(): any;
  14388. /**
  14389. * Initializes the effect layer with the required options.
  14390. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  14391. */
  14392. protected _init(options: Partial<IEffectLayerOptions>): void;
  14393. /**
  14394. * Generates the index buffer of the full screen quad blending to the main canvas.
  14395. */
  14396. private _generateIndexBuffer;
  14397. /**
  14398. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  14399. */
  14400. private _genrateVertexBuffer;
  14401. /**
  14402. * Sets the main texture desired size which is the closest power of two
  14403. * of the engine canvas size.
  14404. */
  14405. private _setMainTextureSize;
  14406. /**
  14407. * Creates the main texture for the effect layer.
  14408. */
  14409. protected _createMainTexture(): void;
  14410. /**
  14411. * Checks for the readiness of the element composing the layer.
  14412. * @param subMesh the mesh to check for
  14413. * @param useInstances specify wether or not to use instances to render the mesh
  14414. * @param emissiveTexture the associated emissive texture used to generate the glow
  14415. * @return true if ready otherwise, false
  14416. */
  14417. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  14418. /**
  14419. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  14420. */
  14421. render(): void;
  14422. /**
  14423. * Determine if a given mesh will be used in the current effect.
  14424. * @param mesh mesh to test
  14425. * @returns true if the mesh will be used
  14426. */
  14427. hasMesh(mesh: AbstractMesh): boolean;
  14428. /**
  14429. * Returns true if the layer contains information to display, otherwise false.
  14430. * @returns true if the glow layer should be rendered
  14431. */
  14432. shouldRender(): boolean;
  14433. /**
  14434. * Returns true if the mesh should render, otherwise false.
  14435. * @param mesh The mesh to render
  14436. * @returns true if it should render otherwise false
  14437. */
  14438. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14439. /**
  14440. * Returns true if the mesh should render, otherwise false.
  14441. * @param mesh The mesh to render
  14442. * @returns true if it should render otherwise false
  14443. */
  14444. protected _shouldRenderEmissiveTextureForMesh(mesh: Mesh): boolean;
  14445. /**
  14446. * Renders the submesh passed in parameter to the generation map.
  14447. */
  14448. protected _renderSubMesh(subMesh: SubMesh): void;
  14449. /**
  14450. * Rebuild the required buffers.
  14451. * @hidden Internal use only.
  14452. */
  14453. _rebuild(): void;
  14454. /**
  14455. * Dispose only the render target textures and post process.
  14456. */
  14457. private _disposeTextureAndPostProcesses;
  14458. /**
  14459. * Dispose the highlight layer and free resources.
  14460. */
  14461. dispose(): void;
  14462. /**
  14463. * Gets the class name of the effect layer
  14464. * @returns the string with the class name of the effect layer
  14465. */
  14466. getClassName(): string;
  14467. /**
  14468. * Creates an effect layer from parsed effect layer data
  14469. * @param parsedEffectLayer defines effect layer data
  14470. * @param scene defines the current scene
  14471. * @param rootUrl defines the root URL containing the effect layer information
  14472. * @returns a parsed effect Layer
  14473. */
  14474. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  14475. }
  14476. }
  14477. declare module BABYLON {
  14478. interface AbstractScene {
  14479. /**
  14480. * The list of effect layers (highlights/glow) added to the scene
  14481. * @see http://doc.babylonjs.com/how_to/highlight_layer
  14482. * @see http://doc.babylonjs.com/how_to/glow_layer
  14483. */
  14484. effectLayers: Array<EffectLayer>;
  14485. /**
  14486. * Removes the given effect layer from this scene.
  14487. * @param toRemove defines the effect layer to remove
  14488. * @returns the index of the removed effect layer
  14489. */
  14490. removeEffectLayer(toRemove: EffectLayer): number;
  14491. /**
  14492. * Adds the given effect layer to this scene
  14493. * @param newEffectLayer defines the effect layer to add
  14494. */
  14495. addEffectLayer(newEffectLayer: EffectLayer): void;
  14496. }
  14497. /**
  14498. * Defines the layer scene component responsible to manage any effect layers
  14499. * in a given scene.
  14500. */
  14501. class EffectLayerSceneComponent implements ISceneSerializableComponent {
  14502. /**
  14503. * The component name helpfull to identify the component in the list of scene components.
  14504. */
  14505. readonly name: string;
  14506. /**
  14507. * The scene the component belongs to.
  14508. */
  14509. scene: Scene;
  14510. private _engine;
  14511. private _renderEffects;
  14512. private _needStencil;
  14513. private _previousStencilState;
  14514. /**
  14515. * Creates a new instance of the component for the given scene
  14516. * @param scene Defines the scene to register the component in
  14517. */
  14518. constructor(scene: Scene);
  14519. /**
  14520. * Registers the component in a given scene
  14521. */
  14522. register(): void;
  14523. /**
  14524. * Rebuilds the elements related to this component in case of
  14525. * context lost for instance.
  14526. */
  14527. rebuild(): void;
  14528. /**
  14529. * Serializes the component data to the specified json object
  14530. * @param serializationObject The object to serialize to
  14531. */
  14532. serialize(serializationObject: any): void;
  14533. /**
  14534. * Adds all the element from the container to the scene
  14535. * @param container the container holding the elements
  14536. */
  14537. addFromContainer(container: AbstractScene): void;
  14538. /**
  14539. * Removes all the elements in the container from the scene
  14540. * @param container contains the elements to remove
  14541. */
  14542. removeFromContainer(container: AbstractScene): void;
  14543. /**
  14544. * Disposes the component and the associated ressources.
  14545. */
  14546. dispose(): void;
  14547. private _isReadyForMesh;
  14548. private _renderMainTexture;
  14549. private _setStencil;
  14550. private _setStencilBack;
  14551. private _draw;
  14552. private _drawCamera;
  14553. private _drawRenderingGroup;
  14554. }
  14555. }
  14556. declare module BABYLON {
  14557. interface AbstractScene {
  14558. /**
  14559. * Return a the first highlight layer of the scene with a given name.
  14560. * @param name The name of the highlight layer to look for.
  14561. * @return The highlight layer if found otherwise null.
  14562. */
  14563. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  14564. }
  14565. /**
  14566. * Glow layer options. This helps customizing the behaviour
  14567. * of the glow layer.
  14568. */
  14569. interface IGlowLayerOptions {
  14570. /**
  14571. * Multiplication factor apply to the canvas size to compute the render target size
  14572. * used to generated the glowing objects (the smaller the faster).
  14573. */
  14574. mainTextureRatio: number;
  14575. /**
  14576. * Enforces a fixed size texture to ensure resize independant blur.
  14577. */
  14578. mainTextureFixedSize?: number;
  14579. /**
  14580. * How big is the kernel of the blur texture.
  14581. */
  14582. blurKernelSize: number;
  14583. /**
  14584. * The camera attached to the layer.
  14585. */
  14586. camera: Nullable<Camera>;
  14587. /**
  14588. * Enable MSAA by chosing the number of samples.
  14589. */
  14590. mainTextureSamples?: number;
  14591. /**
  14592. * The rendering group to draw the layer in.
  14593. */
  14594. renderingGroupId: number;
  14595. }
  14596. /**
  14597. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  14598. *
  14599. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14600. * glowy meshes to your scene.
  14601. *
  14602. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  14603. */
  14604. class GlowLayer extends EffectLayer {
  14605. /**
  14606. * Effect Name of the layer.
  14607. */
  14608. static readonly EffectName: string;
  14609. /**
  14610. * The default blur kernel size used for the glow.
  14611. */
  14612. static DefaultBlurKernelSize: number;
  14613. /**
  14614. * The default texture size ratio used for the glow.
  14615. */
  14616. static DefaultTextureRatio: number;
  14617. /**
  14618. * Sets the kernel size of the blur.
  14619. */
  14620. /**
  14621. * Gets the kernel size of the blur.
  14622. */
  14623. blurKernelSize: number;
  14624. /**
  14625. * Sets the glow intensity.
  14626. */
  14627. /**
  14628. * Gets the glow intensity.
  14629. */
  14630. intensity: number;
  14631. private _options;
  14632. private _intensity;
  14633. private _horizontalBlurPostprocess1;
  14634. private _verticalBlurPostprocess1;
  14635. private _horizontalBlurPostprocess2;
  14636. private _verticalBlurPostprocess2;
  14637. private _blurTexture1;
  14638. private _blurTexture2;
  14639. private _postProcesses1;
  14640. private _postProcesses2;
  14641. private _includedOnlyMeshes;
  14642. private _excludedMeshes;
  14643. /**
  14644. * Callback used to let the user override the color selection on a per mesh basis
  14645. */
  14646. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  14647. /**
  14648. * Callback used to let the user override the texture selection on a per mesh basis
  14649. */
  14650. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  14651. /**
  14652. * Instantiates a new glow Layer and references it to the scene.
  14653. * @param name The name of the layer
  14654. * @param scene The scene to use the layer in
  14655. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  14656. */
  14657. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  14658. /**
  14659. * Get the effect name of the layer.
  14660. * @return The effect name
  14661. */
  14662. getEffectName(): string;
  14663. /**
  14664. * Create the merge effect. This is the shader use to blit the information back
  14665. * to the main canvas at the end of the scene rendering.
  14666. */
  14667. protected _createMergeEffect(): Effect;
  14668. /**
  14669. * Creates the render target textures and post processes used in the glow layer.
  14670. */
  14671. protected _createTextureAndPostProcesses(): void;
  14672. /**
  14673. * Checks for the readiness of the element composing the layer.
  14674. * @param subMesh the mesh to check for
  14675. * @param useInstances specify wether or not to use instances to render the mesh
  14676. * @param emissiveTexture the associated emissive texture used to generate the glow
  14677. * @return true if ready otherwise, false
  14678. */
  14679. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14680. /**
  14681. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14682. */
  14683. needStencil(): boolean;
  14684. /**
  14685. * Implementation specific of rendering the generating effect on the main canvas.
  14686. * @param effect The effect used to render through
  14687. */
  14688. protected _internalRender(effect: Effect): void;
  14689. /**
  14690. * Sets the required values for both the emissive texture and and the main color.
  14691. */
  14692. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14693. /**
  14694. * Returns true if the mesh should render, otherwise false.
  14695. * @param mesh The mesh to render
  14696. * @returns true if it should render otherwise false
  14697. */
  14698. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14699. /**
  14700. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  14701. * @param mesh The mesh to exclude from the glow layer
  14702. */
  14703. addExcludedMesh(mesh: Mesh): void;
  14704. /**
  14705. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  14706. * @param mesh The mesh to remove
  14707. */
  14708. removeExcludedMesh(mesh: Mesh): void;
  14709. /**
  14710. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  14711. * @param mesh The mesh to include in the glow layer
  14712. */
  14713. addIncludedOnlyMesh(mesh: Mesh): void;
  14714. /**
  14715. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  14716. * @param mesh The mesh to remove
  14717. */
  14718. removeIncludedOnlyMesh(mesh: Mesh): void;
  14719. /**
  14720. * Determine if a given mesh will be used in the glow layer
  14721. * @param mesh The mesh to test
  14722. * @returns true if the mesh will be highlighted by the current glow layer
  14723. */
  14724. hasMesh(mesh: AbstractMesh): boolean;
  14725. /**
  14726. * Free any resources and references associated to a mesh.
  14727. * Internal use
  14728. * @param mesh The mesh to free.
  14729. * @hidden
  14730. */
  14731. _disposeMesh(mesh: Mesh): void;
  14732. /**
  14733. * Gets the class name of the effect layer
  14734. * @returns the string with the class name of the effect layer
  14735. */
  14736. getClassName(): string;
  14737. /**
  14738. * Serializes this glow layer
  14739. * @returns a serialized glow layer object
  14740. */
  14741. serialize(): any;
  14742. /**
  14743. * Creates a Glow Layer from parsed glow layer data
  14744. * @param parsedGlowLayer defines glow layer data
  14745. * @param scene defines the current scene
  14746. * @param rootUrl defines the root URL containing the glow layer information
  14747. * @returns a parsed Glow Layer
  14748. */
  14749. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  14750. }
  14751. }
  14752. declare module BABYLON {
  14753. interface AbstractScene {
  14754. /**
  14755. * Return a the first highlight layer of the scene with a given name.
  14756. * @param name The name of the highlight layer to look for.
  14757. * @return The highlight layer if found otherwise null.
  14758. */
  14759. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  14760. }
  14761. /**
  14762. * Highlight layer options. This helps customizing the behaviour
  14763. * of the highlight layer.
  14764. */
  14765. interface IHighlightLayerOptions {
  14766. /**
  14767. * Multiplication factor apply to the canvas size to compute the render target size
  14768. * used to generated the glowing objects (the smaller the faster).
  14769. */
  14770. mainTextureRatio: number;
  14771. /**
  14772. * Enforces a fixed size texture to ensure resize independant blur.
  14773. */
  14774. mainTextureFixedSize?: number;
  14775. /**
  14776. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  14777. * of the picture to blur (the smaller the faster).
  14778. */
  14779. blurTextureSizeRatio: number;
  14780. /**
  14781. * How big in texel of the blur texture is the vertical blur.
  14782. */
  14783. blurVerticalSize: number;
  14784. /**
  14785. * How big in texel of the blur texture is the horizontal blur.
  14786. */
  14787. blurHorizontalSize: number;
  14788. /**
  14789. * Alpha blending mode used to apply the blur. Default is combine.
  14790. */
  14791. alphaBlendingMode: number;
  14792. /**
  14793. * The camera attached to the layer.
  14794. */
  14795. camera: Nullable<Camera>;
  14796. /**
  14797. * Should we display highlight as a solid stroke?
  14798. */
  14799. isStroke?: boolean;
  14800. /**
  14801. * The rendering group to draw the layer in.
  14802. */
  14803. renderingGroupId: number;
  14804. }
  14805. /**
  14806. * The highlight layer Helps adding a glow effect around a mesh.
  14807. *
  14808. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  14809. * glowy meshes to your scene.
  14810. *
  14811. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  14812. */
  14813. class HighlightLayer extends EffectLayer {
  14814. name: string;
  14815. /**
  14816. * Effect Name of the highlight layer.
  14817. */
  14818. static readonly EffectName: string;
  14819. /**
  14820. * The neutral color used during the preparation of the glow effect.
  14821. * This is black by default as the blend operation is a blend operation.
  14822. */
  14823. static NeutralColor: Color4;
  14824. /**
  14825. * Stencil value used for glowing meshes.
  14826. */
  14827. static GlowingMeshStencilReference: number;
  14828. /**
  14829. * Stencil value used for the other meshes in the scene.
  14830. */
  14831. static NormalMeshStencilReference: number;
  14832. /**
  14833. * Specifies whether or not the inner glow is ACTIVE in the layer.
  14834. */
  14835. innerGlow: boolean;
  14836. /**
  14837. * Specifies whether or not the outer glow is ACTIVE in the layer.
  14838. */
  14839. outerGlow: boolean;
  14840. /**
  14841. * Specifies the horizontal size of the blur.
  14842. */
  14843. /**
  14844. * Gets the horizontal size of the blur.
  14845. */
  14846. blurHorizontalSize: number;
  14847. /**
  14848. * Specifies the vertical size of the blur.
  14849. */
  14850. /**
  14851. * Gets the vertical size of the blur.
  14852. */
  14853. blurVerticalSize: number;
  14854. /**
  14855. * An event triggered when the highlight layer is being blurred.
  14856. */
  14857. onBeforeBlurObservable: Observable<HighlightLayer>;
  14858. /**
  14859. * An event triggered when the highlight layer has been blurred.
  14860. */
  14861. onAfterBlurObservable: Observable<HighlightLayer>;
  14862. private _instanceGlowingMeshStencilReference;
  14863. private _options;
  14864. private _downSamplePostprocess;
  14865. private _horizontalBlurPostprocess;
  14866. private _verticalBlurPostprocess;
  14867. private _blurTexture;
  14868. private _meshes;
  14869. private _excludedMeshes;
  14870. /**
  14871. * Instantiates a new highlight Layer and references it to the scene..
  14872. * @param name The name of the layer
  14873. * @param scene The scene to use the layer in
  14874. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  14875. */
  14876. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  14877. /**
  14878. * Get the effect name of the layer.
  14879. * @return The effect name
  14880. */
  14881. getEffectName(): string;
  14882. /**
  14883. * Create the merge effect. This is the shader use to blit the information back
  14884. * to the main canvas at the end of the scene rendering.
  14885. */
  14886. protected _createMergeEffect(): Effect;
  14887. /**
  14888. * Creates the render target textures and post processes used in the highlight layer.
  14889. */
  14890. protected _createTextureAndPostProcesses(): void;
  14891. /**
  14892. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  14893. */
  14894. needStencil(): boolean;
  14895. /**
  14896. * Checks for the readiness of the element composing the layer.
  14897. * @param subMesh the mesh to check for
  14898. * @param useInstances specify wether or not to use instances to render the mesh
  14899. * @param emissiveTexture the associated emissive texture used to generate the glow
  14900. * @return true if ready otherwise, false
  14901. */
  14902. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  14903. /**
  14904. * Implementation specific of rendering the generating effect on the main canvas.
  14905. * @param effect The effect used to render through
  14906. */
  14907. protected _internalRender(effect: Effect): void;
  14908. /**
  14909. * Returns true if the layer contains information to display, otherwise false.
  14910. */
  14911. shouldRender(): boolean;
  14912. /**
  14913. * Returns true if the mesh should render, otherwise false.
  14914. * @param mesh The mesh to render
  14915. * @returns true if it should render otherwise false
  14916. */
  14917. protected _shouldRenderMesh(mesh: Mesh): boolean;
  14918. /**
  14919. * Sets the required values for both the emissive texture and and the main color.
  14920. */
  14921. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  14922. /**
  14923. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  14924. * @param mesh The mesh to exclude from the highlight layer
  14925. */
  14926. addExcludedMesh(mesh: Mesh): void;
  14927. /**
  14928. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  14929. * @param mesh The mesh to highlight
  14930. */
  14931. removeExcludedMesh(mesh: Mesh): void;
  14932. /**
  14933. * Determine if a given mesh will be highlighted by the current HighlightLayer
  14934. * @param mesh mesh to test
  14935. * @returns true if the mesh will be highlighted by the current HighlightLayer
  14936. */
  14937. hasMesh(mesh: AbstractMesh): boolean;
  14938. /**
  14939. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  14940. * @param mesh The mesh to highlight
  14941. * @param color The color of the highlight
  14942. * @param glowEmissiveOnly Extract the glow from the emissive texture
  14943. */
  14944. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  14945. /**
  14946. * Remove a mesh from the highlight layer in order to make it stop glowing.
  14947. * @param mesh The mesh to highlight
  14948. */
  14949. removeMesh(mesh: Mesh): void;
  14950. /**
  14951. * Force the stencil to the normal expected value for none glowing parts
  14952. */
  14953. private _defaultStencilReference;
  14954. /**
  14955. * Free any resources and references associated to a mesh.
  14956. * Internal use
  14957. * @param mesh The mesh to free.
  14958. * @hidden
  14959. */
  14960. _disposeMesh(mesh: Mesh): void;
  14961. /**
  14962. * Dispose the highlight layer and free resources.
  14963. */
  14964. dispose(): void;
  14965. /**
  14966. * Gets the class name of the effect layer
  14967. * @returns the string with the class name of the effect layer
  14968. */
  14969. getClassName(): string;
  14970. /**
  14971. * Serializes this Highlight layer
  14972. * @returns a serialized Highlight layer object
  14973. */
  14974. serialize(): any;
  14975. /**
  14976. * Creates a Highlight layer from parsed Highlight layer data
  14977. * @param parsedHightlightLayer defines the Highlight layer data
  14978. * @param scene defines the current scene
  14979. * @param rootUrl defines the root URL containing the Highlight layer information
  14980. * @returns a parsed Highlight layer
  14981. */
  14982. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  14983. }
  14984. }
  14985. declare module BABYLON {
  14986. /**
  14987. * This represents a full screen 2d layer.
  14988. * This can be usefull to display a picture in the background of your scene for instance.
  14989. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14990. */
  14991. class Layer {
  14992. /**
  14993. * Define the name of the layer.
  14994. */
  14995. name: string;
  14996. /**
  14997. * Define the texture the layer should display.
  14998. */
  14999. texture: Nullable<Texture>;
  15000. /**
  15001. * Is the layer in background or foreground.
  15002. */
  15003. isBackground: boolean;
  15004. /**
  15005. * Define the color of the layer (instead of texture).
  15006. */
  15007. color: Color4;
  15008. /**
  15009. * Define the scale of the layer in order to zoom in out of the texture.
  15010. */
  15011. scale: Vector2;
  15012. /**
  15013. * Define an offset for the layer in order to shift the texture.
  15014. */
  15015. offset: Vector2;
  15016. /**
  15017. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  15018. */
  15019. alphaBlendingMode: number;
  15020. /**
  15021. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  15022. * Alpha test will not mix with the background color in case of transparency.
  15023. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  15024. */
  15025. alphaTest: boolean;
  15026. /**
  15027. * Define a mask to restrict the layer to only some of the scene cameras.
  15028. */
  15029. layerMask: number;
  15030. /**
  15031. * Define the list of render target the layer is visible into.
  15032. */
  15033. renderTargetTextures: RenderTargetTexture[];
  15034. /**
  15035. * Define if the layer is only used in renderTarget or if it also
  15036. * renders in the main frame buffer of the canvas.
  15037. */
  15038. renderOnlyInRenderTargetTextures: boolean;
  15039. private _scene;
  15040. private _vertexBuffers;
  15041. private _indexBuffer;
  15042. private _effect;
  15043. private _alphaTestEffect;
  15044. /**
  15045. * An event triggered when the layer is disposed.
  15046. */
  15047. onDisposeObservable: Observable<Layer>;
  15048. private _onDisposeObserver;
  15049. /**
  15050. * Back compatibility with callback before the onDisposeObservable existed.
  15051. * The set callback will be triggered when the layer has been disposed.
  15052. */
  15053. onDispose: () => void;
  15054. /**
  15055. * An event triggered before rendering the scene
  15056. */
  15057. onBeforeRenderObservable: Observable<Layer>;
  15058. private _onBeforeRenderObserver;
  15059. /**
  15060. * Back compatibility with callback before the onBeforeRenderObservable existed.
  15061. * The set callback will be triggered just before rendering the layer.
  15062. */
  15063. onBeforeRender: () => void;
  15064. /**
  15065. * An event triggered after rendering the scene
  15066. */
  15067. onAfterRenderObservable: Observable<Layer>;
  15068. private _onAfterRenderObserver;
  15069. /**
  15070. * Back compatibility with callback before the onAfterRenderObservable existed.
  15071. * The set callback will be triggered just after rendering the layer.
  15072. */
  15073. onAfterRender: () => void;
  15074. /**
  15075. * Instantiates a new layer.
  15076. * This represents a full screen 2d layer.
  15077. * This can be usefull to display a picture in the background of your scene for instance.
  15078. * @see https://www.babylonjs-playground.com/#08A2BS#1
  15079. * @param name Define the name of the layer in the scene
  15080. * @param imgUrl Define the url of the texture to display in the layer
  15081. * @param scene Define the scene the layer belongs to
  15082. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  15083. * @param color Defines a color for the layer
  15084. */
  15085. constructor(
  15086. /**
  15087. * Define the name of the layer.
  15088. */
  15089. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  15090. private _createIndexBuffer;
  15091. /** @hidden */
  15092. _rebuild(): void;
  15093. /**
  15094. * Renders the layer in the scene.
  15095. */
  15096. render(): void;
  15097. /**
  15098. * Disposes and releases the associated ressources.
  15099. */
  15100. dispose(): void;
  15101. }
  15102. }
  15103. declare module BABYLON {
  15104. interface AbstractScene {
  15105. /**
  15106. * The list of layers (background and foreground) of the scene
  15107. */
  15108. layers: Array<Layer>;
  15109. }
  15110. /**
  15111. * Defines the layer scene component responsible to manage any layers
  15112. * in a given scene.
  15113. */
  15114. class LayerSceneComponent implements ISceneComponent {
  15115. /**
  15116. * The component name helpfull to identify the component in the list of scene components.
  15117. */
  15118. readonly name: string;
  15119. /**
  15120. * The scene the component belongs to.
  15121. */
  15122. scene: Scene;
  15123. private _engine;
  15124. /**
  15125. * Creates a new instance of the component for the given scene
  15126. * @param scene Defines the scene to register the component in
  15127. */
  15128. constructor(scene: Scene);
  15129. /**
  15130. * Registers the component in a given scene
  15131. */
  15132. register(): void;
  15133. /**
  15134. * Rebuilds the elements related to this component in case of
  15135. * context lost for instance.
  15136. */
  15137. rebuild(): void;
  15138. /**
  15139. * Disposes the component and the associated ressources.
  15140. */
  15141. dispose(): void;
  15142. private _draw;
  15143. private _drawCameraPredicate;
  15144. private _drawCameraBackground;
  15145. private _drawCameraForeground;
  15146. private _drawRenderTargetPredicate;
  15147. private _drawRenderTargetBackground;
  15148. private _drawRenderTargetForeground;
  15149. }
  15150. }
  15151. declare module BABYLON {
  15152. /**
  15153. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15154. * It controls one of the indiviual texture used in the effect.
  15155. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15156. */
  15157. class LensFlare {
  15158. /**
  15159. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15160. */
  15161. size: number;
  15162. /**
  15163. * 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.
  15164. */
  15165. position: number;
  15166. /**
  15167. * Define the lens color.
  15168. */
  15169. color: Color3;
  15170. /**
  15171. * Define the lens texture.
  15172. */
  15173. texture: Nullable<Texture>;
  15174. /**
  15175. * Define the alpha mode to render this particular lens.
  15176. */
  15177. alphaMode: number;
  15178. private _system;
  15179. /**
  15180. * Creates a new Lens Flare.
  15181. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15182. * It controls one of the indiviual texture used in the effect.
  15183. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15184. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  15185. * @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.
  15186. * @param color Define the lens color
  15187. * @param imgUrl Define the lens texture url
  15188. * @param system Define the `lensFlareSystem` this flare is part of
  15189. * @returns The newly created Lens Flare
  15190. */
  15191. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  15192. /**
  15193. * Instantiates a new Lens Flare.
  15194. * This represents one of the lens effect in a `BABYLON.lensFlareSystem`.
  15195. * It controls one of the indiviual texture used in the effect.
  15196. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15197. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  15198. * @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.
  15199. * @param color Define the lens color
  15200. * @param imgUrl Define the lens texture url
  15201. * @param system Define the `lensFlareSystem` this flare is part of
  15202. */
  15203. constructor(
  15204. /**
  15205. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  15206. */
  15207. size: number,
  15208. /**
  15209. * 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.
  15210. */
  15211. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  15212. /**
  15213. * Dispose and release the lens flare with its associated resources.
  15214. */
  15215. dispose(): void;
  15216. }
  15217. }
  15218. declare module BABYLON {
  15219. /**
  15220. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15221. * It is usually composed of several `BABYLON.lensFlare`.
  15222. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15223. */
  15224. class LensFlareSystem {
  15225. /**
  15226. * Define the name of the lens flare system
  15227. */
  15228. name: string;
  15229. /**
  15230. * List of lens flares used in this system.
  15231. */
  15232. lensFlares: LensFlare[];
  15233. /**
  15234. * Define a limit from the border the lens flare can be visible.
  15235. */
  15236. borderLimit: number;
  15237. /**
  15238. * Define a viewport border we do not want to see the lens flare in.
  15239. */
  15240. viewportBorder: number;
  15241. /**
  15242. * Define a predicate which could limit the list of meshes able to occlude the effect.
  15243. */
  15244. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  15245. /**
  15246. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  15247. */
  15248. layerMask: number;
  15249. /**
  15250. * Define the id of the lens flare system in the scene.
  15251. * (equal to name by default)
  15252. */
  15253. id: string;
  15254. private _scene;
  15255. private _emitter;
  15256. private _vertexBuffers;
  15257. private _indexBuffer;
  15258. private _effect;
  15259. private _positionX;
  15260. private _positionY;
  15261. private _isEnabled;
  15262. /**
  15263. * Instantiates a lens flare system.
  15264. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  15265. * It is usually composed of several `BABYLON.lensFlare`.
  15266. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15267. * @param name Define the name of the lens flare system in the scene
  15268. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  15269. * @param scene Define the scene the lens flare system belongs to
  15270. */
  15271. constructor(
  15272. /**
  15273. * Define the name of the lens flare system
  15274. */
  15275. name: string, emitter: any, scene: Scene);
  15276. /**
  15277. * Define if the lens flare system is enabled.
  15278. */
  15279. isEnabled: boolean;
  15280. /**
  15281. * Get the scene the effects belongs to.
  15282. * @returns the scene holding the lens flare system
  15283. */
  15284. getScene(): Scene;
  15285. /**
  15286. * Get the emitter of the lens flare system.
  15287. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15288. * @returns the emitter of the lens flare system
  15289. */
  15290. getEmitter(): any;
  15291. /**
  15292. * Set the emitter of the lens flare system.
  15293. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  15294. * @param newEmitter Define the new emitter of the system
  15295. */
  15296. setEmitter(newEmitter: any): void;
  15297. /**
  15298. * Get the lens flare system emitter position.
  15299. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  15300. * @returns the position
  15301. */
  15302. getEmitterPosition(): Vector3;
  15303. /**
  15304. * @hidden
  15305. */
  15306. computeEffectivePosition(globalViewport: Viewport): boolean;
  15307. /** @hidden */
  15308. _isVisible(): boolean;
  15309. /**
  15310. * @hidden
  15311. */
  15312. render(): boolean;
  15313. /**
  15314. * Dispose and release the lens flare with its associated resources.
  15315. */
  15316. dispose(): void;
  15317. /**
  15318. * Parse a lens flare system from a JSON repressentation
  15319. * @param parsedLensFlareSystem Define the JSON to parse
  15320. * @param scene Define the scene the parsed system should be instantiated in
  15321. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  15322. * @returns the parsed system
  15323. */
  15324. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  15325. /**
  15326. * Serialize the current Lens Flare System into a JSON representation.
  15327. * @returns the serialized JSON
  15328. */
  15329. serialize(): any;
  15330. }
  15331. }
  15332. declare module BABYLON {
  15333. interface AbstractScene {
  15334. /**
  15335. * The list of lens flare system added to the scene
  15336. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  15337. */
  15338. lensFlareSystems: Array<LensFlareSystem>;
  15339. /**
  15340. * Removes the given lens flare system from this scene.
  15341. * @param toRemove The lens flare system to remove
  15342. * @returns The index of the removed lens flare system
  15343. */
  15344. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  15345. /**
  15346. * Adds the given lens flare system to this scene
  15347. * @param newLensFlareSystem The lens flare system to add
  15348. */
  15349. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  15350. /**
  15351. * Gets a lens flare system using its name
  15352. * @param name defines the name to look for
  15353. * @returns the lens flare system or null if not found
  15354. */
  15355. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  15356. /**
  15357. * Gets a lens flare system using its id
  15358. * @param id defines the id to look for
  15359. * @returns the lens flare system or null if not found
  15360. */
  15361. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  15362. }
  15363. /**
  15364. * Defines the lens flare scene component responsible to manage any lens flares
  15365. * in a given scene.
  15366. */
  15367. class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  15368. /**
  15369. * The component name helpfull to identify the component in the list of scene components.
  15370. */
  15371. readonly name: string;
  15372. /**
  15373. * The scene the component belongs to.
  15374. */
  15375. scene: Scene;
  15376. /**
  15377. * Creates a new instance of the component for the given scene
  15378. * @param scene Defines the scene to register the component in
  15379. */
  15380. constructor(scene: Scene);
  15381. /**
  15382. * Registers the component in a given scene
  15383. */
  15384. register(): void;
  15385. /**
  15386. * Rebuilds the elements related to this component in case of
  15387. * context lost for instance.
  15388. */
  15389. rebuild(): void;
  15390. /**
  15391. * Adds all the element from the container to the scene
  15392. * @param container the container holding the elements
  15393. */
  15394. addFromContainer(container: AbstractScene): void;
  15395. /**
  15396. * Removes all the elements in the container from the scene
  15397. * @param container contains the elements to remove
  15398. */
  15399. removeFromContainer(container: AbstractScene): void;
  15400. /**
  15401. * Serializes the component data to the specified json object
  15402. * @param serializationObject The object to serialize to
  15403. */
  15404. serialize(serializationObject: any): void;
  15405. /**
  15406. * Disposes the component and the associated ressources.
  15407. */
  15408. dispose(): void;
  15409. private _draw;
  15410. }
  15411. }
  15412. declare module BABYLON {
  15413. /**
  15414. * A directional light is defined by a direction (what a surprise!).
  15415. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  15416. * 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.
  15417. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15418. */
  15419. class DirectionalLight extends ShadowLight {
  15420. private _shadowFrustumSize;
  15421. /**
  15422. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  15423. */
  15424. /**
  15425. * Specifies a fix frustum size for the shadow generation.
  15426. */
  15427. shadowFrustumSize: number;
  15428. private _shadowOrthoScale;
  15429. /**
  15430. * Gets the shadow projection scale against the optimal computed one.
  15431. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15432. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15433. */
  15434. /**
  15435. * Sets the shadow projection scale against the optimal computed one.
  15436. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  15437. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  15438. */
  15439. shadowOrthoScale: number;
  15440. /**
  15441. * Automatically compute the projection matrix to best fit (including all the casters)
  15442. * on each frame.
  15443. */
  15444. autoUpdateExtends: boolean;
  15445. private _orthoLeft;
  15446. private _orthoRight;
  15447. private _orthoTop;
  15448. private _orthoBottom;
  15449. /**
  15450. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  15451. * The directional light is emitted from everywhere in the given direction.
  15452. * It can cast shadows.
  15453. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15454. * @param name The friendly name of the light
  15455. * @param direction The direction of the light
  15456. * @param scene The scene the light belongs to
  15457. */
  15458. constructor(name: string, direction: Vector3, scene: Scene);
  15459. /**
  15460. * Returns the string "DirectionalLight".
  15461. * @return The class name
  15462. */
  15463. getClassName(): string;
  15464. /**
  15465. * Returns the integer 1.
  15466. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15467. */
  15468. getTypeID(): number;
  15469. /**
  15470. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  15471. * Returns the DirectionalLight Shadow projection matrix.
  15472. */
  15473. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15474. /**
  15475. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  15476. * Returns the DirectionalLight Shadow projection matrix.
  15477. */
  15478. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  15479. /**
  15480. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  15481. * Returns the DirectionalLight Shadow projection matrix.
  15482. */
  15483. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  15484. protected _buildUniformLayout(): void;
  15485. /**
  15486. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  15487. * @param effect The effect to update
  15488. * @param lightIndex The index of the light in the effect to update
  15489. * @returns The directional light
  15490. */
  15491. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  15492. /**
  15493. * Gets the minZ used for shadow according to both the scene and the light.
  15494. *
  15495. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15496. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15497. * @param activeCamera The camera we are returning the min for
  15498. * @returns the depth min z
  15499. */
  15500. getDepthMinZ(activeCamera: Camera): number;
  15501. /**
  15502. * Gets the maxZ used for shadow according to both the scene and the light.
  15503. *
  15504. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  15505. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  15506. * @param activeCamera The camera we are returning the max for
  15507. * @returns the depth max z
  15508. */
  15509. getDepthMaxZ(activeCamera: Camera): number;
  15510. /**
  15511. * Prepares the list of defines specific to the light type.
  15512. * @param defines the list of defines
  15513. * @param lightIndex defines the index of the light for the effect
  15514. */
  15515. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15516. }
  15517. }
  15518. declare module BABYLON {
  15519. /**
  15520. * The HemisphericLight simulates the ambient environment light,
  15521. * so the passed direction is the light reflection direction, not the incoming direction.
  15522. */
  15523. class HemisphericLight extends Light {
  15524. /**
  15525. * The groundColor is the light in the opposite direction to the one specified during creation.
  15526. * 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.
  15527. */
  15528. groundColor: Color3;
  15529. /**
  15530. * The light reflection direction, not the incoming direction.
  15531. */
  15532. direction: Vector3;
  15533. /**
  15534. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15535. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15536. * The HemisphericLight can't cast shadows.
  15537. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15538. * @param name The friendly name of the light
  15539. * @param direction The direction of the light reflection
  15540. * @param scene The scene the light belongs to
  15541. */
  15542. constructor(name: string, direction: Vector3, scene: Scene);
  15543. protected _buildUniformLayout(): void;
  15544. /**
  15545. * Returns the string "HemisphericLight".
  15546. * @return The class name
  15547. */
  15548. getClassName(): string;
  15549. /**
  15550. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15551. * Returns the updated direction.
  15552. * @param target The target the direction should point to
  15553. * @return The computed direction
  15554. */
  15555. setDirectionToTarget(target: Vector3): Vector3;
  15556. /**
  15557. * Returns the shadow generator associated to the light.
  15558. * @returns Always null for hemispheric lights because it does not support shadows.
  15559. */
  15560. getShadowGenerator(): Nullable<IShadowGenerator>;
  15561. /**
  15562. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15563. * @param effect The effect to update
  15564. * @param lightIndex The index of the light in the effect to update
  15565. * @returns The hemispheric light
  15566. */
  15567. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15568. /**
  15569. * Computes the world matrix of the node
  15570. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15571. * @param useWasUpdatedFlag defines a reserved property
  15572. * @returns the world matrix
  15573. */
  15574. computeWorldMatrix(force?: boolean, useWasUpdatedFlag?: boolean): Matrix;
  15575. /**
  15576. * Returns the integer 3.
  15577. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15578. */
  15579. getTypeID(): number;
  15580. /**
  15581. * Prepares the list of defines specific to the light type.
  15582. * @param defines the list of defines
  15583. * @param lightIndex defines the index of the light for the effect
  15584. */
  15585. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15586. }
  15587. }
  15588. declare module BABYLON {
  15589. /**
  15590. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  15591. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  15592. * 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.
  15593. */
  15594. abstract class Light extends Node {
  15595. /**
  15596. * Falloff Default: light is falling off following the material specification:
  15597. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  15598. */
  15599. static readonly FALLOFF_DEFAULT: number;
  15600. /**
  15601. * Falloff Physical: light is falling off following the inverse squared distance law.
  15602. */
  15603. static readonly FALLOFF_PHYSICAL: number;
  15604. /**
  15605. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  15606. * to enhance interoperability with other engines.
  15607. */
  15608. static readonly FALLOFF_GLTF: number;
  15609. /**
  15610. * Falloff Standard: light is falling off like in the standard material
  15611. * to enhance interoperability with other materials.
  15612. */
  15613. static readonly FALLOFF_STANDARD: number;
  15614. /**
  15615. * If every light affecting the material is in this lightmapMode,
  15616. * material.lightmapTexture adds or multiplies
  15617. * (depends on material.useLightmapAsShadowmap)
  15618. * after every other light calculations.
  15619. */
  15620. static readonly LIGHTMAP_DEFAULT: number;
  15621. /**
  15622. * material.lightmapTexture as only diffuse lighting from this light
  15623. * adds only specular lighting from this light
  15624. * adds dynamic shadows
  15625. */
  15626. static readonly LIGHTMAP_SPECULAR: number;
  15627. /**
  15628. * material.lightmapTexture as only lighting
  15629. * no light calculation from this light
  15630. * only adds dynamic shadows from this light
  15631. */
  15632. static readonly LIGHTMAP_SHADOWSONLY: number;
  15633. /**
  15634. * Each light type uses the default quantity according to its type:
  15635. * point/spot lights use luminous intensity
  15636. * directional lights use illuminance
  15637. */
  15638. static readonly INTENSITYMODE_AUTOMATIC: number;
  15639. /**
  15640. * lumen (lm)
  15641. */
  15642. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  15643. /**
  15644. * candela (lm/sr)
  15645. */
  15646. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  15647. /**
  15648. * lux (lm/m^2)
  15649. */
  15650. static readonly INTENSITYMODE_ILLUMINANCE: number;
  15651. /**
  15652. * nit (cd/m^2)
  15653. */
  15654. static readonly INTENSITYMODE_LUMINANCE: number;
  15655. /**
  15656. * Light type const id of the point light.
  15657. */
  15658. static readonly LIGHTTYPEID_POINTLIGHT: number;
  15659. /**
  15660. * Light type const id of the directional light.
  15661. */
  15662. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  15663. /**
  15664. * Light type const id of the spot light.
  15665. */
  15666. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  15667. /**
  15668. * Light type const id of the hemispheric light.
  15669. */
  15670. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  15671. /**
  15672. * Diffuse gives the basic color to an object.
  15673. */
  15674. diffuse: Color3;
  15675. /**
  15676. * Specular produces a highlight color on an object.
  15677. * Note: This is note affecting PBR materials.
  15678. */
  15679. specular: Color3;
  15680. /**
  15681. * Defines the falloff type for this light. This lets overrriding how punctual light are
  15682. * falling off base on range or angle.
  15683. * This can be set to any values in Light.FALLOFF_x.
  15684. *
  15685. * Note: This is only usefull for PBR Materials at the moment. This could be extended if required to
  15686. * other types of materials.
  15687. */
  15688. falloffType: number;
  15689. /**
  15690. * Strength of the light.
  15691. * Note: By default it is define in the framework own unit.
  15692. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  15693. */
  15694. intensity: number;
  15695. private _range;
  15696. protected _inverseSquaredRange: number;
  15697. /**
  15698. * Defines how far from the source the light is impacting in scene units.
  15699. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15700. */
  15701. /**
  15702. * Defines how far from the source the light is impacting in scene units.
  15703. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  15704. */
  15705. range: number;
  15706. /**
  15707. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  15708. * of light.
  15709. */
  15710. private _photometricScale;
  15711. private _intensityMode;
  15712. /**
  15713. * Gets the photometric scale used to interpret the intensity.
  15714. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15715. */
  15716. /**
  15717. * Sets the photometric scale used to interpret the intensity.
  15718. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  15719. */
  15720. intensityMode: number;
  15721. private _radius;
  15722. /**
  15723. * Gets the light radius used by PBR Materials to simulate soft area lights.
  15724. */
  15725. /**
  15726. * sets the light radius used by PBR Materials to simulate soft area lights.
  15727. */
  15728. radius: number;
  15729. private _renderPriority;
  15730. /**
  15731. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  15732. * exceeding the number allowed of the materials.
  15733. */
  15734. renderPriority: number;
  15735. private _shadowEnabled;
  15736. /**
  15737. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15738. * the current shadow generator.
  15739. */
  15740. /**
  15741. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  15742. * the current shadow generator.
  15743. */
  15744. shadowEnabled: boolean;
  15745. private _includedOnlyMeshes;
  15746. /**
  15747. * Gets the only meshes impacted by this light.
  15748. */
  15749. /**
  15750. * Sets the only meshes impacted by this light.
  15751. */
  15752. includedOnlyMeshes: AbstractMesh[];
  15753. private _excludedMeshes;
  15754. /**
  15755. * Gets the meshes not impacted by this light.
  15756. */
  15757. /**
  15758. * Sets the meshes not impacted by this light.
  15759. */
  15760. excludedMeshes: AbstractMesh[];
  15761. private _excludeWithLayerMask;
  15762. /**
  15763. * Gets the layer id use to find what meshes are not impacted by the light.
  15764. * Inactive if 0
  15765. */
  15766. /**
  15767. * Sets the layer id use to find what meshes are not impacted by the light.
  15768. * Inactive if 0
  15769. */
  15770. excludeWithLayerMask: number;
  15771. private _includeOnlyWithLayerMask;
  15772. /**
  15773. * Gets the layer id use to find what meshes are impacted by the light.
  15774. * Inactive if 0
  15775. */
  15776. /**
  15777. * Sets the layer id use to find what meshes are impacted by the light.
  15778. * Inactive if 0
  15779. */
  15780. includeOnlyWithLayerMask: number;
  15781. private _lightmapMode;
  15782. /**
  15783. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15784. */
  15785. /**
  15786. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  15787. */
  15788. lightmapMode: number;
  15789. /**
  15790. * Shadow generator associted to the light.
  15791. * @hidden Internal use only.
  15792. */
  15793. _shadowGenerator: Nullable<IShadowGenerator>;
  15794. /**
  15795. * @hidden Internal use only.
  15796. */
  15797. _excludedMeshesIds: string[];
  15798. /**
  15799. * @hidden Internal use only.
  15800. */
  15801. _includedOnlyMeshesIds: string[];
  15802. /**
  15803. * The current light unifom buffer.
  15804. * @hidden Internal use only.
  15805. */
  15806. _uniformBuffer: UniformBuffer;
  15807. /**
  15808. * Creates a Light object in the scene.
  15809. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15810. * @param name The firendly name of the light
  15811. * @param scene The scene the light belongs too
  15812. */
  15813. constructor(name: string, scene: Scene);
  15814. protected abstract _buildUniformLayout(): void;
  15815. /**
  15816. * Sets the passed Effect "effect" with the Light information.
  15817. * @param effect The effect to update
  15818. * @param lightIndex The index of the light in the effect to update
  15819. * @returns The light
  15820. */
  15821. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  15822. /**
  15823. * Returns the string "Light".
  15824. * @returns the class name
  15825. */
  15826. getClassName(): string;
  15827. /**
  15828. * Converts the light information to a readable string for debug purpose.
  15829. * @param fullDetails Supports for multiple levels of logging within scene loading
  15830. * @returns the human readable light info
  15831. */
  15832. toString(fullDetails?: boolean): string;
  15833. /** @hidden */
  15834. protected _syncParentEnabledState(): void;
  15835. /**
  15836. * Set the enabled state of this node.
  15837. * @param value - the new enabled state
  15838. */
  15839. setEnabled(value: boolean): void;
  15840. /**
  15841. * Returns the Light associated shadow generator if any.
  15842. * @return the associated shadow generator.
  15843. */
  15844. getShadowGenerator(): Nullable<IShadowGenerator>;
  15845. /**
  15846. * Returns a Vector3, the absolute light position in the World.
  15847. * @returns the world space position of the light
  15848. */
  15849. getAbsolutePosition(): Vector3;
  15850. /**
  15851. * Specifies if the light will affect the passed mesh.
  15852. * @param mesh The mesh to test against the light
  15853. * @return true the mesh is affected otherwise, false.
  15854. */
  15855. canAffectMesh(mesh: AbstractMesh): boolean;
  15856. /**
  15857. * Sort function to order lights for rendering.
  15858. * @param a First Light object to compare to second.
  15859. * @param b Second Light object to compare first.
  15860. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  15861. */
  15862. static CompareLightsPriority(a: Light, b: Light): number;
  15863. /**
  15864. * Releases resources associated with this node.
  15865. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15866. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15867. */
  15868. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15869. /**
  15870. * Returns the light type ID (integer).
  15871. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15872. */
  15873. getTypeID(): number;
  15874. /**
  15875. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  15876. * @returns the scaled intensity in intensity mode unit
  15877. */
  15878. getScaledIntensity(): number;
  15879. /**
  15880. * Returns a new Light object, named "name", from the current one.
  15881. * @param name The name of the cloned light
  15882. * @returns the new created light
  15883. */
  15884. clone(name: string): Nullable<Light>;
  15885. /**
  15886. * Serializes the current light into a Serialization object.
  15887. * @returns the serialized object.
  15888. */
  15889. serialize(): any;
  15890. /**
  15891. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  15892. * This new light is named "name" and added to the passed scene.
  15893. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  15894. * @param name The friendly name of the light
  15895. * @param scene The scene the new light will belong to
  15896. * @returns the constructor function
  15897. */
  15898. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  15899. /**
  15900. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  15901. * @param parsedLight The JSON representation of the light
  15902. * @param scene The scene to create the parsed light in
  15903. * @returns the created light after parsing
  15904. */
  15905. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  15906. private _hookArrayForExcluded;
  15907. private _hookArrayForIncludedOnly;
  15908. private _resyncMeshes;
  15909. /**
  15910. * Forces the meshes to update their light related information in their rendering used effects
  15911. * @hidden Internal Use Only
  15912. */
  15913. _markMeshesAsLightDirty(): void;
  15914. /**
  15915. * Recomputes the cached photometric scale if needed.
  15916. */
  15917. private _computePhotometricScale;
  15918. /**
  15919. * Returns the Photometric Scale according to the light type and intensity mode.
  15920. */
  15921. private _getPhotometricScale;
  15922. /**
  15923. * Reorder the light in the scene according to their defined priority.
  15924. * @hidden Internal Use Only
  15925. */
  15926. _reorderLightsInScene(): void;
  15927. /**
  15928. * Prepares the list of defines specific to the light type.
  15929. * @param defines the list of defines
  15930. * @param lightIndex defines the index of the light for the effect
  15931. */
  15932. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15933. }
  15934. }
  15935. declare module BABYLON {
  15936. /**
  15937. * A point light is a light defined by an unique point in world space.
  15938. * The light is emitted in every direction from this point.
  15939. * A good example of a point light is a standard light bulb.
  15940. * Documentation: https://doc.babylonjs.com/babylon101/lights
  15941. */
  15942. class PointLight extends ShadowLight {
  15943. private _shadowAngle;
  15944. /**
  15945. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15946. * This specifies what angle the shadow will use to be created.
  15947. *
  15948. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15949. */
  15950. /**
  15951. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15952. * This specifies what angle the shadow will use to be created.
  15953. *
  15954. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  15955. */
  15956. shadowAngle: number;
  15957. /**
  15958. * Gets the direction if it has been set.
  15959. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15960. */
  15961. /**
  15962. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  15963. */
  15964. direction: Vector3;
  15965. /**
  15966. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  15967. * A PointLight emits the light in every direction.
  15968. * It can cast shadows.
  15969. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  15970. * ```javascript
  15971. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  15972. * ```
  15973. * Documentation : http://doc.babylonjs.com/tutorials/lights
  15974. * @param name The light friendly name
  15975. * @param position The position of the point light in the scene
  15976. * @param scene The scene the lights belongs to
  15977. */
  15978. constructor(name: string, position: Vector3, scene: Scene);
  15979. /**
  15980. * Returns the string "PointLight"
  15981. * @returns the class name
  15982. */
  15983. getClassName(): string;
  15984. /**
  15985. * Returns the integer 0.
  15986. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15987. */
  15988. getTypeID(): number;
  15989. /**
  15990. * Specifies wether or not the shadowmap should be a cube texture.
  15991. * @returns true if the shadowmap needs to be a cube texture.
  15992. */
  15993. needCube(): boolean;
  15994. /**
  15995. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  15996. * @param faceIndex The index of the face we are computed the direction to generate shadow
  15997. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  15998. */
  15999. getShadowDirection(faceIndex?: number): Vector3;
  16000. /**
  16001. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  16002. * - fov = PI / 2
  16003. * - aspect ratio : 1.0
  16004. * - z-near and far equal to the active camera minZ and maxZ.
  16005. * Returns the PointLight.
  16006. */
  16007. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16008. protected _buildUniformLayout(): void;
  16009. /**
  16010. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  16011. * @param effect The effect to update
  16012. * @param lightIndex The index of the light in the effect to update
  16013. * @returns The point light
  16014. */
  16015. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  16016. /**
  16017. * Prepares the list of defines specific to the light type.
  16018. * @param defines the list of defines
  16019. * @param lightIndex defines the index of the light for the effect
  16020. */
  16021. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16022. }
  16023. }
  16024. declare module BABYLON {
  16025. /**
  16026. * Interface describing all the common properties and methods a shadow light needs to implement.
  16027. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  16028. * as well as binding the different shadow properties to the effects.
  16029. */
  16030. interface IShadowLight extends Light {
  16031. /**
  16032. * The light id in the scene (used in scene.findLighById for instance)
  16033. */
  16034. id: string;
  16035. /**
  16036. * The position the shdow will be casted from.
  16037. */
  16038. position: Vector3;
  16039. /**
  16040. * In 2d mode (needCube being false), the direction used to cast the shadow.
  16041. */
  16042. direction: Vector3;
  16043. /**
  16044. * The transformed position. Position of the light in world space taking parenting in account.
  16045. */
  16046. transformedPosition: Vector3;
  16047. /**
  16048. * The transformed direction. Direction of the light in world space taking parenting in account.
  16049. */
  16050. transformedDirection: Vector3;
  16051. /**
  16052. * The friendly name of the light in the scene.
  16053. */
  16054. name: string;
  16055. /**
  16056. * Defines the shadow projection clipping minimum z value.
  16057. */
  16058. shadowMinZ: number;
  16059. /**
  16060. * Defines the shadow projection clipping maximum z value.
  16061. */
  16062. shadowMaxZ: number;
  16063. /**
  16064. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16065. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16066. */
  16067. computeTransformedInformation(): boolean;
  16068. /**
  16069. * Gets the scene the light belongs to.
  16070. * @returns The scene
  16071. */
  16072. getScene(): Scene;
  16073. /**
  16074. * Callback defining a custom Projection Matrix Builder.
  16075. * This can be used to override the default projection matrix computation.
  16076. */
  16077. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16078. /**
  16079. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16080. * @param matrix The materix to updated with the projection information
  16081. * @param viewMatrix The transform matrix of the light
  16082. * @param renderList The list of mesh to render in the map
  16083. * @returns The current light
  16084. */
  16085. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16086. /**
  16087. * Gets the current depth scale used in ESM.
  16088. * @returns The scale
  16089. */
  16090. getDepthScale(): number;
  16091. /**
  16092. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16093. * @returns true if a cube texture needs to be use
  16094. */
  16095. needCube(): boolean;
  16096. /**
  16097. * Detects if the projection matrix requires to be recomputed this frame.
  16098. * @returns true if it requires to be recomputed otherwise, false.
  16099. */
  16100. needProjectionMatrixCompute(): boolean;
  16101. /**
  16102. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16103. */
  16104. forceProjectionMatrixCompute(): void;
  16105. /**
  16106. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16107. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16108. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16109. */
  16110. getShadowDirection(faceIndex?: number): Vector3;
  16111. /**
  16112. * Gets the minZ used for shadow according to both the scene and the light.
  16113. * @param activeCamera The camera we are returning the min for
  16114. * @returns the depth min z
  16115. */
  16116. getDepthMinZ(activeCamera: Camera): number;
  16117. /**
  16118. * Gets the maxZ used for shadow according to both the scene and the light.
  16119. * @param activeCamera The camera we are returning the max for
  16120. * @returns the depth max z
  16121. */
  16122. getDepthMaxZ(activeCamera: Camera): number;
  16123. }
  16124. /**
  16125. * Base implementation IShadowLight
  16126. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  16127. */
  16128. abstract class ShadowLight extends Light implements IShadowLight {
  16129. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16130. protected _position: Vector3;
  16131. protected _setPosition(value: Vector3): void;
  16132. /**
  16133. * Sets the position the shadow will be casted from. Also use as the light position for both
  16134. * point and spot lights.
  16135. */
  16136. /**
  16137. * Sets the position the shadow will be casted from. Also use as the light position for both
  16138. * point and spot lights.
  16139. */
  16140. position: Vector3;
  16141. protected _direction: Vector3;
  16142. protected _setDirection(value: Vector3): void;
  16143. /**
  16144. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  16145. * Also use as the light direction on spot and directional lights.
  16146. */
  16147. /**
  16148. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  16149. * Also use as the light direction on spot and directional lights.
  16150. */
  16151. direction: Vector3;
  16152. private _shadowMinZ;
  16153. /**
  16154. * Gets the shadow projection clipping minimum z value.
  16155. */
  16156. /**
  16157. * Sets the shadow projection clipping minimum z value.
  16158. */
  16159. shadowMinZ: number;
  16160. private _shadowMaxZ;
  16161. /**
  16162. * Sets the shadow projection clipping maximum z value.
  16163. */
  16164. /**
  16165. * Gets the shadow projection clipping maximum z value.
  16166. */
  16167. shadowMaxZ: number;
  16168. /**
  16169. * Callback defining a custom Projection Matrix Builder.
  16170. * This can be used to override the default projection matrix computation.
  16171. */
  16172. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  16173. /**
  16174. * The transformed position. Position of the light in world space taking parenting in account.
  16175. */
  16176. transformedPosition: Vector3;
  16177. /**
  16178. * The transformed direction. Direction of the light in world space taking parenting in account.
  16179. */
  16180. transformedDirection: Vector3;
  16181. private _needProjectionMatrixCompute;
  16182. /**
  16183. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  16184. * @returns true if the information has been computed, false if it does not need to (no parenting)
  16185. */
  16186. computeTransformedInformation(): boolean;
  16187. /**
  16188. * Return the depth scale used for the shadow map.
  16189. * @returns the depth scale.
  16190. */
  16191. getDepthScale(): number;
  16192. /**
  16193. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  16194. * @param faceIndex The index of the face we are computed the direction to generate shadow
  16195. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  16196. */
  16197. getShadowDirection(faceIndex?: number): Vector3;
  16198. /**
  16199. * Returns the ShadowLight absolute position in the World.
  16200. * @returns the position vector in world space
  16201. */
  16202. getAbsolutePosition(): Vector3;
  16203. /**
  16204. * Sets the ShadowLight direction toward the passed target.
  16205. * @param target The point tot target in local space
  16206. * @returns the updated ShadowLight direction
  16207. */
  16208. setDirectionToTarget(target: Vector3): Vector3;
  16209. /**
  16210. * Returns the light rotation in euler definition.
  16211. * @returns the x y z rotation in local space.
  16212. */
  16213. getRotation(): Vector3;
  16214. /**
  16215. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  16216. * @returns true if a cube texture needs to be use
  16217. */
  16218. needCube(): boolean;
  16219. /**
  16220. * Detects if the projection matrix requires to be recomputed this frame.
  16221. * @returns true if it requires to be recomputed otherwise, false.
  16222. */
  16223. needProjectionMatrixCompute(): boolean;
  16224. /**
  16225. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  16226. */
  16227. forceProjectionMatrixCompute(): void;
  16228. /** @hidden */
  16229. _initCache(): void;
  16230. /** @hidden */
  16231. _isSynchronized(): boolean;
  16232. /**
  16233. * Computes the world matrix of the node
  16234. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  16235. * @returns the world matrix
  16236. */
  16237. computeWorldMatrix(force?: boolean): Matrix;
  16238. /**
  16239. * Gets the minZ used for shadow according to both the scene and the light.
  16240. * @param activeCamera The camera we are returning the min for
  16241. * @returns the depth min z
  16242. */
  16243. getDepthMinZ(activeCamera: Camera): number;
  16244. /**
  16245. * Gets the maxZ used for shadow according to both the scene and the light.
  16246. * @param activeCamera The camera we are returning the max for
  16247. * @returns the depth max z
  16248. */
  16249. getDepthMaxZ(activeCamera: Camera): number;
  16250. /**
  16251. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  16252. * @param matrix The materix to updated with the projection information
  16253. * @param viewMatrix The transform matrix of the light
  16254. * @param renderList The list of mesh to render in the map
  16255. * @returns The current light
  16256. */
  16257. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  16258. }
  16259. }
  16260. declare module BABYLON {
  16261. /**
  16262. * A spot light is defined by a position, a direction, an angle, and an exponent.
  16263. * These values define a cone of light starting from the position, emitting toward the direction.
  16264. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  16265. * and the exponent defines the speed of the decay of the light with distance (reach).
  16266. * Documentation: https://doc.babylonjs.com/babylon101/lights
  16267. */
  16268. class SpotLight extends ShadowLight {
  16269. private _angle;
  16270. private _innerAngle;
  16271. private _cosHalfAngle;
  16272. private _lightAngleScale;
  16273. private _lightAngleOffset;
  16274. /**
  16275. * Gets the cone angle of the spot light in Radians.
  16276. */
  16277. /**
  16278. * Sets the cone angle of the spot light in Radians.
  16279. */
  16280. angle: number;
  16281. /**
  16282. * Only used in gltf falloff mode, this defines the angle where
  16283. * the directional falloff will start before cutting at angle which could be seen
  16284. * as outer angle.
  16285. */
  16286. /**
  16287. * Only used in gltf falloff mode, this defines the angle where
  16288. * the directional falloff will start before cutting at angle which could be seen
  16289. * as outer angle.
  16290. */
  16291. innerAngle: number;
  16292. private _shadowAngleScale;
  16293. /**
  16294. * Allows scaling the angle of the light for shadow generation only.
  16295. */
  16296. /**
  16297. * Allows scaling the angle of the light for shadow generation only.
  16298. */
  16299. shadowAngleScale: number;
  16300. /**
  16301. * The light decay speed with the distance from the emission spot.
  16302. */
  16303. exponent: number;
  16304. private _projectionTextureMatrix;
  16305. /**
  16306. * Allows reading the projecton texture
  16307. */
  16308. readonly projectionTextureMatrix: Matrix;
  16309. protected _projectionTextureLightNear: number;
  16310. /**
  16311. * Gets the near clip of the Spotlight for texture projection.
  16312. */
  16313. /**
  16314. * Sets the near clip of the Spotlight for texture projection.
  16315. */
  16316. projectionTextureLightNear: number;
  16317. protected _projectionTextureLightFar: number;
  16318. /**
  16319. * Gets the far clip of the Spotlight for texture projection.
  16320. */
  16321. /**
  16322. * Sets the far clip of the Spotlight for texture projection.
  16323. */
  16324. projectionTextureLightFar: number;
  16325. protected _projectionTextureUpDirection: Vector3;
  16326. /**
  16327. * Gets the Up vector of the Spotlight for texture projection.
  16328. */
  16329. /**
  16330. * Sets the Up vector of the Spotlight for texture projection.
  16331. */
  16332. projectionTextureUpDirection: Vector3;
  16333. private _projectionTexture;
  16334. /**
  16335. * Gets the projection texture of the light.
  16336. */
  16337. /**
  16338. * Sets the projection texture of the light.
  16339. */
  16340. projectionTexture: Nullable<BaseTexture>;
  16341. private _projectionTextureViewLightDirty;
  16342. private _projectionTextureProjectionLightDirty;
  16343. private _projectionTextureDirty;
  16344. private _projectionTextureViewTargetVector;
  16345. private _projectionTextureViewLightMatrix;
  16346. private _projectionTextureProjectionLightMatrix;
  16347. private _projectionTextureScalingMatrix;
  16348. /**
  16349. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  16350. * It can cast shadows.
  16351. * Documentation : http://doc.babylonjs.com/tutorials/lights
  16352. * @param name The light friendly name
  16353. * @param position The position of the spot light in the scene
  16354. * @param direction The direction of the light in the scene
  16355. * @param angle The cone angle of the light in Radians
  16356. * @param exponent The light decay speed with the distance from the emission spot
  16357. * @param scene The scene the lights belongs to
  16358. */
  16359. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  16360. /**
  16361. * Returns the string "SpotLight".
  16362. * @returns the class name
  16363. */
  16364. getClassName(): string;
  16365. /**
  16366. * Returns the integer 2.
  16367. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16368. */
  16369. getTypeID(): number;
  16370. /**
  16371. * Overrides the direction setter to recompute the projection texture view light Matrix.
  16372. */
  16373. protected _setDirection(value: Vector3): void;
  16374. /**
  16375. * Overrides the position setter to recompute the projection texture view light Matrix.
  16376. */
  16377. protected _setPosition(value: Vector3): void;
  16378. /**
  16379. * 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.
  16380. * Returns the SpotLight.
  16381. */
  16382. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  16383. protected _computeProjectionTextureViewLightMatrix(): void;
  16384. protected _computeProjectionTextureProjectionLightMatrix(): void;
  16385. /**
  16386. * Main function for light texture projection matrix computing.
  16387. */
  16388. protected _computeProjectionTextureMatrix(): void;
  16389. protected _buildUniformLayout(): void;
  16390. private _computeAngleValues;
  16391. /**
  16392. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  16393. * @param effect The effect to update
  16394. * @param lightIndex The index of the light in the effect to update
  16395. * @returns The spot light
  16396. */
  16397. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  16398. /**
  16399. * Disposes the light and the associated resources.
  16400. */
  16401. dispose(): void;
  16402. /**
  16403. * Prepares the list of defines specific to the light type.
  16404. * @param defines the list of defines
  16405. * @param lightIndex defines the index of the light for the effect
  16406. */
  16407. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  16408. }
  16409. }
  16410. declare module BABYLON {
  16411. /**
  16412. * Interface used to present a loading screen while loading a scene
  16413. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16414. */
  16415. interface ILoadingScreen {
  16416. /**
  16417. * Function called to display the loading screen
  16418. */
  16419. displayLoadingUI: () => void;
  16420. /**
  16421. * Function called to hide the loading screen
  16422. */
  16423. hideLoadingUI: () => void;
  16424. /**
  16425. * Gets or sets the color to use for the background
  16426. */
  16427. loadingUIBackgroundColor: string;
  16428. /**
  16429. * Gets or sets the text to display while loading
  16430. */
  16431. loadingUIText: string;
  16432. }
  16433. /**
  16434. * Class used for the default loading screen
  16435. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  16436. */
  16437. class DefaultLoadingScreen implements ILoadingScreen {
  16438. private _renderingCanvas;
  16439. private _loadingText;
  16440. private _loadingDivBackgroundColor;
  16441. private _loadingDiv;
  16442. private _loadingTextDiv;
  16443. /**
  16444. * Creates a new default loading screen
  16445. * @param _renderingCanvas defines the canvas used to render the scene
  16446. * @param _loadingText defines the default text to display
  16447. * @param _loadingDivBackgroundColor defines the default background color
  16448. */
  16449. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  16450. /**
  16451. * Function called to display the loading screen
  16452. */
  16453. displayLoadingUI(): void;
  16454. /**
  16455. * Function called to hide the loading screen
  16456. */
  16457. hideLoadingUI(): void;
  16458. /**
  16459. * Gets or sets the text to display while loading
  16460. */
  16461. loadingUIText: string;
  16462. /**
  16463. * Gets or sets the color to use for the background
  16464. */
  16465. loadingUIBackgroundColor: string;
  16466. private _resizeLoadingUI;
  16467. }
  16468. }
  16469. declare module BABYLON {
  16470. /**
  16471. * Class used to represent data loading progression
  16472. */
  16473. class SceneLoaderProgressEvent {
  16474. /** defines if data length to load can be evaluated */
  16475. readonly lengthComputable: boolean;
  16476. /** defines the loaded data length */
  16477. readonly loaded: number;
  16478. /** defines the data length to load */
  16479. readonly total: number;
  16480. /**
  16481. * Create a new progress event
  16482. * @param lengthComputable defines if data length to load can be evaluated
  16483. * @param loaded defines the loaded data length
  16484. * @param total defines the data length to load
  16485. */
  16486. constructor(
  16487. /** defines if data length to load can be evaluated */
  16488. lengthComputable: boolean,
  16489. /** defines the loaded data length */
  16490. loaded: number,
  16491. /** defines the data length to load */
  16492. total: number);
  16493. /**
  16494. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  16495. * @param event defines the source event
  16496. * @returns a new SceneLoaderProgressEvent
  16497. */
  16498. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  16499. }
  16500. /**
  16501. * Interface used by SceneLoader plugins to define supported file extensions
  16502. */
  16503. interface ISceneLoaderPluginExtensions {
  16504. /**
  16505. * Defines the list of supported extensions
  16506. */
  16507. [extension: string]: {
  16508. isBinary: boolean;
  16509. };
  16510. }
  16511. /**
  16512. * Interface used by SceneLoader plugin factory
  16513. */
  16514. interface ISceneLoaderPluginFactory {
  16515. /**
  16516. * Defines the name of the factory
  16517. */
  16518. name: string;
  16519. /**
  16520. * Function called to create a new plugin
  16521. * @return the new plugin
  16522. */
  16523. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  16524. /**
  16525. * Boolean indicating if the plugin can direct load specific data
  16526. */
  16527. canDirectLoad?: (data: string) => boolean;
  16528. }
  16529. /**
  16530. * Interface used to define a SceneLoader plugin
  16531. */
  16532. interface ISceneLoaderPlugin {
  16533. /**
  16534. * The friendly name of this plugin.
  16535. */
  16536. name: string;
  16537. /**
  16538. * The file extensions supported by this plugin.
  16539. */
  16540. extensions: string | ISceneLoaderPluginExtensions;
  16541. /**
  16542. * Import meshes into a scene.
  16543. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16544. * @param scene The scene to import into
  16545. * @param data The data to import
  16546. * @param rootUrl The root url for scene and resources
  16547. * @param meshes The meshes array to import into
  16548. * @param particleSystems The particle systems array to import into
  16549. * @param skeletons The skeletons array to import into
  16550. * @param onError The callback when import fails
  16551. * @returns True if successful or false otherwise
  16552. */
  16553. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  16554. /**
  16555. * Load into a scene.
  16556. * @param scene The scene to load into
  16557. * @param data The data to import
  16558. * @param rootUrl The root url for scene and resources
  16559. * @param onError The callback when import fails
  16560. * @returns true if successful or false otherwise
  16561. */
  16562. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  16563. /**
  16564. * The callback that returns true if the data can be directly loaded.
  16565. */
  16566. canDirectLoad?: (data: string) => boolean;
  16567. /**
  16568. * The callback that allows custom handling of the root url based on the response url.
  16569. */
  16570. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16571. /**
  16572. * Load into an asset container.
  16573. * @param scene The scene to load into
  16574. * @param data The data to import
  16575. * @param rootUrl The root url for scene and resources
  16576. * @param onError The callback when import fails
  16577. * @returns The loaded asset container
  16578. */
  16579. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  16580. }
  16581. /**
  16582. * Interface used to define an async SceneLoader plugin
  16583. */
  16584. interface ISceneLoaderPluginAsync {
  16585. /**
  16586. * The friendly name of this plugin.
  16587. */
  16588. name: string;
  16589. /**
  16590. * The file extensions supported by this plugin.
  16591. */
  16592. extensions: string | ISceneLoaderPluginExtensions;
  16593. /**
  16594. * Import meshes into a scene.
  16595. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16596. * @param scene The scene to import into
  16597. * @param data The data to import
  16598. * @param rootUrl The root url for scene and resources
  16599. * @param onProgress The callback when the load progresses
  16600. * @param fileName Defines the name of the file to load
  16601. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  16602. */
  16603. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  16604. meshes: AbstractMesh[];
  16605. particleSystems: IParticleSystem[];
  16606. skeletons: Skeleton[];
  16607. animationGroups: AnimationGroup[];
  16608. }>;
  16609. /**
  16610. * Load into a scene.
  16611. * @param scene The scene to load into
  16612. * @param data The data to import
  16613. * @param rootUrl The root url for scene and resources
  16614. * @param onProgress The callback when the load progresses
  16615. * @param fileName Defines the name of the file to load
  16616. * @returns Nothing
  16617. */
  16618. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  16619. /**
  16620. * The callback that returns true if the data can be directly loaded.
  16621. */
  16622. canDirectLoad?: (data: string) => boolean;
  16623. /**
  16624. * The callback that allows custom handling of the root url based on the response url.
  16625. */
  16626. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  16627. /**
  16628. * Load into an asset container.
  16629. * @param scene The scene to load into
  16630. * @param data The data to import
  16631. * @param rootUrl The root url for scene and resources
  16632. * @param onProgress The callback when the load progresses
  16633. * @param fileName Defines the name of the file to load
  16634. * @returns The loaded asset container
  16635. */
  16636. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  16637. }
  16638. /**
  16639. * Class used to load scene from various file formats using registered plugins
  16640. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  16641. */
  16642. class SceneLoader {
  16643. private static _ForceFullSceneLoadingForIncremental;
  16644. private static _ShowLoadingScreen;
  16645. private static _CleanBoneMatrixWeights;
  16646. /**
  16647. * No logging while loading
  16648. */
  16649. static readonly NO_LOGGING: number;
  16650. /**
  16651. * Minimal logging while loading
  16652. */
  16653. static readonly MINIMAL_LOGGING: number;
  16654. /**
  16655. * Summary logging while loading
  16656. */
  16657. static readonly SUMMARY_LOGGING: number;
  16658. /**
  16659. * Detailled logging while loading
  16660. */
  16661. static readonly DETAILED_LOGGING: number;
  16662. private static _loggingLevel;
  16663. /**
  16664. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  16665. */
  16666. static ForceFullSceneLoadingForIncremental: boolean;
  16667. /**
  16668. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  16669. */
  16670. static ShowLoadingScreen: boolean;
  16671. /**
  16672. * Defines the current logging level (while loading the scene)
  16673. * @ignorenaming
  16674. */
  16675. static loggingLevel: number;
  16676. /**
  16677. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  16678. */
  16679. static CleanBoneMatrixWeights: boolean;
  16680. /**
  16681. * Event raised when a plugin is used to load a scene
  16682. */
  16683. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16684. private static _registeredPlugins;
  16685. private static _getDefaultPlugin;
  16686. private static _getPluginForExtension;
  16687. private static _getPluginForDirectLoad;
  16688. private static _getPluginForFilename;
  16689. private static _getDirectLoad;
  16690. private static _loadData;
  16691. private static _getFileInfo;
  16692. /**
  16693. * Gets a plugin that can load the given extension
  16694. * @param extension defines the extension to load
  16695. * @returns a plugin or null if none works
  16696. */
  16697. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  16698. /**
  16699. * Gets a boolean indicating that the given extension can be loaded
  16700. * @param extension defines the extension to load
  16701. * @returns true if the extension is supported
  16702. */
  16703. static IsPluginForExtensionAvailable(extension: string): boolean;
  16704. /**
  16705. * Adds a new plugin to the list of registered plugins
  16706. * @param plugin defines the plugin to add
  16707. */
  16708. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  16709. /**
  16710. * Import meshes into a scene
  16711. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16712. * @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)
  16713. * @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)
  16714. * @param scene the instance of BABYLON.Scene to append to
  16715. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  16716. * @param onProgress a callback with a progress event for each file being loaded
  16717. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16718. * @param pluginExtension the extension used to determine the plugin
  16719. * @returns The loaded plugin
  16720. */
  16721. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16722. /**
  16723. * Import meshes into a scene
  16724. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  16725. * @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)
  16726. * @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)
  16727. * @param scene the instance of BABYLON.Scene to append to
  16728. * @param onProgress a callback with a progress event for each file being loaded
  16729. * @param pluginExtension the extension used to determine the plugin
  16730. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  16731. */
  16732. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  16733. meshes: AbstractMesh[];
  16734. particleSystems: IParticleSystem[];
  16735. skeletons: Skeleton[];
  16736. animationGroups: AnimationGroup[];
  16737. }>;
  16738. /**
  16739. * Load a scene
  16740. * @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)
  16741. * @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)
  16742. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16743. * @param onSuccess a callback with the scene when import succeeds
  16744. * @param onProgress a callback with a progress event for each file being loaded
  16745. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16746. * @param pluginExtension the extension used to determine the plugin
  16747. * @returns The loaded plugin
  16748. */
  16749. static Load(rootUrl: string, sceneFilename: string, engine: Engine, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16750. /**
  16751. * Load a scene
  16752. * @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)
  16753. * @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)
  16754. * @param engine is the instance of BABYLON.Engine to use to create the scene
  16755. * @param onProgress a callback with a progress event for each file being loaded
  16756. * @param pluginExtension the extension used to determine the plugin
  16757. * @returns The loaded scene
  16758. */
  16759. static LoadAsync(rootUrl: string, sceneFilename: string, engine: Engine, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16760. /**
  16761. * Append a scene
  16762. * @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)
  16763. * @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)
  16764. * @param scene is the instance of BABYLON.Scene to append to
  16765. * @param onSuccess a callback with the scene when import succeeds
  16766. * @param onProgress a callback with a progress event for each file being loaded
  16767. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16768. * @param pluginExtension the extension used to determine the plugin
  16769. * @returns The loaded plugin
  16770. */
  16771. static Append(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16772. /**
  16773. * Append a scene
  16774. * @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)
  16775. * @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)
  16776. * @param scene is the instance of BABYLON.Scene to append to
  16777. * @param onProgress a callback with a progress event for each file being loaded
  16778. * @param pluginExtension the extension used to determine the plugin
  16779. * @returns The given scene
  16780. */
  16781. static AppendAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  16782. /**
  16783. * Load a scene into an asset container
  16784. * @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)
  16785. * @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)
  16786. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  16787. * @param onSuccess a callback with the scene when import succeeds
  16788. * @param onProgress a callback with a progress event for each file being loaded
  16789. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  16790. * @param pluginExtension the extension used to determine the plugin
  16791. * @returns The loaded plugin
  16792. */
  16793. static LoadAssetContainer(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onSuccess?: Nullable<(assets: AssetContainer) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  16794. /**
  16795. * Load a scene into an asset container
  16796. * @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)
  16797. * @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)
  16798. * @param scene is the instance of BABYLON.Scene to append to
  16799. * @param onProgress a callback with a progress event for each file being loaded
  16800. * @param pluginExtension the extension used to determine the plugin
  16801. * @returns The loaded asset container
  16802. */
  16803. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  16804. }
  16805. }
  16806. declare module BABYLON {
  16807. /**
  16808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  16809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  16810. * 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;
  16811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  16812. */
  16813. class ColorCurves {
  16814. private _dirty;
  16815. private _tempColor;
  16816. private _globalCurve;
  16817. private _highlightsCurve;
  16818. private _midtonesCurve;
  16819. private _shadowsCurve;
  16820. private _positiveCurve;
  16821. private _negativeCurve;
  16822. private _globalHue;
  16823. private _globalDensity;
  16824. private _globalSaturation;
  16825. private _globalExposure;
  16826. /**
  16827. * Gets the global Hue value.
  16828. * 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).
  16829. */
  16830. /**
  16831. * Sets the global Hue value.
  16832. * 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).
  16833. */
  16834. globalHue: number;
  16835. /**
  16836. * Gets the global Density value.
  16837. * 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.
  16838. * Values less than zero provide a filter of opposite hue.
  16839. */
  16840. /**
  16841. * Sets the global Density value.
  16842. * 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.
  16843. * Values less than zero provide a filter of opposite hue.
  16844. */
  16845. globalDensity: number;
  16846. /**
  16847. * Gets the global Saturation value.
  16848. * 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.
  16849. */
  16850. /**
  16851. * Sets the global Saturation value.
  16852. * 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.
  16853. */
  16854. globalSaturation: number;
  16855. /**
  16856. * Gets the global Exposure value.
  16857. * 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.
  16858. */
  16859. /**
  16860. * Sets the global Exposure value.
  16861. * 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.
  16862. */
  16863. globalExposure: number;
  16864. private _highlightsHue;
  16865. private _highlightsDensity;
  16866. private _highlightsSaturation;
  16867. private _highlightsExposure;
  16868. /**
  16869. * Gets the highlights Hue value.
  16870. * 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).
  16871. */
  16872. /**
  16873. * Sets the highlights Hue value.
  16874. * 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).
  16875. */
  16876. highlightsHue: number;
  16877. /**
  16878. * Gets the highlights Density value.
  16879. * 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.
  16880. * Values less than zero provide a filter of opposite hue.
  16881. */
  16882. /**
  16883. * Sets the highlights Density value.
  16884. * 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.
  16885. * Values less than zero provide a filter of opposite hue.
  16886. */
  16887. highlightsDensity: number;
  16888. /**
  16889. * Gets the highlights Saturation value.
  16890. * 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.
  16891. */
  16892. /**
  16893. * Sets the highlights Saturation value.
  16894. * 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.
  16895. */
  16896. highlightsSaturation: number;
  16897. /**
  16898. * Gets the highlights Exposure value.
  16899. * 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.
  16900. */
  16901. /**
  16902. * Sets the highlights Exposure value.
  16903. * 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.
  16904. */
  16905. highlightsExposure: number;
  16906. private _midtonesHue;
  16907. private _midtonesDensity;
  16908. private _midtonesSaturation;
  16909. private _midtonesExposure;
  16910. /**
  16911. * Gets the midtones Hue value.
  16912. * 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).
  16913. */
  16914. /**
  16915. * Sets the midtones Hue value.
  16916. * 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).
  16917. */
  16918. midtonesHue: number;
  16919. /**
  16920. * Gets the midtones Density value.
  16921. * 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.
  16922. * Values less than zero provide a filter of opposite hue.
  16923. */
  16924. /**
  16925. * Sets the midtones Density value.
  16926. * 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.
  16927. * Values less than zero provide a filter of opposite hue.
  16928. */
  16929. midtonesDensity: number;
  16930. /**
  16931. * Gets the midtones Saturation value.
  16932. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  16933. */
  16934. /**
  16935. * Sets the midtones Saturation value.
  16936. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  16937. */
  16938. midtonesSaturation: number;
  16939. /**
  16940. * Gets the midtones Exposure value.
  16941. * 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.
  16942. */
  16943. /**
  16944. * Sets the midtones Exposure value.
  16945. * 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.
  16946. */
  16947. midtonesExposure: number;
  16948. private _shadowsHue;
  16949. private _shadowsDensity;
  16950. private _shadowsSaturation;
  16951. private _shadowsExposure;
  16952. /**
  16953. * Gets the shadows Hue value.
  16954. * 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).
  16955. */
  16956. /**
  16957. * Sets the shadows Hue value.
  16958. * 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).
  16959. */
  16960. shadowsHue: number;
  16961. /**
  16962. * Gets the shadows Density value.
  16963. * 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.
  16964. * Values less than zero provide a filter of opposite hue.
  16965. */
  16966. /**
  16967. * Sets the shadows Density value.
  16968. * 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.
  16969. * Values less than zero provide a filter of opposite hue.
  16970. */
  16971. shadowsDensity: number;
  16972. /**
  16973. * Gets the shadows Saturation value.
  16974. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  16975. */
  16976. /**
  16977. * Sets the shadows Saturation value.
  16978. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  16979. */
  16980. shadowsSaturation: number;
  16981. /**
  16982. * Gets the shadows Exposure value.
  16983. * 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.
  16984. */
  16985. /**
  16986. * Sets the shadows Exposure value.
  16987. * 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.
  16988. */
  16989. shadowsExposure: number;
  16990. /**
  16991. * Returns the class name
  16992. * @returns The class name
  16993. */
  16994. getClassName(): string;
  16995. /**
  16996. * Binds the color curves to the shader.
  16997. * @param colorCurves The color curve to bind
  16998. * @param effect The effect to bind to
  16999. * @param positiveUniform The positive uniform shader parameter
  17000. * @param neutralUniform The neutral uniform shader parameter
  17001. * @param negativeUniform The negative uniform shader parameter
  17002. */
  17003. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  17004. /**
  17005. * Prepare the list of uniforms associated with the ColorCurves effects.
  17006. * @param uniformsList The list of uniforms used in the effect
  17007. */
  17008. static PrepareUniforms(uniformsList: string[]): void;
  17009. /**
  17010. * Returns color grading data based on a hue, density, saturation and exposure value.
  17011. * @param filterHue The hue of the color filter.
  17012. * @param filterDensity The density of the color filter.
  17013. * @param saturation The saturation.
  17014. * @param exposure The exposure.
  17015. * @param result The result data container.
  17016. */
  17017. private getColorGradingDataToRef;
  17018. /**
  17019. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  17020. * @param value The input slider value in range [-100,100].
  17021. * @returns Adjusted value.
  17022. */
  17023. private static applyColorGradingSliderNonlinear;
  17024. /**
  17025. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  17026. * @param hue The hue (H) input.
  17027. * @param saturation The saturation (S) input.
  17028. * @param brightness The brightness (B) input.
  17029. * @result An RGBA color represented as Vector4.
  17030. */
  17031. private static fromHSBToRef;
  17032. /**
  17033. * Returns a value clamped between min and max
  17034. * @param value The value to clamp
  17035. * @param min The minimum of value
  17036. * @param max The maximum of value
  17037. * @returns The clamped value.
  17038. */
  17039. private static clamp;
  17040. /**
  17041. * Clones the current color curve instance.
  17042. * @return The cloned curves
  17043. */
  17044. clone(): ColorCurves;
  17045. /**
  17046. * Serializes the current color curve instance to a json representation.
  17047. * @return a JSON representation
  17048. */
  17049. serialize(): any;
  17050. /**
  17051. * Parses the color curve from a json representation.
  17052. * @param source the JSON source to parse
  17053. * @return The parsed curves
  17054. */
  17055. static Parse(source: any): ColorCurves;
  17056. }
  17057. }
  17058. declare module BABYLON {
  17059. /**
  17060. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  17061. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  17062. */
  17063. class EffectFallbacks {
  17064. private _defines;
  17065. private _currentRank;
  17066. private _maxRank;
  17067. private _mesh;
  17068. /**
  17069. * Removes the fallback from the bound mesh.
  17070. */
  17071. unBindMesh(): void;
  17072. /**
  17073. * Adds a fallback on the specified property.
  17074. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17075. * @param define The name of the define in the shader
  17076. */
  17077. addFallback(rank: number, define: string): void;
  17078. /**
  17079. * Sets the mesh to use CPU skinning when needing to fallback.
  17080. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  17081. * @param mesh The mesh to use the fallbacks.
  17082. */
  17083. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  17084. /**
  17085. * Checks to see if more fallbacks are still availible.
  17086. */
  17087. readonly isMoreFallbacks: boolean;
  17088. /**
  17089. * Removes the defines that shoould be removed when falling back.
  17090. * @param currentDefines defines the current define statements for the shader.
  17091. * @param effect defines the current effect we try to compile
  17092. * @returns The resulting defines with defines of the current rank removed.
  17093. */
  17094. reduce(currentDefines: string, effect: Effect): string;
  17095. }
  17096. /**
  17097. * Options to be used when creating an effect.
  17098. */
  17099. class EffectCreationOptions {
  17100. /**
  17101. * Atrributes that will be used in the shader.
  17102. */
  17103. attributes: string[];
  17104. /**
  17105. * Uniform varible names that will be set in the shader.
  17106. */
  17107. uniformsNames: string[];
  17108. /**
  17109. * Uniform buffer varible names that will be set in the shader.
  17110. */
  17111. uniformBuffersNames: string[];
  17112. /**
  17113. * Sampler texture variable names that will be set in the shader.
  17114. */
  17115. samplers: string[];
  17116. /**
  17117. * Define statements that will be set in the shader.
  17118. */
  17119. defines: any;
  17120. /**
  17121. * Possible fallbacks for this effect to improve performance when needed.
  17122. */
  17123. fallbacks: Nullable<EffectFallbacks>;
  17124. /**
  17125. * Callback that will be called when the shader is compiled.
  17126. */
  17127. onCompiled: Nullable<(effect: Effect) => void>;
  17128. /**
  17129. * Callback that will be called if an error occurs during shader compilation.
  17130. */
  17131. onError: Nullable<(effect: Effect, errors: string) => void>;
  17132. /**
  17133. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17134. */
  17135. indexParameters: any;
  17136. /**
  17137. * Max number of lights that can be used in the shader.
  17138. */
  17139. maxSimultaneousLights: number;
  17140. /**
  17141. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  17142. */
  17143. transformFeedbackVaryings: Nullable<string[]>;
  17144. }
  17145. /**
  17146. * Effect containing vertex and fragment shader that can be executed on an object.
  17147. */
  17148. class Effect {
  17149. /**
  17150. * Name of the effect.
  17151. */
  17152. name: any;
  17153. /**
  17154. * String container all the define statements that should be set on the shader.
  17155. */
  17156. defines: string;
  17157. /**
  17158. * Callback that will be called when the shader is compiled.
  17159. */
  17160. onCompiled: Nullable<(effect: Effect) => void>;
  17161. /**
  17162. * Callback that will be called if an error occurs during shader compilation.
  17163. */
  17164. onError: Nullable<(effect: Effect, errors: string) => void>;
  17165. /**
  17166. * Callback that will be called when effect is bound.
  17167. */
  17168. onBind: Nullable<(effect: Effect) => void>;
  17169. /**
  17170. * Unique ID of the effect.
  17171. */
  17172. uniqueId: number;
  17173. /**
  17174. * Observable that will be called when the shader is compiled.
  17175. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  17176. */
  17177. onCompileObservable: Observable<Effect>;
  17178. /**
  17179. * Observable that will be called if an error occurs during shader compilation.
  17180. */
  17181. onErrorObservable: Observable<Effect>;
  17182. /** @hidden */
  17183. _onBindObservable: Nullable<Observable<Effect>>;
  17184. /**
  17185. * Observable that will be called when effect is bound.
  17186. */
  17187. readonly onBindObservable: Observable<Effect>;
  17188. /** @hidden */
  17189. _bonesComputationForcedToCPU: boolean;
  17190. private static _uniqueIdSeed;
  17191. private _engine;
  17192. private _uniformBuffersNames;
  17193. private _uniformsNames;
  17194. private _samplers;
  17195. private _isReady;
  17196. private _compilationError;
  17197. private _attributesNames;
  17198. private _attributes;
  17199. private _uniforms;
  17200. /**
  17201. * Key for the effect.
  17202. * @hidden
  17203. */
  17204. _key: string;
  17205. private _indexParameters;
  17206. private _fallbacks;
  17207. private _vertexSourceCode;
  17208. private _fragmentSourceCode;
  17209. private _vertexSourceCodeOverride;
  17210. private _fragmentSourceCodeOverride;
  17211. private _transformFeedbackVaryings;
  17212. /**
  17213. * Compiled shader to webGL program.
  17214. * @hidden
  17215. */
  17216. _program: WebGLProgram;
  17217. private _valueCache;
  17218. private static _baseCache;
  17219. /**
  17220. * Instantiates an effect.
  17221. * An effect can be used to create/manage/execute vertex and fragment shaders.
  17222. * @param baseName Name of the effect.
  17223. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  17224. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  17225. * @param samplers List of sampler variables that will be passed to the shader.
  17226. * @param engine Engine to be used to render the effect
  17227. * @param defines Define statements to be added to the shader.
  17228. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  17229. * @param onCompiled Callback that will be called when the shader is compiled.
  17230. * @param onError Callback that will be called if an error occurs during shader compilation.
  17231. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  17232. */
  17233. 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);
  17234. /**
  17235. * Unique key for this effect
  17236. */
  17237. readonly key: string;
  17238. /**
  17239. * If the effect has been compiled and prepared.
  17240. * @returns if the effect is compiled and prepared.
  17241. */
  17242. isReady(): boolean;
  17243. /**
  17244. * The engine the effect was initialized with.
  17245. * @returns the engine.
  17246. */
  17247. getEngine(): Engine;
  17248. /**
  17249. * The compiled webGL program for the effect
  17250. * @returns the webGL program.
  17251. */
  17252. getProgram(): WebGLProgram;
  17253. /**
  17254. * The set of names of attribute variables for the shader.
  17255. * @returns An array of attribute names.
  17256. */
  17257. getAttributesNames(): string[];
  17258. /**
  17259. * Returns the attribute at the given index.
  17260. * @param index The index of the attribute.
  17261. * @returns The location of the attribute.
  17262. */
  17263. getAttributeLocation(index: number): number;
  17264. /**
  17265. * Returns the attribute based on the name of the variable.
  17266. * @param name of the attribute to look up.
  17267. * @returns the attribute location.
  17268. */
  17269. getAttributeLocationByName(name: string): number;
  17270. /**
  17271. * The number of attributes.
  17272. * @returns the numnber of attributes.
  17273. */
  17274. getAttributesCount(): number;
  17275. /**
  17276. * Gets the index of a uniform variable.
  17277. * @param uniformName of the uniform to look up.
  17278. * @returns the index.
  17279. */
  17280. getUniformIndex(uniformName: string): number;
  17281. /**
  17282. * Returns the attribute based on the name of the variable.
  17283. * @param uniformName of the uniform to look up.
  17284. * @returns the location of the uniform.
  17285. */
  17286. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  17287. /**
  17288. * Returns an array of sampler variable names
  17289. * @returns The array of sampler variable neames.
  17290. */
  17291. getSamplers(): string[];
  17292. /**
  17293. * The error from the last compilation.
  17294. * @returns the error string.
  17295. */
  17296. getCompilationError(): string;
  17297. /**
  17298. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  17299. * @param func The callback to be used.
  17300. */
  17301. executeWhenCompiled(func: (effect: Effect) => void): void;
  17302. private _checkIsReady;
  17303. /** @hidden */
  17304. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  17305. /** @hidden */
  17306. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  17307. /** @hidden */
  17308. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  17309. private _processShaderConversion;
  17310. private _processIncludes;
  17311. private _processPrecision;
  17312. /**
  17313. * Recompiles the webGL program
  17314. * @param vertexSourceCode The source code for the vertex shader.
  17315. * @param fragmentSourceCode The source code for the fragment shader.
  17316. * @param onCompiled Callback called when completed.
  17317. * @param onError Callback called on error.
  17318. * @hidden
  17319. */
  17320. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  17321. /**
  17322. * Gets the uniform locations of the the specified variable names
  17323. * @param names THe names of the variables to lookup.
  17324. * @returns Array of locations in the same order as variable names.
  17325. */
  17326. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  17327. /**
  17328. * Prepares the effect
  17329. * @hidden
  17330. */
  17331. _prepareEffect(): void;
  17332. /**
  17333. * Checks if the effect is supported. (Must be called after compilation)
  17334. */
  17335. readonly isSupported: boolean;
  17336. /**
  17337. * Binds a texture to the engine to be used as output of the shader.
  17338. * @param channel Name of the output variable.
  17339. * @param texture Texture to bind.
  17340. * @hidden
  17341. */
  17342. _bindTexture(channel: string, texture: InternalTexture): void;
  17343. /**
  17344. * Sets a texture on the engine to be used in the shader.
  17345. * @param channel Name of the sampler variable.
  17346. * @param texture Texture to set.
  17347. */
  17348. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  17349. /**
  17350. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  17351. * @param channel Name of the sampler variable.
  17352. * @param texture Texture to set.
  17353. */
  17354. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  17355. /**
  17356. * Sets an array of textures on the engine to be used in the shader.
  17357. * @param channel Name of the variable.
  17358. * @param textures Textures to set.
  17359. */
  17360. setTextureArray(channel: string, textures: BaseTexture[]): void;
  17361. /**
  17362. * 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)
  17363. * @param channel Name of the sampler variable.
  17364. * @param postProcess Post process to get the input texture from.
  17365. */
  17366. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  17367. /**
  17368. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  17369. * 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)
  17370. * @param channel Name of the sampler variable.
  17371. * @param postProcess Post process to get the output texture from.
  17372. */
  17373. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  17374. /** @hidden */
  17375. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  17376. /** @hidden */
  17377. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  17378. /** @hidden */
  17379. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  17380. /** @hidden */
  17381. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  17382. /**
  17383. * Binds a buffer to a uniform.
  17384. * @param buffer Buffer to bind.
  17385. * @param name Name of the uniform variable to bind to.
  17386. */
  17387. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  17388. /**
  17389. * Binds block to a uniform.
  17390. * @param blockName Name of the block to bind.
  17391. * @param index Index to bind.
  17392. */
  17393. bindUniformBlock(blockName: string, index: number): void;
  17394. /**
  17395. * Sets an interger value on a uniform variable.
  17396. * @param uniformName Name of the variable.
  17397. * @param value Value to be set.
  17398. * @returns this effect.
  17399. */
  17400. setInt(uniformName: string, value: number): Effect;
  17401. /**
  17402. * Sets an int array on a uniform variable.
  17403. * @param uniformName Name of the variable.
  17404. * @param array array to be set.
  17405. * @returns this effect.
  17406. */
  17407. setIntArray(uniformName: string, array: Int32Array): Effect;
  17408. /**
  17409. * 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)
  17410. * @param uniformName Name of the variable.
  17411. * @param array array to be set.
  17412. * @returns this effect.
  17413. */
  17414. setIntArray2(uniformName: string, array: Int32Array): Effect;
  17415. /**
  17416. * 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)
  17417. * @param uniformName Name of the variable.
  17418. * @param array array to be set.
  17419. * @returns this effect.
  17420. */
  17421. setIntArray3(uniformName: string, array: Int32Array): Effect;
  17422. /**
  17423. * 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)
  17424. * @param uniformName Name of the variable.
  17425. * @param array array to be set.
  17426. * @returns this effect.
  17427. */
  17428. setIntArray4(uniformName: string, array: Int32Array): Effect;
  17429. /**
  17430. * Sets an float array on a uniform variable.
  17431. * @param uniformName Name of the variable.
  17432. * @param array array to be set.
  17433. * @returns this effect.
  17434. */
  17435. setFloatArray(uniformName: string, array: Float32Array): Effect;
  17436. /**
  17437. * 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)
  17438. * @param uniformName Name of the variable.
  17439. * @param array array to be set.
  17440. * @returns this effect.
  17441. */
  17442. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  17443. /**
  17444. * 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)
  17445. * @param uniformName Name of the variable.
  17446. * @param array array to be set.
  17447. * @returns this effect.
  17448. */
  17449. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  17450. /**
  17451. * 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)
  17452. * @param uniformName Name of the variable.
  17453. * @param array array to be set.
  17454. * @returns this effect.
  17455. */
  17456. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  17457. /**
  17458. * Sets an array on a uniform variable.
  17459. * @param uniformName Name of the variable.
  17460. * @param array array to be set.
  17461. * @returns this effect.
  17462. */
  17463. setArray(uniformName: string, array: number[]): Effect;
  17464. /**
  17465. * 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)
  17466. * @param uniformName Name of the variable.
  17467. * @param array array to be set.
  17468. * @returns this effect.
  17469. */
  17470. setArray2(uniformName: string, array: number[]): Effect;
  17471. /**
  17472. * 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)
  17473. * @param uniformName Name of the variable.
  17474. * @param array array to be set.
  17475. * @returns this effect.
  17476. */
  17477. setArray3(uniformName: string, array: number[]): Effect;
  17478. /**
  17479. * 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)
  17480. * @param uniformName Name of the variable.
  17481. * @param array array to be set.
  17482. * @returns this effect.
  17483. */
  17484. setArray4(uniformName: string, array: number[]): Effect;
  17485. /**
  17486. * Sets matrices on a uniform variable.
  17487. * @param uniformName Name of the variable.
  17488. * @param matrices matrices to be set.
  17489. * @returns this effect.
  17490. */
  17491. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  17492. /**
  17493. * Sets matrix on a uniform variable.
  17494. * @param uniformName Name of the variable.
  17495. * @param matrix matrix to be set.
  17496. * @returns this effect.
  17497. */
  17498. setMatrix(uniformName: string, matrix: Matrix): Effect;
  17499. /**
  17500. * 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)
  17501. * @param uniformName Name of the variable.
  17502. * @param matrix matrix to be set.
  17503. * @returns this effect.
  17504. */
  17505. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  17506. /**
  17507. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  17508. * @param uniformName Name of the variable.
  17509. * @param matrix matrix to be set.
  17510. * @returns this effect.
  17511. */
  17512. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  17513. /**
  17514. * Sets a float on a uniform variable.
  17515. * @param uniformName Name of the variable.
  17516. * @param value value to be set.
  17517. * @returns this effect.
  17518. */
  17519. setFloat(uniformName: string, value: number): Effect;
  17520. /**
  17521. * Sets a boolean on a uniform variable.
  17522. * @param uniformName Name of the variable.
  17523. * @param bool value to be set.
  17524. * @returns this effect.
  17525. */
  17526. setBool(uniformName: string, bool: boolean): Effect;
  17527. /**
  17528. * Sets a Vector2 on a uniform variable.
  17529. * @param uniformName Name of the variable.
  17530. * @param vector2 vector2 to be set.
  17531. * @returns this effect.
  17532. */
  17533. setVector2(uniformName: string, vector2: Vector2): Effect;
  17534. /**
  17535. * Sets a float2 on a uniform variable.
  17536. * @param uniformName Name of the variable.
  17537. * @param x First float in float2.
  17538. * @param y Second float in float2.
  17539. * @returns this effect.
  17540. */
  17541. setFloat2(uniformName: string, x: number, y: number): Effect;
  17542. /**
  17543. * Sets a Vector3 on a uniform variable.
  17544. * @param uniformName Name of the variable.
  17545. * @param vector3 Value to be set.
  17546. * @returns this effect.
  17547. */
  17548. setVector3(uniformName: string, vector3: Vector3): Effect;
  17549. /**
  17550. * Sets a float3 on a uniform variable.
  17551. * @param uniformName Name of the variable.
  17552. * @param x First float in float3.
  17553. * @param y Second float in float3.
  17554. * @param z Third float in float3.
  17555. * @returns this effect.
  17556. */
  17557. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  17558. /**
  17559. * Sets a Vector4 on a uniform variable.
  17560. * @param uniformName Name of the variable.
  17561. * @param vector4 Value to be set.
  17562. * @returns this effect.
  17563. */
  17564. setVector4(uniformName: string, vector4: Vector4): Effect;
  17565. /**
  17566. * Sets a float4 on a uniform variable.
  17567. * @param uniformName Name of the variable.
  17568. * @param x First float in float4.
  17569. * @param y Second float in float4.
  17570. * @param z Third float in float4.
  17571. * @param w Fourth float in float4.
  17572. * @returns this effect.
  17573. */
  17574. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  17575. /**
  17576. * Sets a Color3 on a uniform variable.
  17577. * @param uniformName Name of the variable.
  17578. * @param color3 Value to be set.
  17579. * @returns this effect.
  17580. */
  17581. setColor3(uniformName: string, color3: Color3): Effect;
  17582. /**
  17583. * Sets a Color4 on a uniform variable.
  17584. * @param uniformName Name of the variable.
  17585. * @param color3 Value to be set.
  17586. * @param alpha Alpha value to be set.
  17587. * @returns this effect.
  17588. */
  17589. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  17590. /**
  17591. * Sets a Color4 on a uniform variable
  17592. * @param uniformName defines the name of the variable
  17593. * @param color4 defines the value to be set
  17594. * @returns this effect.
  17595. */
  17596. setDirectColor4(uniformName: string, color4: Color4): Effect;
  17597. /**
  17598. * This function will add a new shader to the shader store
  17599. * @param name the name of the shader
  17600. * @param pixelShader optional pixel shader content
  17601. * @param vertexShader optional vertex shader content
  17602. */
  17603. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  17604. /**
  17605. * Store of each shader (The can be looked up using effect.key)
  17606. */
  17607. static ShadersStore: {
  17608. [key: string]: string;
  17609. };
  17610. /**
  17611. * Store of each included file for a shader (The can be looked up using effect.key)
  17612. */
  17613. static IncludesShadersStore: {
  17614. [key: string]: string;
  17615. };
  17616. /**
  17617. * Resets the cache of effects.
  17618. */
  17619. static ResetCache(): void;
  17620. }
  17621. }
  17622. declare module BABYLON {
  17623. /**
  17624. * This represents all the required information to add a fresnel effect on a material:
  17625. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  17626. */
  17627. class FresnelParameters {
  17628. private _isEnabled;
  17629. /**
  17630. * Define if the fresnel effect is enable or not.
  17631. */
  17632. isEnabled: boolean;
  17633. /**
  17634. * Define the color used on edges (grazing angle)
  17635. */
  17636. leftColor: Color3;
  17637. /**
  17638. * Define the color used on center
  17639. */
  17640. rightColor: Color3;
  17641. /**
  17642. * Define bias applied to computed fresnel term
  17643. */
  17644. bias: number;
  17645. /**
  17646. * Defined the power exponent applied to fresnel term
  17647. */
  17648. power: number;
  17649. /**
  17650. * Clones the current fresnel and its valuues
  17651. * @returns a clone fresnel configuration
  17652. */
  17653. clone(): FresnelParameters;
  17654. /**
  17655. * Serializes the current fresnel parameters to a JSON representation.
  17656. * @return the JSON serialization
  17657. */
  17658. serialize(): any;
  17659. /**
  17660. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  17661. * @param parsedFresnelParameters Define the JSON representation
  17662. * @returns the parsed parameters
  17663. */
  17664. static Parse(parsedFresnelParameters: any): FresnelParameters;
  17665. }
  17666. }
  17667. declare module BABYLON {
  17668. /**
  17669. * Interface to follow in your material defines to integrate easily the
  17670. * Image proccessing functions.
  17671. * @hidden
  17672. */
  17673. interface IImageProcessingConfigurationDefines {
  17674. IMAGEPROCESSING: boolean;
  17675. VIGNETTE: boolean;
  17676. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17677. VIGNETTEBLENDMODEOPAQUE: boolean;
  17678. TONEMAPPING: boolean;
  17679. TONEMAPPING_ACES: boolean;
  17680. CONTRAST: boolean;
  17681. EXPOSURE: boolean;
  17682. COLORCURVES: boolean;
  17683. COLORGRADING: boolean;
  17684. COLORGRADING3D: boolean;
  17685. SAMPLER3DGREENDEPTH: boolean;
  17686. SAMPLER3DBGRMAP: boolean;
  17687. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17688. }
  17689. /**
  17690. * @hidden
  17691. */
  17692. class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17693. IMAGEPROCESSING: boolean;
  17694. VIGNETTE: boolean;
  17695. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17696. VIGNETTEBLENDMODEOPAQUE: boolean;
  17697. TONEMAPPING: boolean;
  17698. TONEMAPPING_ACES: boolean;
  17699. CONTRAST: boolean;
  17700. COLORCURVES: boolean;
  17701. COLORGRADING: boolean;
  17702. COLORGRADING3D: boolean;
  17703. SAMPLER3DGREENDEPTH: boolean;
  17704. SAMPLER3DBGRMAP: boolean;
  17705. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17706. EXPOSURE: boolean;
  17707. constructor();
  17708. }
  17709. /**
  17710. * This groups together the common properties used for image processing either in direct forward pass
  17711. * or through post processing effect depending on the use of the image processing pipeline in your scene
  17712. * or not.
  17713. */
  17714. class ImageProcessingConfiguration {
  17715. /**
  17716. * Default tone mapping applied in BabylonJS.
  17717. */
  17718. static readonly TONEMAPPING_STANDARD: number;
  17719. /**
  17720. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  17721. * to other engines rendering to increase portability.
  17722. */
  17723. static readonly TONEMAPPING_ACES: number;
  17724. /**
  17725. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  17726. */
  17727. colorCurves: Nullable<ColorCurves>;
  17728. private _colorCurvesEnabled;
  17729. /**
  17730. * Gets wether the color curves effect is enabled.
  17731. */
  17732. /**
  17733. * Sets wether the color curves effect is enabled.
  17734. */
  17735. colorCurvesEnabled: boolean;
  17736. private _colorGradingTexture;
  17737. /**
  17738. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17739. */
  17740. /**
  17741. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  17742. */
  17743. colorGradingTexture: Nullable<BaseTexture>;
  17744. private _colorGradingEnabled;
  17745. /**
  17746. * Gets wether the color grading effect is enabled.
  17747. */
  17748. /**
  17749. * Sets wether the color grading effect is enabled.
  17750. */
  17751. colorGradingEnabled: boolean;
  17752. private _colorGradingWithGreenDepth;
  17753. /**
  17754. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  17755. */
  17756. /**
  17757. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  17758. */
  17759. colorGradingWithGreenDepth: boolean;
  17760. private _colorGradingBGR;
  17761. /**
  17762. * Gets wether the color grading texture contains BGR values.
  17763. */
  17764. /**
  17765. * Sets wether the color grading texture contains BGR values.
  17766. */
  17767. colorGradingBGR: boolean;
  17768. /** @hidden */
  17769. _exposure: number;
  17770. /**
  17771. * Gets the Exposure used in the effect.
  17772. */
  17773. /**
  17774. * Sets the Exposure used in the effect.
  17775. */
  17776. exposure: number;
  17777. private _toneMappingEnabled;
  17778. /**
  17779. * Gets wether the tone mapping effect is enabled.
  17780. */
  17781. /**
  17782. * Sets wether the tone mapping effect is enabled.
  17783. */
  17784. toneMappingEnabled: boolean;
  17785. private _toneMappingType;
  17786. /**
  17787. * Gets the type of tone mapping effect.
  17788. */
  17789. /**
  17790. * Sets the type of tone mapping effect used in BabylonJS.
  17791. */
  17792. toneMappingType: number;
  17793. protected _contrast: number;
  17794. /**
  17795. * Gets the contrast used in the effect.
  17796. */
  17797. /**
  17798. * Sets the contrast used in the effect.
  17799. */
  17800. contrast: number;
  17801. /**
  17802. * Vignette stretch size.
  17803. */
  17804. vignetteStretch: number;
  17805. /**
  17806. * Vignette centre X Offset.
  17807. */
  17808. vignetteCentreX: number;
  17809. /**
  17810. * Vignette centre Y Offset.
  17811. */
  17812. vignetteCentreY: number;
  17813. /**
  17814. * Vignette weight or intensity of the vignette effect.
  17815. */
  17816. vignetteWeight: number;
  17817. /**
  17818. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17819. * if vignetteEnabled is set to true.
  17820. */
  17821. vignetteColor: Color4;
  17822. /**
  17823. * Camera field of view used by the Vignette effect.
  17824. */
  17825. vignetteCameraFov: number;
  17826. private _vignetteBlendMode;
  17827. /**
  17828. * Gets the vignette blend mode allowing different kind of effect.
  17829. */
  17830. /**
  17831. * Sets the vignette blend mode allowing different kind of effect.
  17832. */
  17833. vignetteBlendMode: number;
  17834. private _vignetteEnabled;
  17835. /**
  17836. * Gets wether the vignette effect is enabled.
  17837. */
  17838. /**
  17839. * Sets wether the vignette effect is enabled.
  17840. */
  17841. vignetteEnabled: boolean;
  17842. private _applyByPostProcess;
  17843. /**
  17844. * Gets wether the image processing is applied through a post process or not.
  17845. */
  17846. /**
  17847. * Sets wether the image processing is applied through a post process or not.
  17848. */
  17849. applyByPostProcess: boolean;
  17850. private _isEnabled;
  17851. /**
  17852. * Gets wether the image processing is enabled or not.
  17853. */
  17854. /**
  17855. * Sets wether the image processing is enabled or not.
  17856. */
  17857. isEnabled: boolean;
  17858. /**
  17859. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  17860. */
  17861. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  17862. /**
  17863. * Method called each time the image processing information changes requires to recompile the effect.
  17864. */
  17865. protected _updateParameters(): void;
  17866. /**
  17867. * Gets the current class name.
  17868. * @return "ImageProcessingConfiguration"
  17869. */
  17870. getClassName(): string;
  17871. /**
  17872. * Prepare the list of uniforms associated with the Image Processing effects.
  17873. * @param uniforms The list of uniforms used in the effect
  17874. * @param defines the list of defines currently in use
  17875. */
  17876. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  17877. /**
  17878. * Prepare the list of samplers associated with the Image Processing effects.
  17879. * @param samplersList The list of uniforms used in the effect
  17880. * @param defines the list of defines currently in use
  17881. */
  17882. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  17883. /**
  17884. * Prepare the list of defines associated to the shader.
  17885. * @param defines the list of defines to complete
  17886. * @param forPostProcess Define if we are currently in post process mode or not
  17887. */
  17888. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  17889. /**
  17890. * Returns true if all the image processing information are ready.
  17891. * @returns True if ready, otherwise, false
  17892. */
  17893. isReady(): boolean;
  17894. /**
  17895. * Binds the image processing to the shader.
  17896. * @param effect The effect to bind to
  17897. * @param aspectRatio Define the current aspect ratio of the effect
  17898. */
  17899. bind(effect: Effect, aspectRatio?: number): void;
  17900. /**
  17901. * Clones the current image processing instance.
  17902. * @return The cloned image processing
  17903. */
  17904. clone(): ImageProcessingConfiguration;
  17905. /**
  17906. * Serializes the current image processing instance to a json representation.
  17907. * @return a JSON representation
  17908. */
  17909. serialize(): any;
  17910. /**
  17911. * Parses the image processing from a json representation.
  17912. * @param source the JSON source to parse
  17913. * @return The parsed image processing
  17914. */
  17915. static Parse(source: any): ImageProcessingConfiguration;
  17916. private static _VIGNETTEMODE_MULTIPLY;
  17917. private static _VIGNETTEMODE_OPAQUE;
  17918. /**
  17919. * Used to apply the vignette as a mix with the pixel color.
  17920. */
  17921. static readonly VIGNETTEMODE_MULTIPLY: number;
  17922. /**
  17923. * Used to apply the vignette as a replacement of the pixel color.
  17924. */
  17925. static readonly VIGNETTEMODE_OPAQUE: number;
  17926. }
  17927. }
  17928. declare module BABYLON {
  17929. /**
  17930. * Manages the defines for the Material
  17931. */
  17932. class MaterialDefines {
  17933. private _keys;
  17934. private _isDirty;
  17935. /** @hidden */
  17936. _renderId: number;
  17937. /** @hidden */
  17938. _areLightsDirty: boolean;
  17939. /** @hidden */
  17940. _areAttributesDirty: boolean;
  17941. /** @hidden */
  17942. _areTexturesDirty: boolean;
  17943. /** @hidden */
  17944. _areFresnelDirty: boolean;
  17945. /** @hidden */
  17946. _areMiscDirty: boolean;
  17947. /** @hidden */
  17948. _areImageProcessingDirty: boolean;
  17949. /** @hidden */
  17950. _normals: boolean;
  17951. /** @hidden */
  17952. _uvs: boolean;
  17953. /** @hidden */
  17954. _needNormals: boolean;
  17955. /** @hidden */
  17956. _needUVs: boolean;
  17957. /**
  17958. * Specifies if the material needs to be re-calculated
  17959. */
  17960. readonly isDirty: boolean;
  17961. /**
  17962. * Marks the material to indicate that it has been re-calculated
  17963. */
  17964. markAsProcessed(): void;
  17965. /**
  17966. * Marks the material to indicate that it needs to be re-calculated
  17967. */
  17968. markAsUnprocessed(): void;
  17969. /**
  17970. * Marks the material to indicate all of its defines need to be re-calculated
  17971. */
  17972. markAllAsDirty(): void;
  17973. /**
  17974. * Marks the material to indicate that image processing needs to be re-calculated
  17975. */
  17976. markAsImageProcessingDirty(): void;
  17977. /**
  17978. * Marks the material to indicate the lights need to be re-calculated
  17979. */
  17980. markAsLightDirty(): void;
  17981. /**
  17982. * Marks the attribute state as changed
  17983. */
  17984. markAsAttributesDirty(): void;
  17985. /**
  17986. * Marks the texture state as changed
  17987. */
  17988. markAsTexturesDirty(): void;
  17989. /**
  17990. * Marks the fresnel state as changed
  17991. */
  17992. markAsFresnelDirty(): void;
  17993. /**
  17994. * Marks the misc state as changed
  17995. */
  17996. markAsMiscDirty(): void;
  17997. /**
  17998. * Rebuilds the material defines
  17999. */
  18000. rebuild(): void;
  18001. /**
  18002. * Specifies if two material defines are equal
  18003. * @param other - A material define instance to compare to
  18004. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  18005. */
  18006. isEqual(other: MaterialDefines): boolean;
  18007. /**
  18008. * Clones this instance's defines to another instance
  18009. * @param other - material defines to clone values to
  18010. */
  18011. cloneTo(other: MaterialDefines): void;
  18012. /**
  18013. * Resets the material define values
  18014. */
  18015. reset(): void;
  18016. /**
  18017. * Converts the material define values to a string
  18018. * @returns - String of material define information
  18019. */
  18020. toString(): string;
  18021. }
  18022. /**
  18023. * Base class for the main features of a material in Babylon.js
  18024. */
  18025. class Material implements IAnimatable {
  18026. private static _TriangleFillMode;
  18027. private static _WireFrameFillMode;
  18028. private static _PointFillMode;
  18029. private static _PointListDrawMode;
  18030. private static _LineListDrawMode;
  18031. private static _LineLoopDrawMode;
  18032. private static _LineStripDrawMode;
  18033. private static _TriangleStripDrawMode;
  18034. private static _TriangleFanDrawMode;
  18035. /**
  18036. * Returns the triangle fill mode
  18037. */
  18038. static readonly TriangleFillMode: number;
  18039. /**
  18040. * Returns the wireframe mode
  18041. */
  18042. static readonly WireFrameFillMode: number;
  18043. /**
  18044. * Returns the point fill mode
  18045. */
  18046. static readonly PointFillMode: number;
  18047. /**
  18048. * Returns the point list draw mode
  18049. */
  18050. static readonly PointListDrawMode: number;
  18051. /**
  18052. * Returns the line list draw mode
  18053. */
  18054. static readonly LineListDrawMode: number;
  18055. /**
  18056. * Returns the line loop draw mode
  18057. */
  18058. static readonly LineLoopDrawMode: number;
  18059. /**
  18060. * Returns the line strip draw mode
  18061. */
  18062. static readonly LineStripDrawMode: number;
  18063. /**
  18064. * Returns the triangle strip draw mode
  18065. */
  18066. static readonly TriangleStripDrawMode: number;
  18067. /**
  18068. * Returns the triangle fan draw mode
  18069. */
  18070. static readonly TriangleFanDrawMode: number;
  18071. /**
  18072. * Stores the clock-wise side orientation
  18073. */
  18074. private static _ClockWiseSideOrientation;
  18075. /**
  18076. * Stores the counter clock-wise side orientation
  18077. */
  18078. private static _CounterClockWiseSideOrientation;
  18079. /**
  18080. * Returns the clock-wise side orientation
  18081. */
  18082. static readonly ClockWiseSideOrientation: number;
  18083. /**
  18084. * Returns the counter clock-wise side orientation
  18085. */
  18086. static readonly CounterClockWiseSideOrientation: number;
  18087. /**
  18088. * The dirty texture flag value
  18089. */
  18090. static readonly TextureDirtyFlag: number;
  18091. /**
  18092. * The dirty light flag value
  18093. */
  18094. static readonly LightDirtyFlag: number;
  18095. /**
  18096. * The dirty fresnel flag value
  18097. */
  18098. static readonly FresnelDirtyFlag: number;
  18099. /**
  18100. * The dirty attribute flag value
  18101. */
  18102. static readonly AttributesDirtyFlag: number;
  18103. /**
  18104. * The dirty misc flag value
  18105. */
  18106. static readonly MiscDirtyFlag: number;
  18107. /**
  18108. * The all dirty flag value
  18109. */
  18110. static readonly AllDirtyFlag: number;
  18111. /**
  18112. * The ID of the material
  18113. */
  18114. id: string;
  18115. /**
  18116. * Gets or sets the unique id of the material
  18117. */
  18118. uniqueId: number;
  18119. /**
  18120. * The name of the material
  18121. */
  18122. name: string;
  18123. /**
  18124. * Gets or sets user defined metadata
  18125. */
  18126. metadata: any;
  18127. /**
  18128. * Specifies if the ready state should be checked on each call
  18129. */
  18130. checkReadyOnEveryCall: boolean;
  18131. /**
  18132. * Specifies if the ready state should be checked once
  18133. */
  18134. checkReadyOnlyOnce: boolean;
  18135. /**
  18136. * The state of the material
  18137. */
  18138. state: string;
  18139. /**
  18140. * The alpha value of the material
  18141. */
  18142. protected _alpha: number;
  18143. /**
  18144. * Sets the alpha value of the material
  18145. */
  18146. /**
  18147. * Gets the alpha value of the material
  18148. */
  18149. alpha: number;
  18150. /**
  18151. * Specifies if back face culling is enabled
  18152. */
  18153. protected _backFaceCulling: boolean;
  18154. /**
  18155. * Sets the back-face culling state
  18156. */
  18157. /**
  18158. * Gets the back-face culling state
  18159. */
  18160. backFaceCulling: boolean;
  18161. /**
  18162. * Stores the value for side orientation
  18163. */
  18164. sideOrientation: number;
  18165. /**
  18166. * Callback triggered when the material is compiled
  18167. */
  18168. onCompiled: (effect: Effect) => void;
  18169. /**
  18170. * Callback triggered when an error occurs
  18171. */
  18172. onError: (effect: Effect, errors: string) => void;
  18173. /**
  18174. * Callback triggered to get the render target textures
  18175. */
  18176. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  18177. /**
  18178. * Gets a boolean indicating that current material needs to register RTT
  18179. */
  18180. readonly hasRenderTargetTextures: boolean;
  18181. /**
  18182. * Specifies if the material should be serialized
  18183. */
  18184. doNotSerialize: boolean;
  18185. /**
  18186. * @hidden
  18187. */
  18188. _storeEffectOnSubMeshes: boolean;
  18189. /**
  18190. * Stores the animations for the material
  18191. */
  18192. animations: Array<Animation>;
  18193. /**
  18194. * An event triggered when the material is disposed
  18195. */
  18196. onDisposeObservable: Observable<Material>;
  18197. /**
  18198. * An observer which watches for dispose events
  18199. */
  18200. private _onDisposeObserver;
  18201. private _onUnBindObservable;
  18202. /**
  18203. * Called during a dispose event
  18204. */
  18205. onDispose: () => void;
  18206. private _onBindObservable;
  18207. /**
  18208. * An event triggered when the material is bound
  18209. */
  18210. readonly onBindObservable: Observable<AbstractMesh>;
  18211. /**
  18212. * An observer which watches for bind events
  18213. */
  18214. private _onBindObserver;
  18215. /**
  18216. * Called during a bind event
  18217. */
  18218. onBind: (Mesh: AbstractMesh) => void;
  18219. /**
  18220. * An event triggered when the material is unbound
  18221. */
  18222. readonly onUnBindObservable: Observable<Material>;
  18223. /**
  18224. * Stores the value of the alpha mode
  18225. */
  18226. private _alphaMode;
  18227. /**
  18228. * Sets the value of the alpha mode.
  18229. *
  18230. * | Value | Type | Description |
  18231. * | --- | --- | --- |
  18232. * | 0 | ALPHA_DISABLE | |
  18233. * | 1 | ALPHA_ADD | |
  18234. * | 2 | ALPHA_COMBINE | |
  18235. * | 3 | ALPHA_SUBTRACT | |
  18236. * | 4 | ALPHA_MULTIPLY | |
  18237. * | 5 | ALPHA_MAXIMIZED | |
  18238. * | 6 | ALPHA_ONEONE | |
  18239. * | 7 | ALPHA_PREMULTIPLIED | |
  18240. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  18241. * | 9 | ALPHA_INTERPOLATE | |
  18242. * | 10 | ALPHA_SCREENMODE | |
  18243. *
  18244. */
  18245. /**
  18246. * Gets the value of the alpha mode
  18247. */
  18248. alphaMode: number;
  18249. /**
  18250. * Stores the state of the need depth pre-pass value
  18251. */
  18252. private _needDepthPrePass;
  18253. /**
  18254. * Sets the need depth pre-pass value
  18255. */
  18256. /**
  18257. * Gets the depth pre-pass value
  18258. */
  18259. needDepthPrePass: boolean;
  18260. /**
  18261. * Specifies if depth writing should be disabled
  18262. */
  18263. disableDepthWrite: boolean;
  18264. /**
  18265. * Specifies if depth writing should be forced
  18266. */
  18267. forceDepthWrite: boolean;
  18268. /**
  18269. * Specifies if there should be a separate pass for culling
  18270. */
  18271. separateCullingPass: boolean;
  18272. /**
  18273. * Stores the state specifing if fog should be enabled
  18274. */
  18275. private _fogEnabled;
  18276. /**
  18277. * Sets the state for enabling fog
  18278. */
  18279. /**
  18280. * Gets the value of the fog enabled state
  18281. */
  18282. fogEnabled: boolean;
  18283. /**
  18284. * Stores the size of points
  18285. */
  18286. pointSize: number;
  18287. /**
  18288. * Stores the z offset value
  18289. */
  18290. zOffset: number;
  18291. /**
  18292. * Gets a value specifying if wireframe mode is enabled
  18293. */
  18294. /**
  18295. * Sets the state of wireframe mode
  18296. */
  18297. wireframe: boolean;
  18298. /**
  18299. * Gets the value specifying if point clouds are enabled
  18300. */
  18301. /**
  18302. * Sets the state of point cloud mode
  18303. */
  18304. pointsCloud: boolean;
  18305. /**
  18306. * Gets the material fill mode
  18307. */
  18308. /**
  18309. * Sets the material fill mode
  18310. */
  18311. fillMode: number;
  18312. /**
  18313. * @hidden
  18314. * Stores the effects for the material
  18315. */
  18316. _effect: Nullable<Effect>;
  18317. /**
  18318. * @hidden
  18319. * Specifies if the material was previously ready
  18320. */
  18321. _wasPreviouslyReady: boolean;
  18322. /**
  18323. * Specifies if uniform buffers should be used
  18324. */
  18325. private _useUBO;
  18326. /**
  18327. * Stores a reference to the scene
  18328. */
  18329. private _scene;
  18330. /**
  18331. * Stores the fill mode state
  18332. */
  18333. private _fillMode;
  18334. /**
  18335. * Specifies if the depth write state should be cached
  18336. */
  18337. private _cachedDepthWriteState;
  18338. /**
  18339. * Stores the uniform buffer
  18340. */
  18341. protected _uniformBuffer: UniformBuffer;
  18342. /** @hidden */
  18343. _indexInSceneMaterialArray: number;
  18344. /** @hidden */
  18345. meshMap: Nullable<{
  18346. [id: string]: AbstractMesh | undefined;
  18347. }>;
  18348. /**
  18349. * Creates a material instance
  18350. * @param name defines the name of the material
  18351. * @param scene defines the scene to reference
  18352. * @param doNotAdd specifies if the material should be added to the scene
  18353. */
  18354. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  18355. /**
  18356. * Returns a string representation of the current material
  18357. * @param fullDetails defines a boolean indicating which levels of logging is desired
  18358. * @returns a string with material information
  18359. */
  18360. toString(fullDetails?: boolean): string;
  18361. /**
  18362. * Gets the class name of the material
  18363. * @returns a string with the class name of the material
  18364. */
  18365. getClassName(): string;
  18366. /**
  18367. * Specifies if updates for the material been locked
  18368. */
  18369. readonly isFrozen: boolean;
  18370. /**
  18371. * Locks updates for the material
  18372. */
  18373. freeze(): void;
  18374. /**
  18375. * Unlocks updates for the material
  18376. */
  18377. unfreeze(): void;
  18378. /**
  18379. * Specifies if the material is ready to be used
  18380. * @param mesh defines the mesh to check
  18381. * @param useInstances specifies if instances should be used
  18382. * @returns a boolean indicating if the material is ready to be used
  18383. */
  18384. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18385. /**
  18386. * Specifies that the submesh is ready to be used
  18387. * @param mesh defines the mesh to check
  18388. * @param subMesh defines which submesh to check
  18389. * @param useInstances specifies that instances should be used
  18390. * @returns a boolean indicating that the submesh is ready or not
  18391. */
  18392. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18393. /**
  18394. * Returns the material effect
  18395. * @returns the effect associated with the material
  18396. */
  18397. getEffect(): Nullable<Effect>;
  18398. /**
  18399. * Returns the current scene
  18400. * @returns a Scene
  18401. */
  18402. getScene(): Scene;
  18403. /**
  18404. * Specifies if the material will require alpha blending
  18405. * @returns a boolean specifying if alpha blending is needed
  18406. */
  18407. needAlphaBlending(): boolean;
  18408. /**
  18409. * Specifies if the mesh will require alpha blending
  18410. * @param mesh defines the mesh to check
  18411. * @returns a boolean specifying if alpha blending is needed for the mesh
  18412. */
  18413. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  18414. /**
  18415. * Specifies if this material should be rendered in alpha test mode
  18416. * @returns a boolean specifying if an alpha test is needed.
  18417. */
  18418. needAlphaTesting(): boolean;
  18419. /**
  18420. * Gets the texture used for the alpha test
  18421. * @returns the texture to use for alpha testing
  18422. */
  18423. getAlphaTestTexture(): Nullable<BaseTexture>;
  18424. /**
  18425. * Marks the material to indicate that it needs to be re-calculated
  18426. */
  18427. markDirty(): void;
  18428. /** @hidden */
  18429. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  18430. /**
  18431. * Binds the material to the mesh
  18432. * @param world defines the world transformation matrix
  18433. * @param mesh defines the mesh to bind the material to
  18434. */
  18435. bind(world: Matrix, mesh?: Mesh): void;
  18436. /**
  18437. * Binds the submesh to the material
  18438. * @param world defines the world transformation matrix
  18439. * @param mesh defines the mesh containing the submesh
  18440. * @param subMesh defines the submesh to bind the material to
  18441. */
  18442. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18443. /**
  18444. * Binds the world matrix to the material
  18445. * @param world defines the world transformation matrix
  18446. */
  18447. bindOnlyWorldMatrix(world: Matrix): void;
  18448. /**
  18449. * Binds the scene's uniform buffer to the effect.
  18450. * @param effect defines the effect to bind to the scene uniform buffer
  18451. * @param sceneUbo defines the uniform buffer storing scene data
  18452. */
  18453. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  18454. /**
  18455. * Binds the view matrix to the effect
  18456. * @param effect defines the effect to bind the view matrix to
  18457. */
  18458. bindView(effect: Effect): void;
  18459. /**
  18460. * Binds the view projection matrix to the effect
  18461. * @param effect defines the effect to bind the view projection matrix to
  18462. */
  18463. bindViewProjection(effect: Effect): void;
  18464. /**
  18465. * Specifies if material alpha testing should be turned on for the mesh
  18466. * @param mesh defines the mesh to check
  18467. */
  18468. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  18469. /**
  18470. * Processes to execute after binding the material to a mesh
  18471. * @param mesh defines the rendered mesh
  18472. */
  18473. protected _afterBind(mesh?: Mesh): void;
  18474. /**
  18475. * Unbinds the material from the mesh
  18476. */
  18477. unbind(): void;
  18478. /**
  18479. * Gets the active textures from the material
  18480. * @returns an array of textures
  18481. */
  18482. getActiveTextures(): BaseTexture[];
  18483. /**
  18484. * Specifies if the material uses a texture
  18485. * @param texture defines the texture to check against the material
  18486. * @returns a boolean specifying if the material uses the texture
  18487. */
  18488. hasTexture(texture: BaseTexture): boolean;
  18489. /**
  18490. * Makes a duplicate of the material, and gives it a new name
  18491. * @param name defines the new name for the duplicated material
  18492. * @returns the cloned material
  18493. */
  18494. clone(name: string): Nullable<Material>;
  18495. /**
  18496. * Gets the meshes bound to the material
  18497. * @returns an array of meshes bound to the material
  18498. */
  18499. getBindedMeshes(): AbstractMesh[];
  18500. /**
  18501. * Force shader compilation
  18502. * @param mesh defines the mesh associated with this material
  18503. * @param onCompiled defines a function to execute once the material is compiled
  18504. * @param options defines the options to configure the compilation
  18505. */
  18506. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  18507. clipPlane: boolean;
  18508. }>): void;
  18509. /**
  18510. * Force shader compilation
  18511. * @param mesh defines the mesh that will use this material
  18512. * @param options defines additional options for compiling the shaders
  18513. * @returns a promise that resolves when the compilation completes
  18514. */
  18515. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  18516. clipPlane: boolean;
  18517. }>): Promise<void>;
  18518. private static readonly _ImageProcessingDirtyCallBack;
  18519. private static readonly _TextureDirtyCallBack;
  18520. private static readonly _FresnelDirtyCallBack;
  18521. private static readonly _MiscDirtyCallBack;
  18522. private static readonly _LightsDirtyCallBack;
  18523. private static readonly _AttributeDirtyCallBack;
  18524. private static _FresnelAndMiscDirtyCallBack;
  18525. private static _TextureAndMiscDirtyCallBack;
  18526. private static readonly _DirtyCallbackArray;
  18527. private static readonly _RunDirtyCallBacks;
  18528. /**
  18529. * Marks a define in the material to indicate that it needs to be re-computed
  18530. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  18531. */
  18532. markAsDirty(flag: number): void;
  18533. /**
  18534. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  18535. * @param func defines a function which checks material defines against the submeshes
  18536. */
  18537. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  18538. /**
  18539. * Indicates that image processing needs to be re-calculated for all submeshes
  18540. */
  18541. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  18542. /**
  18543. * Indicates that textures need to be re-calculated for all submeshes
  18544. */
  18545. protected _markAllSubMeshesAsTexturesDirty(): void;
  18546. /**
  18547. * Indicates that fresnel needs to be re-calculated for all submeshes
  18548. */
  18549. protected _markAllSubMeshesAsFresnelDirty(): void;
  18550. /**
  18551. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  18552. */
  18553. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  18554. /**
  18555. * Indicates that lights need to be re-calculated for all submeshes
  18556. */
  18557. protected _markAllSubMeshesAsLightsDirty(): void;
  18558. /**
  18559. * Indicates that attributes need to be re-calculated for all submeshes
  18560. */
  18561. protected _markAllSubMeshesAsAttributesDirty(): void;
  18562. /**
  18563. * Indicates that misc needs to be re-calculated for all submeshes
  18564. */
  18565. protected _markAllSubMeshesAsMiscDirty(): void;
  18566. /**
  18567. * Indicates that textures and misc need to be re-calculated for all submeshes
  18568. */
  18569. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  18570. /**
  18571. * Disposes the material
  18572. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18573. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18574. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18575. */
  18576. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18577. /** @hidden */
  18578. private releaseVertexArrayObject;
  18579. /**
  18580. * Serializes this material
  18581. * @returns the serialized material object
  18582. */
  18583. serialize(): any;
  18584. /**
  18585. * Creates a MultiMaterial from parsed MultiMaterial data.
  18586. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  18587. * @param scene defines the hosting scene
  18588. * @returns a new MultiMaterial
  18589. */
  18590. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  18591. /**
  18592. * Creates a material from parsed material data
  18593. * @param parsedMaterial defines parsed material data
  18594. * @param scene defines the hosting scene
  18595. * @param rootUrl defines the root URL to use to load textures
  18596. * @returns a new material
  18597. */
  18598. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  18599. }
  18600. }
  18601. declare module BABYLON {
  18602. /**
  18603. * "Static Class" containing the most commonly used helper while dealing with material for
  18604. * rendering purpose.
  18605. *
  18606. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  18607. *
  18608. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  18609. */
  18610. class MaterialHelper {
  18611. /**
  18612. * Bind the current view position to an effect.
  18613. * @param effect The effect to be bound
  18614. * @param scene The scene the eyes position is used from
  18615. */
  18616. static BindEyePosition(effect: Effect, scene: Scene): void;
  18617. /**
  18618. * Helps preparing the defines values about the UVs in used in the effect.
  18619. * UVs are shared as much as we can accross channels in the shaders.
  18620. * @param texture The texture we are preparing the UVs for
  18621. * @param defines The defines to update
  18622. * @param key The channel key "diffuse", "specular"... used in the shader
  18623. */
  18624. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  18625. /**
  18626. * Binds a texture matrix value to its corrsponding uniform
  18627. * @param texture The texture to bind the matrix for
  18628. * @param uniformBuffer The uniform buffer receivin the data
  18629. * @param key The channel key "diffuse", "specular"... used in the shader
  18630. */
  18631. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  18632. /**
  18633. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  18634. * @param mesh defines the current mesh
  18635. * @param scene defines the current scene
  18636. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  18637. * @param pointsCloud defines if point cloud rendering has to be turned on
  18638. * @param fogEnabled defines if fog has to be turned on
  18639. * @param alphaTest defines if alpha testing has to be turned on
  18640. * @param defines defines the current list of defines
  18641. */
  18642. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  18643. /**
  18644. * Helper used to prepare the list of defines associated with frame values for shader compilation
  18645. * @param scene defines the current scene
  18646. * @param engine defines the current engine
  18647. * @param defines specifies the list of active defines
  18648. * @param useInstances defines if instances have to be turned on
  18649. * @param useClipPlane defines if clip plane have to be turned on
  18650. */
  18651. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  18652. /**
  18653. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  18654. * @param mesh The mesh containing the geometry data we will draw
  18655. * @param defines The defines to update
  18656. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  18657. * @param useBones Precise whether bones should be used or not (override mesh info)
  18658. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  18659. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  18660. * @returns false if defines are considered not dirty and have not been checked
  18661. */
  18662. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  18663. /**
  18664. * Prepares the defines related to the light information passed in parameter
  18665. * @param scene The scene we are intending to draw
  18666. * @param mesh The mesh the effect is compiling for
  18667. * @param defines The defines to update
  18668. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  18669. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  18670. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  18671. * @returns true if normals will be required for the rest of the effect
  18672. */
  18673. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  18674. /**
  18675. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  18676. * that won t be acctive due to defines being turned off.
  18677. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  18678. * @param samplersList The samplers list
  18679. * @param defines The defines helping in the list generation
  18680. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  18681. */
  18682. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  18683. /**
  18684. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  18685. * @param defines The defines to update while falling back
  18686. * @param fallbacks The authorized effect fallbacks
  18687. * @param maxSimultaneousLights The maximum number of lights allowed
  18688. * @param rank the current rank of the Effect
  18689. * @returns The newly affected rank
  18690. */
  18691. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  18692. /**
  18693. * Prepares the list of attributes required for morph targets according to the effect defines.
  18694. * @param attribs The current list of supported attribs
  18695. * @param mesh The mesh to prepare the morph targets attributes for
  18696. * @param defines The current Defines of the effect
  18697. */
  18698. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  18699. /**
  18700. * Prepares the list of attributes required for bones according to the effect defines.
  18701. * @param attribs The current list of supported attribs
  18702. * @param mesh The mesh to prepare the bones attributes for
  18703. * @param defines The current Defines of the effect
  18704. * @param fallbacks The current efffect fallback strategy
  18705. */
  18706. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  18707. /**
  18708. * Prepares the list of attributes required for instances according to the effect defines.
  18709. * @param attribs The current list of supported attribs
  18710. * @param defines The current Defines of the effect
  18711. */
  18712. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  18713. /**
  18714. * Binds the light shadow information to the effect for the given mesh.
  18715. * @param light The light containing the generator
  18716. * @param scene The scene the lights belongs to
  18717. * @param mesh The mesh we are binding the information to render
  18718. * @param lightIndex The light index in the effect used to render the mesh
  18719. * @param effect The effect we are binding the data to
  18720. */
  18721. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  18722. /**
  18723. * Binds the light information to the effect.
  18724. * @param light The light containing the generator
  18725. * @param effect The effect we are binding the data to
  18726. * @param lightIndex The light index in the effect used to render
  18727. */
  18728. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  18729. /**
  18730. * Binds the lights information from the scene to the effect for the given mesh.
  18731. * @param scene The scene the lights belongs to
  18732. * @param mesh The mesh we are binding the information to render
  18733. * @param effect The effect we are binding the data to
  18734. * @param defines The generated defines for the effect
  18735. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  18736. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  18737. */
  18738. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  18739. private static _tempFogColor;
  18740. /**
  18741. * Binds the fog information from the scene to the effect for the given mesh.
  18742. * @param scene The scene the lights belongs to
  18743. * @param mesh The mesh we are binding the information to render
  18744. * @param effect The effect we are binding the data to
  18745. * @param linearSpace Defines if the fog effect is applied in linear space
  18746. */
  18747. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  18748. /**
  18749. * Binds the bones information from the mesh to the effect.
  18750. * @param mesh The mesh we are binding the information to render
  18751. * @param effect The effect we are binding the data to
  18752. */
  18753. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  18754. /**
  18755. * Binds the morph targets information from the mesh to the effect.
  18756. * @param abstractMesh The mesh we are binding the information to render
  18757. * @param effect The effect we are binding the data to
  18758. */
  18759. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  18760. /**
  18761. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  18762. * @param defines The generated defines used in the effect
  18763. * @param effect The effect we are binding the data to
  18764. * @param scene The scene we are willing to render with logarithmic scale for
  18765. */
  18766. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  18767. /**
  18768. * Binds the clip plane information from the scene to the effect.
  18769. * @param scene The scene the clip plane information are extracted from
  18770. * @param effect The effect we are binding the data to
  18771. */
  18772. static BindClipPlane(effect: Effect, scene: Scene): void;
  18773. }
  18774. }
  18775. declare module BABYLON {
  18776. /**
  18777. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18778. * separate meshes. This can be use to improve performances.
  18779. * @see http://doc.babylonjs.com/how_to/multi_materials
  18780. */
  18781. class MultiMaterial extends Material {
  18782. private _subMaterials;
  18783. /**
  18784. * Gets or Sets the list of Materials used within the multi material.
  18785. * They need to be ordered according to the submeshes order in the associated mesh
  18786. */
  18787. subMaterials: Nullable<Material>[];
  18788. /**
  18789. * Function used to align with Node.getChildren()
  18790. * @returns the list of Materials used within the multi material
  18791. */
  18792. getChildren(): Nullable<Material>[];
  18793. /**
  18794. * Instantiates a new Multi Material
  18795. * A multi-material is used to apply different materials to different parts of the same object without the need of
  18796. * separate meshes. This can be use to improve performances.
  18797. * @see http://doc.babylonjs.com/how_to/multi_materials
  18798. * @param name Define the name in the scene
  18799. * @param scene Define the scene the material belongs to
  18800. */
  18801. constructor(name: string, scene: Scene);
  18802. private _hookArray;
  18803. /**
  18804. * Get one of the submaterial by its index in the submaterials array
  18805. * @param index The index to look the sub material at
  18806. * @returns The Material if the index has been defined
  18807. */
  18808. getSubMaterial(index: number): Nullable<Material>;
  18809. /**
  18810. * Get the list of active textures for the whole sub materials list.
  18811. * @returns All the textures that will be used during the rendering
  18812. */
  18813. getActiveTextures(): BaseTexture[];
  18814. /**
  18815. * Gets the current class name of the material e.g. "MultiMaterial"
  18816. * Mainly use in serialization.
  18817. * @returns the class name
  18818. */
  18819. getClassName(): string;
  18820. /**
  18821. * Checks if the material is ready to render the requested sub mesh
  18822. * @param mesh Define the mesh the submesh belongs to
  18823. * @param subMesh Define the sub mesh to look readyness for
  18824. * @param useInstances Define whether or not the material is used with instances
  18825. * @returns true if ready, otherwise false
  18826. */
  18827. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18828. /**
  18829. * Clones the current material and its related sub materials
  18830. * @param name Define the name of the newly cloned material
  18831. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  18832. * @returns the cloned material
  18833. */
  18834. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  18835. /**
  18836. * Serializes the materials into a JSON representation.
  18837. * @returns the JSON representation
  18838. */
  18839. serialize(): any;
  18840. /**
  18841. * Dispose the material and release its associated resources
  18842. * @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)
  18843. * @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)
  18844. */
  18845. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  18846. }
  18847. }
  18848. declare module BABYLON {
  18849. /**
  18850. * Base class of materials working in push mode in babylon JS
  18851. * @hidden
  18852. */
  18853. class PushMaterial extends Material {
  18854. protected _activeEffect: Effect;
  18855. protected _normalMatrix: Matrix;
  18856. /**
  18857. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  18858. * This means that the material can keep using a previous shader while a new one is being compiled.
  18859. * This is mostly used when shader parallel compilation is supported (true by default)
  18860. */
  18861. allowShaderHotSwapping: boolean;
  18862. constructor(name: string, scene: Scene);
  18863. getEffect(): Effect;
  18864. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18865. /**
  18866. * Binds the given world matrix to the active effect
  18867. *
  18868. * @param world the matrix to bind
  18869. */
  18870. bindOnlyWorldMatrix(world: Matrix): void;
  18871. /**
  18872. * Binds the given normal matrix to the active effect
  18873. *
  18874. * @param normalMatrix the matrix to bind
  18875. */
  18876. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  18877. bind(world: Matrix, mesh?: Mesh): void;
  18878. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  18879. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  18880. }
  18881. }
  18882. declare module BABYLON {
  18883. /**
  18884. * Defines the options associated with the creation of a shader material.
  18885. */
  18886. interface IShaderMaterialOptions {
  18887. /**
  18888. * Does the material work in alpha blend mode
  18889. */
  18890. needAlphaBlending: boolean;
  18891. /**
  18892. * Does the material work in alpha test mode
  18893. */
  18894. needAlphaTesting: boolean;
  18895. /**
  18896. * The list of attribute names used in the shader
  18897. */
  18898. attributes: string[];
  18899. /**
  18900. * The list of unifrom names used in the shader
  18901. */
  18902. uniforms: string[];
  18903. /**
  18904. * The list of UBO names used in the shader
  18905. */
  18906. uniformBuffers: string[];
  18907. /**
  18908. * The list of sampler names used in the shader
  18909. */
  18910. samplers: string[];
  18911. /**
  18912. * The list of defines used in the shader
  18913. */
  18914. defines: string[];
  18915. }
  18916. /**
  18917. * 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.
  18918. *
  18919. * This returned material effects how the mesh will look based on the code in the shaders.
  18920. *
  18921. * @see http://doc.babylonjs.com/how_to/shader_material
  18922. */
  18923. class ShaderMaterial extends Material {
  18924. private _shaderPath;
  18925. private _options;
  18926. private _textures;
  18927. private _textureArrays;
  18928. private _floats;
  18929. private _ints;
  18930. private _floatsArrays;
  18931. private _colors3;
  18932. private _colors3Arrays;
  18933. private _colors4;
  18934. private _vectors2;
  18935. private _vectors3;
  18936. private _vectors4;
  18937. private _matrices;
  18938. private _matrices3x3;
  18939. private _matrices2x2;
  18940. private _vectors2Arrays;
  18941. private _vectors3Arrays;
  18942. private _cachedWorldViewMatrix;
  18943. private _renderId;
  18944. /**
  18945. * Instantiate a new shader material.
  18946. * 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.
  18947. * This returned material effects how the mesh will look based on the code in the shaders.
  18948. * @see http://doc.babylonjs.com/how_to/shader_material
  18949. * @param name Define the name of the material in the scene
  18950. * @param scene Define the scene the material belongs to
  18951. * @param shaderPath Defines the route to the shader code in one of three ways:
  18952. * - object - { vertex: "custom", fragment: "custom" }, used with BABYLON.Effect.ShadersStore["customVertexShader"] and BABYLON.Effect.ShadersStore["customFragmentShader"]
  18953. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18954. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18955. * @param options Define the options used to create the shader
  18956. */
  18957. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18958. /**
  18959. * Gets the current class name of the material e.g. "ShaderMaterial"
  18960. * Mainly use in serialization.
  18961. * @returns the class name
  18962. */
  18963. getClassName(): string;
  18964. /**
  18965. * Specifies if the material will require alpha blending
  18966. * @returns a boolean specifying if alpha blending is needed
  18967. */
  18968. needAlphaBlending(): boolean;
  18969. /**
  18970. * Specifies if this material should be rendered in alpha test mode
  18971. * @returns a boolean specifying if an alpha test is needed.
  18972. */
  18973. needAlphaTesting(): boolean;
  18974. private _checkUniform;
  18975. /**
  18976. * Set a texture in the shader.
  18977. * @param name Define the name of the uniform samplers as defined in the shader
  18978. * @param texture Define the texture to bind to this sampler
  18979. * @return the material itself allowing "fluent" like uniform updates
  18980. */
  18981. setTexture(name: string, texture: Texture): ShaderMaterial;
  18982. /**
  18983. * Set a texture array in the shader.
  18984. * @param name Define the name of the uniform sampler array as defined in the shader
  18985. * @param textures Define the list of textures to bind to this sampler
  18986. * @return the material itself allowing "fluent" like uniform updates
  18987. */
  18988. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18989. /**
  18990. * Set a float in the shader.
  18991. * @param name Define the name of the uniform as defined in the shader
  18992. * @param value Define the value to give to the uniform
  18993. * @return the material itself allowing "fluent" like uniform updates
  18994. */
  18995. setFloat(name: string, value: number): ShaderMaterial;
  18996. /**
  18997. * Set a int in the shader.
  18998. * @param name Define the name of the uniform as defined in the shader
  18999. * @param value Define the value to give to the uniform
  19000. * @return the material itself allowing "fluent" like uniform updates
  19001. */
  19002. setInt(name: string, value: number): ShaderMaterial;
  19003. /**
  19004. * Set an array of floats in the shader.
  19005. * @param name Define the name of the uniform as defined in the shader
  19006. * @param value Define the value to give to the uniform
  19007. * @return the material itself allowing "fluent" like uniform updates
  19008. */
  19009. setFloats(name: string, value: number[]): ShaderMaterial;
  19010. /**
  19011. * Set a vec3 in the shader from a Color3.
  19012. * @param name Define the name of the uniform as defined in the shader
  19013. * @param value Define the value to give to the uniform
  19014. * @return the material itself allowing "fluent" like uniform updates
  19015. */
  19016. setColor3(name: string, value: Color3): ShaderMaterial;
  19017. /**
  19018. * Set a vec3 array in the shader from a Color3 array.
  19019. * @param name Define the name of the uniform as defined in the shader
  19020. * @param value Define the value to give to the uniform
  19021. * @return the material itself allowing "fluent" like uniform updates
  19022. */
  19023. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19024. /**
  19025. * Set a vec4 in the shader from a Color4.
  19026. * @param name Define the name of the uniform as defined in the shader
  19027. * @param value Define the value to give to the uniform
  19028. * @return the material itself allowing "fluent" like uniform updates
  19029. */
  19030. setColor4(name: string, value: Color4): ShaderMaterial;
  19031. /**
  19032. * Set a vec2 in the shader from a Vector2.
  19033. * @param name Define the name of the uniform as defined in the shader
  19034. * @param value Define the value to give to the uniform
  19035. * @return the material itself allowing "fluent" like uniform updates
  19036. */
  19037. setVector2(name: string, value: Vector2): ShaderMaterial;
  19038. /**
  19039. * Set a vec3 in the shader from a Vector3.
  19040. * @param name Define the name of the uniform as defined in the shader
  19041. * @param value Define the value to give to the uniform
  19042. * @return the material itself allowing "fluent" like uniform updates
  19043. */
  19044. setVector3(name: string, value: Vector3): ShaderMaterial;
  19045. /**
  19046. * Set a vec4 in the shader from a Vector4.
  19047. * @param name Define the name of the uniform as defined in the shader
  19048. * @param value Define the value to give to the uniform
  19049. * @return the material itself allowing "fluent" like uniform updates
  19050. */
  19051. setVector4(name: string, value: Vector4): ShaderMaterial;
  19052. /**
  19053. * Set a mat4 in the shader from a Matrix.
  19054. * @param name Define the name of the uniform as defined in the shader
  19055. * @param value Define the value to give to the uniform
  19056. * @return the material itself allowing "fluent" like uniform updates
  19057. */
  19058. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19059. /**
  19060. * Set a mat3 in the shader from a Float32Array.
  19061. * @param name Define the name of the uniform as defined in the shader
  19062. * @param value Define the value to give to the uniform
  19063. * @return the material itself allowing "fluent" like uniform updates
  19064. */
  19065. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19066. /**
  19067. * Set a mat2 in the shader from a Float32Array.
  19068. * @param name Define the name of the uniform as defined in the shader
  19069. * @param value Define the value to give to the uniform
  19070. * @return the material itself allowing "fluent" like uniform updates
  19071. */
  19072. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19073. /**
  19074. * Set a vec2 array in the shader from a number array.
  19075. * @param name Define the name of the uniform as defined in the shader
  19076. * @param value Define the value to give to the uniform
  19077. * @return the material itself allowing "fluent" like uniform updates
  19078. */
  19079. setArray2(name: string, value: number[]): ShaderMaterial;
  19080. /**
  19081. * Set a vec3 array in the shader from a number array.
  19082. * @param name Define the name of the uniform as defined in the shader
  19083. * @param value Define the value to give to the uniform
  19084. * @return the material itself allowing "fluent" like uniform updates
  19085. */
  19086. setArray3(name: string, value: number[]): ShaderMaterial;
  19087. private _checkCache;
  19088. /**
  19089. * Checks if the material is ready to render the requested mesh
  19090. * @param mesh Define the mesh to render
  19091. * @param useInstances Define whether or not the material is used with instances
  19092. * @returns true if ready, otherwise false
  19093. */
  19094. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19095. /**
  19096. * Binds the world matrix to the material
  19097. * @param world defines the world transformation matrix
  19098. */
  19099. bindOnlyWorldMatrix(world: Matrix): void;
  19100. /**
  19101. * Binds the material to the mesh
  19102. * @param world defines the world transformation matrix
  19103. * @param mesh defines the mesh to bind the material to
  19104. */
  19105. bind(world: Matrix, mesh?: Mesh): void;
  19106. /**
  19107. * Gets the active textures from the material
  19108. * @returns an array of textures
  19109. */
  19110. getActiveTextures(): BaseTexture[];
  19111. /**
  19112. * Specifies if the material uses a texture
  19113. * @param texture defines the texture to check against the material
  19114. * @returns a boolean specifying if the material uses the texture
  19115. */
  19116. hasTexture(texture: BaseTexture): boolean;
  19117. /**
  19118. * Makes a duplicate of the material, and gives it a new name
  19119. * @param name defines the new name for the duplicated material
  19120. * @returns the cloned material
  19121. */
  19122. clone(name: string): ShaderMaterial;
  19123. /**
  19124. * Disposes the material
  19125. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19126. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19127. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19128. */
  19129. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19130. /**
  19131. * Serializes this material in a JSON representation
  19132. * @returns the serialized material object
  19133. */
  19134. serialize(): any;
  19135. /**
  19136. * Creates a shader material from parsed shader material data
  19137. * @param source defines the JSON represnetation of the material
  19138. * @param scene defines the hosting scene
  19139. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19140. * @returns a new material
  19141. */
  19142. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19143. }
  19144. }
  19145. declare module BABYLON {
  19146. /** @hidden */
  19147. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  19148. MAINUV1: boolean;
  19149. MAINUV2: boolean;
  19150. DIFFUSE: boolean;
  19151. DIFFUSEDIRECTUV: number;
  19152. AMBIENT: boolean;
  19153. AMBIENTDIRECTUV: number;
  19154. OPACITY: boolean;
  19155. OPACITYDIRECTUV: number;
  19156. OPACITYRGB: boolean;
  19157. REFLECTION: boolean;
  19158. EMISSIVE: boolean;
  19159. EMISSIVEDIRECTUV: number;
  19160. SPECULAR: boolean;
  19161. SPECULARDIRECTUV: number;
  19162. BUMP: boolean;
  19163. BUMPDIRECTUV: number;
  19164. PARALLAX: boolean;
  19165. PARALLAXOCCLUSION: boolean;
  19166. SPECULAROVERALPHA: boolean;
  19167. CLIPPLANE: boolean;
  19168. CLIPPLANE2: boolean;
  19169. CLIPPLANE3: boolean;
  19170. CLIPPLANE4: boolean;
  19171. ALPHATEST: boolean;
  19172. DEPTHPREPASS: boolean;
  19173. ALPHAFROMDIFFUSE: boolean;
  19174. POINTSIZE: boolean;
  19175. FOG: boolean;
  19176. SPECULARTERM: boolean;
  19177. DIFFUSEFRESNEL: boolean;
  19178. OPACITYFRESNEL: boolean;
  19179. REFLECTIONFRESNEL: boolean;
  19180. REFRACTIONFRESNEL: boolean;
  19181. EMISSIVEFRESNEL: boolean;
  19182. FRESNEL: boolean;
  19183. NORMAL: boolean;
  19184. UV1: boolean;
  19185. UV2: boolean;
  19186. VERTEXCOLOR: boolean;
  19187. VERTEXALPHA: boolean;
  19188. NUM_BONE_INFLUENCERS: number;
  19189. BonesPerMesh: number;
  19190. BONETEXTURE: boolean;
  19191. INSTANCES: boolean;
  19192. GLOSSINESS: boolean;
  19193. ROUGHNESS: boolean;
  19194. EMISSIVEASILLUMINATION: boolean;
  19195. LINKEMISSIVEWITHDIFFUSE: boolean;
  19196. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19197. LIGHTMAP: boolean;
  19198. LIGHTMAPDIRECTUV: number;
  19199. OBJECTSPACE_NORMALMAP: boolean;
  19200. USELIGHTMAPASSHADOWMAP: boolean;
  19201. REFLECTIONMAP_3D: boolean;
  19202. REFLECTIONMAP_SPHERICAL: boolean;
  19203. REFLECTIONMAP_PLANAR: boolean;
  19204. REFLECTIONMAP_CUBIC: boolean;
  19205. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19206. REFLECTIONMAP_PROJECTION: boolean;
  19207. REFLECTIONMAP_SKYBOX: boolean;
  19208. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  19209. REFLECTIONMAP_EXPLICIT: boolean;
  19210. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19211. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19212. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19213. INVERTCUBICMAP: boolean;
  19214. LOGARITHMICDEPTH: boolean;
  19215. REFRACTION: boolean;
  19216. REFRACTIONMAP_3D: boolean;
  19217. REFLECTIONOVERALPHA: boolean;
  19218. TWOSIDEDLIGHTING: boolean;
  19219. SHADOWFLOAT: boolean;
  19220. MORPHTARGETS: boolean;
  19221. MORPHTARGETS_NORMAL: boolean;
  19222. MORPHTARGETS_TANGENT: boolean;
  19223. NUM_MORPH_INFLUENCERS: number;
  19224. NONUNIFORMSCALING: boolean;
  19225. PREMULTIPLYALPHA: boolean;
  19226. IMAGEPROCESSING: boolean;
  19227. VIGNETTE: boolean;
  19228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19229. VIGNETTEBLENDMODEOPAQUE: boolean;
  19230. TONEMAPPING: boolean;
  19231. TONEMAPPING_ACES: boolean;
  19232. CONTRAST: boolean;
  19233. COLORCURVES: boolean;
  19234. COLORGRADING: boolean;
  19235. COLORGRADING3D: boolean;
  19236. SAMPLER3DGREENDEPTH: boolean;
  19237. SAMPLER3DBGRMAP: boolean;
  19238. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19239. /**
  19240. * If the reflection texture on this material is in linear color space
  19241. * @hidden
  19242. */
  19243. IS_REFLECTION_LINEAR: boolean;
  19244. /**
  19245. * If the refraction texture on this material is in linear color space
  19246. * @hidden
  19247. */
  19248. IS_REFRACTION_LINEAR: boolean;
  19249. EXPOSURE: boolean;
  19250. constructor();
  19251. setReflectionMode(modeToEnable: string): void;
  19252. }
  19253. /**
  19254. * This is the default material used in Babylon. It is the best trade off between quality
  19255. * and performances.
  19256. * @see http://doc.babylonjs.com/babylon101/materials
  19257. */
  19258. class StandardMaterial extends PushMaterial {
  19259. private _diffuseTexture;
  19260. /**
  19261. * The basic texture of the material as viewed under a light.
  19262. */
  19263. diffuseTexture: Nullable<BaseTexture>;
  19264. private _ambientTexture;
  19265. /**
  19266. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19267. */
  19268. ambientTexture: Nullable<BaseTexture>;
  19269. private _opacityTexture;
  19270. /**
  19271. * Define the transparency of the material from a texture.
  19272. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19273. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19274. */
  19275. opacityTexture: Nullable<BaseTexture>;
  19276. private _reflectionTexture;
  19277. /**
  19278. * Define the texture used to display the reflection.
  19279. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19280. */
  19281. reflectionTexture: Nullable<BaseTexture>;
  19282. private _emissiveTexture;
  19283. /**
  19284. * Define texture of the material as if self lit.
  19285. * This will be mixed in the final result even in the absence of light.
  19286. */
  19287. emissiveTexture: Nullable<BaseTexture>;
  19288. private _specularTexture;
  19289. /**
  19290. * Define how the color and intensity of the highlight given by the light in the material.
  19291. */
  19292. specularTexture: Nullable<BaseTexture>;
  19293. private _bumpTexture;
  19294. /**
  19295. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19296. * 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.
  19297. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  19298. */
  19299. bumpTexture: Nullable<BaseTexture>;
  19300. private _lightmapTexture;
  19301. /**
  19302. * Complex lighting can be computationally expensive to compute at runtime.
  19303. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19304. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  19305. */
  19306. lightmapTexture: Nullable<BaseTexture>;
  19307. private _refractionTexture;
  19308. /**
  19309. * Define the texture used to display the refraction.
  19310. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19311. */
  19312. refractionTexture: Nullable<BaseTexture>;
  19313. /**
  19314. * The color of the material lit by the environmental background lighting.
  19315. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19316. */
  19317. ambientColor: Color3;
  19318. /**
  19319. * The basic color of the material as viewed under a light.
  19320. */
  19321. diffuseColor: Color3;
  19322. /**
  19323. * Define how the color and intensity of the highlight given by the light in the material.
  19324. */
  19325. specularColor: Color3;
  19326. /**
  19327. * Define the color of the material as if self lit.
  19328. * This will be mixed in the final result even in the absence of light.
  19329. */
  19330. emissiveColor: Color3;
  19331. /**
  19332. * Defines how sharp are the highlights in the material.
  19333. * The bigger the value the sharper giving a more glossy feeling to the result.
  19334. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19335. */
  19336. specularPower: number;
  19337. private _useAlphaFromDiffuseTexture;
  19338. /**
  19339. * Does the transparency come from the diffuse texture alpha channel.
  19340. */
  19341. useAlphaFromDiffuseTexture: boolean;
  19342. private _useEmissiveAsIllumination;
  19343. /**
  19344. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19345. */
  19346. useEmissiveAsIllumination: boolean;
  19347. private _linkEmissiveWithDiffuse;
  19348. /**
  19349. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19350. * the emissive level when the final color is close to one.
  19351. */
  19352. linkEmissiveWithDiffuse: boolean;
  19353. private _useSpecularOverAlpha;
  19354. /**
  19355. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19356. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19357. */
  19358. useSpecularOverAlpha: boolean;
  19359. private _useReflectionOverAlpha;
  19360. /**
  19361. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19362. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19363. */
  19364. useReflectionOverAlpha: boolean;
  19365. private _disableLighting;
  19366. /**
  19367. * Does lights from the scene impacts this material.
  19368. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19369. */
  19370. disableLighting: boolean;
  19371. private _useObjectSpaceNormalMap;
  19372. /**
  19373. * Allows using an object space normal map (instead of tangent space).
  19374. */
  19375. useObjectSpaceNormalMap: boolean;
  19376. private _useParallax;
  19377. /**
  19378. * Is parallax enabled or not.
  19379. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19380. */
  19381. useParallax: boolean;
  19382. private _useParallaxOcclusion;
  19383. /**
  19384. * Is parallax occlusion enabled or not.
  19385. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19386. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  19387. */
  19388. useParallaxOcclusion: boolean;
  19389. /**
  19390. * 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.
  19391. */
  19392. parallaxScaleBias: number;
  19393. private _roughness;
  19394. /**
  19395. * Helps to define how blurry the reflections should appears in the material.
  19396. */
  19397. roughness: number;
  19398. /**
  19399. * In case of refraction, define the value of the indice of refraction.
  19400. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19401. */
  19402. indexOfRefraction: number;
  19403. /**
  19404. * Invert the refraction texture alongside the y axis.
  19405. * It can be usefull with procedural textures or probe for instance.
  19406. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19407. */
  19408. invertRefractionY: boolean;
  19409. /**
  19410. * Defines the alpha limits in alpha test mode.
  19411. */
  19412. alphaCutOff: number;
  19413. private _useLightmapAsShadowmap;
  19414. /**
  19415. * In case of light mapping, define whether the map contains light or shadow informations.
  19416. */
  19417. useLightmapAsShadowmap: boolean;
  19418. private _diffuseFresnelParameters;
  19419. /**
  19420. * Define the diffuse fresnel parameters of the material.
  19421. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19422. */
  19423. diffuseFresnelParameters: FresnelParameters;
  19424. private _opacityFresnelParameters;
  19425. /**
  19426. * Define the opacity fresnel parameters of the material.
  19427. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19428. */
  19429. opacityFresnelParameters: FresnelParameters;
  19430. private _reflectionFresnelParameters;
  19431. /**
  19432. * Define the reflection fresnel parameters of the material.
  19433. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19434. */
  19435. reflectionFresnelParameters: FresnelParameters;
  19436. private _refractionFresnelParameters;
  19437. /**
  19438. * Define the refraction fresnel parameters of the material.
  19439. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19440. */
  19441. refractionFresnelParameters: FresnelParameters;
  19442. private _emissiveFresnelParameters;
  19443. /**
  19444. * Define the emissive fresnel parameters of the material.
  19445. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19446. */
  19447. emissiveFresnelParameters: FresnelParameters;
  19448. private _useReflectionFresnelFromSpecular;
  19449. /**
  19450. * If true automatically deducts the fresnels values from the material specularity.
  19451. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19452. */
  19453. useReflectionFresnelFromSpecular: boolean;
  19454. private _useGlossinessFromSpecularMapAlpha;
  19455. /**
  19456. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19457. */
  19458. useGlossinessFromSpecularMapAlpha: boolean;
  19459. private _maxSimultaneousLights;
  19460. /**
  19461. * Defines the maximum number of lights that can be used in the material
  19462. */
  19463. maxSimultaneousLights: number;
  19464. private _invertNormalMapX;
  19465. /**
  19466. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19467. */
  19468. invertNormalMapX: boolean;
  19469. private _invertNormalMapY;
  19470. /**
  19471. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19472. */
  19473. invertNormalMapY: boolean;
  19474. private _twoSidedLighting;
  19475. /**
  19476. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19477. */
  19478. twoSidedLighting: boolean;
  19479. /**
  19480. * Default configuration related to image processing available in the standard Material.
  19481. */
  19482. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19483. /**
  19484. * Gets the image processing configuration used either in this material.
  19485. */
  19486. /**
  19487. * Sets the Default image processing configuration used either in the this material.
  19488. *
  19489. * If sets to null, the scene one is in use.
  19490. */
  19491. imageProcessingConfiguration: ImageProcessingConfiguration;
  19492. /**
  19493. * Keep track of the image processing observer to allow dispose and replace.
  19494. */
  19495. private _imageProcessingObserver;
  19496. /**
  19497. * Attaches a new image processing configuration to the Standard Material.
  19498. * @param configuration
  19499. */
  19500. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19501. /**
  19502. * Gets wether the color curves effect is enabled.
  19503. */
  19504. /**
  19505. * Sets wether the color curves effect is enabled.
  19506. */
  19507. cameraColorCurvesEnabled: boolean;
  19508. /**
  19509. * Gets wether the color grading effect is enabled.
  19510. */
  19511. /**
  19512. * Gets wether the color grading effect is enabled.
  19513. */
  19514. cameraColorGradingEnabled: boolean;
  19515. /**
  19516. * Gets wether tonemapping is enabled or not.
  19517. */
  19518. /**
  19519. * Sets wether tonemapping is enabled or not
  19520. */
  19521. cameraToneMappingEnabled: boolean;
  19522. /**
  19523. * The camera exposure used on this material.
  19524. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19525. * This corresponds to a photographic exposure.
  19526. */
  19527. /**
  19528. * The camera exposure used on this material.
  19529. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19530. * This corresponds to a photographic exposure.
  19531. */
  19532. cameraExposure: number;
  19533. /**
  19534. * Gets The camera contrast used on this material.
  19535. */
  19536. /**
  19537. * Sets The camera contrast used on this material.
  19538. */
  19539. cameraContrast: number;
  19540. /**
  19541. * Gets the Color Grading 2D Lookup Texture.
  19542. */
  19543. /**
  19544. * Sets the Color Grading 2D Lookup Texture.
  19545. */
  19546. cameraColorGradingTexture: Nullable<BaseTexture>;
  19547. /**
  19548. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19549. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19550. * 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;
  19551. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19552. */
  19553. /**
  19554. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19555. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19556. * 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;
  19557. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19558. */
  19559. cameraColorCurves: Nullable<ColorCurves>;
  19560. /**
  19561. * Custom callback helping to override the default shader used in the material.
  19562. */
  19563. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  19564. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19565. protected _worldViewProjectionMatrix: Matrix;
  19566. protected _globalAmbientColor: Color3;
  19567. protected _useLogarithmicDepth: boolean;
  19568. /**
  19569. * Instantiates a new standard material.
  19570. * This is the default material used in Babylon. It is the best trade off between quality
  19571. * and performances.
  19572. * @see http://doc.babylonjs.com/babylon101/materials
  19573. * @param name Define the name of the material in the scene
  19574. * @param scene Define the scene the material belong to
  19575. */
  19576. constructor(name: string, scene: Scene);
  19577. /**
  19578. * Gets a boolean indicating that current material needs to register RTT
  19579. */
  19580. readonly hasRenderTargetTextures: boolean;
  19581. /**
  19582. * Gets the current class name of the material e.g. "StandardMaterial"
  19583. * Mainly use in serialization.
  19584. * @returns the class name
  19585. */
  19586. getClassName(): string;
  19587. /**
  19588. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19589. * You can try switching to logarithmic depth.
  19590. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19591. */
  19592. useLogarithmicDepth: boolean;
  19593. /**
  19594. * Specifies if the material will require alpha blending
  19595. * @returns a boolean specifying if alpha blending is needed
  19596. */
  19597. needAlphaBlending(): boolean;
  19598. /**
  19599. * Specifies if this material should be rendered in alpha test mode
  19600. * @returns a boolean specifying if an alpha test is needed.
  19601. */
  19602. needAlphaTesting(): boolean;
  19603. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19604. /**
  19605. * Get the texture used for alpha test purpose.
  19606. * @returns the diffuse texture in case of the standard material.
  19607. */
  19608. getAlphaTestTexture(): Nullable<BaseTexture>;
  19609. /**
  19610. * Get if the submesh is ready to be used and all its information available.
  19611. * Child classes can use it to update shaders
  19612. * @param mesh defines the mesh to check
  19613. * @param subMesh defines which submesh to check
  19614. * @param useInstances specifies that instances should be used
  19615. * @returns a boolean indicating that the submesh is ready or not
  19616. */
  19617. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19618. /**
  19619. * Builds the material UBO layouts.
  19620. * Used internally during the effect preparation.
  19621. */
  19622. buildUniformLayout(): void;
  19623. /**
  19624. * Unbinds the material from the mesh
  19625. */
  19626. unbind(): void;
  19627. /**
  19628. * Binds the submesh to this material by preparing the effect and shader to draw
  19629. * @param world defines the world transformation matrix
  19630. * @param mesh defines the mesh containing the submesh
  19631. * @param subMesh defines the submesh to bind the material to
  19632. */
  19633. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19634. /**
  19635. * Get the list of animatables in the material.
  19636. * @returns the list of animatables object used in the material
  19637. */
  19638. getAnimatables(): IAnimatable[];
  19639. /**
  19640. * Gets the active textures from the material
  19641. * @returns an array of textures
  19642. */
  19643. getActiveTextures(): BaseTexture[];
  19644. /**
  19645. * Specifies if the material uses a texture
  19646. * @param texture defines the texture to check against the material
  19647. * @returns a boolean specifying if the material uses the texture
  19648. */
  19649. hasTexture(texture: BaseTexture): boolean;
  19650. /**
  19651. * Disposes the material
  19652. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19653. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19654. */
  19655. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19656. /**
  19657. * Makes a duplicate of the material, and gives it a new name
  19658. * @param name defines the new name for the duplicated material
  19659. * @returns the cloned material
  19660. */
  19661. clone(name: string): StandardMaterial;
  19662. /**
  19663. * Serializes this material in a JSON representation
  19664. * @returns the serialized material object
  19665. */
  19666. serialize(): any;
  19667. /**
  19668. * Creates a standard material from parsed material data
  19669. * @param source defines the JSON represnetation of the material
  19670. * @param scene defines the hosting scene
  19671. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19672. * @returns a new material
  19673. */
  19674. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19675. private static _DiffuseTextureEnabled;
  19676. /**
  19677. * Are diffuse textures enabled in the application.
  19678. */
  19679. static DiffuseTextureEnabled: boolean;
  19680. private static _AmbientTextureEnabled;
  19681. /**
  19682. * Are ambient textures enabled in the application.
  19683. */
  19684. static AmbientTextureEnabled: boolean;
  19685. private static _OpacityTextureEnabled;
  19686. /**
  19687. * Are opacity textures enabled in the application.
  19688. */
  19689. static OpacityTextureEnabled: boolean;
  19690. private static _ReflectionTextureEnabled;
  19691. /**
  19692. * Are reflection textures enabled in the application.
  19693. */
  19694. static ReflectionTextureEnabled: boolean;
  19695. private static _EmissiveTextureEnabled;
  19696. /**
  19697. * Are emissive textures enabled in the application.
  19698. */
  19699. static EmissiveTextureEnabled: boolean;
  19700. private static _SpecularTextureEnabled;
  19701. /**
  19702. * Are specular textures enabled in the application.
  19703. */
  19704. static SpecularTextureEnabled: boolean;
  19705. private static _BumpTextureEnabled;
  19706. /**
  19707. * Are bump textures enabled in the application.
  19708. */
  19709. static BumpTextureEnabled: boolean;
  19710. private static _LightmapTextureEnabled;
  19711. /**
  19712. * Are lightmap textures enabled in the application.
  19713. */
  19714. static LightmapTextureEnabled: boolean;
  19715. private static _RefractionTextureEnabled;
  19716. /**
  19717. * Are refraction textures enabled in the application.
  19718. */
  19719. static RefractionTextureEnabled: boolean;
  19720. private static _ColorGradingTextureEnabled;
  19721. /**
  19722. * Are color grading textures enabled in the application.
  19723. */
  19724. static ColorGradingTextureEnabled: boolean;
  19725. private static _FresnelEnabled;
  19726. /**
  19727. * Are fresnels enabled in the application.
  19728. */
  19729. static FresnelEnabled: boolean;
  19730. }
  19731. }
  19732. declare module BABYLON {
  19733. /**
  19734. * Uniform buffer objects.
  19735. *
  19736. * Handles blocks of uniform on the GPU.
  19737. *
  19738. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19739. *
  19740. * For more information, please refer to :
  19741. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19742. */
  19743. class UniformBuffer {
  19744. private _engine;
  19745. private _buffer;
  19746. private _data;
  19747. private _bufferData;
  19748. private _dynamic?;
  19749. private _uniformLocations;
  19750. private _uniformSizes;
  19751. private _uniformLocationPointer;
  19752. private _needSync;
  19753. private _noUBO;
  19754. private _currentEffect;
  19755. private static _MAX_UNIFORM_SIZE;
  19756. private static _tempBuffer;
  19757. /**
  19758. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  19759. * This is dynamic to allow compat with webgl 1 and 2.
  19760. * You will need to pass the name of the uniform as well as the value.
  19761. */
  19762. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  19763. /**
  19764. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  19765. * This is dynamic to allow compat with webgl 1 and 2.
  19766. * You will need to pass the name of the uniform as well as the value.
  19767. */
  19768. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  19769. /**
  19770. * Lambda to Update a single float in a uniform buffer.
  19771. * This is dynamic to allow compat with webgl 1 and 2.
  19772. * You will need to pass the name of the uniform as well as the value.
  19773. */
  19774. updateFloat: (name: string, x: number) => void;
  19775. /**
  19776. * Lambda to Update a vec2 of float in a uniform buffer.
  19777. * This is dynamic to allow compat with webgl 1 and 2.
  19778. * You will need to pass the name of the uniform as well as the value.
  19779. */
  19780. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  19781. /**
  19782. * Lambda to Update a vec3 of float in a uniform buffer.
  19783. * This is dynamic to allow compat with webgl 1 and 2.
  19784. * You will need to pass the name of the uniform as well as the value.
  19785. */
  19786. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  19787. /**
  19788. * Lambda to Update a vec4 of float in a uniform buffer.
  19789. * This is dynamic to allow compat with webgl 1 and 2.
  19790. * You will need to pass the name of the uniform as well as the value.
  19791. */
  19792. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  19793. /**
  19794. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  19795. * This is dynamic to allow compat with webgl 1 and 2.
  19796. * You will need to pass the name of the uniform as well as the value.
  19797. */
  19798. updateMatrix: (name: string, mat: Matrix) => void;
  19799. /**
  19800. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  19801. * This is dynamic to allow compat with webgl 1 and 2.
  19802. * You will need to pass the name of the uniform as well as the value.
  19803. */
  19804. updateVector3: (name: string, vector: Vector3) => void;
  19805. /**
  19806. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  19807. * This is dynamic to allow compat with webgl 1 and 2.
  19808. * You will need to pass the name of the uniform as well as the value.
  19809. */
  19810. updateVector4: (name: string, vector: Vector4) => void;
  19811. /**
  19812. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  19813. * This is dynamic to allow compat with webgl 1 and 2.
  19814. * You will need to pass the name of the uniform as well as the value.
  19815. */
  19816. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  19817. /**
  19818. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  19819. * This is dynamic to allow compat with webgl 1 and 2.
  19820. * You will need to pass the name of the uniform as well as the value.
  19821. */
  19822. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  19823. /**
  19824. * Instantiates a new Uniform buffer objects.
  19825. *
  19826. * Handles blocks of uniform on the GPU.
  19827. *
  19828. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  19829. *
  19830. * For more information, please refer to :
  19831. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  19832. * @param engine Define the engine the buffer is associated with
  19833. * @param data Define the data contained in the buffer
  19834. * @param dynamic Define if the buffer is updatable
  19835. */
  19836. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  19837. /**
  19838. * Indicates if the buffer is using the WebGL2 UBO implementation,
  19839. * or just falling back on setUniformXXX calls.
  19840. */
  19841. readonly useUbo: boolean;
  19842. /**
  19843. * Indicates if the WebGL underlying uniform buffer is in sync
  19844. * with the javascript cache data.
  19845. */
  19846. readonly isSync: boolean;
  19847. /**
  19848. * Indicates if the WebGL underlying uniform buffer is dynamic.
  19849. * Also, a dynamic UniformBuffer will disable cache verification and always
  19850. * update the underlying WebGL uniform buffer to the GPU.
  19851. * @returns if Dynamic, otherwise false
  19852. */
  19853. isDynamic(): boolean;
  19854. /**
  19855. * The data cache on JS side.
  19856. * @returns the underlying data as a float array
  19857. */
  19858. getData(): Float32Array;
  19859. /**
  19860. * The underlying WebGL Uniform buffer.
  19861. * @returns the webgl buffer
  19862. */
  19863. getBuffer(): Nullable<WebGLBuffer>;
  19864. /**
  19865. * std140 layout specifies how to align data within an UBO structure.
  19866. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  19867. * for specs.
  19868. */
  19869. private _fillAlignment;
  19870. /**
  19871. * Adds an uniform in the buffer.
  19872. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  19873. * for the layout to be correct !
  19874. * @param name Name of the uniform, as used in the uniform block in the shader.
  19875. * @param size Data size, or data directly.
  19876. */
  19877. addUniform(name: string, size: number | number[]): void;
  19878. /**
  19879. * Adds a Matrix 4x4 to the uniform buffer.
  19880. * @param name Name of the uniform, as used in the uniform block in the shader.
  19881. * @param mat A 4x4 matrix.
  19882. */
  19883. addMatrix(name: string, mat: Matrix): void;
  19884. /**
  19885. * Adds a vec2 to the uniform buffer.
  19886. * @param name Name of the uniform, as used in the uniform block in the shader.
  19887. * @param x Define the x component value of the vec2
  19888. * @param y Define the y component value of the vec2
  19889. */
  19890. addFloat2(name: string, x: number, y: number): void;
  19891. /**
  19892. * Adds a vec3 to the uniform buffer.
  19893. * @param name Name of the uniform, as used in the uniform block in the shader.
  19894. * @param x Define the x component value of the vec3
  19895. * @param y Define the y component value of the vec3
  19896. * @param z Define the z component value of the vec3
  19897. */
  19898. addFloat3(name: string, x: number, y: number, z: number): void;
  19899. /**
  19900. * Adds a vec3 to the uniform buffer.
  19901. * @param name Name of the uniform, as used in the uniform block in the shader.
  19902. * @param color Define the vec3 from a Color
  19903. */
  19904. addColor3(name: string, color: Color3): void;
  19905. /**
  19906. * Adds a vec4 to the uniform buffer.
  19907. * @param name Name of the uniform, as used in the uniform block in the shader.
  19908. * @param color Define the rgb components from a Color
  19909. * @param alpha Define the a component of the vec4
  19910. */
  19911. addColor4(name: string, color: Color3, alpha: number): void;
  19912. /**
  19913. * Adds a vec3 to the uniform buffer.
  19914. * @param name Name of the uniform, as used in the uniform block in the shader.
  19915. * @param vector Define the vec3 components from a Vector
  19916. */
  19917. addVector3(name: string, vector: Vector3): void;
  19918. /**
  19919. * Adds a Matrix 3x3 to the uniform buffer.
  19920. * @param name Name of the uniform, as used in the uniform block in the shader.
  19921. */
  19922. addMatrix3x3(name: string): void;
  19923. /**
  19924. * Adds a Matrix 2x2 to the uniform buffer.
  19925. * @param name Name of the uniform, as used in the uniform block in the shader.
  19926. */
  19927. addMatrix2x2(name: string): void;
  19928. /**
  19929. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  19930. */
  19931. create(): void;
  19932. /** @hidden */
  19933. _rebuild(): void;
  19934. /**
  19935. * Updates the WebGL Uniform Buffer on the GPU.
  19936. * If the `dynamic` flag is set to true, no cache comparison is done.
  19937. * Otherwise, the buffer will be updated only if the cache differs.
  19938. */
  19939. update(): void;
  19940. /**
  19941. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  19942. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19943. * @param data Define the flattened data
  19944. * @param size Define the size of the data.
  19945. */
  19946. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  19947. private _updateMatrix3x3ForUniform;
  19948. private _updateMatrix3x3ForEffect;
  19949. private _updateMatrix2x2ForEffect;
  19950. private _updateMatrix2x2ForUniform;
  19951. private _updateFloatForEffect;
  19952. private _updateFloatForUniform;
  19953. private _updateFloat2ForEffect;
  19954. private _updateFloat2ForUniform;
  19955. private _updateFloat3ForEffect;
  19956. private _updateFloat3ForUniform;
  19957. private _updateFloat4ForEffect;
  19958. private _updateFloat4ForUniform;
  19959. private _updateMatrixForEffect;
  19960. private _updateMatrixForUniform;
  19961. private _updateVector3ForEffect;
  19962. private _updateVector3ForUniform;
  19963. private _updateVector4ForEffect;
  19964. private _updateVector4ForUniform;
  19965. private _updateColor3ForEffect;
  19966. private _updateColor3ForUniform;
  19967. private _updateColor4ForEffect;
  19968. private _updateColor4ForUniform;
  19969. /**
  19970. * Sets a sampler uniform on the effect.
  19971. * @param name Define the name of the sampler.
  19972. * @param texture Define the texture to set in the sampler
  19973. */
  19974. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  19975. /**
  19976. * Directly updates the value of the uniform in the cache AND on the GPU.
  19977. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  19978. * @param data Define the flattened data
  19979. */
  19980. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  19981. /**
  19982. * Binds this uniform buffer to an effect.
  19983. * @param effect Define the effect to bind the buffer to
  19984. * @param name Name of the uniform block in the shader.
  19985. */
  19986. bindToEffect(effect: Effect, name: string): void;
  19987. /**
  19988. * Disposes the uniform buffer.
  19989. */
  19990. dispose(): void;
  19991. }
  19992. }
  19993. declare module BABYLON {
  19994. /**
  19995. * Scalar computation library
  19996. */
  19997. class Scalar {
  19998. /**
  19999. * Two pi constants convenient for computation.
  20000. */
  20001. static TwoPi: number;
  20002. /**
  20003. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20004. * @param a number
  20005. * @param b number
  20006. * @param epsilon (default = 1.401298E-45)
  20007. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  20008. */
  20009. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  20010. /**
  20011. * Returns a string : the upper case translation of the number i to hexadecimal.
  20012. * @param i number
  20013. * @returns the upper case translation of the number i to hexadecimal.
  20014. */
  20015. static ToHex(i: number): string;
  20016. /**
  20017. * Returns -1 if value is negative and +1 is value is positive.
  20018. * @param value the value
  20019. * @returns the value itself if it's equal to zero.
  20020. */
  20021. static Sign(value: number): number;
  20022. /**
  20023. * Returns the value itself if it's between min and max.
  20024. * Returns min if the value is lower than min.
  20025. * Returns max if the value is greater than max.
  20026. * @param value the value to clmap
  20027. * @param min the min value to clamp to (default: 0)
  20028. * @param max the max value to clamp to (default: 1)
  20029. * @returns the clamped value
  20030. */
  20031. static Clamp(value: number, min?: number, max?: number): number;
  20032. /**
  20033. * the log2 of value.
  20034. * @param value the value to compute log2 of
  20035. * @returns the log2 of value.
  20036. */
  20037. static Log2(value: number): number;
  20038. /**
  20039. * Loops the value, so that it is never larger than length and never smaller than 0.
  20040. *
  20041. * This is similar to the modulo operator but it works with floating point numbers.
  20042. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  20043. * With t = 5 and length = 2.5, the result would be 0.0.
  20044. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  20045. * @param value the value
  20046. * @param length the length
  20047. * @returns the looped value
  20048. */
  20049. static Repeat(value: number, length: number): number;
  20050. /**
  20051. * Normalize the value between 0.0 and 1.0 using min and max values
  20052. * @param value value to normalize
  20053. * @param min max to normalize between
  20054. * @param max min to normalize between
  20055. * @returns the normalized value
  20056. */
  20057. static Normalize(value: number, min: number, max: number): number;
  20058. /**
  20059. * Denormalize the value from 0.0 and 1.0 using min and max values
  20060. * @param normalized value to denormalize
  20061. * @param min max to denormalize between
  20062. * @param max min to denormalize between
  20063. * @returns the denormalized value
  20064. */
  20065. static Denormalize(normalized: number, min: number, max: number): number;
  20066. /**
  20067. * Calculates the shortest difference between two given angles given in degrees.
  20068. * @param current current angle in degrees
  20069. * @param target target angle in degrees
  20070. * @returns the delta
  20071. */
  20072. static DeltaAngle(current: number, target: number): number;
  20073. /**
  20074. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  20075. * @param tx value
  20076. * @param length length
  20077. * @returns The returned value will move back and forth between 0 and length
  20078. */
  20079. static PingPong(tx: number, length: number): number;
  20080. /**
  20081. * Interpolates between min and max with smoothing at the limits.
  20082. *
  20083. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  20084. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  20085. * @param from from
  20086. * @param to to
  20087. * @param tx value
  20088. * @returns the smooth stepped value
  20089. */
  20090. static SmoothStep(from: number, to: number, tx: number): number;
  20091. /**
  20092. * Moves a value current towards target.
  20093. *
  20094. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  20095. * Negative values of maxDelta pushes the value away from target.
  20096. * @param current current value
  20097. * @param target target value
  20098. * @param maxDelta max distance to move
  20099. * @returns resulting value
  20100. */
  20101. static MoveTowards(current: number, target: number, maxDelta: number): number;
  20102. /**
  20103. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20104. *
  20105. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  20106. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  20107. * @param current current value
  20108. * @param target target value
  20109. * @param maxDelta max distance to move
  20110. * @returns resulting angle
  20111. */
  20112. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  20113. /**
  20114. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  20115. * @param start start value
  20116. * @param end target value
  20117. * @param amount amount to lerp between
  20118. * @returns the lerped value
  20119. */
  20120. static Lerp(start: number, end: number, amount: number): number;
  20121. /**
  20122. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  20123. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  20124. * @param start start value
  20125. * @param end target value
  20126. * @param amount amount to lerp between
  20127. * @returns the lerped value
  20128. */
  20129. static LerpAngle(start: number, end: number, amount: number): number;
  20130. /**
  20131. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  20132. * @param a start value
  20133. * @param b target value
  20134. * @param value value between a and b
  20135. * @returns the inverseLerp value
  20136. */
  20137. static InverseLerp(a: number, b: number, value: number): number;
  20138. /**
  20139. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  20140. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  20141. * @param value1 spline value
  20142. * @param tangent1 spline value
  20143. * @param value2 spline value
  20144. * @param tangent2 spline value
  20145. * @param amount input value
  20146. * @returns hermite result
  20147. */
  20148. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  20149. /**
  20150. * Returns a random float number between and min and max values
  20151. * @param min min value of random
  20152. * @param max max value of random
  20153. * @returns random value
  20154. */
  20155. static RandomRange(min: number, max: number): number;
  20156. /**
  20157. * This function returns percentage of a number in a given range.
  20158. *
  20159. * RangeToPercent(40,20,60) will return 0.5 (50%)
  20160. * RangeToPercent(34,0,100) will return 0.34 (34%)
  20161. * @param number to convert to percentage
  20162. * @param min min range
  20163. * @param max max range
  20164. * @returns the percentage
  20165. */
  20166. static RangeToPercent(number: number, min: number, max: number): number;
  20167. /**
  20168. * This function returns number that corresponds to the percentage in a given range.
  20169. *
  20170. * PercentToRange(0.34,0,100) will return 34.
  20171. * @param percent to convert to number
  20172. * @param min min range
  20173. * @param max max range
  20174. * @returns the number
  20175. */
  20176. static PercentToRange(percent: number, min: number, max: number): number;
  20177. /**
  20178. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  20179. * @param angle The angle to normalize in radian.
  20180. * @return The converted angle.
  20181. */
  20182. static NormalizeRadians(angle: number): number;
  20183. }
  20184. }
  20185. declare module BABYLON {
  20186. /**
  20187. * Constant used to convert a value to gamma space
  20188. * @ignorenaming
  20189. */
  20190. const ToGammaSpace: number;
  20191. /**
  20192. * Constant used to convert a value to linear space
  20193. * @ignorenaming
  20194. */
  20195. const ToLinearSpace = 2.2;
  20196. /**
  20197. * Constant used to define the minimal number value in Babylon.js
  20198. * @ignorenaming
  20199. */
  20200. const Epsilon = 0.001;
  20201. /**
  20202. * Class used to hold a RBG color
  20203. */
  20204. class Color3 {
  20205. /**
  20206. * Defines the red component (between 0 and 1, default is 0)
  20207. */
  20208. r: number;
  20209. /**
  20210. * Defines the green component (between 0 and 1, default is 0)
  20211. */
  20212. g: number;
  20213. /**
  20214. * Defines the blue component (between 0 and 1, default is 0)
  20215. */
  20216. b: number;
  20217. /**
  20218. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  20219. * @param r defines the red component (between 0 and 1, default is 0)
  20220. * @param g defines the green component (between 0 and 1, default is 0)
  20221. * @param b defines the blue component (between 0 and 1, default is 0)
  20222. */
  20223. constructor(
  20224. /**
  20225. * Defines the red component (between 0 and 1, default is 0)
  20226. */
  20227. r?: number,
  20228. /**
  20229. * Defines the green component (between 0 and 1, default is 0)
  20230. */
  20231. g?: number,
  20232. /**
  20233. * Defines the blue component (between 0 and 1, default is 0)
  20234. */
  20235. b?: number);
  20236. /**
  20237. * Creates a string with the Color3 current values
  20238. * @returns the string representation of the Color3 object
  20239. */
  20240. toString(): string;
  20241. /**
  20242. * Returns the string "Color3"
  20243. * @returns "Color3"
  20244. */
  20245. getClassName(): string;
  20246. /**
  20247. * Compute the Color3 hash code
  20248. * @returns an unique number that can be used to hash Color3 objects
  20249. */
  20250. getHashCode(): number;
  20251. /**
  20252. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  20253. * @param array defines the array where to store the r,g,b components
  20254. * @param index defines an optional index in the target array to define where to start storing values
  20255. * @returns the current Color3 object
  20256. */
  20257. toArray(array: FloatArray, index?: number): Color3;
  20258. /**
  20259. * Returns a new Color4 object from the current Color3 and the given alpha
  20260. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  20261. * @returns a new Color4 object
  20262. */
  20263. toColor4(alpha?: number): Color4;
  20264. /**
  20265. * Returns a new array populated with 3 numeric elements : red, green and blue values
  20266. * @returns the new array
  20267. */
  20268. asArray(): number[];
  20269. /**
  20270. * Returns the luminance value
  20271. * @returns a float value
  20272. */
  20273. toLuminance(): number;
  20274. /**
  20275. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  20276. * @param otherColor defines the second operand
  20277. * @returns the new Color3 object
  20278. */
  20279. multiply(otherColor: DeepImmutable<Color3>): Color3;
  20280. /**
  20281. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  20282. * @param otherColor defines the second operand
  20283. * @param result defines the Color3 object where to store the result
  20284. * @returns the current Color3
  20285. */
  20286. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20287. /**
  20288. * Determines equality between Color3 objects
  20289. * @param otherColor defines the second operand
  20290. * @returns true if the rgb values are equal to the given ones
  20291. */
  20292. equals(otherColor: DeepImmutable<Color3>): boolean;
  20293. /**
  20294. * Determines equality between the current Color3 object and a set of r,b,g values
  20295. * @param r defines the red component to check
  20296. * @param g defines the green component to check
  20297. * @param b defines the blue component to check
  20298. * @returns true if the rgb values are equal to the given ones
  20299. */
  20300. equalsFloats(r: number, g: number, b: number): boolean;
  20301. /**
  20302. * Multiplies in place each rgb value by scale
  20303. * @param scale defines the scaling factor
  20304. * @returns the updated Color3
  20305. */
  20306. scale(scale: number): Color3;
  20307. /**
  20308. * Multiplies the rgb values by scale and stores the result into "result"
  20309. * @param scale defines the scaling factor
  20310. * @param result defines the Color3 object where to store the result
  20311. * @returns the unmodified current Color3
  20312. */
  20313. scaleToRef(scale: number, result: Color3): Color3;
  20314. /**
  20315. * Scale the current Color3 values by a factor and add the result to a given Color3
  20316. * @param scale defines the scale factor
  20317. * @param result defines color to store the result into
  20318. * @returns the unmodified current Color3
  20319. */
  20320. scaleAndAddToRef(scale: number, result: Color3): Color3;
  20321. /**
  20322. * Clamps the rgb values by the min and max values and stores the result into "result"
  20323. * @param min defines minimum clamping value (default is 0)
  20324. * @param max defines maximum clamping value (default is 1)
  20325. * @param result defines color to store the result into
  20326. * @returns the original Color3
  20327. */
  20328. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  20329. /**
  20330. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  20331. * @param otherColor defines the second operand
  20332. * @returns the new Color3
  20333. */
  20334. add(otherColor: DeepImmutable<Color3>): Color3;
  20335. /**
  20336. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  20337. * @param otherColor defines the second operand
  20338. * @param result defines Color3 object to store the result into
  20339. * @returns the unmodified current Color3
  20340. */
  20341. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20342. /**
  20343. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  20344. * @param otherColor defines the second operand
  20345. * @returns the new Color3
  20346. */
  20347. subtract(otherColor: DeepImmutable<Color3>): Color3;
  20348. /**
  20349. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  20350. * @param otherColor defines the second operand
  20351. * @param result defines Color3 object to store the result into
  20352. * @returns the unmodified current Color3
  20353. */
  20354. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  20355. /**
  20356. * Copy the current object
  20357. * @returns a new Color3 copied the current one
  20358. */
  20359. clone(): Color3;
  20360. /**
  20361. * Copies the rgb values from the source in the current Color3
  20362. * @param source defines the source Color3 object
  20363. * @returns the updated Color3 object
  20364. */
  20365. copyFrom(source: DeepImmutable<Color3>): Color3;
  20366. /**
  20367. * Updates the Color3 rgb values from the given floats
  20368. * @param r defines the red component to read from
  20369. * @param g defines the green component to read from
  20370. * @param b defines the blue component to read from
  20371. * @returns the current Color3 object
  20372. */
  20373. copyFromFloats(r: number, g: number, b: number): Color3;
  20374. /**
  20375. * Updates the Color3 rgb values from the given floats
  20376. * @param r defines the red component to read from
  20377. * @param g defines the green component to read from
  20378. * @param b defines the blue component to read from
  20379. * @returns the current Color3 object
  20380. */
  20381. set(r: number, g: number, b: number): Color3;
  20382. /**
  20383. * Compute the Color3 hexadecimal code as a string
  20384. * @returns a string containing the hexadecimal representation of the Color3 object
  20385. */
  20386. toHexString(): string;
  20387. /**
  20388. * Computes a new Color3 converted from the current one to linear space
  20389. * @returns a new Color3 object
  20390. */
  20391. toLinearSpace(): Color3;
  20392. /**
  20393. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  20394. * @param convertedColor defines the Color3 object where to store the linear space version
  20395. * @returns the unmodified Color3
  20396. */
  20397. toLinearSpaceToRef(convertedColor: Color3): Color3;
  20398. /**
  20399. * Computes a new Color3 converted from the current one to gamma space
  20400. * @returns a new Color3 object
  20401. */
  20402. toGammaSpace(): Color3;
  20403. /**
  20404. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  20405. * @param convertedColor defines the Color3 object where to store the gamma space version
  20406. * @returns the unmodified Color3
  20407. */
  20408. toGammaSpaceToRef(convertedColor: Color3): Color3;
  20409. /**
  20410. * Creates a new Color3 from the string containing valid hexadecimal values
  20411. * @param hex defines a string containing valid hexadecimal values
  20412. * @returns a new Color3 object
  20413. */
  20414. static FromHexString(hex: string): Color3;
  20415. /**
  20416. * Creates a new Vector3 from the starting index of the given array
  20417. * @param array defines the source array
  20418. * @param offset defines an offset in the source array
  20419. * @returns a new Color3 object
  20420. */
  20421. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  20422. /**
  20423. * Creates a new Color3 from integer values (< 256)
  20424. * @param r defines the red component to read from (value between 0 and 255)
  20425. * @param g defines the green component to read from (value between 0 and 255)
  20426. * @param b defines the blue component to read from (value between 0 and 255)
  20427. * @returns a new Color3 object
  20428. */
  20429. static FromInts(r: number, g: number, b: number): Color3;
  20430. /**
  20431. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20432. * @param start defines the start Color3 value
  20433. * @param end defines the end Color3 value
  20434. * @param amount defines the gradient value between start and end
  20435. * @returns a new Color3 object
  20436. */
  20437. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  20438. /**
  20439. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  20440. * @param left defines the start value
  20441. * @param right defines the end value
  20442. * @param amount defines the gradient factor
  20443. * @param result defines the Color3 object where to store the result
  20444. */
  20445. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  20446. /**
  20447. * Returns a Color3 value containing a red color
  20448. * @returns a new Color3 object
  20449. */
  20450. static Red(): Color3;
  20451. /**
  20452. * Returns a Color3 value containing a green color
  20453. * @returns a new Color3 object
  20454. */
  20455. static Green(): Color3;
  20456. /**
  20457. * Returns a Color3 value containing a blue color
  20458. * @returns a new Color3 object
  20459. */
  20460. static Blue(): Color3;
  20461. /**
  20462. * Returns a Color3 value containing a black color
  20463. * @returns a new Color3 object
  20464. */
  20465. static Black(): Color3;
  20466. /**
  20467. * Returns a Color3 value containing a white color
  20468. * @returns a new Color3 object
  20469. */
  20470. static White(): Color3;
  20471. /**
  20472. * Returns a Color3 value containing a purple color
  20473. * @returns a new Color3 object
  20474. */
  20475. static Purple(): Color3;
  20476. /**
  20477. * Returns a Color3 value containing a magenta color
  20478. * @returns a new Color3 object
  20479. */
  20480. static Magenta(): Color3;
  20481. /**
  20482. * Returns a Color3 value containing a yellow color
  20483. * @returns a new Color3 object
  20484. */
  20485. static Yellow(): Color3;
  20486. /**
  20487. * Returns a Color3 value containing a gray color
  20488. * @returns a new Color3 object
  20489. */
  20490. static Gray(): Color3;
  20491. /**
  20492. * Returns a Color3 value containing a teal color
  20493. * @returns a new Color3 object
  20494. */
  20495. static Teal(): Color3;
  20496. /**
  20497. * Returns a Color3 value containing a random color
  20498. * @returns a new Color3 object
  20499. */
  20500. static Random(): Color3;
  20501. }
  20502. /**
  20503. * Class used to hold a RBGA color
  20504. */
  20505. class Color4 {
  20506. /**
  20507. * Defines the red component (between 0 and 1, default is 0)
  20508. */
  20509. r: number;
  20510. /**
  20511. * Defines the green component (between 0 and 1, default is 0)
  20512. */
  20513. g: number;
  20514. /**
  20515. * Defines the blue component (between 0 and 1, default is 0)
  20516. */
  20517. b: number;
  20518. /**
  20519. * Defines the alpha component (between 0 and 1, default is 1)
  20520. */
  20521. a: number;
  20522. /**
  20523. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  20524. * @param r defines the red component (between 0 and 1, default is 0)
  20525. * @param g defines the green component (between 0 and 1, default is 0)
  20526. * @param b defines the blue component (between 0 and 1, default is 0)
  20527. * @param a defines the alpha component (between 0 and 1, default is 1)
  20528. */
  20529. constructor(
  20530. /**
  20531. * Defines the red component (between 0 and 1, default is 0)
  20532. */
  20533. r?: number,
  20534. /**
  20535. * Defines the green component (between 0 and 1, default is 0)
  20536. */
  20537. g?: number,
  20538. /**
  20539. * Defines the blue component (between 0 and 1, default is 0)
  20540. */
  20541. b?: number,
  20542. /**
  20543. * Defines the alpha component (between 0 and 1, default is 1)
  20544. */
  20545. a?: number);
  20546. /**
  20547. * Adds in place the given Color4 values to the current Color4 object
  20548. * @param right defines the second operand
  20549. * @returns the current updated Color4 object
  20550. */
  20551. addInPlace(right: DeepImmutable<Color4>): Color4;
  20552. /**
  20553. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  20554. * @returns the new array
  20555. */
  20556. asArray(): number[];
  20557. /**
  20558. * Stores from the starting index in the given array the Color4 successive values
  20559. * @param array defines the array where to store the r,g,b components
  20560. * @param index defines an optional index in the target array to define where to start storing values
  20561. * @returns the current Color4 object
  20562. */
  20563. toArray(array: number[], index?: number): Color4;
  20564. /**
  20565. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  20566. * @param right defines the second operand
  20567. * @returns a new Color4 object
  20568. */
  20569. add(right: DeepImmutable<Color4>): Color4;
  20570. /**
  20571. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  20572. * @param right defines the second operand
  20573. * @returns a new Color4 object
  20574. */
  20575. subtract(right: DeepImmutable<Color4>): Color4;
  20576. /**
  20577. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  20578. * @param right defines the second operand
  20579. * @param result defines the Color4 object where to store the result
  20580. * @returns the current Color4 object
  20581. */
  20582. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  20583. /**
  20584. * Creates a new Color4 with the current Color4 values multiplied by scale
  20585. * @param scale defines the scaling factor to apply
  20586. * @returns a new Color4 object
  20587. */
  20588. scale(scale: number): Color4;
  20589. /**
  20590. * Multiplies the current Color4 values by scale and stores the result in "result"
  20591. * @param scale defines the scaling factor to apply
  20592. * @param result defines the Color4 object where to store the result
  20593. * @returns the current unmodified Color4
  20594. */
  20595. scaleToRef(scale: number, result: Color4): Color4;
  20596. /**
  20597. * Scale the current Color4 values by a factor and add the result to a given Color4
  20598. * @param scale defines the scale factor
  20599. * @param result defines the Color4 object where to store the result
  20600. * @returns the unmodified current Color4
  20601. */
  20602. scaleAndAddToRef(scale: number, result: Color4): Color4;
  20603. /**
  20604. * Clamps the rgb values by the min and max values and stores the result into "result"
  20605. * @param min defines minimum clamping value (default is 0)
  20606. * @param max defines maximum clamping value (default is 1)
  20607. * @param result defines color to store the result into.
  20608. * @returns the cuurent Color4
  20609. */
  20610. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  20611. /**
  20612. * Multipy an Color4 value by another and return a new Color4 object
  20613. * @param color defines the Color4 value to multiply by
  20614. * @returns a new Color4 object
  20615. */
  20616. multiply(color: Color4): Color4;
  20617. /**
  20618. * Multipy a Color4 value by another and push the result in a reference value
  20619. * @param color defines the Color4 value to multiply by
  20620. * @param result defines the Color4 to fill the result in
  20621. * @returns the result Color4
  20622. */
  20623. multiplyToRef(color: Color4, result: Color4): Color4;
  20624. /**
  20625. * Creates a string with the Color4 current values
  20626. * @returns the string representation of the Color4 object
  20627. */
  20628. toString(): string;
  20629. /**
  20630. * Returns the string "Color4"
  20631. * @returns "Color4"
  20632. */
  20633. getClassName(): string;
  20634. /**
  20635. * Compute the Color4 hash code
  20636. * @returns an unique number that can be used to hash Color4 objects
  20637. */
  20638. getHashCode(): number;
  20639. /**
  20640. * Creates a new Color4 copied from the current one
  20641. * @returns a new Color4 object
  20642. */
  20643. clone(): Color4;
  20644. /**
  20645. * Copies the given Color4 values into the current one
  20646. * @param source defines the source Color4 object
  20647. * @returns the current updated Color4 object
  20648. */
  20649. copyFrom(source: Color4): Color4;
  20650. /**
  20651. * Copies the given float values into the current one
  20652. * @param r defines the red component to read from
  20653. * @param g defines the green component to read from
  20654. * @param b defines the blue component to read from
  20655. * @param a defines the alpha component to read from
  20656. * @returns the current updated Color4 object
  20657. */
  20658. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  20659. /**
  20660. * Copies the given float values into the current one
  20661. * @param r defines the red component to read from
  20662. * @param g defines the green component to read from
  20663. * @param b defines the blue component to read from
  20664. * @param a defines the alpha component to read from
  20665. * @returns the current updated Color4 object
  20666. */
  20667. set(r: number, g: number, b: number, a: number): Color4;
  20668. /**
  20669. * Compute the Color4 hexadecimal code as a string
  20670. * @returns a string containing the hexadecimal representation of the Color4 object
  20671. */
  20672. toHexString(): string;
  20673. /**
  20674. * Computes a new Color4 converted from the current one to linear space
  20675. * @returns a new Color4 object
  20676. */
  20677. toLinearSpace(): Color4;
  20678. /**
  20679. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  20680. * @param convertedColor defines the Color4 object where to store the linear space version
  20681. * @returns the unmodified Color4
  20682. */
  20683. toLinearSpaceToRef(convertedColor: Color4): Color4;
  20684. /**
  20685. * Computes a new Color4 converted from the current one to gamma space
  20686. * @returns a new Color4 object
  20687. */
  20688. toGammaSpace(): Color4;
  20689. /**
  20690. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  20691. * @param convertedColor defines the Color4 object where to store the gamma space version
  20692. * @returns the unmodified Color4
  20693. */
  20694. toGammaSpaceToRef(convertedColor: Color4): Color4;
  20695. /**
  20696. * Creates a new Color4 from the string containing valid hexadecimal values
  20697. * @param hex defines a string containing valid hexadecimal values
  20698. * @returns a new Color4 object
  20699. */
  20700. static FromHexString(hex: string): Color4;
  20701. /**
  20702. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20703. * @param left defines the start value
  20704. * @param right defines the end value
  20705. * @param amount defines the gradient factor
  20706. * @returns a new Color4 object
  20707. */
  20708. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  20709. /**
  20710. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  20711. * @param left defines the start value
  20712. * @param right defines the end value
  20713. * @param amount defines the gradient factor
  20714. * @param result defines the Color4 object where to store data
  20715. */
  20716. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  20717. /**
  20718. * Creates a new Color4 from a Color3 and an alpha value
  20719. * @param color3 defines the source Color3 to read from
  20720. * @param alpha defines the alpha component (1.0 by default)
  20721. * @returns a new Color4 object
  20722. */
  20723. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  20724. /**
  20725. * Creates a new Color4 from the starting index element of the given array
  20726. * @param array defines the source array to read from
  20727. * @param offset defines the offset in the source array
  20728. * @returns a new Color4 object
  20729. */
  20730. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  20731. /**
  20732. * Creates a new Color3 from integer values (< 256)
  20733. * @param r defines the red component to read from (value between 0 and 255)
  20734. * @param g defines the green component to read from (value between 0 and 255)
  20735. * @param b defines the blue component to read from (value between 0 and 255)
  20736. * @param a defines the alpha component to read from (value between 0 and 255)
  20737. * @returns a new Color3 object
  20738. */
  20739. static FromInts(r: number, g: number, b: number, a: number): Color4;
  20740. /**
  20741. * Check the content of a given array and convert it to an array containing RGBA data
  20742. * If the original array was already containing count * 4 values then it is returned directly
  20743. * @param colors defines the array to check
  20744. * @param count defines the number of RGBA data to expect
  20745. * @returns an array containing count * 4 values (RGBA)
  20746. */
  20747. static CheckColors4(colors: number[], count: number): number[];
  20748. }
  20749. /**
  20750. * Class representing a vector containing 2 coordinates
  20751. */
  20752. class Vector2 {
  20753. /** defines the first coordinate */
  20754. x: number;
  20755. /** defines the second coordinate */
  20756. y: number;
  20757. /**
  20758. * Creates a new Vector2 from the given x and y coordinates
  20759. * @param x defines the first coordinate
  20760. * @param y defines the second coordinate
  20761. */
  20762. constructor(
  20763. /** defines the first coordinate */
  20764. x?: number,
  20765. /** defines the second coordinate */
  20766. y?: number);
  20767. /**
  20768. * Gets a string with the Vector2 coordinates
  20769. * @returns a string with the Vector2 coordinates
  20770. */
  20771. toString(): string;
  20772. /**
  20773. * Gets class name
  20774. * @returns the string "Vector2"
  20775. */
  20776. getClassName(): string;
  20777. /**
  20778. * Gets current vector hash code
  20779. * @returns the Vector2 hash code as a number
  20780. */
  20781. getHashCode(): number;
  20782. /**
  20783. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  20784. * @param array defines the source array
  20785. * @param index defines the offset in source array
  20786. * @returns the current Vector2
  20787. */
  20788. toArray(array: FloatArray, index?: number): Vector2;
  20789. /**
  20790. * Copy the current vector to an array
  20791. * @returns a new array with 2 elements: the Vector2 coordinates.
  20792. */
  20793. asArray(): number[];
  20794. /**
  20795. * Sets the Vector2 coordinates with the given Vector2 coordinates
  20796. * @param source defines the source Vector2
  20797. * @returns the current updated Vector2
  20798. */
  20799. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  20800. /**
  20801. * Sets the Vector2 coordinates with the given floats
  20802. * @param x defines the first coordinate
  20803. * @param y defines the second coordinate
  20804. * @returns the current updated Vector2
  20805. */
  20806. copyFromFloats(x: number, y: number): Vector2;
  20807. /**
  20808. * Sets the Vector2 coordinates with the given floats
  20809. * @param x defines the first coordinate
  20810. * @param y defines the second coordinate
  20811. * @returns the current updated Vector2
  20812. */
  20813. set(x: number, y: number): Vector2;
  20814. /**
  20815. * Add another vector with the current one
  20816. * @param otherVector defines the other vector
  20817. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  20818. */
  20819. add(otherVector: DeepImmutable<Vector2>): Vector2;
  20820. /**
  20821. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  20822. * @param otherVector defines the other vector
  20823. * @param result defines the target vector
  20824. * @returns the unmodified current Vector2
  20825. */
  20826. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20827. /**
  20828. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  20829. * @param otherVector defines the other vector
  20830. * @returns the current updated Vector2
  20831. */
  20832. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20833. /**
  20834. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  20835. * @param otherVector defines the other vector
  20836. * @returns a new Vector2
  20837. */
  20838. addVector3(otherVector: Vector3): Vector2;
  20839. /**
  20840. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  20841. * @param otherVector defines the other vector
  20842. * @returns a new Vector2
  20843. */
  20844. subtract(otherVector: Vector2): Vector2;
  20845. /**
  20846. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  20847. * @param otherVector defines the other vector
  20848. * @param result defines the target vector
  20849. * @returns the unmodified current Vector2
  20850. */
  20851. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20852. /**
  20853. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  20854. * @param otherVector defines the other vector
  20855. * @returns the current updated Vector2
  20856. */
  20857. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20858. /**
  20859. * Multiplies in place the current Vector2 coordinates by the given ones
  20860. * @param otherVector defines the other vector
  20861. * @returns the current updated Vector2
  20862. */
  20863. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20864. /**
  20865. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  20866. * @param otherVector defines the other vector
  20867. * @returns a new Vector2
  20868. */
  20869. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  20870. /**
  20871. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  20872. * @param otherVector defines the other vector
  20873. * @param result defines the target vector
  20874. * @returns the unmodified current Vector2
  20875. */
  20876. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20877. /**
  20878. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  20879. * @param x defines the first coordinate
  20880. * @param y defines the second coordinate
  20881. * @returns a new Vector2
  20882. */
  20883. multiplyByFloats(x: number, y: number): Vector2;
  20884. /**
  20885. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  20886. * @param otherVector defines the other vector
  20887. * @returns a new Vector2
  20888. */
  20889. divide(otherVector: Vector2): Vector2;
  20890. /**
  20891. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  20892. * @param otherVector defines the other vector
  20893. * @param result defines the target vector
  20894. * @returns the unmodified current Vector2
  20895. */
  20896. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  20897. /**
  20898. * Divides the current Vector2 coordinates by the given ones
  20899. * @param otherVector defines the other vector
  20900. * @returns the current updated Vector2
  20901. */
  20902. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  20903. /**
  20904. * Gets a new Vector2 with current Vector2 negated coordinates
  20905. * @returns a new Vector2
  20906. */
  20907. negate(): Vector2;
  20908. /**
  20909. * Multiply the Vector2 coordinates by scale
  20910. * @param scale defines the scaling factor
  20911. * @returns the current updated Vector2
  20912. */
  20913. scaleInPlace(scale: number): Vector2;
  20914. /**
  20915. * Returns a new Vector2 scaled by "scale" from the current Vector2
  20916. * @param scale defines the scaling factor
  20917. * @returns a new Vector2
  20918. */
  20919. scale(scale: number): Vector2;
  20920. /**
  20921. * Scale the current Vector2 values by a factor to a given Vector2
  20922. * @param scale defines the scale factor
  20923. * @param result defines the Vector2 object where to store the result
  20924. * @returns the unmodified current Vector2
  20925. */
  20926. scaleToRef(scale: number, result: Vector2): Vector2;
  20927. /**
  20928. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  20929. * @param scale defines the scale factor
  20930. * @param result defines the Vector2 object where to store the result
  20931. * @returns the unmodified current Vector2
  20932. */
  20933. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  20934. /**
  20935. * Gets a boolean if two vectors are equals
  20936. * @param otherVector defines the other vector
  20937. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  20938. */
  20939. equals(otherVector: DeepImmutable<Vector2>): boolean;
  20940. /**
  20941. * Gets a boolean if two vectors are equals (using an epsilon value)
  20942. * @param otherVector defines the other vector
  20943. * @param epsilon defines the minimal distance to consider equality
  20944. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  20945. */
  20946. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  20947. /**
  20948. * Gets a new Vector2 from current Vector2 floored values
  20949. * @returns a new Vector2
  20950. */
  20951. floor(): Vector2;
  20952. /**
  20953. * Gets a new Vector2 from current Vector2 floored values
  20954. * @returns a new Vector2
  20955. */
  20956. fract(): Vector2;
  20957. /**
  20958. * Gets the length of the vector
  20959. * @returns the vector length (float)
  20960. */
  20961. length(): number;
  20962. /**
  20963. * Gets the vector squared length
  20964. * @returns the vector squared length (float)
  20965. */
  20966. lengthSquared(): number;
  20967. /**
  20968. * Normalize the vector
  20969. * @returns the current updated Vector2
  20970. */
  20971. normalize(): Vector2;
  20972. /**
  20973. * Gets a new Vector2 copied from the Vector2
  20974. * @returns a new Vector2
  20975. */
  20976. clone(): Vector2;
  20977. /**
  20978. * Gets a new Vector2(0, 0)
  20979. * @returns a new Vector2
  20980. */
  20981. static Zero(): Vector2;
  20982. /**
  20983. * Gets a new Vector2(1, 1)
  20984. * @returns a new Vector2
  20985. */
  20986. static One(): Vector2;
  20987. /**
  20988. * Gets a new Vector2 set from the given index element of the given array
  20989. * @param array defines the data source
  20990. * @param offset defines the offset in the data source
  20991. * @returns a new Vector2
  20992. */
  20993. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  20994. /**
  20995. * Sets "result" from the given index element of the given array
  20996. * @param array defines the data source
  20997. * @param offset defines the offset in the data source
  20998. * @param result defines the target vector
  20999. */
  21000. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  21001. /**
  21002. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  21003. * @param value1 defines 1st point of control
  21004. * @param value2 defines 2nd point of control
  21005. * @param value3 defines 3rd point of control
  21006. * @param value4 defines 4th point of control
  21007. * @param amount defines the interpolation factor
  21008. * @returns a new Vector2
  21009. */
  21010. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  21011. /**
  21012. * 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".
  21013. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  21014. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  21015. * @param value defines the value to clamp
  21016. * @param min defines the lower limit
  21017. * @param max defines the upper limit
  21018. * @returns a new Vector2
  21019. */
  21020. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  21021. /**
  21022. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  21023. * @param value1 defines the 1st control point
  21024. * @param tangent1 defines the outgoing tangent
  21025. * @param value2 defines the 2nd control point
  21026. * @param tangent2 defines the incoming tangent
  21027. * @param amount defines the interpolation factor
  21028. * @returns a new Vector2
  21029. */
  21030. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  21031. /**
  21032. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  21033. * @param start defines the start vector
  21034. * @param end defines the end vector
  21035. * @param amount defines the interpolation factor
  21036. * @returns a new Vector2
  21037. */
  21038. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  21039. /**
  21040. * Gets the dot product of the vector "left" and the vector "right"
  21041. * @param left defines first vector
  21042. * @param right defines second vector
  21043. * @returns the dot product (float)
  21044. */
  21045. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  21046. /**
  21047. * Returns a new Vector2 equal to the normalized given vector
  21048. * @param vector defines the vector to normalize
  21049. * @returns a new Vector2
  21050. */
  21051. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  21052. /**
  21053. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  21054. * @param left defines 1st vector
  21055. * @param right defines 2nd vector
  21056. * @returns a new Vector2
  21057. */
  21058. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21059. /**
  21060. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  21061. * @param left defines 1st vector
  21062. * @param right defines 2nd vector
  21063. * @returns a new Vector2
  21064. */
  21065. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  21066. /**
  21067. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  21068. * @param vector defines the vector to transform
  21069. * @param transformation defines the matrix to apply
  21070. * @returns a new Vector2
  21071. */
  21072. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  21073. /**
  21074. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  21075. * @param vector defines the vector to transform
  21076. * @param transformation defines the matrix to apply
  21077. * @param result defines the target vector
  21078. */
  21079. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  21080. /**
  21081. * Determines if a given vector is included in a triangle
  21082. * @param p defines the vector to test
  21083. * @param p0 defines 1st triangle point
  21084. * @param p1 defines 2nd triangle point
  21085. * @param p2 defines 3rd triangle point
  21086. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  21087. */
  21088. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  21089. /**
  21090. * Gets the distance between the vectors "value1" and "value2"
  21091. * @param value1 defines first vector
  21092. * @param value2 defines second vector
  21093. * @returns the distance between vectors
  21094. */
  21095. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21096. /**
  21097. * Returns the squared distance between the vectors "value1" and "value2"
  21098. * @param value1 defines first vector
  21099. * @param value2 defines second vector
  21100. * @returns the squared distance between vectors
  21101. */
  21102. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  21103. /**
  21104. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  21105. * @param value1 defines first vector
  21106. * @param value2 defines second vector
  21107. * @returns a new Vector2
  21108. */
  21109. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  21110. /**
  21111. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  21112. * @param p defines the middle point
  21113. * @param segA defines one point of the segment
  21114. * @param segB defines the other point of the segment
  21115. * @returns the shortest distance
  21116. */
  21117. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  21118. }
  21119. /**
  21120. * Classed used to store (x,y,z) vector representation
  21121. * A Vector3 is the main object used in 3D geometry
  21122. * It can represent etiher the coordinates of a point the space, either a direction
  21123. * Reminder: Babylon.js uses a left handed forward facing system
  21124. */
  21125. class Vector3 {
  21126. /**
  21127. * Defines the first coordinates (on X axis)
  21128. */
  21129. x: number;
  21130. /**
  21131. * Defines the second coordinates (on Y axis)
  21132. */
  21133. y: number;
  21134. /**
  21135. * Defines the third coordinates (on Z axis)
  21136. */
  21137. z: number;
  21138. /**
  21139. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  21140. * @param x defines the first coordinates (on X axis)
  21141. * @param y defines the second coordinates (on Y axis)
  21142. * @param z defines the third coordinates (on Z axis)
  21143. */
  21144. constructor(
  21145. /**
  21146. * Defines the first coordinates (on X axis)
  21147. */
  21148. x?: number,
  21149. /**
  21150. * Defines the second coordinates (on Y axis)
  21151. */
  21152. y?: number,
  21153. /**
  21154. * Defines the third coordinates (on Z axis)
  21155. */
  21156. z?: number);
  21157. /**
  21158. * Creates a string representation of the Vector3
  21159. * @returns a string with the Vector3 coordinates.
  21160. */
  21161. toString(): string;
  21162. /**
  21163. * Gets the class name
  21164. * @returns the string "Vector3"
  21165. */
  21166. getClassName(): string;
  21167. /**
  21168. * Creates the Vector3 hash code
  21169. * @returns a number which tends to be unique between Vector3 instances
  21170. */
  21171. getHashCode(): number;
  21172. /**
  21173. * Creates an array containing three elements : the coordinates of the Vector3
  21174. * @returns a new array of numbers
  21175. */
  21176. asArray(): number[];
  21177. /**
  21178. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  21179. * @param array defines the destination array
  21180. * @param index defines the offset in the destination array
  21181. * @returns the current Vector3
  21182. */
  21183. toArray(array: FloatArray, index?: number): Vector3;
  21184. /**
  21185. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  21186. * @returns a new Quaternion object, computed from the Vector3 coordinates
  21187. */
  21188. toQuaternion(): Quaternion;
  21189. /**
  21190. * Adds the given vector to the current Vector3
  21191. * @param otherVector defines the second operand
  21192. * @returns the current updated Vector3
  21193. */
  21194. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21195. /**
  21196. * Adds the given coordinates to the current Vector3
  21197. * @param x defines the x coordinate of the operand
  21198. * @param y defines the y coordinate of the operand
  21199. * @param z defines the z coordinate of the operand
  21200. * @returns the current updated Vector3
  21201. */
  21202. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21203. /**
  21204. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  21205. * @param otherVector defines the second operand
  21206. * @returns the resulting Vector3
  21207. */
  21208. add(otherVector: DeepImmutable<Vector3>): Vector3;
  21209. /**
  21210. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  21211. * @param otherVector defines the second operand
  21212. * @param result defines the Vector3 object where to store the result
  21213. * @returns the current Vector3
  21214. */
  21215. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21216. /**
  21217. * Subtract the given vector from the current Vector3
  21218. * @param otherVector defines the second operand
  21219. * @returns the current updated Vector3
  21220. */
  21221. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21222. /**
  21223. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  21224. * @param otherVector defines the second operand
  21225. * @returns the resulting Vector3
  21226. */
  21227. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  21228. /**
  21229. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  21230. * @param otherVector defines the second operand
  21231. * @param result defines the Vector3 object where to store the result
  21232. * @returns the current Vector3
  21233. */
  21234. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21235. /**
  21236. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  21237. * @param x defines the x coordinate of the operand
  21238. * @param y defines the y coordinate of the operand
  21239. * @param z defines the z coordinate of the operand
  21240. * @returns the resulting Vector3
  21241. */
  21242. subtractFromFloats(x: number, y: number, z: number): Vector3;
  21243. /**
  21244. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  21245. * @param x defines the x coordinate of the operand
  21246. * @param y defines the y coordinate of the operand
  21247. * @param z defines the z coordinate of the operand
  21248. * @param result defines the Vector3 object where to store the result
  21249. * @returns the current Vector3
  21250. */
  21251. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  21252. /**
  21253. * Gets a new Vector3 set with the current Vector3 negated coordinates
  21254. * @returns a new Vector3
  21255. */
  21256. negate(): Vector3;
  21257. /**
  21258. * Multiplies the Vector3 coordinates by the float "scale"
  21259. * @param scale defines the multiplier factor
  21260. * @returns the current updated Vector3
  21261. */
  21262. scaleInPlace(scale: number): Vector3;
  21263. /**
  21264. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  21265. * @param scale defines the multiplier factor
  21266. * @returns a new Vector3
  21267. */
  21268. scale(scale: number): Vector3;
  21269. /**
  21270. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  21271. * @param scale defines the multiplier factor
  21272. * @param result defines the Vector3 object where to store the result
  21273. * @returns the current Vector3
  21274. */
  21275. scaleToRef(scale: number, result: Vector3): Vector3;
  21276. /**
  21277. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  21278. * @param scale defines the scale factor
  21279. * @param result defines the Vector3 object where to store the result
  21280. * @returns the unmodified current Vector3
  21281. */
  21282. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  21283. /**
  21284. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  21285. * @param otherVector defines the second operand
  21286. * @returns true if both vectors are equals
  21287. */
  21288. equals(otherVector: DeepImmutable<Vector3>): boolean;
  21289. /**
  21290. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  21291. * @param otherVector defines the second operand
  21292. * @param epsilon defines the minimal distance to define values as equals
  21293. * @returns true if both vectors are distant less than epsilon
  21294. */
  21295. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  21296. /**
  21297. * Returns true if the current Vector3 coordinates equals the given floats
  21298. * @param x defines the x coordinate of the operand
  21299. * @param y defines the y coordinate of the operand
  21300. * @param z defines the z coordinate of the operand
  21301. * @returns true if both vectors are equals
  21302. */
  21303. equalsToFloats(x: number, y: number, z: number): boolean;
  21304. /**
  21305. * Multiplies the current Vector3 coordinates by the given ones
  21306. * @param otherVector defines the second operand
  21307. * @returns the current updated Vector3
  21308. */
  21309. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  21310. /**
  21311. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  21312. * @param otherVector defines the second operand
  21313. * @returns the new Vector3
  21314. */
  21315. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  21316. /**
  21317. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  21318. * @param otherVector defines the second operand
  21319. * @param result defines the Vector3 object where to store the result
  21320. * @returns the current Vector3
  21321. */
  21322. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21323. /**
  21324. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  21325. * @param x defines the x coordinate of the operand
  21326. * @param y defines the y coordinate of the operand
  21327. * @param z defines the z coordinate of the operand
  21328. * @returns the new Vector3
  21329. */
  21330. multiplyByFloats(x: number, y: number, z: number): Vector3;
  21331. /**
  21332. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  21333. * @param otherVector defines the second operand
  21334. * @returns the new Vector3
  21335. */
  21336. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  21337. /**
  21338. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  21339. * @param otherVector defines the second operand
  21340. * @param result defines the Vector3 object where to store the result
  21341. * @returns the current Vector3
  21342. */
  21343. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  21344. /**
  21345. * Divides the current Vector3 coordinates by the given ones.
  21346. * @param otherVector defines the second operand
  21347. * @returns the current updated Vector3
  21348. */
  21349. divideInPlace(otherVector: Vector3): Vector3;
  21350. /**
  21351. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  21352. * @param other defines the second operand
  21353. * @returns the current updated Vector3
  21354. */
  21355. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21356. /**
  21357. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  21358. * @param other defines the second operand
  21359. * @returns the current updated Vector3
  21360. */
  21361. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  21362. /**
  21363. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  21364. * @param x defines the x coordinate of the operand
  21365. * @param y defines the y coordinate of the operand
  21366. * @param z defines the z coordinate of the operand
  21367. * @returns the current updated Vector3
  21368. */
  21369. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21370. /**
  21371. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  21372. * @param x defines the x coordinate of the operand
  21373. * @param y defines the y coordinate of the operand
  21374. * @param z defines the z coordinate of the operand
  21375. * @returns the current updated Vector3
  21376. */
  21377. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  21378. /**
  21379. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  21380. */
  21381. readonly isNonUniform: boolean;
  21382. /**
  21383. * Gets a new Vector3 from current Vector3 floored values
  21384. * @returns a new Vector3
  21385. */
  21386. floor(): Vector3;
  21387. /**
  21388. * Gets a new Vector3 from current Vector3 floored values
  21389. * @returns a new Vector3
  21390. */
  21391. fract(): Vector3;
  21392. /**
  21393. * Gets the length of the Vector3
  21394. * @returns the length of the Vecto3
  21395. */
  21396. length(): number;
  21397. /**
  21398. * Gets the squared length of the Vector3
  21399. * @returns squared length of the Vector3
  21400. */
  21401. lengthSquared(): number;
  21402. /**
  21403. * Normalize the current Vector3.
  21404. * Please note that this is an in place operation.
  21405. * @returns the current updated Vector3
  21406. */
  21407. normalize(): Vector3;
  21408. /**
  21409. * Reorders the x y z properties of the vector in place
  21410. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  21411. * @returns the current updated vector
  21412. */
  21413. reorderInPlace(order: string): this;
  21414. /**
  21415. * Rotates the vector around 0,0,0 by a quaternion
  21416. * @param quaternion the rotation quaternion
  21417. * @param result vector to store the result
  21418. * @returns the resulting vector
  21419. */
  21420. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  21421. /**
  21422. * Rotates a vector around a given point
  21423. * @param quaternion the rotation quaternion
  21424. * @param point the point to rotate around
  21425. * @param result vector to store the result
  21426. * @returns the resulting vector
  21427. */
  21428. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  21429. /**
  21430. * Normalize the current Vector3 with the given input length.
  21431. * Please note that this is an in place operation.
  21432. * @param len the length of the vector
  21433. * @returns the current updated Vector3
  21434. */
  21435. normalizeFromLength(len: number): Vector3;
  21436. /**
  21437. * Normalize the current Vector3 to a new vector
  21438. * @returns the new Vector3
  21439. */
  21440. normalizeToNew(): Vector3;
  21441. /**
  21442. * Normalize the current Vector3 to the reference
  21443. * @param reference define the Vector3 to update
  21444. * @returns the updated Vector3
  21445. */
  21446. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  21447. /**
  21448. * Creates a new Vector3 copied from the current Vector3
  21449. * @returns the new Vector3
  21450. */
  21451. clone(): Vector3;
  21452. /**
  21453. * Copies the given vector coordinates to the current Vector3 ones
  21454. * @param source defines the source Vector3
  21455. * @returns the current updated Vector3
  21456. */
  21457. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  21458. /**
  21459. * Copies the given floats to the current Vector3 coordinates
  21460. * @param x defines the x coordinate of the operand
  21461. * @param y defines the y coordinate of the operand
  21462. * @param z defines the z coordinate of the operand
  21463. * @returns the current updated Vector3
  21464. */
  21465. copyFromFloats(x: number, y: number, z: number): Vector3;
  21466. /**
  21467. * Copies the given floats to the current Vector3 coordinates
  21468. * @param x defines the x coordinate of the operand
  21469. * @param y defines the y coordinate of the operand
  21470. * @param z defines the z coordinate of the operand
  21471. * @returns the current updated Vector3
  21472. */
  21473. set(x: number, y: number, z: number): Vector3;
  21474. /**
  21475. * Copies the given float to the current Vector3 coordinates
  21476. * @param v defines the x, y and z coordinates of the operand
  21477. * @returns the current updated Vector3
  21478. */
  21479. setAll(v: number): Vector3;
  21480. /**
  21481. * Get the clip factor between two vectors
  21482. * @param vector0 defines the first operand
  21483. * @param vector1 defines the second operand
  21484. * @param axis defines the axis to use
  21485. * @param size defines the size along the axis
  21486. * @returns the clip factor
  21487. */
  21488. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  21489. /**
  21490. * Get angle between two vectors
  21491. * @param vector0 angle between vector0 and vector1
  21492. * @param vector1 angle between vector0 and vector1
  21493. * @param normal direction of the normal
  21494. * @return the angle between vector0 and vector1
  21495. */
  21496. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  21497. /**
  21498. * Returns a new Vector3 set from the index "offset" of the given array
  21499. * @param array defines the source array
  21500. * @param offset defines the offset in the source array
  21501. * @returns the new Vector3
  21502. */
  21503. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  21504. /**
  21505. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  21506. * This function is deprecated. Use FromArray instead
  21507. * @param array defines the source array
  21508. * @param offset defines the offset in the source array
  21509. * @returns the new Vector3
  21510. */
  21511. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  21512. /**
  21513. * Sets the given vector "result" with the element values from the index "offset" of the given array
  21514. * @param array defines the source array
  21515. * @param offset defines the offset in the source array
  21516. * @param result defines the Vector3 where to store the result
  21517. */
  21518. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  21519. /**
  21520. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  21521. * This function is deprecated. Use FromArrayToRef instead.
  21522. * @param array defines the source array
  21523. * @param offset defines the offset in the source array
  21524. * @param result defines the Vector3 where to store the result
  21525. */
  21526. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  21527. /**
  21528. * Sets the given vector "result" with the given floats.
  21529. * @param x defines the x coordinate of the source
  21530. * @param y defines the y coordinate of the source
  21531. * @param z defines the z coordinate of the source
  21532. * @param result defines the Vector3 where to store the result
  21533. */
  21534. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  21535. /**
  21536. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  21537. * @returns a new empty Vector3
  21538. */
  21539. static Zero(): Vector3;
  21540. /**
  21541. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  21542. * @returns a new unit Vector3
  21543. */
  21544. static One(): Vector3;
  21545. /**
  21546. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  21547. * @returns a new up Vector3
  21548. */
  21549. static Up(): Vector3;
  21550. /**
  21551. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  21552. * @returns a new down Vector3
  21553. */
  21554. static Down(): Vector3;
  21555. /**
  21556. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  21557. * @returns a new forward Vector3
  21558. */
  21559. static Forward(): Vector3;
  21560. /**
  21561. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  21562. * @returns a new forward Vector3
  21563. */
  21564. static Backward(): Vector3;
  21565. /**
  21566. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  21567. * @returns a new right Vector3
  21568. */
  21569. static Right(): Vector3;
  21570. /**
  21571. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  21572. * @returns a new left Vector3
  21573. */
  21574. static Left(): Vector3;
  21575. /**
  21576. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  21577. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21578. * @param vector defines the Vector3 to transform
  21579. * @param transformation defines the transformation matrix
  21580. * @returns the transformed Vector3
  21581. */
  21582. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21583. /**
  21584. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  21585. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  21586. * @param vector defines the Vector3 to transform
  21587. * @param transformation defines the transformation matrix
  21588. * @param result defines the Vector3 where to store the result
  21589. */
  21590. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21591. /**
  21592. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  21593. * This method computes tranformed coordinates only, not transformed direction vectors
  21594. * @param x define the x coordinate of the source vector
  21595. * @param y define the y coordinate of the source vector
  21596. * @param z define the z coordinate of the source vector
  21597. * @param transformation defines the transformation matrix
  21598. * @param result defines the Vector3 where to store the result
  21599. */
  21600. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21601. /**
  21602. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  21603. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21604. * @param vector defines the Vector3 to transform
  21605. * @param transformation defines the transformation matrix
  21606. * @returns the new Vector3
  21607. */
  21608. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  21609. /**
  21610. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  21611. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21612. * @param vector defines the Vector3 to transform
  21613. * @param transformation defines the transformation matrix
  21614. * @param result defines the Vector3 where to store the result
  21615. */
  21616. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21617. /**
  21618. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  21619. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  21620. * @param x define the x coordinate of the source vector
  21621. * @param y define the y coordinate of the source vector
  21622. * @param z define the z coordinate of the source vector
  21623. * @param transformation defines the transformation matrix
  21624. * @param result defines the Vector3 where to store the result
  21625. */
  21626. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  21627. /**
  21628. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  21629. * @param value1 defines the first control point
  21630. * @param value2 defines the second control point
  21631. * @param value3 defines the third control point
  21632. * @param value4 defines the fourth control point
  21633. * @param amount defines the amount on the spline to use
  21634. * @returns the new Vector3
  21635. */
  21636. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  21637. /**
  21638. * 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"
  21639. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21640. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21641. * @param value defines the current value
  21642. * @param min defines the lower range value
  21643. * @param max defines the upper range value
  21644. * @returns the new Vector3
  21645. */
  21646. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  21647. /**
  21648. * 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"
  21649. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  21650. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  21651. * @param value defines the current value
  21652. * @param min defines the lower range value
  21653. * @param max defines the upper range value
  21654. * @param result defines the Vector3 where to store the result
  21655. */
  21656. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  21657. /**
  21658. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  21659. * @param value1 defines the first control point
  21660. * @param tangent1 defines the first tangent vector
  21661. * @param value2 defines the second control point
  21662. * @param tangent2 defines the second tangent vector
  21663. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  21664. * @returns the new Vector3
  21665. */
  21666. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  21667. /**
  21668. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  21669. * @param start defines the start value
  21670. * @param end defines the end value
  21671. * @param amount max defines amount between both (between 0 and 1)
  21672. * @returns the new Vector3
  21673. */
  21674. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  21675. /**
  21676. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  21677. * @param start defines the start value
  21678. * @param end defines the end value
  21679. * @param amount max defines amount between both (between 0 and 1)
  21680. * @param result defines the Vector3 where to store the result
  21681. */
  21682. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  21683. /**
  21684. * Returns the dot product (float) between the vectors "left" and "right"
  21685. * @param left defines the left operand
  21686. * @param right defines the right operand
  21687. * @returns the dot product
  21688. */
  21689. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  21690. /**
  21691. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  21692. * The cross product is then orthogonal to both "left" and "right"
  21693. * @param left defines the left operand
  21694. * @param right defines the right operand
  21695. * @returns the cross product
  21696. */
  21697. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21698. /**
  21699. * Sets the given vector "result" with the cross product of "left" and "right"
  21700. * The cross product is then orthogonal to both "left" and "right"
  21701. * @param left defines the left operand
  21702. * @param right defines the right operand
  21703. * @param result defines the Vector3 where to store the result
  21704. */
  21705. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  21706. /**
  21707. * Returns a new Vector3 as the normalization of the given vector
  21708. * @param vector defines the Vector3 to normalize
  21709. * @returns the new Vector3
  21710. */
  21711. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  21712. /**
  21713. * Sets the given vector "result" with the normalization of the given first vector
  21714. * @param vector defines the Vector3 to normalize
  21715. * @param result defines the Vector3 where to store the result
  21716. */
  21717. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  21718. /**
  21719. * Project a Vector3 onto screen space
  21720. * @param vector defines the Vector3 to project
  21721. * @param world defines the world matrix to use
  21722. * @param transform defines the transform (view x projection) matrix to use
  21723. * @param viewport defines the screen viewport to use
  21724. * @returns the new Vector3
  21725. */
  21726. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  21727. /** @hidden */
  21728. private static UnprojectFromInvertedMatrixToRef;
  21729. /**
  21730. * Unproject from screen space to object space
  21731. * @param source defines the screen space Vector3 to use
  21732. * @param viewportWidth defines the current width of the viewport
  21733. * @param viewportHeight defines the current height of the viewport
  21734. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21735. * @param transform defines the transform (view x projection) matrix to use
  21736. * @returns the new Vector3
  21737. */
  21738. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  21739. /**
  21740. * Unproject from screen space to object space
  21741. * @param source defines the screen space Vector3 to use
  21742. * @param viewportWidth defines the current width of the viewport
  21743. * @param viewportHeight defines the current height of the viewport
  21744. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21745. * @param view defines the view matrix to use
  21746. * @param projection defines the projection matrix to use
  21747. * @returns the new Vector3
  21748. */
  21749. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  21750. /**
  21751. * Unproject from screen space to object space
  21752. * @param source defines the screen space Vector3 to use
  21753. * @param viewportWidth defines the current width of the viewport
  21754. * @param viewportHeight defines the current height of the viewport
  21755. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21756. * @param view defines the view matrix to use
  21757. * @param projection defines the projection matrix to use
  21758. * @param result defines the Vector3 where to store the result
  21759. */
  21760. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21761. /**
  21762. * Unproject from screen space to object space
  21763. * @param sourceX defines the screen space x coordinate to use
  21764. * @param sourceY defines the screen space y coordinate to use
  21765. * @param sourceZ defines the screen space z coordinate to use
  21766. * @param viewportWidth defines the current width of the viewport
  21767. * @param viewportHeight defines the current height of the viewport
  21768. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21769. * @param view defines the view matrix to use
  21770. * @param projection defines the projection matrix to use
  21771. * @param result defines the Vector3 where to store the result
  21772. */
  21773. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  21774. /**
  21775. * Unproject a ray from screen space to object space
  21776. * @param sourceX defines the screen space x coordinate to use
  21777. * @param sourceY defines the screen space y coordinate to use
  21778. * @param viewportWidth defines the current width of the viewport
  21779. * @param viewportHeight defines the current height of the viewport
  21780. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21781. * @param view defines the view matrix to use
  21782. * @param projection defines the projection matrix to use
  21783. * @param ray defines the Ray where to store the result
  21784. */
  21785. static UnprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, ray: Ray): void;
  21786. /**
  21787. * Gets the minimal coordinate values between two Vector3
  21788. * @param left defines the first operand
  21789. * @param right defines the second operand
  21790. * @returns the new Vector3
  21791. */
  21792. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21793. /**
  21794. * Gets the maximal coordinate values between two Vector3
  21795. * @param left defines the first operand
  21796. * @param right defines the second operand
  21797. * @returns the new Vector3
  21798. */
  21799. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  21800. /**
  21801. * Returns the distance between the vectors "value1" and "value2"
  21802. * @param value1 defines the first operand
  21803. * @param value2 defines the second operand
  21804. * @returns the distance
  21805. */
  21806. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21807. /**
  21808. * Returns the squared distance between the vectors "value1" and "value2"
  21809. * @param value1 defines the first operand
  21810. * @param value2 defines the second operand
  21811. * @returns the squared distance
  21812. */
  21813. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  21814. /**
  21815. * Returns a new Vector3 located at the center between "value1" and "value2"
  21816. * @param value1 defines the first operand
  21817. * @param value2 defines the second operand
  21818. * @returns the new Vector3
  21819. */
  21820. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  21821. /**
  21822. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  21823. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  21824. * to something in order to rotate it from its local system to the given target system
  21825. * Note: axis1, axis2 and axis3 are normalized during this operation
  21826. * @param axis1 defines the first axis
  21827. * @param axis2 defines the second axis
  21828. * @param axis3 defines the third axis
  21829. * @returns a new Vector3
  21830. */
  21831. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  21832. /**
  21833. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  21834. * @param axis1 defines the first axis
  21835. * @param axis2 defines the second axis
  21836. * @param axis3 defines the third axis
  21837. * @param ref defines the Vector3 where to store the result
  21838. */
  21839. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  21840. }
  21841. /**
  21842. * Vector4 class created for EulerAngle class conversion to Quaternion
  21843. */
  21844. class Vector4 {
  21845. /** x value of the vector */
  21846. x: number;
  21847. /** y value of the vector */
  21848. y: number;
  21849. /** z value of the vector */
  21850. z: number;
  21851. /** w value of the vector */
  21852. w: number;
  21853. /**
  21854. * Creates a Vector4 object from the given floats.
  21855. * @param x x value of the vector
  21856. * @param y y value of the vector
  21857. * @param z z value of the vector
  21858. * @param w w value of the vector
  21859. */
  21860. constructor(
  21861. /** x value of the vector */
  21862. x: number,
  21863. /** y value of the vector */
  21864. y: number,
  21865. /** z value of the vector */
  21866. z: number,
  21867. /** w value of the vector */
  21868. w: number);
  21869. /**
  21870. * Returns the string with the Vector4 coordinates.
  21871. * @returns a string containing all the vector values
  21872. */
  21873. toString(): string;
  21874. /**
  21875. * Returns the string "Vector4".
  21876. * @returns "Vector4"
  21877. */
  21878. getClassName(): string;
  21879. /**
  21880. * Returns the Vector4 hash code.
  21881. * @returns a unique hash code
  21882. */
  21883. getHashCode(): number;
  21884. /**
  21885. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  21886. * @returns the resulting array
  21887. */
  21888. asArray(): number[];
  21889. /**
  21890. * Populates the given array from the given index with the Vector4 coordinates.
  21891. * @param array array to populate
  21892. * @param index index of the array to start at (default: 0)
  21893. * @returns the Vector4.
  21894. */
  21895. toArray(array: FloatArray, index?: number): Vector4;
  21896. /**
  21897. * Adds the given vector to the current Vector4.
  21898. * @param otherVector the vector to add
  21899. * @returns the updated Vector4.
  21900. */
  21901. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21902. /**
  21903. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  21904. * @param otherVector the vector to add
  21905. * @returns the resulting vector
  21906. */
  21907. add(otherVector: DeepImmutable<Vector4>): Vector4;
  21908. /**
  21909. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  21910. * @param otherVector the vector to add
  21911. * @param result the vector to store the result
  21912. * @returns the current Vector4.
  21913. */
  21914. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21915. /**
  21916. * Subtract in place the given vector from the current Vector4.
  21917. * @param otherVector the vector to subtract
  21918. * @returns the updated Vector4.
  21919. */
  21920. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  21921. /**
  21922. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  21923. * @param otherVector the vector to add
  21924. * @returns the new vector with the result
  21925. */
  21926. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  21927. /**
  21928. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  21929. * @param otherVector the vector to subtract
  21930. * @param result the vector to store the result
  21931. * @returns the current Vector4.
  21932. */
  21933. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  21934. /**
  21935. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21936. */
  21937. /**
  21938. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21939. * @param x value to subtract
  21940. * @param y value to subtract
  21941. * @param z value to subtract
  21942. * @param w value to subtract
  21943. * @returns new vector containing the result
  21944. */
  21945. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  21946. /**
  21947. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  21948. * @param x value to subtract
  21949. * @param y value to subtract
  21950. * @param z value to subtract
  21951. * @param w value to subtract
  21952. * @param result the vector to store the result in
  21953. * @returns the current Vector4.
  21954. */
  21955. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  21956. /**
  21957. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  21958. * @returns a new vector with the negated values
  21959. */
  21960. negate(): Vector4;
  21961. /**
  21962. * Multiplies the current Vector4 coordinates by scale (float).
  21963. * @param scale the number to scale with
  21964. * @returns the updated Vector4.
  21965. */
  21966. scaleInPlace(scale: number): Vector4;
  21967. /**
  21968. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  21969. * @param scale the number to scale with
  21970. * @returns a new vector with the result
  21971. */
  21972. scale(scale: number): Vector4;
  21973. /**
  21974. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  21975. * @param scale the number to scale with
  21976. * @param result a vector to store the result in
  21977. * @returns the current Vector4.
  21978. */
  21979. scaleToRef(scale: number, result: Vector4): Vector4;
  21980. /**
  21981. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  21982. * @param scale defines the scale factor
  21983. * @param result defines the Vector4 object where to store the result
  21984. * @returns the unmodified current Vector4
  21985. */
  21986. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  21987. /**
  21988. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  21989. * @param otherVector the vector to compare against
  21990. * @returns true if they are equal
  21991. */
  21992. equals(otherVector: DeepImmutable<Vector4>): boolean;
  21993. /**
  21994. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  21995. * @param otherVector vector to compare against
  21996. * @param epsilon (Default: very small number)
  21997. * @returns true if they are equal
  21998. */
  21999. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  22000. /**
  22001. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  22002. * @param x x value to compare against
  22003. * @param y y value to compare against
  22004. * @param z z value to compare against
  22005. * @param w w value to compare against
  22006. * @returns true if equal
  22007. */
  22008. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  22009. /**
  22010. * Multiplies in place the current Vector4 by the given one.
  22011. * @param otherVector vector to multiple with
  22012. * @returns the updated Vector4.
  22013. */
  22014. multiplyInPlace(otherVector: Vector4): Vector4;
  22015. /**
  22016. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  22017. * @param otherVector vector to multiple with
  22018. * @returns resulting new vector
  22019. */
  22020. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  22021. /**
  22022. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  22023. * @param otherVector vector to multiple with
  22024. * @param result vector to store the result
  22025. * @returns the current Vector4.
  22026. */
  22027. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22028. /**
  22029. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  22030. * @param x x value multiply with
  22031. * @param y y value multiply with
  22032. * @param z z value multiply with
  22033. * @param w w value multiply with
  22034. * @returns resulting new vector
  22035. */
  22036. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  22037. /**
  22038. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  22039. * @param otherVector vector to devide with
  22040. * @returns resulting new vector
  22041. */
  22042. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  22043. /**
  22044. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  22045. * @param otherVector vector to devide with
  22046. * @param result vector to store the result
  22047. * @returns the current Vector4.
  22048. */
  22049. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  22050. /**
  22051. * Divides the current Vector3 coordinates by the given ones.
  22052. * @param otherVector vector to devide with
  22053. * @returns the updated Vector3.
  22054. */
  22055. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  22056. /**
  22057. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  22058. * @param other defines the second operand
  22059. * @returns the current updated Vector4
  22060. */
  22061. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22062. /**
  22063. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  22064. * @param other defines the second operand
  22065. * @returns the current updated Vector4
  22066. */
  22067. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  22068. /**
  22069. * Gets a new Vector4 from current Vector4 floored values
  22070. * @returns a new Vector4
  22071. */
  22072. floor(): Vector4;
  22073. /**
  22074. * Gets a new Vector4 from current Vector3 floored values
  22075. * @returns a new Vector4
  22076. */
  22077. fract(): Vector4;
  22078. /**
  22079. * Returns the Vector4 length (float).
  22080. * @returns the length
  22081. */
  22082. length(): number;
  22083. /**
  22084. * Returns the Vector4 squared length (float).
  22085. * @returns the length squared
  22086. */
  22087. lengthSquared(): number;
  22088. /**
  22089. * Normalizes in place the Vector4.
  22090. * @returns the updated Vector4.
  22091. */
  22092. normalize(): Vector4;
  22093. /**
  22094. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  22095. * @returns this converted to a new vector3
  22096. */
  22097. toVector3(): Vector3;
  22098. /**
  22099. * Returns a new Vector4 copied from the current one.
  22100. * @returns the new cloned vector
  22101. */
  22102. clone(): Vector4;
  22103. /**
  22104. * Updates the current Vector4 with the given one coordinates.
  22105. * @param source the source vector to copy from
  22106. * @returns the updated Vector4.
  22107. */
  22108. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  22109. /**
  22110. * Updates the current Vector4 coordinates with the given floats.
  22111. * @param x float to copy from
  22112. * @param y float to copy from
  22113. * @param z float to copy from
  22114. * @param w float to copy from
  22115. * @returns the updated Vector4.
  22116. */
  22117. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  22118. /**
  22119. * Updates the current Vector4 coordinates with the given floats.
  22120. * @param x float to set from
  22121. * @param y float to set from
  22122. * @param z float to set from
  22123. * @param w float to set from
  22124. * @returns the updated Vector4.
  22125. */
  22126. set(x: number, y: number, z: number, w: number): Vector4;
  22127. /**
  22128. * Copies the given float to the current Vector3 coordinates
  22129. * @param v defines the x, y, z and w coordinates of the operand
  22130. * @returns the current updated Vector3
  22131. */
  22132. setAll(v: number): Vector4;
  22133. /**
  22134. * Returns a new Vector4 set from the starting index of the given array.
  22135. * @param array the array to pull values from
  22136. * @param offset the offset into the array to start at
  22137. * @returns the new vector
  22138. */
  22139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  22140. /**
  22141. * Updates the given vector "result" from the starting index of the given array.
  22142. * @param array the array to pull values from
  22143. * @param offset the offset into the array to start at
  22144. * @param result the vector to store the result in
  22145. */
  22146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  22147. /**
  22148. * Updates the given vector "result" from the starting index of the given Float32Array.
  22149. * @param array the array to pull values from
  22150. * @param offset the offset into the array to start at
  22151. * @param result the vector to store the result in
  22152. */
  22153. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  22154. /**
  22155. * Updates the given vector "result" coordinates from the given floats.
  22156. * @param x float to set from
  22157. * @param y float to set from
  22158. * @param z float to set from
  22159. * @param w float to set from
  22160. * @param result the vector to the floats in
  22161. */
  22162. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  22163. /**
  22164. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  22165. * @returns the new vector
  22166. */
  22167. static Zero(): Vector4;
  22168. /**
  22169. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  22170. * @returns the new vector
  22171. */
  22172. static One(): Vector4;
  22173. /**
  22174. * Returns a new normalized Vector4 from the given one.
  22175. * @param vector the vector to normalize
  22176. * @returns the vector
  22177. */
  22178. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  22179. /**
  22180. * Updates the given vector "result" from the normalization of the given one.
  22181. * @param vector the vector to normalize
  22182. * @param result the vector to store the result in
  22183. */
  22184. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  22185. /**
  22186. * Returns a vector with the minimum values from the left and right vectors
  22187. * @param left left vector to minimize
  22188. * @param right right vector to minimize
  22189. * @returns a new vector with the minimum of the left and right vector values
  22190. */
  22191. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22192. /**
  22193. * Returns a vector with the maximum values from the left and right vectors
  22194. * @param left left vector to maximize
  22195. * @param right right vector to maximize
  22196. * @returns a new vector with the maximum of the left and right vector values
  22197. */
  22198. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  22199. /**
  22200. * Returns the distance (float) between the vectors "value1" and "value2".
  22201. * @param value1 value to calulate the distance between
  22202. * @param value2 value to calulate the distance between
  22203. * @return the distance between the two vectors
  22204. */
  22205. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22206. /**
  22207. * Returns the squared distance (float) between the vectors "value1" and "value2".
  22208. * @param value1 value to calulate the distance between
  22209. * @param value2 value to calulate the distance between
  22210. * @return the distance between the two vectors squared
  22211. */
  22212. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  22213. /**
  22214. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  22215. * @param value1 value to calulate the center between
  22216. * @param value2 value to calulate the center between
  22217. * @return the center between the two vectors
  22218. */
  22219. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  22220. /**
  22221. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  22222. * This methods computes transformed normalized direction vectors only.
  22223. * @param vector the vector to transform
  22224. * @param transformation the transformation matrix to apply
  22225. * @returns the new vector
  22226. */
  22227. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  22228. /**
  22229. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  22230. * This methods computes transformed normalized direction vectors only.
  22231. * @param vector the vector to transform
  22232. * @param transformation the transformation matrix to apply
  22233. * @param result the vector to store the result in
  22234. */
  22235. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22236. /**
  22237. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  22238. * This methods computes transformed normalized direction vectors only.
  22239. * @param x value to transform
  22240. * @param y value to transform
  22241. * @param z value to transform
  22242. * @param w value to transform
  22243. * @param transformation the transformation matrix to apply
  22244. * @param result the vector to store the results in
  22245. */
  22246. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  22247. }
  22248. /**
  22249. * Interface for the size containing width and height
  22250. */
  22251. interface ISize {
  22252. /**
  22253. * Width
  22254. */
  22255. width: number;
  22256. /**
  22257. * Heighht
  22258. */
  22259. height: number;
  22260. }
  22261. /**
  22262. * Size containing widht and height
  22263. */
  22264. class Size implements ISize {
  22265. /**
  22266. * Width
  22267. */
  22268. width: number;
  22269. /**
  22270. * Height
  22271. */
  22272. height: number;
  22273. /**
  22274. * Creates a Size object from the given width and height (floats).
  22275. * @param width width of the new size
  22276. * @param height height of the new size
  22277. */
  22278. constructor(width: number, height: number);
  22279. /**
  22280. * Returns a string with the Size width and height
  22281. * @returns a string with the Size width and height
  22282. */
  22283. toString(): string;
  22284. /**
  22285. * "Size"
  22286. * @returns the string "Size"
  22287. */
  22288. getClassName(): string;
  22289. /**
  22290. * Returns the Size hash code.
  22291. * @returns a hash code for a unique width and height
  22292. */
  22293. getHashCode(): number;
  22294. /**
  22295. * Updates the current size from the given one.
  22296. * @param src the given size
  22297. */
  22298. copyFrom(src: Size): void;
  22299. /**
  22300. * Updates in place the current Size from the given floats.
  22301. * @param width width of the new size
  22302. * @param height height of the new size
  22303. * @returns the updated Size.
  22304. */
  22305. copyFromFloats(width: number, height: number): Size;
  22306. /**
  22307. * Updates in place the current Size from the given floats.
  22308. * @param width width to set
  22309. * @param height height to set
  22310. * @returns the updated Size.
  22311. */
  22312. set(width: number, height: number): Size;
  22313. /**
  22314. * Multiplies the width and height by numbers
  22315. * @param w factor to multiple the width by
  22316. * @param h factor to multiple the height by
  22317. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  22318. */
  22319. multiplyByFloats(w: number, h: number): Size;
  22320. /**
  22321. * Clones the size
  22322. * @returns a new Size copied from the given one.
  22323. */
  22324. clone(): Size;
  22325. /**
  22326. * True if the current Size and the given one width and height are strictly equal.
  22327. * @param other the other size to compare against
  22328. * @returns True if the current Size and the given one width and height are strictly equal.
  22329. */
  22330. equals(other: Size): boolean;
  22331. /**
  22332. * The surface of the Size : width * height (float).
  22333. */
  22334. readonly surface: number;
  22335. /**
  22336. * Create a new size of zero
  22337. * @returns a new Size set to (0.0, 0.0)
  22338. */
  22339. static Zero(): Size;
  22340. /**
  22341. * Sums the width and height of two sizes
  22342. * @param otherSize size to add to this size
  22343. * @returns a new Size set as the addition result of the current Size and the given one.
  22344. */
  22345. add(otherSize: Size): Size;
  22346. /**
  22347. * Subtracts the width and height of two
  22348. * @param otherSize size to subtract to this size
  22349. * @returns a new Size set as the subtraction result of the given one from the current Size.
  22350. */
  22351. subtract(otherSize: Size): Size;
  22352. /**
  22353. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  22354. * @param start starting size to lerp between
  22355. * @param end end size to lerp between
  22356. * @param amount amount to lerp between the start and end values
  22357. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  22358. */
  22359. static Lerp(start: Size, end: Size, amount: number): Size;
  22360. }
  22361. /**
  22362. * Class used to store quaternion data
  22363. * @see https://en.wikipedia.org/wiki/Quaternion
  22364. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  22365. */
  22366. class Quaternion {
  22367. /** defines the first component (0 by default) */
  22368. x: number;
  22369. /** defines the second component (0 by default) */
  22370. y: number;
  22371. /** defines the third component (0 by default) */
  22372. z: number;
  22373. /** defines the fourth component (1.0 by default) */
  22374. w: number;
  22375. /**
  22376. * Creates a new Quaternion from the given floats
  22377. * @param x defines the first component (0 by default)
  22378. * @param y defines the second component (0 by default)
  22379. * @param z defines the third component (0 by default)
  22380. * @param w defines the fourth component (1.0 by default)
  22381. */
  22382. constructor(
  22383. /** defines the first component (0 by default) */
  22384. x?: number,
  22385. /** defines the second component (0 by default) */
  22386. y?: number,
  22387. /** defines the third component (0 by default) */
  22388. z?: number,
  22389. /** defines the fourth component (1.0 by default) */
  22390. w?: number);
  22391. /**
  22392. * Gets a string representation for the current quaternion
  22393. * @returns a string with the Quaternion coordinates
  22394. */
  22395. toString(): string;
  22396. /**
  22397. * Gets the class name of the quaternion
  22398. * @returns the string "Quaternion"
  22399. */
  22400. getClassName(): string;
  22401. /**
  22402. * Gets a hash code for this quaternion
  22403. * @returns the quaternion hash code
  22404. */
  22405. getHashCode(): number;
  22406. /**
  22407. * Copy the quaternion to an array
  22408. * @returns a new array populated with 4 elements from the quaternion coordinates
  22409. */
  22410. asArray(): number[];
  22411. /**
  22412. * Check if two quaternions are equals
  22413. * @param otherQuaternion defines the second operand
  22414. * @return true if the current quaternion and the given one coordinates are strictly equals
  22415. */
  22416. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  22417. /**
  22418. * Clone the current quaternion
  22419. * @returns a new quaternion copied from the current one
  22420. */
  22421. clone(): Quaternion;
  22422. /**
  22423. * Copy a quaternion to the current one
  22424. * @param other defines the other quaternion
  22425. * @returns the updated current quaternion
  22426. */
  22427. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  22428. /**
  22429. * Updates the current quaternion with the given float coordinates
  22430. * @param x defines the x coordinate
  22431. * @param y defines the y coordinate
  22432. * @param z defines the z coordinate
  22433. * @param w defines the w coordinate
  22434. * @returns the updated current quaternion
  22435. */
  22436. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  22437. /**
  22438. * Updates the current quaternion from the given float coordinates
  22439. * @param x defines the x coordinate
  22440. * @param y defines the y coordinate
  22441. * @param z defines the z coordinate
  22442. * @param w defines the w coordinate
  22443. * @returns the updated current quaternion
  22444. */
  22445. set(x: number, y: number, z: number, w: number): Quaternion;
  22446. /**
  22447. * Adds two quaternions
  22448. * @param other defines the second operand
  22449. * @returns a new quaternion as the addition result of the given one and the current quaternion
  22450. */
  22451. add(other: DeepImmutable<Quaternion>): Quaternion;
  22452. /**
  22453. * Add a quaternion to the current one
  22454. * @param other defines the quaternion to add
  22455. * @returns the current quaternion
  22456. */
  22457. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  22458. /**
  22459. * Subtract two quaternions
  22460. * @param other defines the second operand
  22461. * @returns a new quaternion as the subtraction result of the given one from the current one
  22462. */
  22463. subtract(other: Quaternion): Quaternion;
  22464. /**
  22465. * Multiplies the current quaternion by a scale factor
  22466. * @param value defines the scale factor
  22467. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  22468. */
  22469. scale(value: number): Quaternion;
  22470. /**
  22471. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  22472. * @param scale defines the scale factor
  22473. * @param result defines the Quaternion object where to store the result
  22474. * @returns the unmodified current quaternion
  22475. */
  22476. scaleToRef(scale: number, result: Quaternion): Quaternion;
  22477. /**
  22478. * Multiplies in place the current quaternion by a scale factor
  22479. * @param value defines the scale factor
  22480. * @returns the current modified quaternion
  22481. */
  22482. scaleInPlace(value: number): Quaternion;
  22483. /**
  22484. * Scale the current quaternion values by a factor and add the result to a given quaternion
  22485. * @param scale defines the scale factor
  22486. * @param result defines the Quaternion object where to store the result
  22487. * @returns the unmodified current quaternion
  22488. */
  22489. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  22490. /**
  22491. * Multiplies two quaternions
  22492. * @param q1 defines the second operand
  22493. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  22494. */
  22495. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  22496. /**
  22497. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  22498. * @param q1 defines the second operand
  22499. * @param result defines the target quaternion
  22500. * @returns the current quaternion
  22501. */
  22502. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  22503. /**
  22504. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  22505. * @param q1 defines the second operand
  22506. * @returns the currentupdated quaternion
  22507. */
  22508. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  22509. /**
  22510. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  22511. * @param ref defines the target quaternion
  22512. * @returns the current quaternion
  22513. */
  22514. conjugateToRef(ref: Quaternion): Quaternion;
  22515. /**
  22516. * Conjugates in place (1-q) the current quaternion
  22517. * @returns the current updated quaternion
  22518. */
  22519. conjugateInPlace(): Quaternion;
  22520. /**
  22521. * Conjugates in place (1-q) the current quaternion
  22522. * @returns a new quaternion
  22523. */
  22524. conjugate(): Quaternion;
  22525. /**
  22526. * Gets length of current quaternion
  22527. * @returns the quaternion length (float)
  22528. */
  22529. length(): number;
  22530. /**
  22531. * Normalize in place the current quaternion
  22532. * @returns the current updated quaternion
  22533. */
  22534. normalize(): Quaternion;
  22535. /**
  22536. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  22537. * @param order is a reserved parameter and is ignore for now
  22538. * @returns a new Vector3 containing the Euler angles
  22539. */
  22540. toEulerAngles(order?: string): Vector3;
  22541. /**
  22542. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  22543. * @param result defines the vector which will be filled with the Euler angles
  22544. * @param order is a reserved parameter and is ignore for now
  22545. * @returns the current unchanged quaternion
  22546. */
  22547. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  22548. /**
  22549. * Updates the given rotation matrix with the current quaternion values
  22550. * @param result defines the target matrix
  22551. * @returns the current unchanged quaternion
  22552. */
  22553. toRotationMatrix(result: Matrix): Quaternion;
  22554. /**
  22555. * Updates the current quaternion from the given rotation matrix values
  22556. * @param matrix defines the source matrix
  22557. * @returns the current updated quaternion
  22558. */
  22559. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22560. /**
  22561. * Creates a new quaternion from a rotation matrix
  22562. * @param matrix defines the source matrix
  22563. * @returns a new quaternion created from the given rotation matrix values
  22564. */
  22565. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  22566. /**
  22567. * Updates the given quaternion with the given rotation matrix values
  22568. * @param matrix defines the source matrix
  22569. * @param result defines the target quaternion
  22570. */
  22571. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  22572. /**
  22573. * Returns the dot product (float) between the quaternions "left" and "right"
  22574. * @param left defines the left operand
  22575. * @param right defines the right operand
  22576. * @returns the dot product
  22577. */
  22578. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  22579. /**
  22580. * Checks if the two quaternions are close to each other
  22581. * @param quat0 defines the first quaternion to check
  22582. * @param quat1 defines the second quaternion to check
  22583. * @returns true if the two quaternions are close to each other
  22584. */
  22585. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  22586. /**
  22587. * Creates an empty quaternion
  22588. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  22589. */
  22590. static Zero(): Quaternion;
  22591. /**
  22592. * Inverse a given quaternion
  22593. * @param q defines the source quaternion
  22594. * @returns a new quaternion as the inverted current quaternion
  22595. */
  22596. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  22597. /**
  22598. * Inverse a given quaternion
  22599. * @param q defines the source quaternion
  22600. * @param result the quaternion the result will be stored in
  22601. * @returns the result quaternion
  22602. */
  22603. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  22604. /**
  22605. * Creates an identity quaternion
  22606. * @returns the identity quaternion
  22607. */
  22608. static Identity(): Quaternion;
  22609. /**
  22610. * Gets a boolean indicating if the given quaternion is identity
  22611. * @param quaternion defines the quaternion to check
  22612. * @returns true if the quaternion is identity
  22613. */
  22614. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  22615. /**
  22616. * Creates a quaternion from a rotation around an axis
  22617. * @param axis defines the axis to use
  22618. * @param angle defines the angle to use
  22619. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  22620. */
  22621. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  22622. /**
  22623. * Creates a rotation around an axis and stores it into the given quaternion
  22624. * @param axis defines the axis to use
  22625. * @param angle defines the angle to use
  22626. * @param result defines the target quaternion
  22627. * @returns the target quaternion
  22628. */
  22629. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  22630. /**
  22631. * Creates a new quaternion from data stored into an array
  22632. * @param array defines the data source
  22633. * @param offset defines the offset in the source array where the data starts
  22634. * @returns a new quaternion
  22635. */
  22636. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  22637. /**
  22638. * Create a quaternion from Euler rotation angles
  22639. * @param x Pitch
  22640. * @param y Yaw
  22641. * @param z Roll
  22642. * @returns the new Quaternion
  22643. */
  22644. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  22645. /**
  22646. * Updates a quaternion from Euler rotation angles
  22647. * @param x Pitch
  22648. * @param y Yaw
  22649. * @param z Roll
  22650. * @param result the quaternion to store the result
  22651. * @returns the updated quaternion
  22652. */
  22653. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  22654. /**
  22655. * Create a quaternion from Euler rotation vector
  22656. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22657. * @returns the new Quaternion
  22658. */
  22659. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  22660. /**
  22661. * Updates a quaternion from Euler rotation vector
  22662. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  22663. * @param result the quaternion to store the result
  22664. * @returns the updated quaternion
  22665. */
  22666. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  22667. /**
  22668. * Creates a new quaternion from the given Euler float angles (y, x, z)
  22669. * @param yaw defines the rotation around Y axis
  22670. * @param pitch defines the rotation around X axis
  22671. * @param roll defines the rotation around Z axis
  22672. * @returns the new quaternion
  22673. */
  22674. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  22675. /**
  22676. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  22677. * @param yaw defines the rotation around Y axis
  22678. * @param pitch defines the rotation around X axis
  22679. * @param roll defines the rotation around Z axis
  22680. * @param result defines the target quaternion
  22681. */
  22682. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  22683. /**
  22684. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  22685. * @param alpha defines the rotation around first axis
  22686. * @param beta defines the rotation around second axis
  22687. * @param gamma defines the rotation around third axis
  22688. * @returns the new quaternion
  22689. */
  22690. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  22691. /**
  22692. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  22693. * @param alpha defines the rotation around first axis
  22694. * @param beta defines the rotation around second axis
  22695. * @param gamma defines the rotation around third axis
  22696. * @param result defines the target quaternion
  22697. */
  22698. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  22699. /**
  22700. * 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)
  22701. * @param axis1 defines the first axis
  22702. * @param axis2 defines the second axis
  22703. * @param axis3 defines the third axis
  22704. * @returns the new quaternion
  22705. */
  22706. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  22707. /**
  22708. * 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
  22709. * @param axis1 defines the first axis
  22710. * @param axis2 defines the second axis
  22711. * @param axis3 defines the third axis
  22712. * @param ref defines the target quaternion
  22713. */
  22714. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  22715. /**
  22716. * Interpolates between two quaternions
  22717. * @param left defines first quaternion
  22718. * @param right defines second quaternion
  22719. * @param amount defines the gradient to use
  22720. * @returns the new interpolated quaternion
  22721. */
  22722. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22723. /**
  22724. * Interpolates between two quaternions and stores it into a target quaternion
  22725. * @param left defines first quaternion
  22726. * @param right defines second quaternion
  22727. * @param amount defines the gradient to use
  22728. * @param result defines the target quaternion
  22729. */
  22730. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  22731. /**
  22732. * Interpolate between two quaternions using Hermite interpolation
  22733. * @param value1 defines first quaternion
  22734. * @param tangent1 defines the incoming tangent
  22735. * @param value2 defines second quaternion
  22736. * @param tangent2 defines the outgoing tangent
  22737. * @param amount defines the target quaternion
  22738. * @returns the new interpolated quaternion
  22739. */
  22740. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  22741. }
  22742. /**
  22743. * Class used to store matrix data (4x4)
  22744. */
  22745. class Matrix {
  22746. private static _updateFlagSeed;
  22747. private static _identityReadOnly;
  22748. private _isIdentity;
  22749. private _isIdentityDirty;
  22750. private _isIdentity3x2;
  22751. private _isIdentity3x2Dirty;
  22752. /**
  22753. * Gets the update flag of the matrix which is an unique number for the matrix.
  22754. * It will be incremented every time the matrix data change.
  22755. * You can use it to speed the comparison between two versions of the same matrix.
  22756. */
  22757. updateFlag: number;
  22758. private readonly _m;
  22759. /**
  22760. * Gets the internal data of the matrix
  22761. */
  22762. readonly m: DeepImmutable<Float32Array>;
  22763. /** @hidden */
  22764. _markAsUpdated(): void;
  22765. /** @hidden */
  22766. private _updateIdentityStatus;
  22767. /**
  22768. * Creates an empty matrix (filled with zeros)
  22769. */
  22770. constructor();
  22771. /**
  22772. * Check if the current matrix is identity
  22773. * @returns true is the matrix is the identity matrix
  22774. */
  22775. isIdentity(): boolean;
  22776. /**
  22777. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  22778. * @returns true is the matrix is the identity matrix
  22779. */
  22780. isIdentityAs3x2(): boolean;
  22781. /**
  22782. * Gets the determinant of the matrix
  22783. * @returns the matrix determinant
  22784. */
  22785. determinant(): number;
  22786. /**
  22787. * Returns the matrix as a Float32Array
  22788. * @returns the matrix underlying array
  22789. */
  22790. toArray(): DeepImmutable<Float32Array>;
  22791. /**
  22792. * Returns the matrix as a Float32Array
  22793. * @returns the matrix underlying array.
  22794. */
  22795. asArray(): DeepImmutable<Float32Array>;
  22796. /**
  22797. * Inverts the current matrix in place
  22798. * @returns the current inverted matrix
  22799. */
  22800. invert(): Matrix;
  22801. /**
  22802. * Sets all the matrix elements to zero
  22803. * @returns the current matrix
  22804. */
  22805. reset(): Matrix;
  22806. /**
  22807. * Adds the current matrix with a second one
  22808. * @param other defines the matrix to add
  22809. * @returns a new matrix as the addition of the current matrix and the given one
  22810. */
  22811. add(other: DeepImmutable<Matrix>): Matrix;
  22812. /**
  22813. * Sets the given matrix "result" to the addition of the current matrix and the given one
  22814. * @param other defines the matrix to add
  22815. * @param result defines the target matrix
  22816. * @returns the current matrix
  22817. */
  22818. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22819. /**
  22820. * Adds in place the given matrix to the current matrix
  22821. * @param other defines the second operand
  22822. * @returns the current updated matrix
  22823. */
  22824. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  22825. /**
  22826. * Sets the given matrix to the current inverted Matrix
  22827. * @param other defines the target matrix
  22828. * @returns the unmodified current matrix
  22829. */
  22830. invertToRef(other: Matrix): Matrix;
  22831. /**
  22832. * add a value at the specified position in the current Matrix
  22833. * @param index the index of the value within the matrix. between 0 and 15.
  22834. * @param value the value to be added
  22835. * @returns the current updated matrix
  22836. */
  22837. addAtIndex(index: number, value: number): Matrix;
  22838. /**
  22839. * mutiply the specified position in the current Matrix by a value
  22840. * @param index the index of the value within the matrix. between 0 and 15.
  22841. * @param value the value to be added
  22842. * @returns the current updated matrix
  22843. */
  22844. multiplyAtIndex(index: number, value: number): Matrix;
  22845. /**
  22846. * Inserts the translation vector (using 3 floats) in the current matrix
  22847. * @param x defines the 1st component of the translation
  22848. * @param y defines the 2nd component of the translation
  22849. * @param z defines the 3rd component of the translation
  22850. * @returns the current updated matrix
  22851. */
  22852. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  22853. /**
  22854. * Inserts the translation vector in the current matrix
  22855. * @param vector3 defines the translation to insert
  22856. * @returns the current updated matrix
  22857. */
  22858. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  22859. /**
  22860. * Gets the translation value of the current matrix
  22861. * @returns a new Vector3 as the extracted translation from the matrix
  22862. */
  22863. getTranslation(): Vector3;
  22864. /**
  22865. * Fill a Vector3 with the extracted translation from the matrix
  22866. * @param result defines the Vector3 where to store the translation
  22867. * @returns the current matrix
  22868. */
  22869. getTranslationToRef(result: Vector3): Matrix;
  22870. /**
  22871. * Remove rotation and scaling part from the matrix
  22872. * @returns the updated matrix
  22873. */
  22874. removeRotationAndScaling(): Matrix;
  22875. /**
  22876. * Multiply two matrices
  22877. * @param other defines the second operand
  22878. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  22879. */
  22880. multiply(other: DeepImmutable<Matrix>): Matrix;
  22881. /**
  22882. * Copy the current matrix from the given one
  22883. * @param other defines the source matrix
  22884. * @returns the current updated matrix
  22885. */
  22886. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  22887. /**
  22888. * Populates the given array from the starting index with the current matrix values
  22889. * @param array defines the target array
  22890. * @param offset defines the offset in the target array where to start storing values
  22891. * @returns the current matrix
  22892. */
  22893. copyToArray(array: Float32Array, offset?: number): Matrix;
  22894. /**
  22895. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  22896. * @param other defines the second operand
  22897. * @param result defines the matrix where to store the multiplication
  22898. * @returns the current matrix
  22899. */
  22900. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  22901. /**
  22902. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  22903. * @param other defines the second operand
  22904. * @param result defines the array where to store the multiplication
  22905. * @param offset defines the offset in the target array where to start storing values
  22906. * @returns the current matrix
  22907. */
  22908. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  22909. /**
  22910. * Check equality between this matrix and a second one
  22911. * @param value defines the second matrix to compare
  22912. * @returns true is the current matrix and the given one values are strictly equal
  22913. */
  22914. equals(value: DeepImmutable<Matrix>): boolean;
  22915. /**
  22916. * Clone the current matrix
  22917. * @returns a new matrix from the current matrix
  22918. */
  22919. clone(): Matrix;
  22920. /**
  22921. * Returns the name of the current matrix class
  22922. * @returns the string "Matrix"
  22923. */
  22924. getClassName(): string;
  22925. /**
  22926. * Gets the hash code of the current matrix
  22927. * @returns the hash code
  22928. */
  22929. getHashCode(): number;
  22930. /**
  22931. * Decomposes the current Matrix into a translation, rotation and scaling components
  22932. * @param scale defines the scale vector3 given as a reference to update
  22933. * @param rotation defines the rotation quaternion given as a reference to update
  22934. * @param translation defines the translation vector3 given as a reference to update
  22935. * @returns true if operation was successful
  22936. */
  22937. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  22938. /**
  22939. * Gets specific row of the matrix
  22940. * @param index defines the number of the row to get
  22941. * @returns the index-th row of the current matrix as a new Vector4
  22942. */
  22943. getRow(index: number): Nullable<Vector4>;
  22944. /**
  22945. * Sets the index-th row of the current matrix to the vector4 values
  22946. * @param index defines the number of the row to set
  22947. * @param row defines the target vector4
  22948. * @returns the updated current matrix
  22949. */
  22950. setRow(index: number, row: Vector4): Matrix;
  22951. /**
  22952. * Compute the transpose of the matrix
  22953. * @returns the new transposed matrix
  22954. */
  22955. transpose(): Matrix;
  22956. /**
  22957. * Compute the transpose of the matrix and store it in a given matrix
  22958. * @param result defines the target matrix
  22959. * @returns the current matrix
  22960. */
  22961. transposeToRef(result: Matrix): Matrix;
  22962. /**
  22963. * Sets the index-th row of the current matrix with the given 4 x float values
  22964. * @param index defines the row index
  22965. * @param x defines the x component to set
  22966. * @param y defines the y component to set
  22967. * @param z defines the z component to set
  22968. * @param w defines the w component to set
  22969. * @returns the updated current matrix
  22970. */
  22971. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  22972. /**
  22973. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  22974. * @param scale defines the scale factor
  22975. * @returns a new matrix
  22976. */
  22977. scale(scale: number): Matrix;
  22978. /**
  22979. * Scale the current matrix values by a factor to a given result matrix
  22980. * @param scale defines the scale factor
  22981. * @param result defines the matrix to store the result
  22982. * @returns the current matrix
  22983. */
  22984. scaleToRef(scale: number, result: Matrix): Matrix;
  22985. /**
  22986. * Scale the current matrix values by a factor and add the result to a given matrix
  22987. * @param scale defines the scale factor
  22988. * @param result defines the Matrix to store the result
  22989. * @returns the current matrix
  22990. */
  22991. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  22992. /**
  22993. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  22994. * @param ref matrix to store the result
  22995. */
  22996. toNormalMatrix(ref: Matrix): void;
  22997. /**
  22998. * Gets only rotation part of the current matrix
  22999. * @returns a new matrix sets to the extracted rotation matrix from the current one
  23000. */
  23001. getRotationMatrix(): Matrix;
  23002. /**
  23003. * Extracts the rotation matrix from the current one and sets it as the given "result"
  23004. * @param result defines the target matrix to store data to
  23005. * @returns the current matrix
  23006. */
  23007. getRotationMatrixToRef(result: Matrix): Matrix;
  23008. /**
  23009. * Toggles model matrix from being right handed to left handed in place and vice versa
  23010. */
  23011. toggleModelMatrixHandInPlace(): void;
  23012. /**
  23013. * Toggles projection matrix from being right handed to left handed in place and vice versa
  23014. */
  23015. toggleProjectionMatrixHandInPlace(): void;
  23016. /**
  23017. * Creates a matrix from an array
  23018. * @param array defines the source array
  23019. * @param offset defines an offset in the source array
  23020. * @returns a new Matrix set from the starting index of the given array
  23021. */
  23022. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  23023. /**
  23024. * Copy the content of an array into a given matrix
  23025. * @param array defines the source array
  23026. * @param offset defines an offset in the source array
  23027. * @param result defines the target matrix
  23028. */
  23029. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  23030. /**
  23031. * Stores an array into a matrix after having multiplied each component by a given factor
  23032. * @param array defines the source array
  23033. * @param offset defines the offset in the source array
  23034. * @param scale defines the scaling factor
  23035. * @param result defines the target matrix
  23036. */
  23037. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  23038. /**
  23039. * Gets an identity matrix that must not be updated
  23040. */
  23041. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  23042. /**
  23043. * Stores a list of values (16) inside a given matrix
  23044. * @param initialM11 defines 1st value of 1st row
  23045. * @param initialM12 defines 2nd value of 1st row
  23046. * @param initialM13 defines 3rd value of 1st row
  23047. * @param initialM14 defines 4th value of 1st row
  23048. * @param initialM21 defines 1st value of 2nd row
  23049. * @param initialM22 defines 2nd value of 2nd row
  23050. * @param initialM23 defines 3rd value of 2nd row
  23051. * @param initialM24 defines 4th value of 2nd row
  23052. * @param initialM31 defines 1st value of 3rd row
  23053. * @param initialM32 defines 2nd value of 3rd row
  23054. * @param initialM33 defines 3rd value of 3rd row
  23055. * @param initialM34 defines 4th value of 3rd row
  23056. * @param initialM41 defines 1st value of 4th row
  23057. * @param initialM42 defines 2nd value of 4th row
  23058. * @param initialM43 defines 3rd value of 4th row
  23059. * @param initialM44 defines 4th value of 4th row
  23060. * @param result defines the target matrix
  23061. */
  23062. 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;
  23063. /**
  23064. * Creates new matrix from a list of values (16)
  23065. * @param initialM11 defines 1st value of 1st row
  23066. * @param initialM12 defines 2nd value of 1st row
  23067. * @param initialM13 defines 3rd value of 1st row
  23068. * @param initialM14 defines 4th value of 1st row
  23069. * @param initialM21 defines 1st value of 2nd row
  23070. * @param initialM22 defines 2nd value of 2nd row
  23071. * @param initialM23 defines 3rd value of 2nd row
  23072. * @param initialM24 defines 4th value of 2nd row
  23073. * @param initialM31 defines 1st value of 3rd row
  23074. * @param initialM32 defines 2nd value of 3rd row
  23075. * @param initialM33 defines 3rd value of 3rd row
  23076. * @param initialM34 defines 4th value of 3rd row
  23077. * @param initialM41 defines 1st value of 4th row
  23078. * @param initialM42 defines 2nd value of 4th row
  23079. * @param initialM43 defines 3rd value of 4th row
  23080. * @param initialM44 defines 4th value of 4th row
  23081. * @returns the new matrix
  23082. */
  23083. 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;
  23084. /**
  23085. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23086. * @param scale defines the scale vector3
  23087. * @param rotation defines the rotation quaternion
  23088. * @param translation defines the translation vector3
  23089. * @returns a new matrix
  23090. */
  23091. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  23092. /**
  23093. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  23094. * @param scale defines the scale vector3
  23095. * @param rotation defines the rotation quaternion
  23096. * @param translation defines the translation vector3
  23097. * @param result defines the target matrix
  23098. */
  23099. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  23100. /**
  23101. * Creates a new identity matrix
  23102. * @returns a new identity matrix
  23103. */
  23104. static Identity(): Matrix;
  23105. /**
  23106. * Creates a new identity matrix and stores the result in a given matrix
  23107. * @param result defines the target matrix
  23108. */
  23109. static IdentityToRef(result: Matrix): void;
  23110. /**
  23111. * Creates a new zero matrix
  23112. * @returns a new zero matrix
  23113. */
  23114. static Zero(): Matrix;
  23115. /**
  23116. * Creates a new rotation matrix for "angle" radians around the X axis
  23117. * @param angle defines the angle (in radians) to use
  23118. * @return the new matrix
  23119. */
  23120. static RotationX(angle: number): Matrix;
  23121. /**
  23122. * Creates a new matrix as the invert of a given matrix
  23123. * @param source defines the source matrix
  23124. * @returns the new matrix
  23125. */
  23126. static Invert(source: DeepImmutable<Matrix>): Matrix;
  23127. /**
  23128. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  23129. * @param angle defines the angle (in radians) to use
  23130. * @param result defines the target matrix
  23131. */
  23132. static RotationXToRef(angle: number, result: Matrix): void;
  23133. /**
  23134. * Creates a new rotation matrix for "angle" radians around the Y axis
  23135. * @param angle defines the angle (in radians) to use
  23136. * @return the new matrix
  23137. */
  23138. static RotationY(angle: number): Matrix;
  23139. /**
  23140. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  23141. * @param angle defines the angle (in radians) to use
  23142. * @param result defines the target matrix
  23143. */
  23144. static RotationYToRef(angle: number, result: Matrix): void;
  23145. /**
  23146. * Creates a new rotation matrix for "angle" radians around the Z axis
  23147. * @param angle defines the angle (in radians) to use
  23148. * @return the new matrix
  23149. */
  23150. static RotationZ(angle: number): Matrix;
  23151. /**
  23152. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  23153. * @param angle defines the angle (in radians) to use
  23154. * @param result defines the target matrix
  23155. */
  23156. static RotationZToRef(angle: number, result: Matrix): void;
  23157. /**
  23158. * Creates a new rotation matrix for "angle" radians around the given axis
  23159. * @param axis defines the axis to use
  23160. * @param angle defines the angle (in radians) to use
  23161. * @return the new matrix
  23162. */
  23163. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  23164. /**
  23165. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  23166. * @param axis defines the axis to use
  23167. * @param angle defines the angle (in radians) to use
  23168. * @param result defines the target matrix
  23169. */
  23170. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  23171. /**
  23172. * Creates a rotation matrix
  23173. * @param yaw defines the yaw angle in radians (Y axis)
  23174. * @param pitch defines the pitch angle in radians (X axis)
  23175. * @param roll defines the roll angle in radians (X axis)
  23176. * @returns the new rotation matrix
  23177. */
  23178. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  23179. /**
  23180. * Creates a rotation matrix and stores it in a given matrix
  23181. * @param yaw defines the yaw angle in radians (Y axis)
  23182. * @param pitch defines the pitch angle in radians (X axis)
  23183. * @param roll defines the roll angle in radians (X axis)
  23184. * @param result defines the target matrix
  23185. */
  23186. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  23187. /**
  23188. * Creates a scaling matrix
  23189. * @param x defines the scale factor on X axis
  23190. * @param y defines the scale factor on Y axis
  23191. * @param z defines the scale factor on Z axis
  23192. * @returns the new matrix
  23193. */
  23194. static Scaling(x: number, y: number, z: number): Matrix;
  23195. /**
  23196. * Creates a scaling matrix and stores it in a given matrix
  23197. * @param x defines the scale factor on X axis
  23198. * @param y defines the scale factor on Y axis
  23199. * @param z defines the scale factor on Z axis
  23200. * @param result defines the target matrix
  23201. */
  23202. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  23203. /**
  23204. * Creates a translation matrix
  23205. * @param x defines the translation on X axis
  23206. * @param y defines the translation on Y axis
  23207. * @param z defines the translationon Z axis
  23208. * @returns the new matrix
  23209. */
  23210. static Translation(x: number, y: number, z: number): Matrix;
  23211. /**
  23212. * Creates a translation matrix and stores it in a given matrix
  23213. * @param x defines the translation on X axis
  23214. * @param y defines the translation on Y axis
  23215. * @param z defines the translationon Z axis
  23216. * @param result defines the target matrix
  23217. */
  23218. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  23219. /**
  23220. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23221. * @param startValue defines the start value
  23222. * @param endValue defines the end value
  23223. * @param gradient defines the gradient factor
  23224. * @returns the new matrix
  23225. */
  23226. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23227. /**
  23228. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  23229. * @param startValue defines the start value
  23230. * @param endValue defines the end value
  23231. * @param gradient defines the gradient factor
  23232. * @param result defines the Matrix object where to store data
  23233. */
  23234. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23235. /**
  23236. * Builds a new matrix whose values are computed by:
  23237. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23238. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23239. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23240. * @param startValue defines the first matrix
  23241. * @param endValue defines the second matrix
  23242. * @param gradient defines the gradient between the two matrices
  23243. * @returns the new matrix
  23244. */
  23245. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  23246. /**
  23247. * Update a matrix to values which are computed by:
  23248. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  23249. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  23250. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  23251. * @param startValue defines the first matrix
  23252. * @param endValue defines the second matrix
  23253. * @param gradient defines the gradient between the two matrices
  23254. * @param result defines the target matrix
  23255. */
  23256. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  23257. /**
  23258. * 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"
  23259. * This function works in left handed mode
  23260. * @param eye defines the final position of the entity
  23261. * @param target defines where the entity should look at
  23262. * @param up defines the up vector for the entity
  23263. * @returns the new matrix
  23264. */
  23265. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23266. /**
  23267. * 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".
  23268. * This function works in left handed mode
  23269. * @param eye defines the final position of the entity
  23270. * @param target defines where the entity should look at
  23271. * @param up defines the up vector for the entity
  23272. * @param result defines the target matrix
  23273. */
  23274. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23275. /**
  23276. * 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"
  23277. * This function works in right handed mode
  23278. * @param eye defines the final position of the entity
  23279. * @param target defines where the entity should look at
  23280. * @param up defines the up vector for the entity
  23281. * @returns the new matrix
  23282. */
  23283. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  23284. /**
  23285. * 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".
  23286. * This function works in right handed mode
  23287. * @param eye defines the final position of the entity
  23288. * @param target defines where the entity should look at
  23289. * @param up defines the up vector for the entity
  23290. * @param result defines the target matrix
  23291. */
  23292. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  23293. /**
  23294. * Create a left-handed orthographic projection matrix
  23295. * @param width defines the viewport width
  23296. * @param height defines the viewport height
  23297. * @param znear defines the near clip plane
  23298. * @param zfar defines the far clip plane
  23299. * @returns a new matrix as a left-handed orthographic projection matrix
  23300. */
  23301. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23302. /**
  23303. * Store a left-handed orthographic projection to a given matrix
  23304. * @param width defines the viewport width
  23305. * @param height defines the viewport height
  23306. * @param znear defines the near clip plane
  23307. * @param zfar defines the far clip plane
  23308. * @param result defines the target matrix
  23309. */
  23310. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  23311. /**
  23312. * Create a left-handed orthographic projection matrix
  23313. * @param left defines the viewport left coordinate
  23314. * @param right defines the viewport right coordinate
  23315. * @param bottom defines the viewport bottom coordinate
  23316. * @param top defines the viewport top coordinate
  23317. * @param znear defines the near clip plane
  23318. * @param zfar defines the far clip plane
  23319. * @returns a new matrix as a left-handed orthographic projection matrix
  23320. */
  23321. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23322. /**
  23323. * Stores a left-handed orthographic projection into a given matrix
  23324. * @param left defines the viewport left coordinate
  23325. * @param right defines the viewport right coordinate
  23326. * @param bottom defines the viewport bottom coordinate
  23327. * @param top defines the viewport top coordinate
  23328. * @param znear defines the near clip plane
  23329. * @param zfar defines the far clip plane
  23330. * @param result defines the target matrix
  23331. */
  23332. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23333. /**
  23334. * Creates a right-handed orthographic projection matrix
  23335. * @param left defines the viewport left coordinate
  23336. * @param right defines the viewport right coordinate
  23337. * @param bottom defines the viewport bottom coordinate
  23338. * @param top defines the viewport top coordinate
  23339. * @param znear defines the near clip plane
  23340. * @param zfar defines the far clip plane
  23341. * @returns a new matrix as a right-handed orthographic projection matrix
  23342. */
  23343. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  23344. /**
  23345. * Stores a right-handed orthographic projection into a given matrix
  23346. * @param left defines the viewport left coordinate
  23347. * @param right defines the viewport right coordinate
  23348. * @param bottom defines the viewport bottom coordinate
  23349. * @param top defines the viewport top coordinate
  23350. * @param znear defines the near clip plane
  23351. * @param zfar defines the far clip plane
  23352. * @param result defines the target matrix
  23353. */
  23354. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  23355. /**
  23356. * Creates a left-handed perspective projection matrix
  23357. * @param width defines the viewport width
  23358. * @param height defines the viewport height
  23359. * @param znear defines the near clip plane
  23360. * @param zfar defines the far clip plane
  23361. * @returns a new matrix as a left-handed perspective projection matrix
  23362. */
  23363. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  23364. /**
  23365. * Creates a left-handed perspective projection matrix
  23366. * @param fov defines the horizontal field of view
  23367. * @param aspect defines the aspect ratio
  23368. * @param znear defines the near clip plane
  23369. * @param zfar defines the far clip plane
  23370. * @returns a new matrix as a left-handed perspective projection matrix
  23371. */
  23372. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23373. /**
  23374. * Stores a left-handed perspective projection into a given matrix
  23375. * @param fov defines the horizontal field of view
  23376. * @param aspect defines the aspect ratio
  23377. * @param znear defines the near clip plane
  23378. * @param zfar defines the far clip plane
  23379. * @param result defines the target matrix
  23380. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23381. */
  23382. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23383. /**
  23384. * Creates a right-handed perspective projection matrix
  23385. * @param fov defines the horizontal field of view
  23386. * @param aspect defines the aspect ratio
  23387. * @param znear defines the near clip plane
  23388. * @param zfar defines the far clip plane
  23389. * @returns a new matrix as a right-handed perspective projection matrix
  23390. */
  23391. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  23392. /**
  23393. * Stores a right-handed perspective projection into a given matrix
  23394. * @param fov defines the horizontal field of view
  23395. * @param aspect defines the aspect ratio
  23396. * @param znear defines the near clip plane
  23397. * @param zfar defines the far clip plane
  23398. * @param result defines the target matrix
  23399. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  23400. */
  23401. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  23402. /**
  23403. * Stores a perspective projection for WebVR info a given matrix
  23404. * @param fov defines the field of view
  23405. * @param znear defines the near clip plane
  23406. * @param zfar defines the far clip plane
  23407. * @param result defines the target matrix
  23408. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  23409. */
  23410. static PerspectiveFovWebVRToRef(fov: {
  23411. upDegrees: number;
  23412. downDegrees: number;
  23413. leftDegrees: number;
  23414. rightDegrees: number;
  23415. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  23416. /**
  23417. * Computes a complete transformation matrix
  23418. * @param viewport defines the viewport to use
  23419. * @param world defines the world matrix
  23420. * @param view defines the view matrix
  23421. * @param projection defines the projection matrix
  23422. * @param zmin defines the near clip plane
  23423. * @param zmax defines the far clip plane
  23424. * @returns the transformation matrix
  23425. */
  23426. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  23427. /**
  23428. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  23429. * @param matrix defines the matrix to use
  23430. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  23431. */
  23432. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  23433. /**
  23434. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  23435. * @param matrix defines the matrix to use
  23436. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  23437. */
  23438. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  23439. /**
  23440. * Compute the transpose of a given matrix
  23441. * @param matrix defines the matrix to transpose
  23442. * @returns the new matrix
  23443. */
  23444. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  23445. /**
  23446. * Compute the transpose of a matrix and store it in a target matrix
  23447. * @param matrix defines the matrix to transpose
  23448. * @param result defines the target matrix
  23449. */
  23450. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  23451. /**
  23452. * Computes a reflection matrix from a plane
  23453. * @param plane defines the reflection plane
  23454. * @returns a new matrix
  23455. */
  23456. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  23457. /**
  23458. * Computes a reflection matrix from a plane
  23459. * @param plane defines the reflection plane
  23460. * @param result defines the target matrix
  23461. */
  23462. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  23463. /**
  23464. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  23465. * @param xaxis defines the value of the 1st axis
  23466. * @param yaxis defines the value of the 2nd axis
  23467. * @param zaxis defines the value of the 3rd axis
  23468. * @param result defines the target matrix
  23469. */
  23470. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  23471. /**
  23472. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  23473. * @param quat defines the quaternion to use
  23474. * @param result defines the target matrix
  23475. */
  23476. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  23477. }
  23478. /**
  23479. * Represens a plane by the equation ax + by + cz + d = 0
  23480. */
  23481. class Plane {
  23482. /**
  23483. * Normal of the plane (a,b,c)
  23484. */
  23485. normal: Vector3;
  23486. /**
  23487. * d component of the plane
  23488. */
  23489. d: number;
  23490. /**
  23491. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  23492. * @param a a component of the plane
  23493. * @param b b component of the plane
  23494. * @param c c component of the plane
  23495. * @param d d component of the plane
  23496. */
  23497. constructor(a: number, b: number, c: number, d: number);
  23498. /**
  23499. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  23500. */
  23501. asArray(): number[];
  23502. /**
  23503. * @returns a new plane copied from the current Plane.
  23504. */
  23505. clone(): Plane;
  23506. /**
  23507. * @returns the string "Plane".
  23508. */
  23509. getClassName(): string;
  23510. /**
  23511. * @returns the Plane hash code.
  23512. */
  23513. getHashCode(): number;
  23514. /**
  23515. * Normalize the current Plane in place.
  23516. * @returns the updated Plane.
  23517. */
  23518. normalize(): Plane;
  23519. /**
  23520. * Applies a transformation the plane and returns the result
  23521. * @param transformation the transformation matrix to be applied to the plane
  23522. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  23523. */
  23524. transform(transformation: DeepImmutable<Matrix>): Plane;
  23525. /**
  23526. * Calcualtte the dot product between the point and the plane normal
  23527. * @param point point to calculate the dot product with
  23528. * @returns the dot product (float) of the point coordinates and the plane normal.
  23529. */
  23530. dotCoordinate(point: DeepImmutable<Vector3>): number;
  23531. /**
  23532. * Updates the current Plane from the plane defined by the three given points.
  23533. * @param point1 one of the points used to contruct the plane
  23534. * @param point2 one of the points used to contruct the plane
  23535. * @param point3 one of the points used to contruct the plane
  23536. * @returns the updated Plane.
  23537. */
  23538. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23539. /**
  23540. * Checks if the plane is facing a given direction
  23541. * @param direction the direction to check if the plane is facing
  23542. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  23543. * @returns True is the vector "direction" is the same side than the plane normal.
  23544. */
  23545. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  23546. /**
  23547. * Calculates the distance to a point
  23548. * @param point point to calculate distance to
  23549. * @returns the signed distance (float) from the given point to the Plane.
  23550. */
  23551. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  23552. /**
  23553. * Creates a plane from an array
  23554. * @param array the array to create a plane from
  23555. * @returns a new Plane from the given array.
  23556. */
  23557. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  23558. /**
  23559. * Creates a plane from three points
  23560. * @param point1 point used to create the plane
  23561. * @param point2 point used to create the plane
  23562. * @param point3 point used to create the plane
  23563. * @returns a new Plane defined by the three given points.
  23564. */
  23565. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  23566. /**
  23567. * Creates a plane from an origin point and a normal
  23568. * @param origin origin of the plane to be constructed
  23569. * @param normal normal of the plane to be constructed
  23570. * @returns a new Plane the normal vector to this plane at the given origin point.
  23571. * Note : the vector "normal" is updated because normalized.
  23572. */
  23573. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  23574. /**
  23575. * Calculates the distance from a plane and a point
  23576. * @param origin origin of the plane to be constructed
  23577. * @param normal normal of the plane to be constructed
  23578. * @param point point to calculate distance to
  23579. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  23580. */
  23581. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  23582. }
  23583. /**
  23584. * Class used to represent a viewport on screen
  23585. */
  23586. class Viewport {
  23587. /** viewport left coordinate */
  23588. x: number;
  23589. /** viewport top coordinate */
  23590. y: number;
  23591. /**viewport width */
  23592. width: number;
  23593. /** viewport height */
  23594. height: number;
  23595. /**
  23596. * Creates a Viewport object located at (x, y) and sized (width, height)
  23597. * @param x defines viewport left coordinate
  23598. * @param y defines viewport top coordinate
  23599. * @param width defines the viewport width
  23600. * @param height defines the viewport height
  23601. */
  23602. constructor(
  23603. /** viewport left coordinate */
  23604. x: number,
  23605. /** viewport top coordinate */
  23606. y: number,
  23607. /**viewport width */
  23608. width: number,
  23609. /** viewport height */
  23610. height: number);
  23611. /**
  23612. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  23613. * @param renderWidthOrEngine defines either an engine or the rendering width
  23614. * @param renderHeight defines the rendering height
  23615. * @returns a new Viewport
  23616. */
  23617. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  23618. /**
  23619. * Returns a new Viewport copied from the current one
  23620. * @returns a new Viewport
  23621. */
  23622. clone(): Viewport;
  23623. }
  23624. /**
  23625. * Reprasents a camera frustum
  23626. */
  23627. class Frustum {
  23628. /**
  23629. * Gets the planes representing the frustum
  23630. * @param transform matrix to be applied to the returned planes
  23631. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  23632. */
  23633. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  23634. /**
  23635. * Gets the near frustum plane transformed by the transform matrix
  23636. * @param transform transformation matrix to be applied to the resulting frustum plane
  23637. * @param frustumPlane the resuling frustum plane
  23638. */
  23639. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23640. /**
  23641. * Gets the far frustum plane transformed by the transform matrix
  23642. * @param transform transformation matrix to be applied to the resulting frustum plane
  23643. * @param frustumPlane the resuling frustum plane
  23644. */
  23645. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23646. /**
  23647. * Gets the left frustum plane transformed by the transform matrix
  23648. * @param transform transformation matrix to be applied to the resulting frustum plane
  23649. * @param frustumPlane the resuling frustum plane
  23650. */
  23651. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23652. /**
  23653. * Gets the right frustum plane transformed by the transform matrix
  23654. * @param transform transformation matrix to be applied to the resulting frustum plane
  23655. * @param frustumPlane the resuling frustum plane
  23656. */
  23657. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23658. /**
  23659. * Gets the top frustum plane transformed by the transform matrix
  23660. * @param transform transformation matrix to be applied to the resulting frustum plane
  23661. * @param frustumPlane the resuling frustum plane
  23662. */
  23663. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23664. /**
  23665. * Gets the bottom frustum plane transformed by the transform matrix
  23666. * @param transform transformation matrix to be applied to the resulting frustum plane
  23667. * @param frustumPlane the resuling frustum plane
  23668. */
  23669. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  23670. /**
  23671. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  23672. * @param transform transformation matrix to be applied to the resulting frustum planes
  23673. * @param frustumPlanes the resuling frustum planes
  23674. */
  23675. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  23676. }
  23677. /** Defines supported spaces */
  23678. enum Space {
  23679. /** Local (object) space */
  23680. LOCAL = 0,
  23681. /** World space */
  23682. WORLD = 1,
  23683. /** Bone space */
  23684. BONE = 2
  23685. }
  23686. /** Defines the 3 main axes */
  23687. class Axis {
  23688. /** X axis */
  23689. static X: Vector3;
  23690. /** Y axis */
  23691. static Y: Vector3;
  23692. /** Z axis */
  23693. static Z: Vector3;
  23694. }
  23695. /** Class used to represent a Bezier curve */
  23696. class BezierCurve {
  23697. /**
  23698. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  23699. * @param t defines the time
  23700. * @param x1 defines the left coordinate on X axis
  23701. * @param y1 defines the left coordinate on Y axis
  23702. * @param x2 defines the right coordinate on X axis
  23703. * @param y2 defines the right coordinate on Y axis
  23704. * @returns the interpolated value
  23705. */
  23706. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  23707. }
  23708. /**
  23709. * Defines potential orientation for back face culling
  23710. */
  23711. enum Orientation {
  23712. /**
  23713. * Clockwise
  23714. */
  23715. CW = 0,
  23716. /** Counter clockwise */
  23717. CCW = 1
  23718. }
  23719. /**
  23720. * Defines angle representation
  23721. */
  23722. class Angle {
  23723. private _radians;
  23724. /**
  23725. * Creates an Angle object of "radians" radians (float).
  23726. */
  23727. constructor(radians: number);
  23728. /**
  23729. * Get value in degrees
  23730. * @returns the Angle value in degrees (float)
  23731. */
  23732. degrees(): number;
  23733. /**
  23734. * Get value in radians
  23735. * @returns the Angle value in radians (float)
  23736. */
  23737. radians(): number;
  23738. /**
  23739. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  23740. * @param a defines first vector
  23741. * @param b defines second vector
  23742. * @returns a new Angle
  23743. */
  23744. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  23745. /**
  23746. * Gets a new Angle object from the given float in radians
  23747. * @param radians defines the angle value in radians
  23748. * @returns a new Angle
  23749. */
  23750. static FromRadians(radians: number): Angle;
  23751. /**
  23752. * Gets a new Angle object from the given float in degrees
  23753. * @param degrees defines the angle value in degrees
  23754. * @returns a new Angle
  23755. */
  23756. static FromDegrees(degrees: number): Angle;
  23757. }
  23758. /**
  23759. * This represents an arc in a 2d space.
  23760. */
  23761. class Arc2 {
  23762. /** Defines the start point of the arc */
  23763. startPoint: Vector2;
  23764. /** Defines the mid point of the arc */
  23765. midPoint: Vector2;
  23766. /** Defines the end point of the arc */
  23767. endPoint: Vector2;
  23768. /**
  23769. * Defines the center point of the arc.
  23770. */
  23771. centerPoint: Vector2;
  23772. /**
  23773. * Defines the radius of the arc.
  23774. */
  23775. radius: number;
  23776. /**
  23777. * Defines the angle of the arc (from mid point to end point).
  23778. */
  23779. angle: Angle;
  23780. /**
  23781. * Defines the start angle of the arc (from start point to middle point).
  23782. */
  23783. startAngle: Angle;
  23784. /**
  23785. * Defines the orientation of the arc (clock wise/counter clock wise).
  23786. */
  23787. orientation: Orientation;
  23788. /**
  23789. * Creates an Arc object from the three given points : start, middle and end.
  23790. * @param startPoint Defines the start point of the arc
  23791. * @param midPoint Defines the midlle point of the arc
  23792. * @param endPoint Defines the end point of the arc
  23793. */
  23794. constructor(
  23795. /** Defines the start point of the arc */
  23796. startPoint: Vector2,
  23797. /** Defines the mid point of the arc */
  23798. midPoint: Vector2,
  23799. /** Defines the end point of the arc */
  23800. endPoint: Vector2);
  23801. }
  23802. /**
  23803. * Represents a 2D path made up of multiple 2D points
  23804. */
  23805. class Path2 {
  23806. private _points;
  23807. private _length;
  23808. /**
  23809. * If the path start and end point are the same
  23810. */
  23811. closed: boolean;
  23812. /**
  23813. * Creates a Path2 object from the starting 2D coordinates x and y.
  23814. * @param x the starting points x value
  23815. * @param y the starting points y value
  23816. */
  23817. constructor(x: number, y: number);
  23818. /**
  23819. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  23820. * @param x the added points x value
  23821. * @param y the added points y value
  23822. * @returns the updated Path2.
  23823. */
  23824. addLineTo(x: number, y: number): Path2;
  23825. /**
  23826. * 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.
  23827. * @param midX middle point x value
  23828. * @param midY middle point y value
  23829. * @param endX end point x value
  23830. * @param endY end point y value
  23831. * @param numberOfSegments (default: 36)
  23832. * @returns the updated Path2.
  23833. */
  23834. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  23835. /**
  23836. * Closes the Path2.
  23837. * @returns the Path2.
  23838. */
  23839. close(): Path2;
  23840. /**
  23841. * Gets the sum of the distance between each sequential point in the path
  23842. * @returns the Path2 total length (float).
  23843. */
  23844. length(): number;
  23845. /**
  23846. * Gets the points which construct the path
  23847. * @returns the Path2 internal array of points.
  23848. */
  23849. getPoints(): Vector2[];
  23850. /**
  23851. * Retreives the point at the distance aways from the starting point
  23852. * @param normalizedLengthPosition the length along the path to retreive the point from
  23853. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  23854. */
  23855. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  23856. /**
  23857. * Creates a new path starting from an x and y position
  23858. * @param x starting x value
  23859. * @param y starting y value
  23860. * @returns a new Path2 starting at the coordinates (x, y).
  23861. */
  23862. static StartingAt(x: number, y: number): Path2;
  23863. }
  23864. /**
  23865. * Represents a 3D path made up of multiple 3D points
  23866. */
  23867. class Path3D {
  23868. /**
  23869. * an array of Vector3, the curve axis of the Path3D
  23870. */
  23871. path: Vector3[];
  23872. private _curve;
  23873. private _distances;
  23874. private _tangents;
  23875. private _normals;
  23876. private _binormals;
  23877. private _raw;
  23878. /**
  23879. * new Path3D(path, normal, raw)
  23880. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  23881. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  23882. * @param path an array of Vector3, the curve axis of the Path3D
  23883. * @param normal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  23884. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  23885. */
  23886. constructor(
  23887. /**
  23888. * an array of Vector3, the curve axis of the Path3D
  23889. */
  23890. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  23891. /**
  23892. * Returns the Path3D array of successive Vector3 designing its curve.
  23893. * @returns the Path3D array of successive Vector3 designing its curve.
  23894. */
  23895. getCurve(): Vector3[];
  23896. /**
  23897. * Returns an array populated with tangent vectors on each Path3D curve point.
  23898. * @returns an array populated with tangent vectors on each Path3D curve point.
  23899. */
  23900. getTangents(): Vector3[];
  23901. /**
  23902. * Returns an array populated with normal vectors on each Path3D curve point.
  23903. * @returns an array populated with normal vectors on each Path3D curve point.
  23904. */
  23905. getNormals(): Vector3[];
  23906. /**
  23907. * Returns an array populated with binormal vectors on each Path3D curve point.
  23908. * @returns an array populated with binormal vectors on each Path3D curve point.
  23909. */
  23910. getBinormals(): Vector3[];
  23911. /**
  23912. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  23913. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  23914. */
  23915. getDistances(): number[];
  23916. /**
  23917. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  23918. * @param path path which all values are copied into the curves points
  23919. * @param firstNormal which should be projected onto the curve
  23920. * @returns the same object updated.
  23921. */
  23922. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  23923. private _compute;
  23924. private _getFirstNonNullVector;
  23925. private _getLastNonNullVector;
  23926. private _normalVector;
  23927. }
  23928. /**
  23929. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23930. * A Curve3 is designed from a series of successive Vector3.
  23931. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  23932. */
  23933. class Curve3 {
  23934. private _points;
  23935. private _length;
  23936. /**
  23937. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  23938. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  23939. * @param v1 (Vector3) the control point
  23940. * @param v2 (Vector3) the end point of the Quadratic Bezier
  23941. * @param nbPoints (integer) the wanted number of points in the curve
  23942. * @returns the created Curve3
  23943. */
  23944. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23945. /**
  23946. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  23947. * @param v0 (Vector3) the origin point of the Cubic Bezier
  23948. * @param v1 (Vector3) the first control point
  23949. * @param v2 (Vector3) the second control point
  23950. * @param v3 (Vector3) the end point of the Cubic Bezier
  23951. * @param nbPoints (integer) the wanted number of points in the curve
  23952. * @returns the created Curve3
  23953. */
  23954. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23955. /**
  23956. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  23957. * @param p1 (Vector3) the origin point of the Hermite Spline
  23958. * @param t1 (Vector3) the tangent vector at the origin point
  23959. * @param p2 (Vector3) the end point of the Hermite Spline
  23960. * @param t2 (Vector3) the tangent vector at the end point
  23961. * @param nbPoints (integer) the wanted number of points in the curve
  23962. * @returns the created Curve3
  23963. */
  23964. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  23965. /**
  23966. * Returns a Curve3 object along a CatmullRom Spline curve :
  23967. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  23968. * @param nbPoints (integer) the wanted number of points between each curve control points
  23969. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  23970. * @returns the created Curve3
  23971. */
  23972. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  23973. /**
  23974. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  23975. * A Curve3 is designed from a series of successive Vector3.
  23976. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  23977. * @param points points which make up the curve
  23978. */
  23979. constructor(points: Vector3[]);
  23980. /**
  23981. * @returns the Curve3 stored array of successive Vector3
  23982. */
  23983. getPoints(): Vector3[];
  23984. /**
  23985. * @returns the computed length (float) of the curve.
  23986. */
  23987. length(): number;
  23988. /**
  23989. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  23990. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  23991. * curveA and curveB keep unchanged.
  23992. * @param curve the curve to continue from this curve
  23993. * @returns the newly constructed curve
  23994. */
  23995. continue(curve: DeepImmutable<Curve3>): Curve3;
  23996. private _computeLength;
  23997. }
  23998. /**
  23999. * Contains position and normal vectors for a vertex
  24000. */
  24001. class PositionNormalVertex {
  24002. /** the position of the vertex (defaut: 0,0,0) */
  24003. position: Vector3;
  24004. /** the normal of the vertex (defaut: 0,1,0) */
  24005. normal: Vector3;
  24006. /**
  24007. * Creates a PositionNormalVertex
  24008. * @param position the position of the vertex (defaut: 0,0,0)
  24009. * @param normal the normal of the vertex (defaut: 0,1,0)
  24010. */
  24011. constructor(
  24012. /** the position of the vertex (defaut: 0,0,0) */
  24013. position?: Vector3,
  24014. /** the normal of the vertex (defaut: 0,1,0) */
  24015. normal?: Vector3);
  24016. /**
  24017. * Clones the PositionNormalVertex
  24018. * @returns the cloned PositionNormalVertex
  24019. */
  24020. clone(): PositionNormalVertex;
  24021. }
  24022. /**
  24023. * Contains position, normal and uv vectors for a vertex
  24024. */
  24025. class PositionNormalTextureVertex {
  24026. /** the position of the vertex (defaut: 0,0,0) */
  24027. position: Vector3;
  24028. /** the normal of the vertex (defaut: 0,1,0) */
  24029. normal: Vector3;
  24030. /** the uv of the vertex (default: 0,0) */
  24031. uv: Vector2;
  24032. /**
  24033. * Creates a PositionNormalTextureVertex
  24034. * @param position the position of the vertex (defaut: 0,0,0)
  24035. * @param normal the normal of the vertex (defaut: 0,1,0)
  24036. * @param uv the uv of the vertex (default: 0,0)
  24037. */
  24038. constructor(
  24039. /** the position of the vertex (defaut: 0,0,0) */
  24040. position?: Vector3,
  24041. /** the normal of the vertex (defaut: 0,1,0) */
  24042. normal?: Vector3,
  24043. /** the uv of the vertex (default: 0,0) */
  24044. uv?: Vector2);
  24045. /**
  24046. * Clones the PositionNormalTextureVertex
  24047. * @returns the cloned PositionNormalTextureVertex
  24048. */
  24049. clone(): PositionNormalTextureVertex;
  24050. }
  24051. /**
  24052. * @hidden
  24053. */
  24054. class Tmp {
  24055. static Color3: Color3[];
  24056. static Color4: Color4[];
  24057. static Vector2: Vector2[];
  24058. static Vector3: Vector3[];
  24059. static Vector4: Vector4[];
  24060. static Quaternion: Quaternion[];
  24061. static Matrix: Matrix[];
  24062. }
  24063. }
  24064. declare module BABYLON {
  24065. /**
  24066. * Class representing spherical polynomial coefficients to the 3rd degree
  24067. */
  24068. class SphericalPolynomial {
  24069. /**
  24070. * The x coefficients of the spherical polynomial
  24071. */
  24072. x: Vector3;
  24073. /**
  24074. * The y coefficients of the spherical polynomial
  24075. */
  24076. y: Vector3;
  24077. /**
  24078. * The z coefficients of the spherical polynomial
  24079. */
  24080. z: Vector3;
  24081. /**
  24082. * The xx coefficients of the spherical polynomial
  24083. */
  24084. xx: Vector3;
  24085. /**
  24086. * The yy coefficients of the spherical polynomial
  24087. */
  24088. yy: Vector3;
  24089. /**
  24090. * The zz coefficients of the spherical polynomial
  24091. */
  24092. zz: Vector3;
  24093. /**
  24094. * The xy coefficients of the spherical polynomial
  24095. */
  24096. xy: Vector3;
  24097. /**
  24098. * The yz coefficients of the spherical polynomial
  24099. */
  24100. yz: Vector3;
  24101. /**
  24102. * The zx coefficients of the spherical polynomial
  24103. */
  24104. zx: Vector3;
  24105. /**
  24106. * Adds an ambient color to the spherical polynomial
  24107. * @param color the color to add
  24108. */
  24109. addAmbient(color: Color3): void;
  24110. /**
  24111. * Scales the spherical polynomial by the given amount
  24112. * @param scale the amount to scale
  24113. */
  24114. scale(scale: number): void;
  24115. /**
  24116. * Gets the spherical polynomial from harmonics
  24117. * @param harmonics the spherical harmonics
  24118. * @returns the spherical polynomial
  24119. */
  24120. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  24121. /**
  24122. * Constructs a spherical polynomial from an array.
  24123. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  24124. * @returns the spherical polynomial
  24125. */
  24126. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  24127. }
  24128. /**
  24129. * Class representing spherical harmonics coefficients to the 3rd degree
  24130. */
  24131. class SphericalHarmonics {
  24132. /**
  24133. * The l0,0 coefficients of the spherical harmonics
  24134. */
  24135. l00: Vector3;
  24136. /**
  24137. * The l1,-1 coefficients of the spherical harmonics
  24138. */
  24139. l1_1: Vector3;
  24140. /**
  24141. * The l1,0 coefficients of the spherical harmonics
  24142. */
  24143. l10: Vector3;
  24144. /**
  24145. * The l1,1 coefficients of the spherical harmonics
  24146. */
  24147. l11: Vector3;
  24148. /**
  24149. * The l2,-2 coefficients of the spherical harmonics
  24150. */
  24151. l2_2: Vector3;
  24152. /**
  24153. * The l2,-1 coefficients of the spherical harmonics
  24154. */
  24155. l2_1: Vector3;
  24156. /**
  24157. * The l2,0 coefficients of the spherical harmonics
  24158. */
  24159. l20: Vector3;
  24160. /**
  24161. * The l2,1 coefficients of the spherical harmonics
  24162. */
  24163. l21: Vector3;
  24164. /**
  24165. * The l2,2 coefficients of the spherical harmonics
  24166. */
  24167. lL22: Vector3;
  24168. /**
  24169. * Adds a light to the spherical harmonics
  24170. * @param direction the direction of the light
  24171. * @param color the color of the light
  24172. * @param deltaSolidAngle the delta solid angle of the light
  24173. */
  24174. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  24175. /**
  24176. * Scales the spherical harmonics by the given amount
  24177. * @param scale the amount to scale
  24178. */
  24179. scale(scale: number): void;
  24180. /**
  24181. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  24182. *
  24183. * ```
  24184. * E_lm = A_l * L_lm
  24185. * ```
  24186. *
  24187. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  24188. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  24189. * the scaling factors are given in equation 9.
  24190. */
  24191. convertIncidentRadianceToIrradiance(): void;
  24192. /**
  24193. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  24194. *
  24195. * ```
  24196. * L = (1/pi) * E * rho
  24197. * ```
  24198. *
  24199. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  24200. */
  24201. convertIrradianceToLambertianRadiance(): void;
  24202. /**
  24203. * Gets the spherical harmonics from polynomial
  24204. * @param polynomial the spherical polynomial
  24205. * @returns the spherical harmonics
  24206. */
  24207. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  24208. /**
  24209. * Constructs a spherical harmonics from an array.
  24210. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  24211. * @returns the spherical harmonics
  24212. */
  24213. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  24214. }
  24215. }
  24216. declare module BABYLON {
  24217. /**
  24218. * Defines a target to use with MorphTargetManager
  24219. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24220. */
  24221. class MorphTarget implements IAnimatable {
  24222. /** defines the name of the target */
  24223. name: string;
  24224. /**
  24225. * Gets or sets the list of animations
  24226. */
  24227. animations: Animation[];
  24228. private _scene;
  24229. private _positions;
  24230. private _normals;
  24231. private _tangents;
  24232. private _influence;
  24233. /**
  24234. * Observable raised when the influence changes
  24235. */
  24236. onInfluenceChanged: Observable<boolean>;
  24237. /** @hidden */
  24238. _onDataLayoutChanged: Observable<void>;
  24239. /**
  24240. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  24241. */
  24242. influence: number;
  24243. /**
  24244. * Gets or sets the id of the morph Target
  24245. */
  24246. id: string;
  24247. private _animationPropertiesOverride;
  24248. /**
  24249. * Gets or sets the animation properties override
  24250. */
  24251. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24252. /**
  24253. * Creates a new MorphTarget
  24254. * @param name defines the name of the target
  24255. * @param influence defines the influence to use
  24256. */
  24257. constructor(
  24258. /** defines the name of the target */
  24259. name: string, influence?: number, scene?: Nullable<Scene>);
  24260. /**
  24261. * Gets a boolean defining if the target contains position data
  24262. */
  24263. readonly hasPositions: boolean;
  24264. /**
  24265. * Gets a boolean defining if the target contains normal data
  24266. */
  24267. readonly hasNormals: boolean;
  24268. /**
  24269. * Gets a boolean defining if the target contains tangent data
  24270. */
  24271. readonly hasTangents: boolean;
  24272. /**
  24273. * Affects position data to this target
  24274. * @param data defines the position data to use
  24275. */
  24276. setPositions(data: Nullable<FloatArray>): void;
  24277. /**
  24278. * Gets the position data stored in this target
  24279. * @returns a FloatArray containing the position data (or null if not present)
  24280. */
  24281. getPositions(): Nullable<FloatArray>;
  24282. /**
  24283. * Affects normal data to this target
  24284. * @param data defines the normal data to use
  24285. */
  24286. setNormals(data: Nullable<FloatArray>): void;
  24287. /**
  24288. * Gets the normal data stored in this target
  24289. * @returns a FloatArray containing the normal data (or null if not present)
  24290. */
  24291. getNormals(): Nullable<FloatArray>;
  24292. /**
  24293. * Affects tangent data to this target
  24294. * @param data defines the tangent data to use
  24295. */
  24296. setTangents(data: Nullable<FloatArray>): void;
  24297. /**
  24298. * Gets the tangent data stored in this target
  24299. * @returns a FloatArray containing the tangent data (or null if not present)
  24300. */
  24301. getTangents(): Nullable<FloatArray>;
  24302. /**
  24303. * Serializes the current target into a Serialization object
  24304. * @returns the serialized object
  24305. */
  24306. serialize(): any;
  24307. /**
  24308. * Returns the string "MorphTarget"
  24309. * @returns "MorphTarget"
  24310. */
  24311. getClassName(): string;
  24312. /**
  24313. * Creates a new target from serialized data
  24314. * @param serializationObject defines the serialized data to use
  24315. * @returns a new MorphTarget
  24316. */
  24317. static Parse(serializationObject: any): MorphTarget;
  24318. /**
  24319. * Creates a MorphTarget from mesh data
  24320. * @param mesh defines the source mesh
  24321. * @param name defines the name to use for the new target
  24322. * @param influence defines the influence to attach to the target
  24323. * @returns a new MorphTarget
  24324. */
  24325. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  24326. }
  24327. }
  24328. declare module BABYLON {
  24329. /**
  24330. * This class is used to deform meshes using morphing between different targets
  24331. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24332. */
  24333. class MorphTargetManager {
  24334. private _targets;
  24335. private _targetInfluenceChangedObservers;
  24336. private _targetDataLayoutChangedObservers;
  24337. private _activeTargets;
  24338. private _scene;
  24339. private _influences;
  24340. private _supportsNormals;
  24341. private _supportsTangents;
  24342. private _vertexCount;
  24343. private _uniqueId;
  24344. private _tempInfluences;
  24345. /**
  24346. * Creates a new MorphTargetManager
  24347. * @param scene defines the current scene
  24348. */
  24349. constructor(scene?: Nullable<Scene>);
  24350. /**
  24351. * Gets the unique ID of this manager
  24352. */
  24353. readonly uniqueId: number;
  24354. /**
  24355. * Gets the number of vertices handled by this manager
  24356. */
  24357. readonly vertexCount: number;
  24358. /**
  24359. * Gets a boolean indicating if this manager supports morphing of normals
  24360. */
  24361. readonly supportsNormals: boolean;
  24362. /**
  24363. * Gets a boolean indicating if this manager supports morphing of tangents
  24364. */
  24365. readonly supportsTangents: boolean;
  24366. /**
  24367. * Gets the number of targets stored in this manager
  24368. */
  24369. readonly numTargets: number;
  24370. /**
  24371. * Gets the number of influencers (ie. the number of targets with influences > 0)
  24372. */
  24373. readonly numInfluencers: number;
  24374. /**
  24375. * Gets the list of influences (one per target)
  24376. */
  24377. readonly influences: Float32Array;
  24378. /**
  24379. * Gets the active target at specified index. An active target is a target with an influence > 0
  24380. * @param index defines the index to check
  24381. * @returns the requested target
  24382. */
  24383. getActiveTarget(index: number): MorphTarget;
  24384. /**
  24385. * Gets the target at specified index
  24386. * @param index defines the index to check
  24387. * @returns the requested target
  24388. */
  24389. getTarget(index: number): MorphTarget;
  24390. /**
  24391. * Add a new target to this manager
  24392. * @param target defines the target to add
  24393. */
  24394. addTarget(target: MorphTarget): void;
  24395. /**
  24396. * Removes a target from the manager
  24397. * @param target defines the target to remove
  24398. */
  24399. removeTarget(target: MorphTarget): void;
  24400. /**
  24401. * Serializes the current manager into a Serialization object
  24402. * @returns the serialized object
  24403. */
  24404. serialize(): any;
  24405. private _syncActiveTargets;
  24406. /**
  24407. * Syncrhonize the targets with all the meshes using this morph target manager
  24408. */
  24409. synchronize(): void;
  24410. /**
  24411. * Creates a new MorphTargetManager from serialized data
  24412. * @param serializationObject defines the serialized data
  24413. * @param scene defines the hosting scene
  24414. * @returns the new MorphTargetManager
  24415. */
  24416. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  24417. }
  24418. }
  24419. declare module BABYLON {
  24420. /**
  24421. * Class used to store all common mesh properties
  24422. */
  24423. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24424. /** No occlusion */
  24425. static OCCLUSION_TYPE_NONE: number;
  24426. /** Occlusion set to optimisitic */
  24427. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24428. /** Occlusion set to strict */
  24429. static OCCLUSION_TYPE_STRICT: number;
  24430. /** Use an accurante occlusion algorithm */
  24431. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24432. /** Use a conservative occlusion algorithm */
  24433. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24434. /** Default culling strategy with bounding box and bounding sphere and then frustum culling */
  24435. static readonly CULLINGSTRATEGY_STANDARD: number;
  24436. /** Culling strategy with bounding sphere only and then frustum culling */
  24437. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24438. /**
  24439. * No billboard
  24440. */
  24441. static readonly BILLBOARDMODE_NONE: number;
  24442. /** Billboard on X axis */
  24443. static readonly BILLBOARDMODE_X: number;
  24444. /** Billboard on Y axis */
  24445. static readonly BILLBOARDMODE_Y: number;
  24446. /** Billboard on Z axis */
  24447. static readonly BILLBOARDMODE_Z: number;
  24448. /** Billboard on all axes */
  24449. static readonly BILLBOARDMODE_ALL: number;
  24450. private _facetData;
  24451. /** Gets ot sets the culling strategy to use to find visible meshes */
  24452. cullingStrategy: number;
  24453. /**
  24454. * Gets the number of facets in the mesh
  24455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24456. */
  24457. readonly facetNb: number;
  24458. /**
  24459. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24461. */
  24462. partitioningSubdivisions: number;
  24463. /**
  24464. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24465. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24466. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24467. */
  24468. partitioningBBoxRatio: number;
  24469. /**
  24470. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24471. * Works only for updatable meshes.
  24472. * Doesn't work with multi-materials
  24473. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24474. */
  24475. mustDepthSortFacets: boolean;
  24476. /**
  24477. * The location (Vector3) where the facet depth sort must be computed from.
  24478. * By default, the active camera position.
  24479. * Used only when facet depth sort is enabled
  24480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24481. */
  24482. facetDepthSortFrom: Vector3;
  24483. /**
  24484. * gets a boolean indicating if facetData is enabled
  24485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24486. */
  24487. readonly isFacetDataEnabled: boolean;
  24488. /** @hidden */
  24489. _updateNonUniformScalingState(value: boolean): boolean;
  24490. /**
  24491. * An event triggered when this mesh collides with another one
  24492. */
  24493. onCollideObservable: Observable<AbstractMesh>;
  24494. private _onCollideObserver;
  24495. /** Set a function to call when this mesh collides with another one */
  24496. onCollide: () => void;
  24497. /**
  24498. * An event triggered when the collision's position changes
  24499. */
  24500. onCollisionPositionChangeObservable: Observable<Vector3>;
  24501. private _onCollisionPositionChangeObserver;
  24502. /** Set a function to call when the collision's position changes */
  24503. onCollisionPositionChange: () => void;
  24504. /**
  24505. * An event triggered when material is changed
  24506. */
  24507. onMaterialChangedObservable: Observable<AbstractMesh>;
  24508. /**
  24509. * Gets or sets the orientation for POV movement & rotation
  24510. */
  24511. definedFacingForward: boolean;
  24512. /** @hidden */
  24513. _occlusionQuery: Nullable<WebGLQuery>;
  24514. private _visibility;
  24515. /**
  24516. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24517. */
  24518. /**
  24519. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24520. */
  24521. visibility: number;
  24522. /** Gets or sets the alpha index used to sort transparent meshes
  24523. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24524. */
  24525. alphaIndex: number;
  24526. /**
  24527. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24528. */
  24529. isVisible: boolean;
  24530. /**
  24531. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24532. */
  24533. isPickable: boolean;
  24534. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24535. showSubMeshesBoundingBox: boolean;
  24536. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24537. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24538. */
  24539. isBlocker: boolean;
  24540. /**
  24541. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24542. */
  24543. enablePointerMoveEvents: boolean;
  24544. /**
  24545. * Specifies the rendering group id for this mesh (0 by default)
  24546. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24547. */
  24548. renderingGroupId: number;
  24549. private _material;
  24550. /** Gets or sets current material */
  24551. material: Nullable<Material>;
  24552. private _receiveShadows;
  24553. /**
  24554. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24555. * @see http://doc.babylonjs.com/babylon101/shadows
  24556. */
  24557. receiveShadows: boolean;
  24558. /** Defines color to use when rendering outline */
  24559. outlineColor: Color3;
  24560. /** Define width to use when rendering outline */
  24561. outlineWidth: number;
  24562. /** Defines color to use when rendering overlay */
  24563. overlayColor: Color3;
  24564. /** Defines alpha to use when rendering overlay */
  24565. overlayAlpha: number;
  24566. private _hasVertexAlpha;
  24567. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24568. hasVertexAlpha: boolean;
  24569. private _useVertexColors;
  24570. /** 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) */
  24571. useVertexColors: boolean;
  24572. private _computeBonesUsingShaders;
  24573. /**
  24574. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24575. */
  24576. computeBonesUsingShaders: boolean;
  24577. private _numBoneInfluencers;
  24578. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24579. numBoneInfluencers: number;
  24580. private _applyFog;
  24581. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24582. applyFog: boolean;
  24583. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24584. useOctreeForRenderingSelection: boolean;
  24585. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24586. useOctreeForPicking: boolean;
  24587. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24588. useOctreeForCollisions: boolean;
  24589. private _layerMask;
  24590. /**
  24591. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24592. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24593. */
  24594. layerMask: number;
  24595. /**
  24596. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24597. */
  24598. alwaysSelectAsActiveMesh: boolean;
  24599. /**
  24600. * Gets or sets the current action manager
  24601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24602. */
  24603. actionManager: Nullable<ActionManager>;
  24604. private _checkCollisions;
  24605. private _collisionMask;
  24606. private _collisionGroup;
  24607. /**
  24608. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24609. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24610. */
  24611. ellipsoid: Vector3;
  24612. /**
  24613. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24614. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24615. */
  24616. ellipsoidOffset: Vector3;
  24617. private _collider;
  24618. private _oldPositionForCollisions;
  24619. private _diffPositionForCollisions;
  24620. /**
  24621. * Gets or sets a collision mask used to mask collisions (default is -1).
  24622. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24623. */
  24624. collisionMask: number;
  24625. /**
  24626. * Gets or sets the current collision group mask (-1 by default).
  24627. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24628. */
  24629. collisionGroup: number;
  24630. /**
  24631. * Defines edge width used when edgesRenderer is enabled
  24632. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24633. */
  24634. edgesWidth: number;
  24635. /**
  24636. * Defines edge color used when edgesRenderer is enabled
  24637. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24638. */
  24639. edgesColor: Color4;
  24640. /** @hidden */
  24641. _edgesRenderer: Nullable<IEdgesRenderer>;
  24642. /** @hidden */
  24643. _masterMesh: Nullable<AbstractMesh>;
  24644. /** @hidden */
  24645. _boundingInfo: Nullable<BoundingInfo>;
  24646. /** @hidden */
  24647. _renderId: number;
  24648. /**
  24649. * Gets or sets the list of subMeshes
  24650. * @see http://doc.babylonjs.com/how_to/multi_materials
  24651. */
  24652. subMeshes: SubMesh[];
  24653. /** @hidden */
  24654. _intersectionsInProgress: AbstractMesh[];
  24655. /** @hidden */
  24656. _unIndexed: boolean;
  24657. /** @hidden */
  24658. _lightSources: Light[];
  24659. /** @hidden */
  24660. readonly _positions: Nullable<Vector3[]>;
  24661. /** @hidden */
  24662. _waitingActions: any;
  24663. /** @hidden */
  24664. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24665. private _skeleton;
  24666. /** @hidden */
  24667. _bonesTransformMatrices: Nullable<Float32Array>;
  24668. /**
  24669. * Gets or sets a skeleton to apply skining transformations
  24670. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24671. */
  24672. skeleton: Nullable<Skeleton>;
  24673. /**
  24674. * An event triggered when the mesh is rebuilt.
  24675. */
  24676. onRebuildObservable: Observable<AbstractMesh>;
  24677. /**
  24678. * Creates a new AbstractMesh
  24679. * @param name defines the name of the mesh
  24680. * @param scene defines the hosting scene
  24681. */
  24682. constructor(name: string, scene?: Nullable<Scene>);
  24683. /**
  24684. * Returns the string "AbstractMesh"
  24685. * @returns "AbstractMesh"
  24686. */
  24687. getClassName(): string;
  24688. /**
  24689. * Gets a string representation of the current mesh
  24690. * @param fullDetails defines a boolean indicating if full details must be included
  24691. * @returns a string representation of the current mesh
  24692. */
  24693. toString(fullDetails?: boolean): string;
  24694. /** @hidden */
  24695. _rebuild(): void;
  24696. /** @hidden */
  24697. _resyncLightSources(): void;
  24698. /** @hidden */
  24699. _resyncLighSource(light: Light): void;
  24700. /** @hidden */
  24701. _unBindEffect(): void;
  24702. /** @hidden */
  24703. _removeLightSource(light: Light): void;
  24704. private _markSubMeshesAsDirty;
  24705. /** @hidden */
  24706. _markSubMeshesAsLightDirty(): void;
  24707. /** @hidden */
  24708. _markSubMeshesAsAttributesDirty(): void;
  24709. /** @hidden */
  24710. _markSubMeshesAsMiscDirty(): void;
  24711. /**
  24712. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24713. */
  24714. scaling: Vector3;
  24715. /**
  24716. * Returns true if the mesh is blocked. Implemented by child classes
  24717. */
  24718. readonly isBlocked: boolean;
  24719. /**
  24720. * Returns the mesh itself by default. Implemented by child classes
  24721. * @param camera defines the camera to use to pick the right LOD level
  24722. * @returns the currentAbstractMesh
  24723. */
  24724. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24725. /**
  24726. * Returns 0 by default. Implemented by child classes
  24727. * @returns an integer
  24728. */
  24729. getTotalVertices(): number;
  24730. /**
  24731. * Returns a positive integer : the total number of indices in this mesh geometry.
  24732. * @returns the numner of indices or zero if the mesh has no geometry.
  24733. */
  24734. getTotalIndices(): number;
  24735. /**
  24736. * Returns null by default. Implemented by child classes
  24737. * @returns null
  24738. */
  24739. getIndices(): Nullable<IndicesArray>;
  24740. /**
  24741. * Returns the array of the requested vertex data kind. Implemented by child classes
  24742. * @param kind defines the vertex data kind to use
  24743. * @returns null
  24744. */
  24745. getVerticesData(kind: string): Nullable<FloatArray>;
  24746. /**
  24747. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24748. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24749. * Note that a new underlying VertexBuffer object is created each call.
  24750. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24751. * @param kind defines vertex data kind:
  24752. * * BABYLON.VertexBuffer.PositionKind
  24753. * * BABYLON.VertexBuffer.UVKind
  24754. * * BABYLON.VertexBuffer.UV2Kind
  24755. * * BABYLON.VertexBuffer.UV3Kind
  24756. * * BABYLON.VertexBuffer.UV4Kind
  24757. * * BABYLON.VertexBuffer.UV5Kind
  24758. * * BABYLON.VertexBuffer.UV6Kind
  24759. * * BABYLON.VertexBuffer.ColorKind
  24760. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24761. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24762. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24763. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24764. * @param data defines the data source
  24765. * @param updatable defines if the data must be flagged as updatable (or static)
  24766. * @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
  24767. * @returns the current mesh
  24768. */
  24769. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24770. /**
  24771. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24772. * If the mesh has no geometry, it is simply returned as it is.
  24773. * @param kind defines vertex data kind:
  24774. * * BABYLON.VertexBuffer.PositionKind
  24775. * * BABYLON.VertexBuffer.UVKind
  24776. * * BABYLON.VertexBuffer.UV2Kind
  24777. * * BABYLON.VertexBuffer.UV3Kind
  24778. * * BABYLON.VertexBuffer.UV4Kind
  24779. * * BABYLON.VertexBuffer.UV5Kind
  24780. * * BABYLON.VertexBuffer.UV6Kind
  24781. * * BABYLON.VertexBuffer.ColorKind
  24782. * * BABYLON.VertexBuffer.MatricesIndicesKind
  24783. * * BABYLON.VertexBuffer.MatricesIndicesExtraKind
  24784. * * BABYLON.VertexBuffer.MatricesWeightsKind
  24785. * * BABYLON.VertexBuffer.MatricesWeightsExtraKind
  24786. * @param data defines the data source
  24787. * @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
  24788. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24789. * @returns the current mesh
  24790. */
  24791. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24792. /**
  24793. * Sets the mesh indices,
  24794. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24795. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24796. * @param totalVertices Defines the total number of vertices
  24797. * @returns the current mesh
  24798. */
  24799. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24800. /**
  24801. * Gets a boolean indicating if specific vertex data is present
  24802. * @param kind defines the vertex data kind to use
  24803. * @returns true is data kind is present
  24804. */
  24805. isVerticesDataPresent(kind: string): boolean;
  24806. /**
  24807. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24808. * @returns a BoundingInfo
  24809. */
  24810. getBoundingInfo(): BoundingInfo;
  24811. /**
  24812. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24813. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  24814. * @returns the current mesh
  24815. */
  24816. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  24817. /**
  24818. * Overwrite the current bounding info
  24819. * @param boundingInfo defines the new bounding info
  24820. * @returns the current mesh
  24821. */
  24822. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24823. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24824. readonly useBones: boolean;
  24825. /** @hidden */
  24826. _preActivate(): void;
  24827. /** @hidden */
  24828. _preActivateForIntermediateRendering(renderId: number): void;
  24829. /** @hidden */
  24830. _activate(renderId: number): void;
  24831. /**
  24832. * Gets the current world matrix
  24833. * @returns a Matrix
  24834. */
  24835. getWorldMatrix(): Matrix;
  24836. /** @hidden */
  24837. _getWorldMatrixDeterminant(): number;
  24838. /**
  24839. * Perform relative position change from the point of view of behind the front of the mesh.
  24840. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24841. * Supports definition of mesh facing forward or backward
  24842. * @param amountRight defines the distance on the right axis
  24843. * @param amountUp defines the distance on the up axis
  24844. * @param amountForward defines the distance on the forward axis
  24845. * @returns the current mesh
  24846. */
  24847. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24848. /**
  24849. * Calculate relative position change from the point of view of behind the front of the mesh.
  24850. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24851. * Supports definition of mesh facing forward or backward
  24852. * @param amountRight defines the distance on the right axis
  24853. * @param amountUp defines the distance on the up axis
  24854. * @param amountForward defines the distance on the forward axis
  24855. * @returns the new displacement vector
  24856. */
  24857. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24858. /**
  24859. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24860. * Supports definition of mesh facing forward or backward
  24861. * @param flipBack defines the flip
  24862. * @param twirlClockwise defines the twirl
  24863. * @param tiltRight defines the tilt
  24864. * @returns the current mesh
  24865. */
  24866. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24867. /**
  24868. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24869. * Supports definition of mesh facing forward or backward.
  24870. * @param flipBack defines the flip
  24871. * @param twirlClockwise defines the twirl
  24872. * @param tiltRight defines the tilt
  24873. * @returns the new rotation vector
  24874. */
  24875. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24876. /**
  24877. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  24878. * @param includeDescendants Include bounding info from descendants as well (true by default)
  24879. * @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
  24880. * @returns the new bounding vectors
  24881. */
  24882. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  24883. min: Vector3;
  24884. max: Vector3;
  24885. };
  24886. /**
  24887. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24888. * This means the mesh underlying bounding box and sphere are recomputed.
  24889. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24890. * @returns the current mesh
  24891. */
  24892. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24893. /** @hidden */
  24894. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24895. /** @hidden */
  24896. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24897. /** @hidden */
  24898. _updateBoundingInfo(): AbstractMesh;
  24899. /** @hidden */
  24900. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  24901. /** @hidden */
  24902. protected _afterComputeWorldMatrix(): void;
  24903. /**
  24904. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24905. * A mesh is in the frustum if its bounding box intersects the frustum
  24906. * @param frustumPlanes defines the frustum to test
  24907. * @returns true if the mesh is in the frustum planes
  24908. */
  24909. isInFrustum(frustumPlanes: Plane[]): boolean;
  24910. /**
  24911. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24912. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24913. * @param frustumPlanes defines the frustum to test
  24914. * @returns true if the mesh is completely in the frustum planes
  24915. */
  24916. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24917. /**
  24918. * True if the mesh intersects another mesh or a SolidParticle object
  24919. * @param mesh defines a target mesh or SolidParticle to test
  24920. * @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)
  24921. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24922. * @returns true if there is an intersection
  24923. */
  24924. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24925. /**
  24926. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24927. * @param point defines the point to test
  24928. * @returns true if there is an intersection
  24929. */
  24930. intersectsPoint(point: Vector3): boolean;
  24931. /**
  24932. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24933. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24934. */
  24935. checkCollisions: boolean;
  24936. /**
  24937. * Gets Collider object used to compute collisions (not physics)
  24938. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24939. */
  24940. readonly collider: Collider;
  24941. /**
  24942. * Move the mesh using collision engine
  24943. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24944. * @param displacement defines the requested displacement vector
  24945. * @returns the current mesh
  24946. */
  24947. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24948. private _onCollisionPositionChange;
  24949. /** @hidden */
  24950. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24951. /** @hidden */
  24952. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24953. /** @hidden */
  24954. _checkCollision(collider: Collider): AbstractMesh;
  24955. /** @hidden */
  24956. _generatePointsArray(): boolean;
  24957. /**
  24958. * Checks if the passed Ray intersects with the mesh
  24959. * @param ray defines the ray to use
  24960. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24961. * @returns the picking info
  24962. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24963. */
  24964. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  24965. /**
  24966. * Clones the current mesh
  24967. * @param name defines the mesh name
  24968. * @param newParent defines the new mesh parent
  24969. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24970. * @returns the new mesh
  24971. */
  24972. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24973. /**
  24974. * Disposes all the submeshes of the current meshnp
  24975. * @returns the current mesh
  24976. */
  24977. releaseSubMeshes(): AbstractMesh;
  24978. /**
  24979. * Releases resources associated with this abstract mesh.
  24980. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24981. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24982. */
  24983. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24984. /**
  24985. * Adds the passed mesh as a child to the current mesh
  24986. * @param mesh defines the child mesh
  24987. * @returns the current mesh
  24988. */
  24989. addChild(mesh: AbstractMesh): AbstractMesh;
  24990. /**
  24991. * Removes the passed mesh from the current mesh children list
  24992. * @param mesh defines the child mesh
  24993. * @returns the current mesh
  24994. */
  24995. removeChild(mesh: AbstractMesh): AbstractMesh;
  24996. /** @hidden */
  24997. private _initFacetData;
  24998. /**
  24999. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25000. * This method can be called within the render loop.
  25001. * 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
  25002. * @returns the current mesh
  25003. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25004. */
  25005. updateFacetData(): AbstractMesh;
  25006. /**
  25007. * Returns the facetLocalNormals array.
  25008. * The normals are expressed in the mesh local spac
  25009. * @returns an array of Vector3
  25010. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25011. */
  25012. getFacetLocalNormals(): Vector3[];
  25013. /**
  25014. * Returns the facetLocalPositions array.
  25015. * The facet positions are expressed in the mesh local space
  25016. * @returns an array of Vector3
  25017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25018. */
  25019. getFacetLocalPositions(): Vector3[];
  25020. /**
  25021. * Returns the facetLocalPartioning array
  25022. * @returns an array of array of numbers
  25023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25024. */
  25025. getFacetLocalPartitioning(): number[][];
  25026. /**
  25027. * Returns the i-th facet position in the world system.
  25028. * This method allocates a new Vector3 per call
  25029. * @param i defines the facet index
  25030. * @returns a new Vector3
  25031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25032. */
  25033. getFacetPosition(i: number): Vector3;
  25034. /**
  25035. * Sets the reference Vector3 with the i-th facet position in the world system
  25036. * @param i defines the facet index
  25037. * @param ref defines the target vector
  25038. * @returns the current mesh
  25039. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25040. */
  25041. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25042. /**
  25043. * Returns the i-th facet normal in the world system.
  25044. * This method allocates a new Vector3 per call
  25045. * @param i defines the facet index
  25046. * @returns a new Vector3
  25047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25048. */
  25049. getFacetNormal(i: number): Vector3;
  25050. /**
  25051. * Sets the reference Vector3 with the i-th facet normal in the world system
  25052. * @param i defines the facet index
  25053. * @param ref defines the target vector
  25054. * @returns the current mesh
  25055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25056. */
  25057. getFacetNormalToRef(i: number, ref: Vector3): this;
  25058. /**
  25059. * 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)
  25060. * @param x defines x coordinate
  25061. * @param y defines y coordinate
  25062. * @param z defines z coordinate
  25063. * @returns the array of facet indexes
  25064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25065. */
  25066. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25067. /**
  25068. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25069. * @param projected sets as the (x,y,z) world projection on the facet
  25070. * @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
  25071. * @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
  25072. * @param x defines x coordinate
  25073. * @param y defines y coordinate
  25074. * @param z defines z coordinate
  25075. * @returns the face index if found (or null instead)
  25076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25077. */
  25078. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25079. /**
  25080. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25081. * @param projected sets as the (x,y,z) local projection on the facet
  25082. * @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
  25083. * @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
  25084. * @param x defines x coordinate
  25085. * @param y defines y coordinate
  25086. * @param z defines z coordinate
  25087. * @returns the face index if found (or null instead)
  25088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25089. */
  25090. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25091. /**
  25092. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25093. * @returns the parameters
  25094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25095. */
  25096. getFacetDataParameters(): any;
  25097. /**
  25098. * Disables the feature FacetData and frees the related memory
  25099. * @returns the current mesh
  25100. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25101. */
  25102. disableFacetData(): AbstractMesh;
  25103. /**
  25104. * Updates the AbstractMesh indices array
  25105. * @param indices defines the data source
  25106. * @returns the current mesh
  25107. */
  25108. updateIndices(indices: IndicesArray): AbstractMesh;
  25109. /**
  25110. * Creates new normals data for the mesh
  25111. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25112. * @returns the current mesh
  25113. */
  25114. createNormals(updatable: boolean): AbstractMesh;
  25115. /**
  25116. * Align the mesh with a normal
  25117. * @param normal defines the normal to use
  25118. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25119. * @returns the current mesh
  25120. */
  25121. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25122. /** @hidden */
  25123. _checkOcclusionQuery(): boolean;
  25124. }
  25125. }
  25126. declare module BABYLON {
  25127. /**
  25128. * Class used to store data that will be store in GPU memory
  25129. */
  25130. class Buffer {
  25131. private _engine;
  25132. private _buffer;
  25133. /** @hidden */
  25134. _data: Nullable<DataArray>;
  25135. private _updatable;
  25136. private _instanced;
  25137. /**
  25138. * Gets the byte stride.
  25139. */
  25140. readonly byteStride: number;
  25141. /**
  25142. * Constructor
  25143. * @param engine the engine
  25144. * @param data the data to use for this buffer
  25145. * @param updatable whether the data is updatable
  25146. * @param stride the stride (optional)
  25147. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  25148. * @param instanced whether the buffer is instanced (optional)
  25149. * @param useBytes set to true if the stride in in bytes (optional)
  25150. */
  25151. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  25152. /**
  25153. * Create a new VertexBuffer based on the current buffer
  25154. * @param kind defines the vertex buffer kind (position, normal, etc.)
  25155. * @param offset defines offset in the buffer (0 by default)
  25156. * @param size defines the size in floats of attributes (position is 3 for instance)
  25157. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  25158. * @param instanced defines if the vertex buffer contains indexed data
  25159. * @param useBytes defines if the offset and stride are in bytes
  25160. * @returns the new vertex buffer
  25161. */
  25162. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  25163. /**
  25164. * Gets a boolean indicating if the Buffer is updatable?
  25165. * @returns true if the buffer is updatable
  25166. */
  25167. isUpdatable(): boolean;
  25168. /**
  25169. * Gets current buffer's data
  25170. * @returns a DataArray or null
  25171. */
  25172. getData(): Nullable<DataArray>;
  25173. /**
  25174. * Gets underlying native buffer
  25175. * @returns underlying native buffer
  25176. */
  25177. getBuffer(): Nullable<WebGLBuffer>;
  25178. /**
  25179. * Gets the stride in float32 units (i.e. byte stride / 4).
  25180. * May not be an integer if the byte stride is not divisible by 4.
  25181. * DEPRECATED. Use byteStride instead.
  25182. * @returns the stride in float32 units
  25183. */
  25184. getStrideSize(): number;
  25185. /**
  25186. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  25187. * @param data defines the data to store
  25188. */
  25189. create(data?: Nullable<DataArray>): void;
  25190. /** @hidden */
  25191. _rebuild(): void;
  25192. /**
  25193. * Update current buffer data
  25194. * @param data defines the data to store
  25195. */
  25196. update(data: DataArray): void;
  25197. /**
  25198. * Updates the data directly.
  25199. * @param data the new data
  25200. * @param offset the new offset
  25201. * @param vertexCount the vertex count (optional)
  25202. * @param useBytes set to true if the offset is in bytes
  25203. */
  25204. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  25205. /**
  25206. * Release all resources
  25207. */
  25208. dispose(): void;
  25209. }
  25210. }
  25211. declare module BABYLON {
  25212. /**
  25213. * Class for building Constructive Solid Geometry
  25214. */
  25215. class CSG {
  25216. private polygons;
  25217. /**
  25218. * The world matrix
  25219. */
  25220. matrix: Matrix;
  25221. /**
  25222. * Stores the position
  25223. */
  25224. position: Vector3;
  25225. /**
  25226. * Stores the rotation
  25227. */
  25228. rotation: Vector3;
  25229. /**
  25230. * Stores the rotation quaternion
  25231. */
  25232. rotationQuaternion: Nullable<Quaternion>;
  25233. /**
  25234. * Stores the scaling vector
  25235. */
  25236. scaling: Vector3;
  25237. /**
  25238. * Convert the BABYLON.Mesh to BABYLON.CSG
  25239. * @param mesh The BABYLON.Mesh to convert to BABYLON.CSG
  25240. * @returns A new BABYLON.CSG from the BABYLON.Mesh
  25241. */
  25242. static FromMesh(mesh: Mesh): CSG;
  25243. /**
  25244. * Construct a BABYLON.CSG solid from a list of `BABYLON.CSG.Polygon` instances.
  25245. * @param polygons Polygons used to construct a BABYLON.CSG solid
  25246. */
  25247. private static FromPolygons;
  25248. /**
  25249. * Clones, or makes a deep copy, of the BABYLON.CSG
  25250. * @returns A new BABYLON.CSG
  25251. */
  25252. clone(): CSG;
  25253. /**
  25254. * Unions this CSG with another CSG
  25255. * @param csg The CSG to union against this CSG
  25256. * @returns The unioned CSG
  25257. */
  25258. union(csg: CSG): CSG;
  25259. /**
  25260. * Unions this CSG with another CSG in place
  25261. * @param csg The CSG to union against this CSG
  25262. */
  25263. unionInPlace(csg: CSG): void;
  25264. /**
  25265. * Subtracts this CSG with another CSG
  25266. * @param csg The CSG to subtract against this CSG
  25267. * @returns A new BABYLON.CSG
  25268. */
  25269. subtract(csg: CSG): CSG;
  25270. /**
  25271. * Subtracts this CSG with another CSG in place
  25272. * @param csg The CSG to subtact against this CSG
  25273. */
  25274. subtractInPlace(csg: CSG): void;
  25275. /**
  25276. * Intersect this CSG with another CSG
  25277. * @param csg The CSG to intersect against this CSG
  25278. * @returns A new BABYLON.CSG
  25279. */
  25280. intersect(csg: CSG): CSG;
  25281. /**
  25282. * Intersects this CSG with another CSG in place
  25283. * @param csg The CSG to intersect against this CSG
  25284. */
  25285. intersectInPlace(csg: CSG): void;
  25286. /**
  25287. * Return a new BABYLON.CSG solid with solid and empty space switched. This solid is
  25288. * not modified.
  25289. * @returns A new BABYLON.CSG solid with solid and empty space switched
  25290. */
  25291. inverse(): CSG;
  25292. /**
  25293. * Inverses the BABYLON.CSG in place
  25294. */
  25295. inverseInPlace(): void;
  25296. /**
  25297. * This is used to keep meshes transformations so they can be restored
  25298. * when we build back a Babylon Mesh
  25299. * NB : All CSG operations are performed in world coordinates
  25300. * @param csg The BABYLON.CSG to copy the transform attributes from
  25301. * @returns This BABYLON.CSG
  25302. */
  25303. copyTransformAttributes(csg: CSG): CSG;
  25304. /**
  25305. * Build Raw mesh from CSG
  25306. * Coordinates here are in world space
  25307. * @param name The name of the mesh geometry
  25308. * @param scene The BABYLON.Scene
  25309. * @param keepSubMeshes Specifies if the submeshes should be kept
  25310. * @returns A new BABYLON.Mesh
  25311. */
  25312. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  25313. /**
  25314. * Build Mesh from CSG taking material and transforms into account
  25315. * @param name The name of the BABYLON.Mesh
  25316. * @param material The material of the BABYLON.Mesh
  25317. * @param scene The BABYLON.Scene
  25318. * @param keepSubMeshes Specifies if submeshes should be kept
  25319. * @returns The new BABYLON.Mesh
  25320. */
  25321. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  25322. }
  25323. }
  25324. declare module BABYLON {
  25325. /**
  25326. * Class used to store geometry data (vertex buffers + index buffer)
  25327. */
  25328. class Geometry implements IGetSetVerticesData {
  25329. /**
  25330. * Gets or sets the unique ID of the geometry
  25331. */
  25332. id: string;
  25333. /**
  25334. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25335. */
  25336. delayLoadState: number;
  25337. /**
  25338. * Gets the file containing the data to load when running in delay load state
  25339. */
  25340. delayLoadingFile: Nullable<string>;
  25341. /**
  25342. * Callback called when the geometry is updated
  25343. */
  25344. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25345. private _scene;
  25346. private _engine;
  25347. private _meshes;
  25348. private _totalVertices;
  25349. /** @hidden */
  25350. _indices: IndicesArray;
  25351. /** @hidden */
  25352. _vertexBuffers: {
  25353. [key: string]: VertexBuffer;
  25354. };
  25355. private _isDisposed;
  25356. private _extend;
  25357. private _boundingBias;
  25358. /** @hidden */
  25359. _delayInfo: Array<string>;
  25360. private _indexBuffer;
  25361. private _indexBufferIsUpdatable;
  25362. /** @hidden */
  25363. _boundingInfo: Nullable<BoundingInfo>;
  25364. /** @hidden */
  25365. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25366. /** @hidden */
  25367. _softwareSkinningFrameId: number;
  25368. private _vertexArrayObjects;
  25369. private _updatable;
  25370. /** @hidden */
  25371. _positions: Nullable<Vector3[]>;
  25372. /**
  25373. * 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
  25374. */
  25375. /**
  25376. * 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
  25377. */
  25378. boundingBias: Vector2;
  25379. /**
  25380. * Static function used to attach a new empty geometry to a mesh
  25381. * @param mesh defines the mesh to attach the geometry to
  25382. * @returns the new Geometry
  25383. */
  25384. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25385. /**
  25386. * Creates a new geometry
  25387. * @param id defines the unique ID
  25388. * @param scene defines the hosting scene
  25389. * @param vertexData defines the VertexData used to get geometry data
  25390. * @param updatable defines if geometry must be updatable (false by default)
  25391. * @param mesh defines the mesh that will be associated with the geometry
  25392. */
  25393. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25394. /**
  25395. * Gets the current extend of the geometry
  25396. */
  25397. readonly extend: {
  25398. minimum: Vector3;
  25399. maximum: Vector3;
  25400. };
  25401. /**
  25402. * Gets the hosting scene
  25403. * @returns the hosting Scene
  25404. */
  25405. getScene(): Scene;
  25406. /**
  25407. * Gets the hosting engine
  25408. * @returns the hosting Engine
  25409. */
  25410. getEngine(): Engine;
  25411. /**
  25412. * Defines if the geometry is ready to use
  25413. * @returns true if the geometry is ready to be used
  25414. */
  25415. isReady(): boolean;
  25416. /**
  25417. * Gets a value indicating that the geometry should not be serialized
  25418. */
  25419. readonly doNotSerialize: boolean;
  25420. /** @hidden */
  25421. _rebuild(): void;
  25422. /**
  25423. * Affects all geometry data in one call
  25424. * @param vertexData defines the geometry data
  25425. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25426. */
  25427. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25428. /**
  25429. * Set specific vertex data
  25430. * @param kind defines the data kind (Position, normal, etc...)
  25431. * @param data defines the vertex data to use
  25432. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25433. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25434. */
  25435. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25436. /**
  25437. * Removes a specific vertex data
  25438. * @param kind defines the data kind (Position, normal, etc...)
  25439. */
  25440. removeVerticesData(kind: string): void;
  25441. /**
  25442. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25443. * @param buffer defines the vertex buffer to use
  25444. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25445. */
  25446. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25447. /**
  25448. * Update a specific vertex buffer
  25449. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  25450. * It will do nothing if the buffer is not updatable
  25451. * @param kind defines the data kind (Position, normal, etc...)
  25452. * @param data defines the data to use
  25453. * @param offset defines the offset in the target buffer where to store the data
  25454. * @param useBytes set to true if the offset is in bytes
  25455. */
  25456. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25457. /**
  25458. * Update a specific vertex buffer
  25459. * This function will create a new buffer if the current one is not updatable
  25460. * @param kind defines the data kind (Position, normal, etc...)
  25461. * @param data defines the data to use
  25462. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25463. */
  25464. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25465. private _updateBoundingInfo;
  25466. /** @hidden */
  25467. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  25468. /**
  25469. * Gets total number of vertices
  25470. * @returns the total number of vertices
  25471. */
  25472. getTotalVertices(): number;
  25473. /**
  25474. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25475. * @param kind defines the data kind (Position, normal, etc...)
  25476. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25477. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25478. * @returns a float array containing vertex data
  25479. */
  25480. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25481. /**
  25482. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25483. * @param kind defines the data kind (Position, normal, etc...)
  25484. * @returns true if the vertex buffer with the specified kind is updatable
  25485. */
  25486. isVertexBufferUpdatable(kind: string): boolean;
  25487. /**
  25488. * Gets a specific vertex buffer
  25489. * @param kind defines the data kind (Position, normal, etc...)
  25490. * @returns a VertexBuffer
  25491. */
  25492. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25493. /**
  25494. * Returns all vertex buffers
  25495. * @return an object holding all vertex buffers indexed by kind
  25496. */
  25497. getVertexBuffers(): Nullable<{
  25498. [key: string]: VertexBuffer;
  25499. }>;
  25500. /**
  25501. * Gets a boolean indicating if specific vertex buffer is present
  25502. * @param kind defines the data kind (Position, normal, etc...)
  25503. * @returns true if data is present
  25504. */
  25505. isVerticesDataPresent(kind: string): boolean;
  25506. /**
  25507. * Gets a list of all attached data kinds (Position, normal, etc...)
  25508. * @returns a list of string containing all kinds
  25509. */
  25510. getVerticesDataKinds(): string[];
  25511. /**
  25512. * Update index buffer
  25513. * @param indices defines the indices to store in the index buffer
  25514. * @param offset defines the offset in the target buffer where to store the data
  25515. */
  25516. updateIndices(indices: IndicesArray, offset?: number): void;
  25517. /**
  25518. * Creates a new index buffer
  25519. * @param indices defines the indices to store in the index buffer
  25520. * @param totalVertices defines the total number of vertices (could be null)
  25521. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25522. */
  25523. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25524. /**
  25525. * Return the total number of indices
  25526. * @returns the total number of indices
  25527. */
  25528. getTotalIndices(): number;
  25529. /**
  25530. * Gets the index buffer array
  25531. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25532. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25533. * @returns the index buffer array
  25534. */
  25535. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25536. /**
  25537. * Gets the index buffer
  25538. * @return the index buffer
  25539. */
  25540. getIndexBuffer(): Nullable<WebGLBuffer>;
  25541. /** @hidden */
  25542. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25543. /**
  25544. * Release the associated resources for a specific mesh
  25545. * @param mesh defines the source mesh
  25546. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25547. */
  25548. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25549. /**
  25550. * Apply current geometry to a given mesh
  25551. * @param mesh defines the mesh to apply geometry to
  25552. */
  25553. applyToMesh(mesh: Mesh): void;
  25554. private _updateExtend;
  25555. private _applyToMesh;
  25556. private notifyUpdate;
  25557. /**
  25558. * Load the geometry if it was flagged as delay loaded
  25559. * @param scene defines the hosting scene
  25560. * @param onLoaded defines a callback called when the geometry is loaded
  25561. */
  25562. load(scene: Scene, onLoaded?: () => void): void;
  25563. private _queueLoad;
  25564. /**
  25565. * Invert the geometry to move from a right handed system to a left handed one.
  25566. */
  25567. toLeftHanded(): void;
  25568. /** @hidden */
  25569. _resetPointsArrayCache(): void;
  25570. /** @hidden */
  25571. _generatePointsArray(): boolean;
  25572. /**
  25573. * Gets a value indicating if the geometry is disposed
  25574. * @returns true if the geometry was disposed
  25575. */
  25576. isDisposed(): boolean;
  25577. private _disposeVertexArrayObjects;
  25578. /**
  25579. * Free all associated resources
  25580. */
  25581. dispose(): void;
  25582. /**
  25583. * Clone the current geometry into a new geometry
  25584. * @param id defines the unique ID of the new geometry
  25585. * @returns a new geometry object
  25586. */
  25587. copy(id: string): Geometry;
  25588. /**
  25589. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25590. * @return a JSON representation of the current geometry data (without the vertices data)
  25591. */
  25592. serialize(): any;
  25593. private toNumberArray;
  25594. /**
  25595. * Serialize all vertices data into a JSON oject
  25596. * @returns a JSON representation of the current geometry data
  25597. */
  25598. serializeVerticeData(): any;
  25599. /**
  25600. * Extracts a clone of a mesh geometry
  25601. * @param mesh defines the source mesh
  25602. * @param id defines the unique ID of the new geometry object
  25603. * @returns the new geometry object
  25604. */
  25605. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25606. /**
  25607. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25608. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25609. * Be aware Math.random() could cause collisions, but:
  25610. * "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"
  25611. * @returns a string containing a new GUID
  25612. */
  25613. static RandomId(): string;
  25614. /** @hidden */
  25615. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25616. private static _CleanMatricesWeights;
  25617. /**
  25618. * Create a new geometry from persisted data (Using .babylon file format)
  25619. * @param parsedVertexData defines the persisted data
  25620. * @param scene defines the hosting scene
  25621. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25622. * @returns the new geometry object
  25623. */
  25624. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25625. }
  25626. /**
  25627. * Abstract class used to provide common services for all typed geometries
  25628. * @hidden
  25629. */
  25630. class _PrimitiveGeometry extends Geometry {
  25631. private _canBeRegenerated;
  25632. private _beingRegenerated;
  25633. /**
  25634. * Creates a new typed geometry
  25635. * @param id defines the unique ID of the geometry
  25636. * @param scene defines the hosting scene
  25637. * @param _canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25638. * @param mesh defines the hosting mesh (can be null)
  25639. */
  25640. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  25641. /**
  25642. * Gets a value indicating if the geometry supports being regenerated with new parameters (false by default)
  25643. * @returns true if the geometry can be regenerated
  25644. */
  25645. canBeRegenerated(): boolean;
  25646. /**
  25647. * If the geometry supports regeneration, the function will recreates the geometry with updated parameter values
  25648. */
  25649. regenerate(): void;
  25650. /**
  25651. * Clone the geometry
  25652. * @param id defines the unique ID of the new geometry
  25653. * @returns the new geometry
  25654. */
  25655. asNewGeometry(id: string): Geometry;
  25656. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25657. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  25658. /** @hidden */
  25659. _regenerateVertexData(): VertexData;
  25660. copy(id: string): Geometry;
  25661. serialize(): any;
  25662. }
  25663. /**
  25664. * Creates a ribbon geometry
  25665. * @description See http://doc.babylonjs.com/how_to/ribbon_tutorial, http://doc.babylonjs.com/resources/maths_make_ribbons
  25666. */
  25667. class RibbonGeometry extends _PrimitiveGeometry {
  25668. /**
  25669. * Defines the array of paths to use
  25670. */
  25671. pathArray: Vector3[][];
  25672. /**
  25673. * Defines if the last and first points of each path in your pathArray must be joined
  25674. */
  25675. closeArray: boolean;
  25676. /**
  25677. * Defines if the last and first points of each path in your pathArray must be joined
  25678. */
  25679. closePath: boolean;
  25680. /**
  25681. * Defines the offset between points
  25682. */
  25683. offset: number;
  25684. /**
  25685. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25686. */
  25687. side: number;
  25688. /**
  25689. * Creates a ribbon geometry
  25690. * @param id defines the unique ID of the geometry
  25691. * @param scene defines the hosting scene
  25692. * @param pathArray defines the array of paths to use
  25693. * @param closeArray defines if the last path and the first path must be joined
  25694. * @param closePath defines if the last and first points of each path in your pathArray must be joined
  25695. * @param offset defines the offset between points
  25696. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25697. * @param mesh defines the hosting mesh (can be null)
  25698. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25699. */
  25700. constructor(id: string, scene: Scene,
  25701. /**
  25702. * Defines the array of paths to use
  25703. */
  25704. pathArray: Vector3[][],
  25705. /**
  25706. * Defines if the last and first points of each path in your pathArray must be joined
  25707. */
  25708. closeArray: boolean,
  25709. /**
  25710. * Defines if the last and first points of each path in your pathArray must be joined
  25711. */
  25712. closePath: boolean,
  25713. /**
  25714. * Defines the offset between points
  25715. */
  25716. offset: number, canBeRegenerated?: boolean, mesh?: Mesh,
  25717. /**
  25718. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25719. */
  25720. side?: number);
  25721. /** @hidden */
  25722. _regenerateVertexData(): VertexData;
  25723. copy(id: string): Geometry;
  25724. }
  25725. /**
  25726. * Creates a box geometry
  25727. * @description see http://doc.babylonjs.com/how_to/set_shapes#box
  25728. */
  25729. class BoxGeometry extends _PrimitiveGeometry {
  25730. /**
  25731. * Defines the zise of the box (width, height and depth are the same)
  25732. */
  25733. size: number;
  25734. /**
  25735. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25736. */
  25737. side: number;
  25738. /**
  25739. * Creates a box geometry
  25740. * @param id defines the unique ID of the geometry
  25741. * @param scene defines the hosting scene
  25742. * @param size defines the zise of the box (width, height and depth are the same)
  25743. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25744. * @param mesh defines the hosting mesh (can be null)
  25745. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25746. */
  25747. constructor(id: string, scene: Scene,
  25748. /**
  25749. * Defines the zise of the box (width, height and depth are the same)
  25750. */
  25751. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25752. /**
  25753. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25754. */
  25755. side?: number);
  25756. /** @hidden */
  25757. _regenerateVertexData(): VertexData;
  25758. copy(id: string): Geometry;
  25759. serialize(): any;
  25760. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  25761. }
  25762. /**
  25763. * Creates a sphere geometry
  25764. * @description see http://doc.babylonjs.com/how_to/set_shapes#sphere
  25765. */
  25766. class SphereGeometry extends _PrimitiveGeometry {
  25767. /**
  25768. * Defines the number of segments to use to create the sphere
  25769. */
  25770. segments: number;
  25771. /**
  25772. * Defines the diameter of the sphere
  25773. */
  25774. diameter: number;
  25775. /**
  25776. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25777. */
  25778. side: number;
  25779. /**
  25780. * Create a new sphere geometry
  25781. * @param id defines the unique ID of the geometry
  25782. * @param scene defines the hosting scene
  25783. * @param segments defines the number of segments to use to create the sphere
  25784. * @param diameter defines the diameter of the sphere
  25785. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25786. * @param mesh defines the hosting mesh (can be null)
  25787. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25788. */
  25789. constructor(id: string, scene: Scene,
  25790. /**
  25791. * Defines the number of segments to use to create the sphere
  25792. */
  25793. segments: number,
  25794. /**
  25795. * Defines the diameter of the sphere
  25796. */
  25797. diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25798. /**
  25799. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25800. */
  25801. side?: number);
  25802. /** @hidden */
  25803. _regenerateVertexData(): VertexData;
  25804. copy(id: string): Geometry;
  25805. serialize(): any;
  25806. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  25807. }
  25808. /**
  25809. * Creates a disc geometry
  25810. * @description see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25811. */
  25812. class DiscGeometry extends _PrimitiveGeometry {
  25813. /**
  25814. * Defines the radius of the disc
  25815. */
  25816. radius: number;
  25817. /**
  25818. * Defines the tesselation factor to apply to the disc
  25819. */
  25820. tessellation: number;
  25821. /**
  25822. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25823. */
  25824. side: number;
  25825. /**
  25826. * Creates a new disc geometry
  25827. * @param id defines the unique ID of the geometry
  25828. * @param scene defines the hosting scene
  25829. * @param radius defines the radius of the disc
  25830. * @param tessellation defines the tesselation factor to apply to the disc
  25831. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25832. * @param mesh defines the hosting mesh (can be null)
  25833. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25834. */
  25835. constructor(id: string, scene: Scene,
  25836. /**
  25837. * Defines the radius of the disc
  25838. */
  25839. radius: number,
  25840. /**
  25841. * Defines the tesselation factor to apply to the disc
  25842. */
  25843. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25844. /**
  25845. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25846. */
  25847. side?: number);
  25848. /** @hidden */
  25849. _regenerateVertexData(): VertexData;
  25850. copy(id: string): Geometry;
  25851. }
  25852. /**
  25853. * Creates a new cylinder geometry
  25854. * @description see http://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  25855. */
  25856. class CylinderGeometry extends _PrimitiveGeometry {
  25857. /**
  25858. * Defines the height of the cylinder
  25859. */
  25860. height: number;
  25861. /**
  25862. * Defines the diameter of the cylinder's top cap
  25863. */
  25864. diameterTop: number;
  25865. /**
  25866. * Defines the diameter of the cylinder's bottom cap
  25867. */
  25868. diameterBottom: number;
  25869. /**
  25870. * Defines the tessellation factor to apply to the cylinder
  25871. */
  25872. tessellation: number;
  25873. /**
  25874. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25875. */
  25876. subdivisions: number;
  25877. /**
  25878. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25879. */
  25880. side: number;
  25881. /**
  25882. * Creates a new cylinder geometry
  25883. * @param id defines the unique ID of the geometry
  25884. * @param scene defines the hosting scene
  25885. * @param height defines the height of the cylinder
  25886. * @param diameterTop defines the diameter of the cylinder's top cap
  25887. * @param diameterBottom defines the diameter of the cylinder's bottom cap
  25888. * @param tessellation defines the tessellation factor to apply to the cylinder (number of radial sides)
  25889. * @param subdivisions defines the number of subdivisions to apply to the cylinder (number of rings) (1 by default)
  25890. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25891. * @param mesh defines the hosting mesh (can be null)
  25892. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25893. */
  25894. constructor(id: string, scene: Scene,
  25895. /**
  25896. * Defines the height of the cylinder
  25897. */
  25898. height: number,
  25899. /**
  25900. * Defines the diameter of the cylinder's top cap
  25901. */
  25902. diameterTop: number,
  25903. /**
  25904. * Defines the diameter of the cylinder's bottom cap
  25905. */
  25906. diameterBottom: number,
  25907. /**
  25908. * Defines the tessellation factor to apply to the cylinder
  25909. */
  25910. tessellation: number,
  25911. /**
  25912. * Defines the number of subdivisions to apply to the cylinder (1 by default)
  25913. */
  25914. subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25915. /**
  25916. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25917. */
  25918. side?: number);
  25919. /** @hidden */
  25920. _regenerateVertexData(): VertexData;
  25921. copy(id: string): Geometry;
  25922. serialize(): any;
  25923. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  25924. }
  25925. /**
  25926. * Creates a new torus geometry
  25927. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus
  25928. */
  25929. class TorusGeometry extends _PrimitiveGeometry {
  25930. /**
  25931. * Defines the diameter of the torus
  25932. */
  25933. diameter: number;
  25934. /**
  25935. * Defines the thickness of the torus (ie. internal diameter)
  25936. */
  25937. thickness: number;
  25938. /**
  25939. * Defines the tesselation factor to apply to the torus
  25940. */
  25941. tessellation: number;
  25942. /**
  25943. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25944. */
  25945. side: number;
  25946. /**
  25947. * Creates a new torus geometry
  25948. * @param id defines the unique ID of the geometry
  25949. * @param scene defines the hosting scene
  25950. * @param diameter defines the diameter of the torus
  25951. * @param thickness defines the thickness of the torus (ie. internal diameter)
  25952. * @param tessellation defines the tesselation factor to apply to the torus (number of segments along the circle)
  25953. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  25954. * @param mesh defines the hosting mesh (can be null)
  25955. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25956. */
  25957. constructor(id: string, scene: Scene,
  25958. /**
  25959. * Defines the diameter of the torus
  25960. */
  25961. diameter: number,
  25962. /**
  25963. * Defines the thickness of the torus (ie. internal diameter)
  25964. */
  25965. thickness: number,
  25966. /**
  25967. * Defines the tesselation factor to apply to the torus
  25968. */
  25969. tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  25970. /**
  25971. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  25972. */
  25973. side?: number);
  25974. /** @hidden */
  25975. _regenerateVertexData(): VertexData;
  25976. copy(id: string): Geometry;
  25977. serialize(): any;
  25978. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  25979. }
  25980. /**
  25981. * Creates a new ground geometry
  25982. * @description see http://doc.babylonjs.com/how_to/set_shapes#ground
  25983. */
  25984. class GroundGeometry extends _PrimitiveGeometry {
  25985. /**
  25986. * Defines the width of the ground
  25987. */
  25988. width: number;
  25989. /**
  25990. * Defines the height of the ground
  25991. */
  25992. height: number;
  25993. /**
  25994. * Defines the subdivisions to apply to the ground
  25995. */
  25996. subdivisions: number;
  25997. /**
  25998. * Creates a new ground geometry
  25999. * @param id defines the unique ID of the geometry
  26000. * @param scene defines the hosting scene
  26001. * @param width defines the width of the ground
  26002. * @param height defines the height of the ground
  26003. * @param subdivisions defines the subdivisions to apply to the ground
  26004. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26005. * @param mesh defines the hosting mesh (can be null)
  26006. */
  26007. constructor(id: string, scene: Scene,
  26008. /**
  26009. * Defines the width of the ground
  26010. */
  26011. width: number,
  26012. /**
  26013. * Defines the height of the ground
  26014. */
  26015. height: number,
  26016. /**
  26017. * Defines the subdivisions to apply to the ground
  26018. */
  26019. subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26020. /** @hidden */
  26021. _regenerateVertexData(): VertexData;
  26022. copy(id: string): Geometry;
  26023. serialize(): any;
  26024. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  26025. }
  26026. /**
  26027. * Creates a tiled ground geometry
  26028. * @description see http://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  26029. */
  26030. class TiledGroundGeometry extends _PrimitiveGeometry {
  26031. /**
  26032. * Defines the minimum value on X axis
  26033. */
  26034. xmin: number;
  26035. /**
  26036. * Defines the minimum value on Z axis
  26037. */
  26038. zmin: number;
  26039. /**
  26040. * Defines the maximum value on X axis
  26041. */
  26042. xmax: number;
  26043. /**
  26044. * Defines the maximum value on Z axis
  26045. */
  26046. zmax: number;
  26047. /**
  26048. * Defines the subdivisions to apply to the ground
  26049. */
  26050. subdivisions: {
  26051. w: number;
  26052. h: number;
  26053. };
  26054. /**
  26055. * Defines the precision to use when computing the tiles
  26056. */
  26057. precision: {
  26058. w: number;
  26059. h: number;
  26060. };
  26061. /**
  26062. * Creates a tiled ground geometry
  26063. * @param id defines the unique ID of the geometry
  26064. * @param scene defines the hosting scene
  26065. * @param xmin defines the minimum value on X axis
  26066. * @param zmin defines the minimum value on Z axis
  26067. * @param xmax defines the maximum value on X axis
  26068. * @param zmax defines the maximum value on Z axis
  26069. * @param subdivisions defines the subdivisions to apply to the ground (number of subdivisions (tiles) on the height and the width of the map)
  26070. * @param precision defines the precision to use when computing the tiles
  26071. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26072. * @param mesh defines the hosting mesh (can be null)
  26073. */
  26074. constructor(id: string, scene: Scene,
  26075. /**
  26076. * Defines the minimum value on X axis
  26077. */
  26078. xmin: number,
  26079. /**
  26080. * Defines the minimum value on Z axis
  26081. */
  26082. zmin: number,
  26083. /**
  26084. * Defines the maximum value on X axis
  26085. */
  26086. xmax: number,
  26087. /**
  26088. * Defines the maximum value on Z axis
  26089. */
  26090. zmax: number,
  26091. /**
  26092. * Defines the subdivisions to apply to the ground
  26093. */
  26094. subdivisions: {
  26095. w: number;
  26096. h: number;
  26097. },
  26098. /**
  26099. * Defines the precision to use when computing the tiles
  26100. */
  26101. precision: {
  26102. w: number;
  26103. h: number;
  26104. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  26105. /** @hidden */
  26106. _regenerateVertexData(): VertexData;
  26107. copy(id: string): Geometry;
  26108. }
  26109. /**
  26110. * Creates a plane geometry
  26111. * @description see http://doc.babylonjs.com/how_to/set_shapes#plane
  26112. */
  26113. class PlaneGeometry extends _PrimitiveGeometry {
  26114. /**
  26115. * Defines the size of the plane (width === height)
  26116. */
  26117. size: number;
  26118. /**
  26119. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26120. */
  26121. side: number;
  26122. /**
  26123. * Creates a plane geometry
  26124. * @param id defines the unique ID of the geometry
  26125. * @param scene defines the hosting scene
  26126. * @param size defines the size of the plane (width === height)
  26127. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26128. * @param mesh defines the hosting mesh (can be null)
  26129. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26130. */
  26131. constructor(id: string, scene: Scene,
  26132. /**
  26133. * Defines the size of the plane (width === height)
  26134. */
  26135. size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26136. /**
  26137. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26138. */
  26139. side?: number);
  26140. /** @hidden */
  26141. _regenerateVertexData(): VertexData;
  26142. copy(id: string): Geometry;
  26143. serialize(): any;
  26144. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  26145. }
  26146. /**
  26147. * Creates a torus knot geometry
  26148. * @description see http://doc.babylonjs.com/how_to/set_shapes#torus-knot
  26149. */
  26150. class TorusKnotGeometry extends _PrimitiveGeometry {
  26151. /**
  26152. * Defines the radius of the torus knot
  26153. */
  26154. radius: number;
  26155. /**
  26156. * Defines the thickness of the torus knot tube
  26157. */
  26158. tube: number;
  26159. /**
  26160. * Defines the number of radial segments
  26161. */
  26162. radialSegments: number;
  26163. /**
  26164. * Defines the number of tubular segments
  26165. */
  26166. tubularSegments: number;
  26167. /**
  26168. * Defines the first number of windings
  26169. */
  26170. p: number;
  26171. /**
  26172. * Defines the second number of windings
  26173. */
  26174. q: number;
  26175. /**
  26176. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26177. */
  26178. side: number;
  26179. /**
  26180. * Creates a torus knot geometry
  26181. * @param id defines the unique ID of the geometry
  26182. * @param scene defines the hosting scene
  26183. * @param radius defines the radius of the torus knot
  26184. * @param tube defines the thickness of the torus knot tube
  26185. * @param radialSegments defines the number of radial segments
  26186. * @param tubularSegments defines the number of tubular segments
  26187. * @param p defines the first number of windings
  26188. * @param q defines the second number of windings
  26189. * @param canBeRegenerated defines if the geometry supports being regenerated with new parameters (false by default)
  26190. * @param mesh defines the hosting mesh (can be null)
  26191. * @param side defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26192. */
  26193. constructor(id: string, scene: Scene,
  26194. /**
  26195. * Defines the radius of the torus knot
  26196. */
  26197. radius: number,
  26198. /**
  26199. * Defines the thickness of the torus knot tube
  26200. */
  26201. tube: number,
  26202. /**
  26203. * Defines the number of radial segments
  26204. */
  26205. radialSegments: number,
  26206. /**
  26207. * Defines the number of tubular segments
  26208. */
  26209. tubularSegments: number,
  26210. /**
  26211. * Defines the first number of windings
  26212. */
  26213. p: number,
  26214. /**
  26215. * Defines the second number of windings
  26216. */
  26217. q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>,
  26218. /**
  26219. * Defines if the created geometry is double sided or not (default is BABYLON.Mesh.DEFAULTSIDE)
  26220. */
  26221. side?: number);
  26222. /** @hidden */
  26223. _regenerateVertexData(): VertexData;
  26224. copy(id: string): Geometry;
  26225. serialize(): any;
  26226. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  26227. }
  26228. }
  26229. declare module BABYLON {
  26230. /**
  26231. * Mesh representing the gorund
  26232. */
  26233. class GroundMesh extends Mesh {
  26234. /** If octree should be generated */
  26235. generateOctree: boolean;
  26236. private _heightQuads;
  26237. /** @hidden */
  26238. _subdivisionsX: number;
  26239. /** @hidden */
  26240. _subdivisionsY: number;
  26241. /** @hidden */
  26242. _width: number;
  26243. /** @hidden */
  26244. _height: number;
  26245. /** @hidden */
  26246. _minX: number;
  26247. /** @hidden */
  26248. _maxX: number;
  26249. /** @hidden */
  26250. _minZ: number;
  26251. /** @hidden */
  26252. _maxZ: number;
  26253. constructor(name: string, scene: Scene);
  26254. /**
  26255. * "GroundMesh"
  26256. * @returns "GroundMesh"
  26257. */
  26258. getClassName(): string;
  26259. /**
  26260. * The minimum of x and y subdivisions
  26261. */
  26262. readonly subdivisions: number;
  26263. /**
  26264. * X subdivisions
  26265. */
  26266. readonly subdivisionsX: number;
  26267. /**
  26268. * Y subdivisions
  26269. */
  26270. readonly subdivisionsY: number;
  26271. /**
  26272. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26273. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26274. * @param chunksCount the number of subdivisions for x and y
  26275. * @param octreeBlocksSize (Default: 32)
  26276. */
  26277. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26278. /**
  26279. * Returns a height (y) value in the Worl system :
  26280. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26281. * @param x x coordinate
  26282. * @param z z coordinate
  26283. * @returns the ground y position if (x, z) are outside the ground surface.
  26284. */
  26285. getHeightAtCoordinates(x: number, z: number): number;
  26286. /**
  26287. * Returns a normalized vector (Vector3) orthogonal to the ground
  26288. * at the ground coordinates (x, z) expressed in the World system.
  26289. * @param x x coordinate
  26290. * @param z z coordinate
  26291. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26292. */
  26293. getNormalAtCoordinates(x: number, z: number): Vector3;
  26294. /**
  26295. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26296. * at the ground coordinates (x, z) expressed in the World system.
  26297. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26298. * @param x x coordinate
  26299. * @param z z coordinate
  26300. * @param ref vector to store the result
  26301. * @returns the GroundMesh.
  26302. */
  26303. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26304. /**
  26305. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26306. * if the ground has been updated.
  26307. * This can be used in the render loop.
  26308. * @returns the GroundMesh.
  26309. */
  26310. updateCoordinateHeights(): GroundMesh;
  26311. private _getFacetAt;
  26312. private _initHeightQuads;
  26313. private _computeHeightQuads;
  26314. /**
  26315. * Serializes this ground mesh
  26316. * @param serializationObject object to write serialization to
  26317. */
  26318. serialize(serializationObject: any): void;
  26319. /**
  26320. * Parses a serialized ground mesh
  26321. * @param parsedMesh the serialized mesh
  26322. * @param scene the scene to create the ground mesh in
  26323. * @returns the created ground mesh
  26324. */
  26325. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26326. }
  26327. }
  26328. declare module BABYLON {
  26329. /**
  26330. * Creates an instance based on a source mesh.
  26331. */
  26332. class InstancedMesh extends AbstractMesh {
  26333. private _sourceMesh;
  26334. private _currentLOD;
  26335. /** @hidden */
  26336. _indexInSourceMeshInstanceArray: number;
  26337. constructor(name: string, source: Mesh);
  26338. /**
  26339. * Returns the string "InstancedMesh".
  26340. */
  26341. getClassName(): string;
  26342. /**
  26343. * If the source mesh receives shadows
  26344. */
  26345. readonly receiveShadows: boolean;
  26346. /**
  26347. * The material of the source mesh
  26348. */
  26349. readonly material: Nullable<Material>;
  26350. /**
  26351. * Visibility of the source mesh
  26352. */
  26353. readonly visibility: number;
  26354. /**
  26355. * Skeleton of the source mesh
  26356. */
  26357. readonly skeleton: Nullable<Skeleton>;
  26358. /**
  26359. * Rendering ground id of the source mesh
  26360. */
  26361. renderingGroupId: number;
  26362. /**
  26363. * Returns the total number of vertices (integer).
  26364. */
  26365. getTotalVertices(): number;
  26366. /**
  26367. * Returns a positive integer : the total number of indices in this mesh geometry.
  26368. * @returns the numner of indices or zero if the mesh has no geometry.
  26369. */
  26370. getTotalIndices(): number;
  26371. /**
  26372. * The source mesh of the instance
  26373. */
  26374. readonly sourceMesh: Mesh;
  26375. /**
  26376. * Is this node ready to be used/rendered
  26377. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26378. * @return {boolean} is it ready
  26379. */
  26380. isReady(completeCheck?: boolean): boolean;
  26381. /**
  26382. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26383. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  26384. * @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.
  26385. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  26386. */
  26387. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  26388. /**
  26389. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26390. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26391. * The `data` are either a numeric array either a Float32Array.
  26392. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  26393. * 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).
  26394. * Note that a new underlying VertexBuffer object is created each call.
  26395. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26396. *
  26397. * Possible `kind` values :
  26398. * - BABYLON.VertexBuffer.PositionKind
  26399. * - BABYLON.VertexBuffer.UVKind
  26400. * - BABYLON.VertexBuffer.UV2Kind
  26401. * - BABYLON.VertexBuffer.UV3Kind
  26402. * - BABYLON.VertexBuffer.UV4Kind
  26403. * - BABYLON.VertexBuffer.UV5Kind
  26404. * - BABYLON.VertexBuffer.UV6Kind
  26405. * - BABYLON.VertexBuffer.ColorKind
  26406. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26407. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26408. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26409. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26410. *
  26411. * Returns the Mesh.
  26412. */
  26413. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26414. /**
  26415. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26416. * If the mesh has no geometry, it is simply returned as it is.
  26417. * The `data` are either a numeric array either a Float32Array.
  26418. * No new underlying VertexBuffer object is created.
  26419. * 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.
  26420. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  26421. *
  26422. * Possible `kind` values :
  26423. * - BABYLON.VertexBuffer.PositionKind
  26424. * - BABYLON.VertexBuffer.UVKind
  26425. * - BABYLON.VertexBuffer.UV2Kind
  26426. * - BABYLON.VertexBuffer.UV3Kind
  26427. * - BABYLON.VertexBuffer.UV4Kind
  26428. * - BABYLON.VertexBuffer.UV5Kind
  26429. * - BABYLON.VertexBuffer.UV6Kind
  26430. * - BABYLON.VertexBuffer.ColorKind
  26431. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26432. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26433. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26434. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26435. *
  26436. * Returns the Mesh.
  26437. */
  26438. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  26439. /**
  26440. * Sets the mesh indices.
  26441. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  26442. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26443. * This method creates a new index buffer each call.
  26444. * Returns the Mesh.
  26445. */
  26446. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  26447. /**
  26448. * Boolean : True if the mesh owns the requested kind of data.
  26449. */
  26450. isVerticesDataPresent(kind: string): boolean;
  26451. /**
  26452. * Returns an array of indices (IndicesArray).
  26453. */
  26454. getIndices(): Nullable<IndicesArray>;
  26455. readonly _positions: Nullable<Vector3[]>;
  26456. /**
  26457. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26458. * This means the mesh underlying bounding box and sphere are recomputed.
  26459. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26460. * @returns the current mesh
  26461. */
  26462. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  26463. /** @hidden */
  26464. _preActivate(): InstancedMesh;
  26465. /** @hidden */
  26466. _activate(renderId: number): InstancedMesh;
  26467. /**
  26468. * Returns the current associated LOD AbstractMesh.
  26469. */
  26470. getLOD(camera: Camera): AbstractMesh;
  26471. /** @hidden */
  26472. _syncSubMeshes(): InstancedMesh;
  26473. /** @hidden */
  26474. _generatePointsArray(): boolean;
  26475. /**
  26476. * Creates a new InstancedMesh from the current mesh.
  26477. * - name (string) : the cloned mesh name
  26478. * - newParent (optional Node) : the optional Node to parent the clone to.
  26479. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  26480. *
  26481. * Returns the clone.
  26482. */
  26483. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  26484. /**
  26485. * Disposes the InstancedMesh.
  26486. * Returns nothing.
  26487. */
  26488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26489. }
  26490. }
  26491. declare module BABYLON {
  26492. /**
  26493. * Line mesh
  26494. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  26495. */
  26496. class LinesMesh extends Mesh {
  26497. /**
  26498. * If vertex color should be applied to the mesh
  26499. */
  26500. useVertexColor?: boolean | undefined;
  26501. /**
  26502. * If vertex alpha should be applied to the mesh
  26503. */
  26504. useVertexAlpha?: boolean | undefined;
  26505. /**
  26506. * Color of the line (Default: White)
  26507. */
  26508. color: Color3;
  26509. /**
  26510. * Alpha of the line (Default: 1)
  26511. */
  26512. alpha: number;
  26513. /**
  26514. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26515. * This margin is expressed in world space coordinates, so its value may vary.
  26516. * Default value is 0.1
  26517. */
  26518. intersectionThreshold: number;
  26519. private _colorShader;
  26520. /**
  26521. * Creates a new LinesMesh
  26522. * @param name defines the name
  26523. * @param scene defines the hosting scene
  26524. * @param parent defines the parent mesh if any
  26525. * @param source defines the optional source LinesMesh used to clone data from
  26526. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26527. * When false, achieved by calling a clone(), also passing False.
  26528. * This will make creation of children, recursive.
  26529. * @param useVertexColor defines if this LinesMesh supports vertex color
  26530. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  26531. */
  26532. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  26533. /**
  26534. * If vertex color should be applied to the mesh
  26535. */
  26536. useVertexColor?: boolean | undefined,
  26537. /**
  26538. * If vertex alpha should be applied to the mesh
  26539. */
  26540. useVertexAlpha?: boolean | undefined);
  26541. /**
  26542. * Returns the string "LineMesh"
  26543. */
  26544. getClassName(): string;
  26545. /**
  26546. * @hidden
  26547. */
  26548. /**
  26549. * @hidden
  26550. */
  26551. material: Material;
  26552. /**
  26553. * @hidden
  26554. */
  26555. readonly checkCollisions: boolean;
  26556. /** @hidden */
  26557. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  26558. /** @hidden */
  26559. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  26560. /**
  26561. * Disposes of the line mesh
  26562. * @param doNotRecurse If children should be disposed
  26563. */
  26564. dispose(doNotRecurse?: boolean): void;
  26565. /**
  26566. * Returns a new LineMesh object cloned from the current one.
  26567. */
  26568. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  26569. /**
  26570. * Creates a new InstancedLinesMesh object from the mesh model.
  26571. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26572. * @param name defines the name of the new instance
  26573. * @returns a new InstancedLinesMesh
  26574. */
  26575. createInstance(name: string): InstancedLinesMesh;
  26576. }
  26577. /**
  26578. * Creates an instance based on a source LinesMesh
  26579. */
  26580. class InstancedLinesMesh extends InstancedMesh {
  26581. /**
  26582. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  26583. * This margin is expressed in world space coordinates, so its value may vary.
  26584. * Initilized with the intersectionThreshold value of the source LinesMesh
  26585. */
  26586. intersectionThreshold: number;
  26587. constructor(name: string, source: LinesMesh);
  26588. /**
  26589. * Returns the string "InstancedLinesMesh".
  26590. */
  26591. getClassName(): string;
  26592. }
  26593. }
  26594. declare module BABYLON {
  26595. /**
  26596. * @hidden
  26597. **/
  26598. class _CreationDataStorage {
  26599. closePath?: boolean;
  26600. closeArray?: boolean;
  26601. idx: number[];
  26602. dashSize: number;
  26603. gapSize: number;
  26604. path3D: Path3D;
  26605. pathArray: Vector3[][];
  26606. arc: number;
  26607. radius: number;
  26608. cap: number;
  26609. tessellation: number;
  26610. }
  26611. /**
  26612. * @hidden
  26613. **/
  26614. class _InstanceDataStorage {
  26615. visibleInstances: any;
  26616. renderIdForInstances: number[];
  26617. batchCache: _InstancesBatch;
  26618. instancesBufferSize: number;
  26619. instancesBuffer: Nullable<Buffer>;
  26620. instancesData: Float32Array;
  26621. overridenInstanceCount: number;
  26622. }
  26623. /**
  26624. * @hidden
  26625. **/
  26626. class _InstancesBatch {
  26627. mustReturn: boolean;
  26628. visibleInstances: Nullable<InstancedMesh[]>[];
  26629. renderSelf: boolean[];
  26630. }
  26631. /**
  26632. * Class used to represent renderable models
  26633. */
  26634. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  26635. /**
  26636. * Mesh side orientation : usually the external or front surface
  26637. */
  26638. static readonly FRONTSIDE: number;
  26639. /**
  26640. * Mesh side orientation : usually the internal or back surface
  26641. */
  26642. static readonly BACKSIDE: number;
  26643. /**
  26644. * Mesh side orientation : both internal and external or front and back surfaces
  26645. */
  26646. static readonly DOUBLESIDE: number;
  26647. /**
  26648. * Mesh side orientation : by default, `FRONTSIDE`
  26649. */
  26650. static readonly DEFAULTSIDE: number;
  26651. /**
  26652. * Mesh cap setting : no cap
  26653. */
  26654. static readonly NO_CAP: number;
  26655. /**
  26656. * Mesh cap setting : one cap at the beginning of the mesh
  26657. */
  26658. static readonly CAP_START: number;
  26659. /**
  26660. * Mesh cap setting : one cap at the end of the mesh
  26661. */
  26662. static readonly CAP_END: number;
  26663. /**
  26664. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  26665. */
  26666. static readonly CAP_ALL: number;
  26667. private _onBeforeRenderObservable;
  26668. private _onAfterRenderObservable;
  26669. private _onBeforeDrawObservable;
  26670. /**
  26671. * An event triggered before rendering the mesh
  26672. */
  26673. readonly onBeforeRenderObservable: Observable<Mesh>;
  26674. /**
  26675. * An event triggered after rendering the mesh
  26676. */
  26677. readonly onAfterRenderObservable: Observable<Mesh>;
  26678. /**
  26679. * An event triggered before drawing the mesh
  26680. */
  26681. readonly onBeforeDrawObservable: Observable<Mesh>;
  26682. private _onBeforeDrawObserver;
  26683. /**
  26684. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  26685. */
  26686. onBeforeDraw: () => void;
  26687. /**
  26688. * Gets the delay loading state of the mesh (when delay loading is turned on)
  26689. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  26690. */
  26691. delayLoadState: number;
  26692. /**
  26693. * Gets the list of instances created from this mesh
  26694. * it is not supposed to be modified manually.
  26695. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  26696. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  26697. */
  26698. instances: InstancedMesh[];
  26699. /**
  26700. * Gets the file containing delay loading data for this mesh
  26701. */
  26702. delayLoadingFile: string;
  26703. /** @hidden */
  26704. _binaryInfo: any;
  26705. private _LODLevels;
  26706. /**
  26707. * User defined function used to change how LOD level selection is done
  26708. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  26709. */
  26710. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  26711. private _morphTargetManager;
  26712. /**
  26713. * Gets or sets the morph target manager
  26714. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26715. */
  26716. morphTargetManager: Nullable<MorphTargetManager>;
  26717. /** @hidden */
  26718. _creationDataStorage: Nullable<_CreationDataStorage>;
  26719. /** @hidden */
  26720. _geometry: Nullable<Geometry>;
  26721. /** @hidden */
  26722. _delayInfo: Array<string>;
  26723. /** @hidden */
  26724. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  26725. /** @hidden */
  26726. _instanceDataStorage: _InstanceDataStorage;
  26727. private _effectiveMaterial;
  26728. /** @hidden */
  26729. _shouldGenerateFlatShading: boolean;
  26730. private _preActivateId;
  26731. /** @hidden */
  26732. _originalBuilderSideOrientation: number;
  26733. /**
  26734. * Use this property to change the original side orientation defined at construction time
  26735. */
  26736. overrideMaterialSideOrientation: Nullable<number>;
  26737. private _areNormalsFrozen;
  26738. private _sourcePositions;
  26739. private _sourceNormals;
  26740. private _source;
  26741. private meshMap;
  26742. /**
  26743. * Gets the source mesh (the one used to clone this one from)
  26744. */
  26745. readonly source: Nullable<Mesh>;
  26746. /**
  26747. * Gets or sets a boolean indicating that this mesh does not use index buffer
  26748. */
  26749. isUnIndexed: boolean;
  26750. /**
  26751. * @constructor
  26752. * @param name The value used by scene.getMeshByName() to do a lookup.
  26753. * @param scene The scene to add this mesh to.
  26754. * @param parent The parent of this mesh, if it has one
  26755. * @param source An optional Mesh from which geometry is shared, cloned.
  26756. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  26757. * When false, achieved by calling a clone(), also passing False.
  26758. * This will make creation of children, recursive.
  26759. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  26760. */
  26761. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  26762. /**
  26763. * Gets the class name
  26764. * @returns the string "Mesh".
  26765. */
  26766. getClassName(): string;
  26767. /**
  26768. * Returns a description of this mesh
  26769. * @param fullDetails define if full details about this mesh must be used
  26770. * @returns a descriptive string representing this mesh
  26771. */
  26772. toString(fullDetails?: boolean): string;
  26773. /** @hidden */
  26774. _unBindEffect(): void;
  26775. /**
  26776. * Gets a boolean indicating if this mesh has LOD
  26777. */
  26778. readonly hasLODLevels: boolean;
  26779. /**
  26780. * Gets the list of MeshLODLevel associated with the current mesh
  26781. * @returns an array of MeshLODLevel
  26782. */
  26783. getLODLevels(): MeshLODLevel[];
  26784. private _sortLODLevels;
  26785. /**
  26786. * Add a mesh as LOD level triggered at the given distance.
  26787. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26788. * @param distance The distance from the center of the object to show this level
  26789. * @param mesh The mesh to be added as LOD level (can be null)
  26790. * @return This mesh (for chaining)
  26791. */
  26792. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  26793. /**
  26794. * Returns the LOD level mesh at the passed distance or null if not found.
  26795. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26796. * @param distance The distance from the center of the object to show this level
  26797. * @returns a Mesh or `null`
  26798. */
  26799. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  26800. /**
  26801. * Remove a mesh from the LOD array
  26802. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26803. * @param mesh defines the mesh to be removed
  26804. * @return This mesh (for chaining)
  26805. */
  26806. removeLODLevel(mesh: Mesh): Mesh;
  26807. /**
  26808. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  26809. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26810. * @param camera defines the camera to use to compute distance
  26811. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  26812. * @return This mesh (for chaining)
  26813. */
  26814. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  26815. /**
  26816. * Gets the mesh internal Geometry object
  26817. */
  26818. readonly geometry: Nullable<Geometry>;
  26819. /**
  26820. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  26821. * @returns the total number of vertices
  26822. */
  26823. getTotalVertices(): number;
  26824. /**
  26825. * Returns the content of an associated vertex buffer
  26826. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26827. * - BABYLON.VertexBuffer.PositionKind
  26828. * - BABYLON.VertexBuffer.UVKind
  26829. * - BABYLON.VertexBuffer.UV2Kind
  26830. * - BABYLON.VertexBuffer.UV3Kind
  26831. * - BABYLON.VertexBuffer.UV4Kind
  26832. * - BABYLON.VertexBuffer.UV5Kind
  26833. * - BABYLON.VertexBuffer.UV6Kind
  26834. * - BABYLON.VertexBuffer.ColorKind
  26835. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26836. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26837. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26838. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26839. * @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
  26840. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  26841. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  26842. */
  26843. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26844. /**
  26845. * Returns the mesh VertexBuffer object from the requested `kind`
  26846. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26847. * - BABYLON.VertexBuffer.PositionKind
  26848. * - BABYLON.VertexBuffer.UVKind
  26849. * - BABYLON.VertexBuffer.UV2Kind
  26850. * - BABYLON.VertexBuffer.UV3Kind
  26851. * - BABYLON.VertexBuffer.UV4Kind
  26852. * - BABYLON.VertexBuffer.UV5Kind
  26853. * - BABYLON.VertexBuffer.UV6Kind
  26854. * - BABYLON.VertexBuffer.ColorKind
  26855. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26856. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26857. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26858. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26859. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  26860. */
  26861. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26862. /**
  26863. * Tests if a specific vertex buffer is associated with this mesh
  26864. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26865. * - BABYLON.VertexBuffer.PositionKind
  26866. * - BABYLON.VertexBuffer.UVKind
  26867. * - BABYLON.VertexBuffer.UV2Kind
  26868. * - BABYLON.VertexBuffer.UV3Kind
  26869. * - BABYLON.VertexBuffer.UV4Kind
  26870. * - BABYLON.VertexBuffer.UV5Kind
  26871. * - BABYLON.VertexBuffer.UV6Kind
  26872. * - BABYLON.VertexBuffer.ColorKind
  26873. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26874. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26875. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26876. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26877. * @returns a boolean
  26878. */
  26879. isVerticesDataPresent(kind: string): boolean;
  26880. /**
  26881. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  26882. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  26883. * - BABYLON.VertexBuffer.PositionKind
  26884. * - BABYLON.VertexBuffer.UVKind
  26885. * - BABYLON.VertexBuffer.UV2Kind
  26886. * - BABYLON.VertexBuffer.UV3Kind
  26887. * - BABYLON.VertexBuffer.UV4Kind
  26888. * - BABYLON.VertexBuffer.UV5Kind
  26889. * - BABYLON.VertexBuffer.UV6Kind
  26890. * - BABYLON.VertexBuffer.ColorKind
  26891. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26892. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26893. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26894. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26895. * @returns a boolean
  26896. */
  26897. isVertexBufferUpdatable(kind: string): boolean;
  26898. /**
  26899. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  26900. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  26901. * - BABYLON.VertexBuffer.PositionKind
  26902. * - BABYLON.VertexBuffer.UVKind
  26903. * - BABYLON.VertexBuffer.UV2Kind
  26904. * - BABYLON.VertexBuffer.UV3Kind
  26905. * - BABYLON.VertexBuffer.UV4Kind
  26906. * - BABYLON.VertexBuffer.UV5Kind
  26907. * - BABYLON.VertexBuffer.UV6Kind
  26908. * - BABYLON.VertexBuffer.ColorKind
  26909. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26910. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26911. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26912. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26913. * @returns an array of strings
  26914. */
  26915. getVerticesDataKinds(): string[];
  26916. /**
  26917. * Returns a positive integer : the total number of indices in this mesh geometry.
  26918. * @returns the numner of indices or zero if the mesh has no geometry.
  26919. */
  26920. getTotalIndices(): number;
  26921. /**
  26922. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26923. * @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.
  26924. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26925. * @returns the indices array or an empty array if the mesh has no geometry
  26926. */
  26927. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26928. readonly isBlocked: boolean;
  26929. /**
  26930. * Determine if the current mesh is ready to be rendered
  26931. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26932. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  26933. * @returns true if all associated assets are ready (material, textures, shaders)
  26934. */
  26935. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  26936. /**
  26937. * 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.
  26938. */
  26939. readonly areNormalsFrozen: boolean;
  26940. /**
  26941. * 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.
  26942. * @returns the current mesh
  26943. */
  26944. freezeNormals(): Mesh;
  26945. /**
  26946. * 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
  26947. * @returns the current mesh
  26948. */
  26949. unfreezeNormals(): Mesh;
  26950. /**
  26951. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  26952. */
  26953. overridenInstanceCount: number;
  26954. /** @hidden */
  26955. _preActivate(): Mesh;
  26956. /** @hidden */
  26957. _preActivateForIntermediateRendering(renderId: number): Mesh;
  26958. /** @hidden */
  26959. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  26960. /**
  26961. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26962. * This means the mesh underlying bounding box and sphere are recomputed.
  26963. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26964. * @returns the current mesh
  26965. */
  26966. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  26967. /** @hidden */
  26968. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  26969. /**
  26970. * This function will subdivide the mesh into multiple submeshes
  26971. * @param count defines the expected number of submeshes
  26972. */
  26973. subdivide(count: number): void;
  26974. /**
  26975. * Copy a FloatArray into a specific associated vertex buffer
  26976. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26977. * - BABYLON.VertexBuffer.PositionKind
  26978. * - BABYLON.VertexBuffer.UVKind
  26979. * - BABYLON.VertexBuffer.UV2Kind
  26980. * - BABYLON.VertexBuffer.UV3Kind
  26981. * - BABYLON.VertexBuffer.UV4Kind
  26982. * - BABYLON.VertexBuffer.UV5Kind
  26983. * - BABYLON.VertexBuffer.UV6Kind
  26984. * - BABYLON.VertexBuffer.ColorKind
  26985. * - BABYLON.VertexBuffer.MatricesIndicesKind
  26986. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  26987. * - BABYLON.VertexBuffer.MatricesWeightsKind
  26988. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  26989. * @param data defines the data source
  26990. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  26991. * @param stride defines the data stride size (can be null)
  26992. * @returns the current mesh
  26993. */
  26994. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  26995. /**
  26996. * Flags an associated vertex buffer as updatable
  26997. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  26998. * - BABYLON.VertexBuffer.PositionKind
  26999. * - BABYLON.VertexBuffer.UVKind
  27000. * - BABYLON.VertexBuffer.UV2Kind
  27001. * - BABYLON.VertexBuffer.UV3Kind
  27002. * - BABYLON.VertexBuffer.UV4Kind
  27003. * - BABYLON.VertexBuffer.UV5Kind
  27004. * - BABYLON.VertexBuffer.UV6Kind
  27005. * - BABYLON.VertexBuffer.ColorKind
  27006. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27007. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27008. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27009. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27010. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27011. */
  27012. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27013. /**
  27014. * Sets the mesh global Vertex Buffer
  27015. * @param buffer defines the buffer to use
  27016. * @returns the current mesh
  27017. */
  27018. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27019. /**
  27020. * Update a specific associated vertex buffer
  27021. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27022. * - BABYLON.VertexBuffer.PositionKind
  27023. * - BABYLON.VertexBuffer.UVKind
  27024. * - BABYLON.VertexBuffer.UV2Kind
  27025. * - BABYLON.VertexBuffer.UV3Kind
  27026. * - BABYLON.VertexBuffer.UV4Kind
  27027. * - BABYLON.VertexBuffer.UV5Kind
  27028. * - BABYLON.VertexBuffer.UV6Kind
  27029. * - BABYLON.VertexBuffer.ColorKind
  27030. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27031. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27032. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27033. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27034. * @param data defines the data source
  27035. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27036. * @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)
  27037. * @returns the current mesh
  27038. */
  27039. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27040. /**
  27041. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27042. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27043. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27044. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27045. * @returns the current mesh
  27046. */
  27047. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27048. /**
  27049. * Creates a un-shared specific occurence of the geometry for the mesh.
  27050. * @returns the current mesh
  27051. */
  27052. makeGeometryUnique(): Mesh;
  27053. /**
  27054. * Set the index buffer of this mesh
  27055. * @param indices defines the source data
  27056. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27057. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27058. * @returns the current mesh
  27059. */
  27060. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  27061. /**
  27062. * Update the current index buffer
  27063. * @param indices defines the source data
  27064. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27065. * @returns the current mesh
  27066. */
  27067. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  27068. /**
  27069. * Invert the geometry to move from a right handed system to a left handed one.
  27070. * @returns the current mesh
  27071. */
  27072. toLeftHanded(): Mesh;
  27073. /** @hidden */
  27074. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27075. /** @hidden */
  27076. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  27077. /**
  27078. * Registers for this mesh a javascript function called just before the rendering process
  27079. * @param func defines the function to call before rendering this mesh
  27080. * @returns the current mesh
  27081. */
  27082. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27083. /**
  27084. * Disposes a previously registered javascript function called before the rendering
  27085. * @param func defines the function to remove
  27086. * @returns the current mesh
  27087. */
  27088. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27089. /**
  27090. * Registers for this mesh a javascript function called just after the rendering is complete
  27091. * @param func defines the function to call after rendering this mesh
  27092. * @returns the current mesh
  27093. */
  27094. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27095. /**
  27096. * Disposes a previously registered javascript function called after the rendering.
  27097. * @param func defines the function to remove
  27098. * @returns the current mesh
  27099. */
  27100. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27101. /** @hidden */
  27102. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  27103. /** @hidden */
  27104. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27105. /** @hidden */
  27106. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27107. /**
  27108. * 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
  27109. * @param subMesh defines the subMesh to render
  27110. * @param enableAlphaMode defines if alpha mode can be changed
  27111. * @returns the current mesh
  27112. */
  27113. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  27114. private _onBeforeDraw;
  27115. /**
  27116. * Renormalize the mesh and patch it up if there are no weights
  27117. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27118. * However in the case of zero weights then we set just a single influence to 1.
  27119. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27120. */
  27121. cleanMatrixWeights(): void;
  27122. private normalizeSkinFourWeights;
  27123. private normalizeSkinWeightsAndExtra;
  27124. /**
  27125. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27126. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27127. * the user know there was an issue with importing the mesh
  27128. * @returns a validation object with skinned, valid and report string
  27129. */
  27130. validateSkinning(): {
  27131. skinned: boolean;
  27132. valid: boolean;
  27133. report: string;
  27134. };
  27135. /** @hidden */
  27136. _checkDelayState(): Mesh;
  27137. private _queueLoad;
  27138. /**
  27139. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27140. * A mesh is in the frustum if its bounding box intersects the frustum
  27141. * @param frustumPlanes defines the frustum to test
  27142. * @returns true if the mesh is in the frustum planes
  27143. */
  27144. isInFrustum(frustumPlanes: Plane[]): boolean;
  27145. /**
  27146. * Sets the mesh material by the material or multiMaterial `id` property
  27147. * @param id is a string identifying the material or the multiMaterial
  27148. * @returns the current mesh
  27149. */
  27150. setMaterialByID(id: string): Mesh;
  27151. /**
  27152. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27153. * @returns an array of IAnimatable
  27154. */
  27155. getAnimatables(): IAnimatable[];
  27156. /**
  27157. * Modifies the mesh geometry according to the passed transformation matrix.
  27158. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27159. * The mesh normals are modified using the same transformation.
  27160. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27161. * @param transform defines the transform matrix to use
  27162. * @see http://doc.babylonjs.com/resources/baking_transformations
  27163. * @returns the current mesh
  27164. */
  27165. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27166. /**
  27167. * Modifies the mesh geometry according to its own current World Matrix.
  27168. * The mesh World Matrix is then reset.
  27169. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27170. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27171. * @see http://doc.babylonjs.com/resources/baking_transformations
  27172. * @returns the current mesh
  27173. */
  27174. bakeCurrentTransformIntoVertices(): Mesh;
  27175. /** @hidden */
  27176. readonly _positions: Nullable<Vector3[]>;
  27177. /** @hidden */
  27178. _resetPointsArrayCache(): Mesh;
  27179. /** @hidden */
  27180. _generatePointsArray(): boolean;
  27181. /**
  27182. * Returns a new Mesh object generated from the current mesh properties.
  27183. * This method must not get confused with createInstance()
  27184. * @param name is a string, the name given to the new mesh
  27185. * @param newParent can be any Node object (default `null`)
  27186. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27187. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27188. * @returns a new mesh
  27189. */
  27190. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27191. /**
  27192. * Releases resources associated with this mesh.
  27193. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27194. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27195. */
  27196. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27197. /**
  27198. * Modifies the mesh geometry according to a displacement map.
  27199. * 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.
  27200. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27201. * @param url is a string, the URL from the image file is to be downloaded.
  27202. * @param minHeight is the lower limit of the displacement.
  27203. * @param maxHeight is the upper limit of the displacement.
  27204. * @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.
  27205. * @param uvOffset is an optional vector2 used to offset UV.
  27206. * @param uvScale is an optional vector2 used to scale UV.
  27207. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  27208. * @returns the Mesh.
  27209. */
  27210. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27211. /**
  27212. * Modifies the mesh geometry according to a displacementMap buffer.
  27213. * 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.
  27214. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27215. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27216. * @param heightMapWidth is the width of the buffer image.
  27217. * @param heightMapHeight is the height of the buffer image.
  27218. * @param minHeight is the lower limit of the displacement.
  27219. * @param maxHeight is the upper limit of the displacement.
  27220. * @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.
  27221. * @param uvOffset is an optional vector2 used to offset UV.
  27222. * @param uvScale is an optional vector2 used to scale UV.
  27223. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is usefull to apply on a deserialized model for instance.
  27224. * @returns the Mesh.
  27225. */
  27226. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27227. /**
  27228. * Modify the mesh to get a flat shading rendering.
  27229. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27230. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27231. * @returns current mesh
  27232. */
  27233. convertToFlatShadedMesh(): Mesh;
  27234. /**
  27235. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27236. * In other words, more vertices, no more indices and a single bigger VBO.
  27237. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27238. * @returns current mesh
  27239. */
  27240. convertToUnIndexedMesh(): Mesh;
  27241. /**
  27242. * Inverses facet orientations.
  27243. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27244. * @param flipNormals will also inverts the normals
  27245. * @returns current mesh
  27246. */
  27247. flipFaces(flipNormals?: boolean): Mesh;
  27248. /**
  27249. * Creates a new InstancedMesh object from the mesh model.
  27250. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  27251. * @param name defines the name of the new instance
  27252. * @returns a new InstancedMesh
  27253. */
  27254. createInstance(name: string): InstancedMesh;
  27255. /**
  27256. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27257. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27258. * @returns the current mesh
  27259. */
  27260. synchronizeInstances(): Mesh;
  27261. /**
  27262. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27263. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27264. * This should be used together with the simplification to avoid disappearing triangles.
  27265. * @param successCallback an optional success callback to be called after the optimization finished.
  27266. * @returns the current mesh
  27267. */
  27268. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  27269. /**
  27270. * Serialize current mesh
  27271. * @param serializationObject defines the object which will receive the serialization data
  27272. */
  27273. serialize(serializationObject: any): void;
  27274. /** @hidden */
  27275. _syncGeometryWithMorphTargetManager(): void;
  27276. /**
  27277. * Returns a new Mesh object parsed from the source provided.
  27278. * @param parsedMesh is the source
  27279. * @param scene defines the hosting scene
  27280. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  27281. * @returns a new Mesh
  27282. */
  27283. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  27284. /**
  27285. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  27286. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27287. * @param name defines the name of the mesh to create
  27288. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  27289. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  27290. * @param closePath creates a seam between the first and the last points of each path of the path array
  27291. * @param offset is taken in account only if the `pathArray` is containing a single path
  27292. * @param scene defines the hosting scene
  27293. * @param updatable defines if the mesh must be flagged as updatable
  27294. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27295. * @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)
  27296. * @returns a new Mesh
  27297. */
  27298. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27299. /**
  27300. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  27301. * @param name defines the name of the mesh to create
  27302. * @param radius sets the radius size (float) of the polygon (default 0.5)
  27303. * @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
  27304. * @param scene defines the hosting scene
  27305. * @param updatable defines if the mesh must be flagged as updatable
  27306. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27307. * @returns a new Mesh
  27308. */
  27309. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27310. /**
  27311. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  27312. * @param name defines the name of the mesh to create
  27313. * @param size sets the size (float) of each box side (default 1)
  27314. * @param scene defines the hosting scene
  27315. * @param updatable defines if the mesh must be flagged as updatable
  27316. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27317. * @returns a new Mesh
  27318. */
  27319. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  27320. /**
  27321. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  27322. * @param name defines the name of the mesh to create
  27323. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  27324. * @param diameter sets the diameter size (float) of the sphere (default 1)
  27325. * @param scene defines the hosting scene
  27326. * @param updatable defines if the mesh must be flagged as updatable
  27327. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27328. * @returns a new Mesh
  27329. */
  27330. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27331. /**
  27332. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  27333. * @param name defines the name of the mesh to create
  27334. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  27335. * @param diameterTop set the top cap diameter (floats, default 1)
  27336. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  27337. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  27338. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  27339. * @param scene defines the hosting scene
  27340. * @param updatable defines if the mesh must be flagged as updatable
  27341. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27342. * @returns a new Mesh
  27343. */
  27344. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  27345. /**
  27346. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  27347. * @param name defines the name of the mesh to create
  27348. * @param diameter sets the diameter size (float) of the torus (default 1)
  27349. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  27350. * @param tessellation sets the number of torus sides (postive integer, default 16)
  27351. * @param scene defines the hosting scene
  27352. * @param updatable defines if the mesh must be flagged as updatable
  27353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27354. * @returns a new Mesh
  27355. */
  27356. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27357. /**
  27358. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  27359. * @param name defines the name of the mesh to create
  27360. * @param radius sets the global radius size (float) of the torus knot (default 2)
  27361. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  27362. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  27363. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  27364. * @param p the number of windings on X axis (positive integers, default 2)
  27365. * @param q the number of windings on Y axis (positive integers, default 3)
  27366. * @param scene defines the hosting scene
  27367. * @param updatable defines if the mesh must be flagged as updatable
  27368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27369. * @returns a new Mesh
  27370. */
  27371. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27372. /**
  27373. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  27374. * @param name defines the name of the mesh to create
  27375. * @param points is an array successive Vector3
  27376. * @param scene defines the hosting scene
  27377. * @param updatable defines if the mesh must be flagged as updatable
  27378. * @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).
  27379. * @returns a new Mesh
  27380. */
  27381. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  27382. /**
  27383. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  27384. * @param name defines the name of the mesh to create
  27385. * @param points is an array successive Vector3
  27386. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  27387. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  27388. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  27389. * @param scene defines the hosting scene
  27390. * @param updatable defines if the mesh must be flagged as updatable
  27391. * @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)
  27392. * @returns a new Mesh
  27393. */
  27394. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  27395. /**
  27396. * Creates a polygon mesh.
  27397. * Please consider using the same method from the MeshBuilder class instead.
  27398. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  27399. * 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.
  27400. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27401. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  27402. * Remember you can only change the shape positions, not their number when updating a polygon.
  27403. */
  27404. /**
  27405. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  27406. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  27407. * @param name defines the name of the mesh to create
  27408. * @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
  27409. * @param scene defines the hosting scene
  27410. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27411. * @param updatable defines if the mesh must be flagged as updatable
  27412. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27413. * @returns a new Mesh
  27414. */
  27415. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27416. /**
  27417. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  27418. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  27419. * @param name defines the name of the mesh to create
  27420. * @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
  27421. * @param depth defines the height of extrusion
  27422. * @param scene defines the hosting scene
  27423. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  27424. * @param updatable defines if the mesh must be flagged as updatable
  27425. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27426. * @returns a new Mesh
  27427. */
  27428. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  27429. /**
  27430. * Creates an extruded shape mesh.
  27431. * 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
  27432. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27433. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27434. * @param name defines the name of the mesh to create
  27435. * @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
  27436. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27437. * @param scale is the value to scale the shape
  27438. * @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
  27439. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27440. * @param scene defines the hosting scene
  27441. * @param updatable defines if the mesh must be flagged as updatable
  27442. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27443. * @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)
  27444. * @returns a new Mesh
  27445. */
  27446. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27447. /**
  27448. * Creates an custom extruded shape mesh.
  27449. * The custom extrusion is a parametric shape.
  27450. * It has no predefined shape. Its final shape will depend on the input parameters.
  27451. * Please consider using the same method from the MeshBuilder class instead
  27452. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  27453. * @param name defines the name of the mesh to create
  27454. * @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
  27455. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  27456. * @param scaleFunction is a custom Javascript function called on each path point
  27457. * @param rotationFunction is a custom Javascript function called on each path point
  27458. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  27459. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  27460. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27461. * @param scene defines the hosting scene
  27462. * @param updatable defines if the mesh must be flagged as updatable
  27463. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27464. * @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)
  27465. * @returns a new Mesh
  27466. */
  27467. 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;
  27468. /**
  27469. * Creates lathe mesh.
  27470. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  27471. * Please consider using the same method from the MeshBuilder class instead
  27472. * @param name defines the name of the mesh to create
  27473. * @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
  27474. * @param radius is the radius value of the lathe
  27475. * @param tessellation is the side number of the lathe.
  27476. * @param scene defines the hosting scene
  27477. * @param updatable defines if the mesh must be flagged as updatable
  27478. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27479. * @returns a new Mesh
  27480. */
  27481. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27482. /**
  27483. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  27484. * @param name defines the name of the mesh to create
  27485. * @param size sets the size (float) of both sides of the plane at once (default 1)
  27486. * @param scene defines the hosting scene
  27487. * @param updatable defines if the mesh must be flagged as updatable
  27488. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27489. * @returns a new Mesh
  27490. */
  27491. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  27492. /**
  27493. * Creates a ground mesh.
  27494. * Please consider using the same method from the MeshBuilder class instead
  27495. * @param name defines the name of the mesh to create
  27496. * @param width set the width of the ground
  27497. * @param height set the height of the ground
  27498. * @param subdivisions sets the number of subdivisions per side
  27499. * @param scene defines the hosting scene
  27500. * @param updatable defines if the mesh must be flagged as updatable
  27501. * @returns a new Mesh
  27502. */
  27503. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  27504. /**
  27505. * Creates a tiled ground mesh.
  27506. * Please consider using the same method from the MeshBuilder class instead
  27507. * @param name defines the name of the mesh to create
  27508. * @param xmin set the ground minimum X coordinate
  27509. * @param zmin set the ground minimum Y coordinate
  27510. * @param xmax set the ground maximum X coordinate
  27511. * @param zmax set the ground maximum Z coordinate
  27512. * @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
  27513. * @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
  27514. * @param scene defines the hosting scene
  27515. * @param updatable defines if the mesh must be flagged as updatable
  27516. * @returns a new Mesh
  27517. */
  27518. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  27519. w: number;
  27520. h: number;
  27521. }, precision: {
  27522. w: number;
  27523. h: number;
  27524. }, scene: Scene, updatable?: boolean): Mesh;
  27525. /**
  27526. * Creates a ground mesh from a height map.
  27527. * Please consider using the same method from the MeshBuilder class instead
  27528. * @see http://doc.babylonjs.com/babylon101/height_map
  27529. * @param name defines the name of the mesh to create
  27530. * @param url sets the URL of the height map image resource
  27531. * @param width set the ground width size
  27532. * @param height set the ground height size
  27533. * @param subdivisions sets the number of subdivision per side
  27534. * @param minHeight is the minimum altitude on the ground
  27535. * @param maxHeight is the maximum altitude on the ground
  27536. * @param scene defines the hosting scene
  27537. * @param updatable defines if the mesh must be flagged as updatable
  27538. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  27539. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  27540. * @returns a new Mesh
  27541. */
  27542. 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;
  27543. /**
  27544. * Creates a tube mesh.
  27545. * The tube is a parametric shape.
  27546. * It has no predefined shape. Its final shape will depend on the input parameters.
  27547. * Please consider using the same method from the MeshBuilder class instead
  27548. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  27549. * @param name defines the name of the mesh to create
  27550. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  27551. * @param radius sets the tube radius size
  27552. * @param tessellation is the number of sides on the tubular surface
  27553. * @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
  27554. * @param cap sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  27555. * @param scene defines the hosting scene
  27556. * @param updatable defines if the mesh must be flagged as updatable
  27557. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  27558. * @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)
  27559. * @returns a new Mesh
  27560. */
  27561. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  27562. (i: number, distance: number): number;
  27563. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  27564. /**
  27565. * Creates a polyhedron mesh.
  27566. * Please consider using the same method from the MeshBuilder class instead.
  27567. * * 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
  27568. * * The parameter `size` (positive float, default 1) sets the polygon size
  27569. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  27570. * * 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`
  27571. * * 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
  27572. * * 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)`)
  27573. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  27574. * * 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
  27575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27576. * * 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
  27577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27578. * @param name defines the name of the mesh to create
  27579. * @param options defines the options used to create the mesh
  27580. * @param scene defines the hosting scene
  27581. * @returns a new Mesh
  27582. */
  27583. static CreatePolyhedron(name: string, options: {
  27584. type?: number;
  27585. size?: number;
  27586. sizeX?: number;
  27587. sizeY?: number;
  27588. sizeZ?: number;
  27589. custom?: any;
  27590. faceUV?: Vector4[];
  27591. faceColors?: Color4[];
  27592. updatable?: boolean;
  27593. sideOrientation?: number;
  27594. }, scene: Scene): Mesh;
  27595. /**
  27596. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  27597. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  27598. * * 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`)
  27599. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  27600. * * 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
  27601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27602. * * 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
  27603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  27604. * @param name defines the name of the mesh
  27605. * @param options defines the options used to create the mesh
  27606. * @param scene defines the hosting scene
  27607. * @returns a new Mesh
  27608. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  27609. */
  27610. static CreateIcoSphere(name: string, options: {
  27611. radius?: number;
  27612. flat?: boolean;
  27613. subdivisions?: number;
  27614. sideOrientation?: number;
  27615. updatable?: boolean;
  27616. }, scene: Scene): Mesh;
  27617. /**
  27618. * Creates a decal mesh.
  27619. * Please consider using the same method from the MeshBuilder class instead.
  27620. * A decal is a mesh usually applied as a model onto the surface of another mesh
  27621. * @param name defines the name of the mesh
  27622. * @param sourceMesh defines the mesh receiving the decal
  27623. * @param position sets the position of the decal in world coordinates
  27624. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  27625. * @param size sets the decal scaling
  27626. * @param angle sets the angle to rotate the decal
  27627. * @returns a new Mesh
  27628. */
  27629. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  27630. /**
  27631. * Prepare internal position array for software CPU skinning
  27632. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  27633. */
  27634. setPositionsForCPUSkinning(): Float32Array;
  27635. /**
  27636. * Prepare internal normal array for software CPU skinning
  27637. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  27638. */
  27639. setNormalsForCPUSkinning(): Float32Array;
  27640. /**
  27641. * Updates the vertex buffer by applying transformation from the bones
  27642. * @param skeleton defines the skeleton to apply to current mesh
  27643. * @returns the current mesh
  27644. */
  27645. applySkeleton(skeleton: Skeleton): Mesh;
  27646. /**
  27647. * 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
  27648. * @param meshes defines the list of meshes to scan
  27649. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  27650. */
  27651. static MinMax(meshes: AbstractMesh[]): {
  27652. min: Vector3;
  27653. max: Vector3;
  27654. };
  27655. /**
  27656. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  27657. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  27658. * @returns a vector3
  27659. */
  27660. static Center(meshesOrMinMaxVector: {
  27661. min: Vector3;
  27662. max: Vector3;
  27663. } | AbstractMesh[]): Vector3;
  27664. /**
  27665. * Merge the array of meshes into a single mesh for performance reasons.
  27666. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  27667. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  27668. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  27669. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  27670. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  27671. * @returns a new mesh
  27672. */
  27673. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  27674. /** @hidden */
  27675. addInstance(instance: InstancedMesh): void;
  27676. /** @hidden */
  27677. removeInstance(instance: InstancedMesh): void;
  27678. }
  27679. }
  27680. declare module BABYLON {
  27681. /**
  27682. * Define an interface for all classes that will get and set the data on vertices
  27683. */
  27684. interface IGetSetVerticesData {
  27685. /**
  27686. * Gets a boolean indicating if specific vertex data is present
  27687. * @param kind defines the vertex data kind to use
  27688. * @returns true is data kind is present
  27689. */
  27690. isVerticesDataPresent(kind: string): boolean;
  27691. /**
  27692. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  27693. * @param kind defines the data kind (Position, normal, etc...)
  27694. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  27695. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27696. * @returns a float array containing vertex data
  27697. */
  27698. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27699. /**
  27700. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27701. * @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.
  27702. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27703. * @returns the indices array or an empty array if the mesh has no geometry
  27704. */
  27705. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27706. /**
  27707. * Set specific vertex data
  27708. * @param kind defines the data kind (Position, normal, etc...)
  27709. * @param data defines the vertex data to use
  27710. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  27711. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  27712. */
  27713. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27714. /**
  27715. * Update a specific associated vertex buffer
  27716. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27717. * - BABYLON.VertexBuffer.PositionKind
  27718. * - BABYLON.VertexBuffer.UVKind
  27719. * - BABYLON.VertexBuffer.UV2Kind
  27720. * - BABYLON.VertexBuffer.UV3Kind
  27721. * - BABYLON.VertexBuffer.UV4Kind
  27722. * - BABYLON.VertexBuffer.UV5Kind
  27723. * - BABYLON.VertexBuffer.UV6Kind
  27724. * - BABYLON.VertexBuffer.ColorKind
  27725. * - BABYLON.VertexBuffer.MatricesIndicesKind
  27726. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  27727. * - BABYLON.VertexBuffer.MatricesWeightsKind
  27728. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  27729. * @param data defines the data source
  27730. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27731. * @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)
  27732. */
  27733. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27734. /**
  27735. * Creates a new index buffer
  27736. * @param indices defines the indices to store in the index buffer
  27737. * @param totalVertices defines the total number of vertices (could be null)
  27738. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27739. */
  27740. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27741. }
  27742. /**
  27743. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27744. */
  27745. class VertexData {
  27746. /**
  27747. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27748. */
  27749. positions: Nullable<FloatArray>;
  27750. /**
  27751. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27752. */
  27753. normals: Nullable<FloatArray>;
  27754. /**
  27755. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27756. */
  27757. tangents: Nullable<FloatArray>;
  27758. /**
  27759. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27760. */
  27761. uvs: Nullable<FloatArray>;
  27762. /**
  27763. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27764. */
  27765. uvs2: Nullable<FloatArray>;
  27766. /**
  27767. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27768. */
  27769. uvs3: Nullable<FloatArray>;
  27770. /**
  27771. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27772. */
  27773. uvs4: Nullable<FloatArray>;
  27774. /**
  27775. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27776. */
  27777. uvs5: Nullable<FloatArray>;
  27778. /**
  27779. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27780. */
  27781. uvs6: Nullable<FloatArray>;
  27782. /**
  27783. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27784. */
  27785. colors: Nullable<FloatArray>;
  27786. /**
  27787. * 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).
  27788. */
  27789. matricesIndices: Nullable<FloatArray>;
  27790. /**
  27791. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27792. */
  27793. matricesWeights: Nullable<FloatArray>;
  27794. /**
  27795. * An array extending the number of possible indices
  27796. */
  27797. matricesIndicesExtra: Nullable<FloatArray>;
  27798. /**
  27799. * An array extending the number of possible weights when the number of indices is extended
  27800. */
  27801. matricesWeightsExtra: Nullable<FloatArray>;
  27802. /**
  27803. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27804. */
  27805. indices: Nullable<IndicesArray>;
  27806. /**
  27807. * Uses the passed data array to set the set the values for the specified kind of data
  27808. * @param data a linear array of floating numbers
  27809. * @param kind the type of data that is being set, eg positions, colors etc
  27810. */
  27811. set(data: FloatArray, kind: string): void;
  27812. /**
  27813. * Associates the vertexData to the passed Mesh.
  27814. * Sets it as updatable or not (default `false`)
  27815. * @param mesh the mesh the vertexData is applied to
  27816. * @param updatable when used and having the value true allows new data to update the vertexData
  27817. * @returns the VertexData
  27818. */
  27819. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27820. /**
  27821. * Associates the vertexData to the passed Geometry.
  27822. * Sets it as updatable or not (default `false`)
  27823. * @param geometry the geometry the vertexData is applied to
  27824. * @param updatable when used and having the value true allows new data to update the vertexData
  27825. * @returns VertexData
  27826. */
  27827. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27828. /**
  27829. * Updates the associated mesh
  27830. * @param mesh the mesh to be updated
  27831. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27832. * @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
  27833. * @returns VertexData
  27834. */
  27835. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27836. /**
  27837. * Updates the associated geometry
  27838. * @param geometry the geometry to be updated
  27839. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27840. * @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
  27841. * @returns VertexData.
  27842. */
  27843. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  27844. private _applyTo;
  27845. private _update;
  27846. /**
  27847. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27848. * @param matrix the transforming matrix
  27849. * @returns the VertexData
  27850. */
  27851. transform(matrix: Matrix): VertexData;
  27852. /**
  27853. * Merges the passed VertexData into the current one
  27854. * @param other the VertexData to be merged into the current one
  27855. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27856. * @returns the modified VertexData
  27857. */
  27858. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27859. private _mergeElement;
  27860. private _validate;
  27861. /**
  27862. * Serializes the VertexData
  27863. * @returns a serialized object
  27864. */
  27865. serialize(): any;
  27866. /**
  27867. * Extracts the vertexData from a mesh
  27868. * @param mesh the mesh from which to extract the VertexData
  27869. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27870. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27871. * @returns the object VertexData associated to the passed mesh
  27872. */
  27873. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27874. /**
  27875. * Extracts the vertexData from the geometry
  27876. * @param geometry the geometry from which to extract the VertexData
  27877. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27878. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27879. * @returns the object VertexData associated to the passed mesh
  27880. */
  27881. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27882. private static _ExtractFrom;
  27883. /**
  27884. * Creates the VertexData for a Ribbon
  27885. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27886. * * pathArray array of paths, each of which an array of successive Vector3
  27887. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27888. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27889. * * 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
  27890. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27891. * * 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)
  27892. * * 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)
  27893. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27894. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27895. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27896. * @returns the VertexData of the ribbon
  27897. */
  27898. static CreateRibbon(options: {
  27899. pathArray: Vector3[][];
  27900. closeArray?: boolean;
  27901. closePath?: boolean;
  27902. offset?: number;
  27903. sideOrientation?: number;
  27904. frontUVs?: Vector4;
  27905. backUVs?: Vector4;
  27906. invertUV?: boolean;
  27907. uvs?: Vector2[];
  27908. colors?: Color4[];
  27909. }): VertexData;
  27910. /**
  27911. * Creates the VertexData for a box
  27912. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27913. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27914. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27915. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27916. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27917. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27918. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27919. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27920. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  27921. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  27922. * @returns the VertexData of the box
  27923. */
  27924. static CreateBox(options: {
  27925. size?: number;
  27926. width?: number;
  27927. height?: number;
  27928. depth?: number;
  27929. faceUV?: Vector4[];
  27930. faceColors?: Color4[];
  27931. sideOrientation?: number;
  27932. frontUVs?: Vector4;
  27933. backUVs?: Vector4;
  27934. }): VertexData;
  27935. /**
  27936. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27937. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27938. * * segments sets the number of horizontal strips optional, default 32
  27939. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27940. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27941. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27942. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27943. * * 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
  27944. * * 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
  27945. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27946. * * 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)
  27947. * * 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)
  27948. * @returns the VertexData of the ellipsoid
  27949. */
  27950. static CreateSphere(options: {
  27951. segments?: number;
  27952. diameter?: number;
  27953. diameterX?: number;
  27954. diameterY?: number;
  27955. diameterZ?: number;
  27956. arc?: number;
  27957. slice?: number;
  27958. sideOrientation?: number;
  27959. frontUVs?: Vector4;
  27960. backUVs?: Vector4;
  27961. }): VertexData;
  27962. /**
  27963. * Creates the VertexData for a cylinder, cone or prism
  27964. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27965. * * height sets the height (y direction) of the cylinder, optional, default 2
  27966. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27967. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27968. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27969. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27970. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27971. * * 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
  27972. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27973. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27974. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27975. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27976. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  27977. * * 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)
  27978. * * 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)
  27979. * @returns the VertexData of the cylinder, cone or prism
  27980. */
  27981. static CreateCylinder(options: {
  27982. height?: number;
  27983. diameterTop?: number;
  27984. diameterBottom?: number;
  27985. diameter?: number;
  27986. tessellation?: number;
  27987. subdivisions?: number;
  27988. arc?: number;
  27989. faceColors?: Color4[];
  27990. faceUV?: Vector4[];
  27991. hasRings?: boolean;
  27992. enclose?: boolean;
  27993. sideOrientation?: number;
  27994. frontUVs?: Vector4;
  27995. backUVs?: Vector4;
  27996. }): VertexData;
  27997. /**
  27998. * Creates the VertexData for a torus
  27999. * @param options an object used to set the following optional parameters for the box, required but can be empty
  28000. * * diameter the diameter of the torus, optional default 1
  28001. * * thickness the diameter of the tube forming the torus, optional default 0.5
  28002. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  28003. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28004. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  28005. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  28006. * @returns the VertexData of the torus
  28007. */
  28008. static CreateTorus(options: {
  28009. diameter?: number;
  28010. thickness?: number;
  28011. tessellation?: number;
  28012. sideOrientation?: number;
  28013. frontUVs?: Vector4;
  28014. backUVs?: Vector4;
  28015. }): VertexData;
  28016. /**
  28017. * Creates the VertexData of the LineSystem
  28018. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  28019. * - lines an array of lines, each line being an array of successive Vector3
  28020. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  28021. * @returns the VertexData of the LineSystem
  28022. */
  28023. static CreateLineSystem(options: {
  28024. lines: Vector3[][];
  28025. colors?: Nullable<Color4[][]>;
  28026. }): VertexData;
  28027. /**
  28028. * Create the VertexData for a DashedLines
  28029. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  28030. * - points an array successive Vector3
  28031. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  28032. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  28033. * - dashNb the intended total number of dashes, optional, default 200
  28034. * @returns the VertexData for the DashedLines
  28035. */
  28036. static CreateDashedLines(options: {
  28037. points: Vector3[];
  28038. dashSize?: number;
  28039. gapSize?: number;
  28040. dashNb?: number;
  28041. }): VertexData;
  28042. /**
  28043. * Creates the VertexData for a Ground
  28044. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28045. * - width the width (x direction) of the ground, optional, default 1
  28046. * - height the height (z direction) of the ground, optional, default 1
  28047. * - subdivisions the number of subdivisions per side, optional, default 1
  28048. * @returns the VertexData of the Ground
  28049. */
  28050. static CreateGround(options: {
  28051. width?: number;
  28052. height?: number;
  28053. subdivisions?: number;
  28054. subdivisionsX?: number;
  28055. subdivisionsY?: number;
  28056. }): VertexData;
  28057. /**
  28058. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  28059. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  28060. * * xmin the ground minimum X coordinate, optional, default -1
  28061. * * zmin the ground minimum Z coordinate, optional, default -1
  28062. * * xmax the ground maximum X coordinate, optional, default 1
  28063. * * zmax the ground maximum Z coordinate, optional, default 1
  28064. * * 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}
  28065. * * 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}
  28066. * @returns the VertexData of the TiledGround
  28067. */
  28068. static CreateTiledGround(options: {
  28069. xmin: number;
  28070. zmin: number;
  28071. xmax: number;
  28072. zmax: number;
  28073. subdivisions?: {
  28074. w: number;
  28075. h: number;
  28076. };
  28077. precision?: {
  28078. w: number;
  28079. h: number;
  28080. };
  28081. }): VertexData;
  28082. /**
  28083. * Creates the VertexData of the Ground designed from a heightmap
  28084. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  28085. * * width the width (x direction) of the ground
  28086. * * height the height (z direction) of the ground
  28087. * * subdivisions the number of subdivisions per side
  28088. * * minHeight the minimum altitude on the ground, optional, default 0
  28089. * * maxHeight the maximum altitude on the ground, optional default 1
  28090. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  28091. * * buffer the array holding the image color data
  28092. * * bufferWidth the width of image
  28093. * * bufferHeight the height of image
  28094. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  28095. * @returns the VertexData of the Ground designed from a heightmap
  28096. */
  28097. static CreateGroundFromHeightMap(options: {
  28098. width: number;
  28099. height: number;
  28100. subdivisions: number;
  28101. minHeight: number;
  28102. maxHeight: number;
  28103. colorFilter: Color3;
  28104. buffer: Uint8Array;
  28105. bufferWidth: number;
  28106. bufferHeight: number;
  28107. alphaFilter: number;
  28108. }): VertexData;
  28109. /**
  28110. * Creates the VertexData for a Plane
  28111. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  28112. * * size sets the width and height of the plane to the value of size, optional default 1
  28113. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  28114. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  28115. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28116. * * 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)
  28117. * * 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)
  28118. * @returns the VertexData of the box
  28119. */
  28120. static CreatePlane(options: {
  28121. size?: number;
  28122. width?: number;
  28123. height?: number;
  28124. sideOrientation?: number;
  28125. frontUVs?: Vector4;
  28126. backUVs?: Vector4;
  28127. }): VertexData;
  28128. /**
  28129. * Creates the VertexData of the Disc or regular Polygon
  28130. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  28131. * * radius the radius of the disc, optional default 0.5
  28132. * * tessellation the number of polygon sides, optional, default 64
  28133. * * 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
  28134. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28135. * * 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)
  28136. * * 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)
  28137. * @returns the VertexData of the box
  28138. */
  28139. static CreateDisc(options: {
  28140. radius?: number;
  28141. tessellation?: number;
  28142. arc?: number;
  28143. sideOrientation?: number;
  28144. frontUVs?: Vector4;
  28145. backUVs?: Vector4;
  28146. }): VertexData;
  28147. /**
  28148. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  28149. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  28150. * @param polygon a mesh built from polygonTriangulation.build()
  28151. * @param sideOrientation takes the values BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28152. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28153. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28154. * @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)
  28155. * @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)
  28156. * @returns the VertexData of the Polygon
  28157. */
  28158. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  28159. /**
  28160. * Creates the VertexData of the IcoSphere
  28161. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  28162. * * radius the radius of the IcoSphere, optional default 1
  28163. * * radiusX allows stretching in the x direction, optional, default radius
  28164. * * radiusY allows stretching in the y direction, optional, default radius
  28165. * * radiusZ allows stretching in the z direction, optional, default radius
  28166. * * flat when true creates a flat shaded mesh, optional, default true
  28167. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28168. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28169. * * 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)
  28170. * * 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)
  28171. * @returns the VertexData of the IcoSphere
  28172. */
  28173. static CreateIcoSphere(options: {
  28174. radius?: number;
  28175. radiusX?: number;
  28176. radiusY?: number;
  28177. radiusZ?: number;
  28178. flat?: boolean;
  28179. subdivisions?: number;
  28180. sideOrientation?: number;
  28181. frontUVs?: Vector4;
  28182. backUVs?: Vector4;
  28183. }): VertexData;
  28184. /**
  28185. * Creates the VertexData for a Polyhedron
  28186. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  28187. * * type provided types are:
  28188. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  28189. * * 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)
  28190. * * size the size of the IcoSphere, optional default 1
  28191. * * sizeX allows stretching in the x direction, optional, default size
  28192. * * sizeY allows stretching in the y direction, optional, default size
  28193. * * sizeZ allows stretching in the z direction, optional, default size
  28194. * * 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
  28195. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  28196. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  28197. * * flat when true creates a flat shaded mesh, optional, default true
  28198. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  28199. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28200. * * 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)
  28201. * * 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)
  28202. * @returns the VertexData of the Polyhedron
  28203. */
  28204. static CreatePolyhedron(options: {
  28205. type?: number;
  28206. size?: number;
  28207. sizeX?: number;
  28208. sizeY?: number;
  28209. sizeZ?: number;
  28210. custom?: any;
  28211. faceUV?: Vector4[];
  28212. faceColors?: Color4[];
  28213. flat?: boolean;
  28214. sideOrientation?: number;
  28215. frontUVs?: Vector4;
  28216. backUVs?: Vector4;
  28217. }): VertexData;
  28218. /**
  28219. * Creates the VertexData for a TorusKnot
  28220. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  28221. * * radius the radius of the torus knot, optional, default 2
  28222. * * tube the thickness of the tube, optional, default 0.5
  28223. * * radialSegments the number of sides on each tube segments, optional, default 32
  28224. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  28225. * * p the number of windings around the z axis, optional, default 2
  28226. * * q the number of windings around the x axis, optional, default 3
  28227. * * sideOrientation optional and takes the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28228. * * 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)
  28229. * * 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)
  28230. * @returns the VertexData of the Torus Knot
  28231. */
  28232. static CreateTorusKnot(options: {
  28233. radius?: number;
  28234. tube?: number;
  28235. radialSegments?: number;
  28236. tubularSegments?: number;
  28237. p?: number;
  28238. q?: number;
  28239. sideOrientation?: number;
  28240. frontUVs?: Vector4;
  28241. backUVs?: Vector4;
  28242. }): VertexData;
  28243. /**
  28244. * Compute normals for given positions and indices
  28245. * @param positions an array of vertex positions, [...., x, y, z, ......]
  28246. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  28247. * @param normals an array of vertex normals, [...., x, y, z, ......]
  28248. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  28249. * * facetNormals : optional array of facet normals (vector3)
  28250. * * facetPositions : optional array of facet positions (vector3)
  28251. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  28252. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  28253. * * bInfo : optional bounding info, required for facetPartitioning computation
  28254. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  28255. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  28256. * * useRightHandedSystem: optional boolean to for right handed system computation
  28257. * * depthSort : optional boolean to enable the facet depth sort computation
  28258. * * distanceTo : optional Vector3 to compute the facet depth from this location
  28259. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  28260. */
  28261. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  28262. facetNormals?: any;
  28263. facetPositions?: any;
  28264. facetPartitioning?: any;
  28265. ratio?: number;
  28266. bInfo?: any;
  28267. bbSize?: Vector3;
  28268. subDiv?: any;
  28269. useRightHandedSystem?: boolean;
  28270. depthSort?: boolean;
  28271. distanceTo?: Vector3;
  28272. depthSortedFacets?: any;
  28273. }): void;
  28274. private static _ComputeSides;
  28275. /**
  28276. * Applies VertexData created from the imported parameters to the geometry
  28277. * @param parsedVertexData the parsed data from an imported file
  28278. * @param geometry the geometry to apply the VertexData to
  28279. */
  28280. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  28281. }
  28282. }
  28283. declare module BABYLON {
  28284. /**
  28285. * Class containing static functions to help procedurally build meshes
  28286. */
  28287. class MeshBuilder {
  28288. private static updateSideOrientation;
  28289. /**
  28290. * Creates a box mesh
  28291. * * The parameter `size` sets the size (float) of each box side (default 1)
  28292. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  28293. * * 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)
  28294. * * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28296. * * 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
  28297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28298. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  28299. * @param name defines the name of the mesh
  28300. * @param options defines the options used to create the mesh
  28301. * @param scene defines the hosting scene
  28302. * @returns the box mesh
  28303. */
  28304. static CreateBox(name: string, options: {
  28305. size?: number;
  28306. width?: number;
  28307. height?: number;
  28308. depth?: number;
  28309. faceUV?: Vector4[];
  28310. faceColors?: Color4[];
  28311. sideOrientation?: number;
  28312. frontUVs?: Vector4;
  28313. backUVs?: Vector4;
  28314. updatable?: boolean;
  28315. }, scene?: Nullable<Scene>): Mesh;
  28316. /**
  28317. * Creates a sphere mesh
  28318. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  28319. * * 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`)
  28320. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  28321. * * 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
  28322. * * 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)
  28323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28324. * * 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
  28325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28326. * @param name defines the name of the mesh
  28327. * @param options defines the options used to create the mesh
  28328. * @param scene defines the hosting scene
  28329. * @returns the sphere mesh
  28330. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  28331. */
  28332. static CreateSphere(name: string, options: {
  28333. segments?: number;
  28334. diameter?: number;
  28335. diameterX?: number;
  28336. diameterY?: number;
  28337. diameterZ?: number;
  28338. arc?: number;
  28339. slice?: number;
  28340. sideOrientation?: number;
  28341. frontUVs?: Vector4;
  28342. backUVs?: Vector4;
  28343. updatable?: boolean;
  28344. }, scene: any): Mesh;
  28345. /**
  28346. * Creates a plane polygonal mesh. By default, this is a disc
  28347. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28348. * * 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
  28349. * * 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
  28350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28351. * * 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
  28352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28353. * @param name defines the name of the mesh
  28354. * @param options defines the options used to create the mesh
  28355. * @param scene defines the hosting scene
  28356. * @returns the plane polygonal mesh
  28357. * @see http://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28358. */
  28359. static CreateDisc(name: string, options: {
  28360. radius?: number;
  28361. tessellation?: number;
  28362. arc?: number;
  28363. updatable?: boolean;
  28364. sideOrientation?: number;
  28365. frontUVs?: Vector4;
  28366. backUVs?: Vector4;
  28367. }, scene?: Nullable<Scene>): Mesh;
  28368. /**
  28369. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28370. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28371. * * 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`)
  28372. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28373. * * 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
  28374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28375. * * 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
  28376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28377. * @param name defines the name of the mesh
  28378. * @param options defines the options used to create the mesh
  28379. * @param scene defines the hosting scene
  28380. * @returns the icosahedron mesh
  28381. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28382. */
  28383. static CreateIcoSphere(name: string, options: {
  28384. radius?: number;
  28385. radiusX?: number;
  28386. radiusY?: number;
  28387. radiusZ?: number;
  28388. flat?: boolean;
  28389. subdivisions?: number;
  28390. sideOrientation?: number;
  28391. frontUVs?: Vector4;
  28392. backUVs?: Vector4;
  28393. updatable?: boolean;
  28394. }, scene: Scene): Mesh;
  28395. /**
  28396. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28397. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  28398. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  28399. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  28400. * * 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
  28401. * * 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
  28402. * * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  28403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28404. * * 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
  28405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28406. * * 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
  28407. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  28408. * * 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
  28409. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  28410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28411. * @param name defines the name of the mesh
  28412. * @param options defines the options used to create the mesh
  28413. * @param scene defines the hosting scene
  28414. * @returns the ribbon mesh
  28415. * @see http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  28416. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28417. */
  28418. static CreateRibbon(name: string, options: {
  28419. pathArray: Vector3[][];
  28420. closeArray?: boolean;
  28421. closePath?: boolean;
  28422. offset?: number;
  28423. updatable?: boolean;
  28424. sideOrientation?: number;
  28425. frontUVs?: Vector4;
  28426. backUVs?: Vector4;
  28427. instance?: Mesh;
  28428. invertUV?: boolean;
  28429. uvs?: Vector2[];
  28430. colors?: Color4[];
  28431. }, scene?: Nullable<Scene>): Mesh;
  28432. /**
  28433. * Creates a cylinder or a cone mesh
  28434. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  28435. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  28436. * * 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.
  28437. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  28438. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  28439. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  28440. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  28441. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  28442. * * 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).
  28443. * * 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
  28444. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  28445. * * 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
  28446. * * 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.
  28447. * * If `enclose` is false, a ring surface is one element.
  28448. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  28449. * * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  28450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28451. * * 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
  28452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28453. * @param name defines the name of the mesh
  28454. * @param options defines the options used to create the mesh
  28455. * @param scene defines the hosting scene
  28456. * @returns the cylinder mesh
  28457. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  28458. */
  28459. static CreateCylinder(name: string, options: {
  28460. height?: number;
  28461. diameterTop?: number;
  28462. diameterBottom?: number;
  28463. diameter?: number;
  28464. tessellation?: number;
  28465. subdivisions?: number;
  28466. arc?: number;
  28467. faceColors?: Color4[];
  28468. faceUV?: Vector4[];
  28469. updatable?: boolean;
  28470. hasRings?: boolean;
  28471. enclose?: boolean;
  28472. sideOrientation?: number;
  28473. frontUVs?: Vector4;
  28474. backUVs?: Vector4;
  28475. }, scene: any): Mesh;
  28476. /**
  28477. * Creates a torus mesh
  28478. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  28479. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  28480. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  28481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28482. * * 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
  28483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28484. * @param name defines the name of the mesh
  28485. * @param options defines the options used to create the mesh
  28486. * @param scene defines the hosting scene
  28487. * @returns the torus mesh
  28488. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  28489. */
  28490. static CreateTorus(name: string, options: {
  28491. diameter?: number;
  28492. thickness?: number;
  28493. tessellation?: number;
  28494. updatable?: boolean;
  28495. sideOrientation?: number;
  28496. frontUVs?: Vector4;
  28497. backUVs?: Vector4;
  28498. }, scene: any): Mesh;
  28499. /**
  28500. * Creates a torus knot mesh
  28501. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  28502. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  28503. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  28504. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  28505. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28506. * * 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
  28507. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28508. * @param name defines the name of the mesh
  28509. * @param options defines the options used to create the mesh
  28510. * @param scene defines the hosting scene
  28511. * @returns the torus knot mesh
  28512. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  28513. */
  28514. static CreateTorusKnot(name: string, options: {
  28515. radius?: number;
  28516. tube?: number;
  28517. radialSegments?: number;
  28518. tubularSegments?: number;
  28519. p?: number;
  28520. q?: number;
  28521. updatable?: boolean;
  28522. sideOrientation?: number;
  28523. frontUVs?: Vector4;
  28524. backUVs?: Vector4;
  28525. }, scene: any): Mesh;
  28526. /**
  28527. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  28528. * * 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
  28529. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  28530. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  28531. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  28532. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  28533. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  28534. * * Updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28535. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  28536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28537. * @see http://doc.babylonjs.com/how_to/parametric_shapes#line-system
  28538. * @param name defines the name of the new line system
  28539. * @param options defines the options used to create the line system
  28540. * @param scene defines the hosting scene
  28541. * @returns a new line system mesh
  28542. */
  28543. static CreateLineSystem(name: string, options: {
  28544. lines: Vector3[][];
  28545. updatable?: boolean;
  28546. instance?: Nullable<LinesMesh>;
  28547. colors?: Nullable<Color4[][]>;
  28548. useVertexAlpha?: boolean;
  28549. }, scene: Nullable<Scene>): LinesMesh;
  28550. /**
  28551. * Creates a line mesh
  28552. * 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
  28553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28554. * * The parameter `points` is an array successive Vector3
  28555. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28556. * * The optional parameter `colors` is an array of successive Color4, one per line point
  28557. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  28558. * * When updating an instance, remember that only point positions can change, not the number of points
  28559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28560. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lines
  28561. * @param name defines the name of the new line system
  28562. * @param options defines the options used to create the line system
  28563. * @param scene defines the hosting scene
  28564. * @returns a new line mesh
  28565. */
  28566. static CreateLines(name: string, options: {
  28567. points: Vector3[];
  28568. updatable?: boolean;
  28569. instance?: Nullable<LinesMesh>;
  28570. colors?: Color4[];
  28571. useVertexAlpha?: boolean;
  28572. }, scene?: Nullable<Scene>): LinesMesh;
  28573. /**
  28574. * Creates a dashed line mesh
  28575. * * 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
  28576. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  28577. * * The parameter `points` is an array successive Vector3
  28578. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  28579. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  28580. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28581. * * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  28582. * * When updating an instance, remember that only point positions can change, not the number of points
  28583. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28584. * @param name defines the name of the mesh
  28585. * @param options defines the options used to create the mesh
  28586. * @param scene defines the hosting scene
  28587. * @returns the dashed line mesh
  28588. * @see http://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  28589. */
  28590. static CreateDashedLines(name: string, options: {
  28591. points: Vector3[];
  28592. dashSize?: number;
  28593. gapSize?: number;
  28594. dashNb?: number;
  28595. updatable?: boolean;
  28596. instance?: LinesMesh;
  28597. }, scene?: Nullable<Scene>): LinesMesh;
  28598. /**
  28599. * 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.
  28600. * * 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.
  28601. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28602. * * 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.
  28603. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  28604. * * 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
  28605. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28606. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  28607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28608. * * 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
  28609. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  28610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28611. * @param name defines the name of the mesh
  28612. * @param options defines the options used to create the mesh
  28613. * @param scene defines the hosting scene
  28614. * @returns the extruded shape mesh
  28615. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28616. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28617. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28618. */
  28619. static ExtrudeShape(name: string, options: {
  28620. shape: Vector3[];
  28621. path: Vector3[];
  28622. scale?: number;
  28623. rotation?: number;
  28624. cap?: number;
  28625. updatable?: boolean;
  28626. sideOrientation?: number;
  28627. frontUVs?: Vector4;
  28628. backUVs?: Vector4;
  28629. instance?: Mesh;
  28630. invertUV?: boolean;
  28631. }, scene?: Nullable<Scene>): Mesh;
  28632. /**
  28633. * Creates an custom extruded shape mesh.
  28634. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  28635. * * 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.
  28636. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  28637. * * 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
  28638. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  28639. * * 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
  28640. * * It must returns a float value that will be the scale value applied to the shape on each path point
  28641. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28642. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  28643. * * 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
  28644. * * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  28645. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  28646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28647. * * 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
  28648. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28650. * @param name defines the name of the mesh
  28651. * @param options defines the options used to create the mesh
  28652. * @param scene defines the hosting scene
  28653. * @returns the custom extruded shape mesh
  28654. * @see http://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  28655. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28656. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28657. */
  28658. static ExtrudeShapeCustom(name: string, options: {
  28659. shape: Vector3[];
  28660. path: Vector3[];
  28661. scaleFunction?: any;
  28662. rotationFunction?: any;
  28663. ribbonCloseArray?: boolean;
  28664. ribbonClosePath?: boolean;
  28665. cap?: number;
  28666. updatable?: boolean;
  28667. sideOrientation?: number;
  28668. frontUVs?: Vector4;
  28669. backUVs?: Vector4;
  28670. instance?: Mesh;
  28671. invertUV?: boolean;
  28672. }, scene: Scene): Mesh;
  28673. /**
  28674. * Creates lathe mesh.
  28675. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  28676. * * 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
  28677. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  28678. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  28679. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  28680. * * 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
  28681. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  28682. * * 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
  28683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28684. * * 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
  28685. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28687. * @param name defines the name of the mesh
  28688. * @param options defines the options used to create the mesh
  28689. * @param scene defines the hosting scene
  28690. * @returns the lathe mesh
  28691. * @see http://doc.babylonjs.com/how_to/parametric_shapes#lathe
  28692. */
  28693. static CreateLathe(name: string, options: {
  28694. shape: Vector3[];
  28695. radius?: number;
  28696. tessellation?: number;
  28697. clip?: number;
  28698. arc?: number;
  28699. closed?: boolean;
  28700. updatable?: boolean;
  28701. sideOrientation?: number;
  28702. frontUVs?: Vector4;
  28703. backUVs?: Vector4;
  28704. cap?: number;
  28705. invertUV?: boolean;
  28706. }, scene: Scene): Mesh;
  28707. /**
  28708. * Creates a plane mesh
  28709. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  28710. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  28711. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  28712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28713. * * 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
  28714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28715. * @param name defines the name of the mesh
  28716. * @param options defines the options used to create the mesh
  28717. * @param scene defines the hosting scene
  28718. * @returns the plane mesh
  28719. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28720. */
  28721. static CreatePlane(name: string, options: {
  28722. size?: number;
  28723. width?: number;
  28724. height?: number;
  28725. sideOrientation?: number;
  28726. frontUVs?: Vector4;
  28727. backUVs?: Vector4;
  28728. updatable?: boolean;
  28729. sourcePlane?: Plane;
  28730. }, scene: Scene): Mesh;
  28731. /**
  28732. * Creates a ground mesh
  28733. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  28734. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  28735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28736. * @param name defines the name of the mesh
  28737. * @param options defines the options used to create the mesh
  28738. * @param scene defines the hosting scene
  28739. * @returns the ground mesh
  28740. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  28741. */
  28742. static CreateGround(name: string, options: {
  28743. width?: number;
  28744. height?: number;
  28745. subdivisions?: number;
  28746. subdivisionsX?: number;
  28747. subdivisionsY?: number;
  28748. updatable?: boolean;
  28749. }, scene: any): Mesh;
  28750. /**
  28751. * Creates a tiled ground mesh
  28752. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  28753. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  28754. * * 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
  28755. * * 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
  28756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28757. * @param name defines the name of the mesh
  28758. * @param options defines the options used to create the mesh
  28759. * @param scene defines the hosting scene
  28760. * @returns the tiled ground mesh
  28761. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  28762. */
  28763. static CreateTiledGround(name: string, options: {
  28764. xmin: number;
  28765. zmin: number;
  28766. xmax: number;
  28767. zmax: number;
  28768. subdivisions?: {
  28769. w: number;
  28770. h: number;
  28771. };
  28772. precision?: {
  28773. w: number;
  28774. h: number;
  28775. };
  28776. updatable?: boolean;
  28777. }, scene: Scene): Mesh;
  28778. /**
  28779. * Creates a ground mesh from a height map
  28780. * * The parameter `url` sets the URL of the height map image resource.
  28781. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  28782. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  28783. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  28784. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  28785. * * 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.
  28786. * * 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).
  28787. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28789. * @param name defines the name of the mesh
  28790. * @param url defines the url to the height map
  28791. * @param options defines the options used to create the mesh
  28792. * @param scene defines the hosting scene
  28793. * @returns the ground mesh
  28794. * @see http://doc.babylonjs.com/babylon101/height_map
  28795. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  28796. */
  28797. static CreateGroundFromHeightMap(name: string, url: string, options: {
  28798. width?: number;
  28799. height?: number;
  28800. subdivisions?: number;
  28801. minHeight?: number;
  28802. maxHeight?: number;
  28803. colorFilter?: Color3;
  28804. alphaFilter?: number;
  28805. updatable?: boolean;
  28806. onReady?: (mesh: GroundMesh) => void;
  28807. }, scene: Scene): GroundMesh;
  28808. /**
  28809. * Creates a polygon mesh
  28810. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  28811. * * 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
  28812. * * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28814. * * 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)
  28815. * * Remember you can only change the shape positions, not their number when updating a polygon
  28816. * @param name defines the name of the mesh
  28817. * @param options defines the options used to create the mesh
  28818. * @param scene defines the hosting scene
  28819. * @returns the polygon mesh
  28820. */
  28821. static CreatePolygon(name: string, options: {
  28822. shape: Vector3[];
  28823. holes?: Vector3[][];
  28824. depth?: number;
  28825. faceUV?: Vector4[];
  28826. faceColors?: Color4[];
  28827. updatable?: boolean;
  28828. sideOrientation?: number;
  28829. frontUVs?: Vector4;
  28830. backUVs?: Vector4;
  28831. }, scene: Scene): Mesh;
  28832. /**
  28833. * Creates an extruded polygon mesh, with depth in the Y direction.
  28834. * * 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)
  28835. * @see http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28836. * @param name defines the name of the mesh
  28837. * @param options defines the options used to create the mesh
  28838. * @param scene defines the hosting scene
  28839. * @returns the polygon mesh
  28840. */
  28841. static ExtrudePolygon(name: string, options: {
  28842. shape: Vector3[];
  28843. holes?: Vector3[][];
  28844. depth?: number;
  28845. faceUV?: Vector4[];
  28846. faceColors?: Color4[];
  28847. updatable?: boolean;
  28848. sideOrientation?: number;
  28849. frontUVs?: Vector4;
  28850. backUVs?: Vector4;
  28851. }, scene: Scene): Mesh;
  28852. /**
  28853. * Creates a tube mesh.
  28854. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  28855. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  28856. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  28857. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  28858. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  28859. * * 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)
  28860. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  28861. * * 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
  28862. * * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  28863. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28864. * * 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
  28865. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  28866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28867. * @param name defines the name of the mesh
  28868. * @param options defines the options used to create the mesh
  28869. * @param scene defines the hosting scene
  28870. * @returns the tube mesh
  28871. * @see http://doc.babylonjs.com/tutorials/Parametric_Shapes
  28872. * @see http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  28873. */
  28874. static CreateTube(name: string, options: {
  28875. path: Vector3[];
  28876. radius?: number;
  28877. tessellation?: number;
  28878. radiusFunction?: {
  28879. (i: number, distance: number): number;
  28880. };
  28881. cap?: number;
  28882. arc?: number;
  28883. updatable?: boolean;
  28884. sideOrientation?: number;
  28885. frontUVs?: Vector4;
  28886. backUVs?: Vector4;
  28887. instance?: Mesh;
  28888. invertUV?: boolean;
  28889. }, scene: Scene): Mesh;
  28890. /**
  28891. * Creates a polyhedron mesh
  28892. * * 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
  28893. * * The parameter `size` (positive float, default 1) sets the polygon size
  28894. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28895. * * 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`
  28896. * * 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
  28897. * * 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)`)
  28898. * * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  28899. * * 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
  28900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28901. * * 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
  28902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28903. * @param name defines the name of the mesh
  28904. * @param options defines the options used to create the mesh
  28905. * @param scene defines the hosting scene
  28906. * @returns the polyhedron mesh
  28907. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes
  28908. */
  28909. static CreatePolyhedron(name: string, options: {
  28910. type?: number;
  28911. size?: number;
  28912. sizeX?: number;
  28913. sizeY?: number;
  28914. sizeZ?: number;
  28915. custom?: any;
  28916. faceUV?: Vector4[];
  28917. faceColors?: Color4[];
  28918. flat?: boolean;
  28919. updatable?: boolean;
  28920. sideOrientation?: number;
  28921. frontUVs?: Vector4;
  28922. backUVs?: Vector4;
  28923. }, scene: Scene): Mesh;
  28924. /**
  28925. * Creates a decal mesh.
  28926. * 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
  28927. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  28928. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  28929. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  28930. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  28931. * @param name defines the name of the mesh
  28932. * @param sourceMesh defines the mesh where the decal must be applied
  28933. * @param options defines the options used to create the mesh
  28934. * @param scene defines the hosting scene
  28935. * @returns the decal mesh
  28936. * @see http://doc.babylonjs.com/how_to/decals
  28937. */
  28938. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  28939. position?: Vector3;
  28940. normal?: Vector3;
  28941. size?: Vector3;
  28942. angle?: number;
  28943. }): Mesh;
  28944. private static _ExtrudeShapeGeneric;
  28945. }
  28946. }
  28947. declare module BABYLON {
  28948. /**
  28949. * Class used to represent a specific level of detail of a mesh
  28950. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  28951. */
  28952. class MeshLODLevel {
  28953. /** Defines the distance where this level should star being displayed */
  28954. distance: number;
  28955. /** Defines the mesh to use to render this level */
  28956. mesh: Nullable<Mesh>;
  28957. /**
  28958. * Creates a new LOD level
  28959. * @param distance defines the distance where this level should star being displayed
  28960. * @param mesh defines the mesh to use to render this level
  28961. */
  28962. constructor(
  28963. /** Defines the distance where this level should star being displayed */
  28964. distance: number,
  28965. /** Defines the mesh to use to render this level */
  28966. mesh: Nullable<Mesh>);
  28967. }
  28968. }
  28969. declare module BABYLON {
  28970. /**
  28971. * A simplifier interface for future simplification implementations
  28972. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28973. */
  28974. interface ISimplifier {
  28975. /**
  28976. * Simplification of a given mesh according to the given settings.
  28977. * Since this requires computation, it is assumed that the function runs async.
  28978. * @param settings The settings of the simplification, including quality and distance
  28979. * @param successCallback A callback that will be called after the mesh was simplified.
  28980. * @param errorCallback in case of an error, this callback will be called. optional.
  28981. */
  28982. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  28983. }
  28984. /**
  28985. * Expected simplification settings.
  28986. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  28987. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  28988. */
  28989. interface ISimplificationSettings {
  28990. /**
  28991. * Gets or sets the expected quality
  28992. */
  28993. quality: number;
  28994. /**
  28995. * Gets or sets the distance when this optimized version should be used
  28996. */
  28997. distance: number;
  28998. /**
  28999. * Gets an already optimized mesh
  29000. */
  29001. optimizeMesh?: boolean;
  29002. }
  29003. /**
  29004. * Class used to specify simplification options
  29005. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29006. */
  29007. class SimplificationSettings implements ISimplificationSettings {
  29008. /** expected quality */
  29009. quality: number;
  29010. /** distance when this optimized version should be used */
  29011. distance: number;
  29012. /** already optimized mesh */
  29013. optimizeMesh?: boolean | undefined;
  29014. /**
  29015. * Creates a SimplificationSettings
  29016. * @param quality expected quality
  29017. * @param distance distance when this optimized version should be used
  29018. * @param optimizeMesh already optimized mesh
  29019. */
  29020. constructor(
  29021. /** expected quality */
  29022. quality: number,
  29023. /** distance when this optimized version should be used */
  29024. distance: number,
  29025. /** already optimized mesh */
  29026. optimizeMesh?: boolean | undefined);
  29027. }
  29028. /**
  29029. * Interface used to define a simplification task
  29030. */
  29031. interface ISimplificationTask {
  29032. /**
  29033. * Array of settings
  29034. */
  29035. settings: Array<ISimplificationSettings>;
  29036. /**
  29037. * Simplification type
  29038. */
  29039. simplificationType: SimplificationType;
  29040. /**
  29041. * Mesh to simplify
  29042. */
  29043. mesh: Mesh;
  29044. /**
  29045. * Callback called on success
  29046. */
  29047. successCallback?: () => void;
  29048. /**
  29049. * Defines if parallel processing can be used
  29050. */
  29051. parallelProcessing: boolean;
  29052. }
  29053. /**
  29054. * Queue used to order the simplification tasks
  29055. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29056. */
  29057. class SimplificationQueue {
  29058. private _simplificationArray;
  29059. /**
  29060. * Gets a boolean indicating that the process is still running
  29061. */
  29062. running: boolean;
  29063. /**
  29064. * Creates a new queue
  29065. */
  29066. constructor();
  29067. /**
  29068. * Adds a new simplification task
  29069. * @param task defines a task to add
  29070. */
  29071. addTask(task: ISimplificationTask): void;
  29072. /**
  29073. * Execute next task
  29074. */
  29075. executeNext(): void;
  29076. /**
  29077. * Execute a simplification task
  29078. * @param task defines the task to run
  29079. */
  29080. runSimplification(task: ISimplificationTask): void;
  29081. private getSimplifier;
  29082. }
  29083. /**
  29084. * The implemented types of simplification
  29085. * At the moment only Quadratic Error Decimation is implemented
  29086. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29087. */
  29088. enum SimplificationType {
  29089. /** Quadratic error decimation */
  29090. QUADRATIC = 0
  29091. }
  29092. }
  29093. declare module BABYLON {
  29094. interface Scene {
  29095. /** @hidden (Backing field) */
  29096. _simplificationQueue: SimplificationQueue;
  29097. /**
  29098. * Gets or sets the simplification queue attached to the scene
  29099. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  29100. */
  29101. simplificationQueue: SimplificationQueue;
  29102. }
  29103. interface Mesh {
  29104. /**
  29105. * Simplify the mesh according to the given array of settings.
  29106. * Function will return immediately and will simplify async
  29107. * @param settings a collection of simplification settings
  29108. * @param parallelProcessing should all levels calculate parallel or one after the other
  29109. * @param simplificationType the type of simplification to run
  29110. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  29111. * @returns the current mesh
  29112. */
  29113. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  29114. }
  29115. /**
  29116. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  29117. * created in a scene
  29118. */
  29119. class SimplicationQueueSceneComponent implements ISceneComponent {
  29120. /**
  29121. * The component name helpfull to identify the component in the list of scene components.
  29122. */
  29123. readonly name: string;
  29124. /**
  29125. * The scene the component belongs to.
  29126. */
  29127. scene: Scene;
  29128. /**
  29129. * Creates a new instance of the component for the given scene
  29130. * @param scene Defines the scene to register the component in
  29131. */
  29132. constructor(scene: Scene);
  29133. /**
  29134. * Registers the component in a given scene
  29135. */
  29136. register(): void;
  29137. /**
  29138. * Rebuilds the elements related to this component in case of
  29139. * context lost for instance.
  29140. */
  29141. rebuild(): void;
  29142. /**
  29143. * Disposes the component and the associated ressources
  29144. */
  29145. dispose(): void;
  29146. private _beforeCameraUpdate;
  29147. }
  29148. }
  29149. declare module BABYLON {
  29150. /**
  29151. * Polygon
  29152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29153. */
  29154. class Polygon {
  29155. /**
  29156. * Creates a rectangle
  29157. * @param xmin bottom X coord
  29158. * @param ymin bottom Y coord
  29159. * @param xmax top X coord
  29160. * @param ymax top Y coord
  29161. * @returns points that make the resulting rectation
  29162. */
  29163. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  29164. /**
  29165. * Creates a circle
  29166. * @param radius radius of circle
  29167. * @param cx scale in x
  29168. * @param cy scale in y
  29169. * @param numberOfSides number of sides that make up the circle
  29170. * @returns points that make the resulting circle
  29171. */
  29172. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  29173. /**
  29174. * Creates a polygon from input string
  29175. * @param input Input polygon data
  29176. * @returns the parsed points
  29177. */
  29178. static Parse(input: string): Vector2[];
  29179. /**
  29180. * Starts building a polygon from x and y coordinates
  29181. * @param x x coordinate
  29182. * @param y y coordinate
  29183. * @returns the started path2
  29184. */
  29185. static StartingAt(x: number, y: number): Path2;
  29186. }
  29187. /**
  29188. * Builds a polygon
  29189. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  29190. */
  29191. class PolygonMeshBuilder {
  29192. private _points;
  29193. private _outlinepoints;
  29194. private _holes;
  29195. private _name;
  29196. private _scene;
  29197. private _epoints;
  29198. private _eholes;
  29199. private _addToepoint;
  29200. /**
  29201. * Creates a PolygonMeshBuilder
  29202. * @param name name of the builder
  29203. * @param contours Path of the polygon
  29204. * @param scene scene to add to
  29205. */
  29206. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene);
  29207. /**
  29208. * Adds a whole within the polygon
  29209. * @param hole Array of points defining the hole
  29210. * @returns this
  29211. */
  29212. addHole(hole: Vector2[]): PolygonMeshBuilder;
  29213. /**
  29214. * Creates the polygon
  29215. * @param updatable If the mesh should be updatable
  29216. * @param depth The depth of the mesh created
  29217. * @returns the created mesh
  29218. */
  29219. build(updatable?: boolean, depth?: number): Mesh;
  29220. /**
  29221. * Adds a side to the polygon
  29222. * @param positions points that make the polygon
  29223. * @param normals normals of the polygon
  29224. * @param uvs uvs of the polygon
  29225. * @param indices indices of the polygon
  29226. * @param bounds bounds of the polygon
  29227. * @param points points of the polygon
  29228. * @param depth depth of the polygon
  29229. * @param flip flip of the polygon
  29230. */
  29231. private addSide;
  29232. }
  29233. }
  29234. declare module BABYLON {
  29235. /**
  29236. * Base class for submeshes
  29237. */
  29238. class BaseSubMesh {
  29239. /** @hidden */
  29240. _materialDefines: Nullable<MaterialDefines>;
  29241. /** @hidden */
  29242. _materialEffect: Nullable<Effect>;
  29243. /**
  29244. * Gets associated effect
  29245. */
  29246. readonly effect: Nullable<Effect>;
  29247. /**
  29248. * Sets associated effect (effect used to render this submesh)
  29249. * @param effect defines the effect to associate with
  29250. * @param defines defines the set of defines used to compile this effect
  29251. */
  29252. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29253. }
  29254. /**
  29255. * Defines a subdivision inside a mesh
  29256. */
  29257. class SubMesh extends BaseSubMesh implements ICullable {
  29258. /** the material index to use */
  29259. materialIndex: number;
  29260. /** vertex index start */
  29261. verticesStart: number;
  29262. /** vertices count */
  29263. verticesCount: number;
  29264. /** index start */
  29265. indexStart: number;
  29266. /** indices count */
  29267. indexCount: number;
  29268. /** @hidden */
  29269. _linesIndexCount: number;
  29270. private _mesh;
  29271. private _renderingMesh;
  29272. private _boundingInfo;
  29273. private _linesIndexBuffer;
  29274. /** @hidden */
  29275. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29276. /** @hidden */
  29277. _trianglePlanes: Plane[];
  29278. /** @hidden */
  29279. _lastColliderTransformMatrix: Matrix;
  29280. /** @hidden */
  29281. _renderId: number;
  29282. /** @hidden */
  29283. _alphaIndex: number;
  29284. /** @hidden */
  29285. _distanceToCamera: number;
  29286. /** @hidden */
  29287. _id: number;
  29288. private _currentMaterial;
  29289. /**
  29290. * Add a new submesh to a mesh
  29291. * @param materialIndex defines the material index to use
  29292. * @param verticesStart defines vertex index start
  29293. * @param verticesCount defines vertices count
  29294. * @param indexStart defines index start
  29295. * @param indexCount defines indices count
  29296. * @param mesh defines the parent mesh
  29297. * @param renderingMesh defines an optional rendering mesh
  29298. * @param createBoundingBox defines if bounding box should be created for this submesh
  29299. * @returns the new submesh
  29300. */
  29301. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29302. /**
  29303. * Creates a new submesh
  29304. * @param materialIndex defines the material index to use
  29305. * @param verticesStart defines vertex index start
  29306. * @param verticesCount defines vertices count
  29307. * @param indexStart defines index start
  29308. * @param indexCount defines indices count
  29309. * @param mesh defines the parent mesh
  29310. * @param renderingMesh defines an optional rendering mesh
  29311. * @param createBoundingBox defines if bounding box should be created for this submesh
  29312. */
  29313. constructor(
  29314. /** the material index to use */
  29315. materialIndex: number,
  29316. /** vertex index start */
  29317. verticesStart: number,
  29318. /** vertices count */
  29319. verticesCount: number,
  29320. /** index start */
  29321. indexStart: number,
  29322. /** indices count */
  29323. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  29324. /**
  29325. * Returns true if this submesh covers the entire parent mesh
  29326. * @ignorenaming
  29327. */
  29328. readonly IsGlobal: boolean;
  29329. /**
  29330. * Returns the submesh BoudingInfo object
  29331. * @returns current bounding info (or mesh's one if the submesh is global)
  29332. */
  29333. getBoundingInfo(): BoundingInfo;
  29334. /**
  29335. * Sets the submesh BoundingInfo
  29336. * @param boundingInfo defines the new bounding info to use
  29337. * @returns the SubMesh
  29338. */
  29339. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29340. /**
  29341. * Returns the mesh of the current submesh
  29342. * @return the parent mesh
  29343. */
  29344. getMesh(): AbstractMesh;
  29345. /**
  29346. * Returns the rendering mesh of the submesh
  29347. * @returns the rendering mesh (could be different from parent mesh)
  29348. */
  29349. getRenderingMesh(): Mesh;
  29350. /**
  29351. * Returns the submesh material
  29352. * @returns null or the current material
  29353. */
  29354. getMaterial(): Nullable<Material>;
  29355. /**
  29356. * Sets a new updated BoundingInfo object to the submesh
  29357. * @returns the SubMesh
  29358. */
  29359. refreshBoundingInfo(): SubMesh;
  29360. /** @hidden */
  29361. _checkCollision(collider: Collider): boolean;
  29362. /**
  29363. * Updates the submesh BoundingInfo
  29364. * @param world defines the world matrix to use to update the bounding info
  29365. * @returns the submesh
  29366. */
  29367. updateBoundingInfo(world: Matrix): SubMesh;
  29368. /**
  29369. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29370. * @param frustumPlanes defines the frustum planes
  29371. * @returns true if the submesh is intersecting with the frustum
  29372. */
  29373. isInFrustum(frustumPlanes: Plane[]): boolean;
  29374. /**
  29375. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29376. * @param frustumPlanes defines the frustum planes
  29377. * @returns true if the submesh is inside the frustum
  29378. */
  29379. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29380. /**
  29381. * Renders the submesh
  29382. * @param enableAlphaMode defines if alpha needs to be used
  29383. * @returns the submesh
  29384. */
  29385. render(enableAlphaMode: boolean): SubMesh;
  29386. /**
  29387. * @hidden
  29388. */
  29389. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  29390. /**
  29391. * Checks if the submesh intersects with a ray
  29392. * @param ray defines the ray to test
  29393. * @returns true is the passed ray intersects the submesh bounding box
  29394. */
  29395. canIntersects(ray: Ray): boolean;
  29396. /**
  29397. * Intersects current submesh with a ray
  29398. * @param ray defines the ray to test
  29399. * @param positions defines mesh's positions array
  29400. * @param indices defines mesh's indices array
  29401. * @param fastCheck defines if only bounding info should be used
  29402. * @returns intersection info or null if no intersection
  29403. */
  29404. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  29405. /** @hidden */
  29406. private _intersectLines;
  29407. /** @hidden */
  29408. private _intersectTriangles;
  29409. /** @hidden */
  29410. _rebuild(): void;
  29411. /**
  29412. * Creates a new submesh from the passed mesh
  29413. * @param newMesh defines the new hosting mesh
  29414. * @param newRenderingMesh defines an optional rendering mesh
  29415. * @returns the new submesh
  29416. */
  29417. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29418. /**
  29419. * Release associated resources
  29420. */
  29421. dispose(): void;
  29422. /**
  29423. * Creates a new submesh from indices data
  29424. * @param materialIndex the index of the main mesh material
  29425. * @param startIndex the index where to start the copy in the mesh indices array
  29426. * @param indexCount the number of indices to copy then from the startIndex
  29427. * @param mesh the main mesh to create the submesh from
  29428. * @param renderingMesh the optional rendering mesh
  29429. * @returns a new submesh
  29430. */
  29431. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29432. }
  29433. }
  29434. declare module BABYLON {
  29435. /**
  29436. * 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.
  29437. * @see https://doc.babylonjs.com/how_to/transformnode
  29438. */
  29439. class TransformNode extends Node {
  29440. /**
  29441. * Object will not rotate to face the camera
  29442. */
  29443. static BILLBOARDMODE_NONE: number;
  29444. /**
  29445. * Object will rotate to face the camera but only on the x axis
  29446. */
  29447. static BILLBOARDMODE_X: number;
  29448. /**
  29449. * Object will rotate to face the camera but only on the y axis
  29450. */
  29451. static BILLBOARDMODE_Y: number;
  29452. /**
  29453. * Object will rotate to face the camera but only on the z axis
  29454. */
  29455. static BILLBOARDMODE_Z: number;
  29456. /**
  29457. * Object will rotate to face the camera
  29458. */
  29459. static BILLBOARDMODE_ALL: number;
  29460. private _forward;
  29461. private _forwardInverted;
  29462. private _up;
  29463. private _right;
  29464. private _rightInverted;
  29465. private _position;
  29466. private _rotation;
  29467. private _rotationQuaternion;
  29468. protected _scaling: Vector3;
  29469. protected _isDirty: boolean;
  29470. private _transformToBoneReferal;
  29471. /**
  29472. * Set the billboard mode. Default is 0.
  29473. *
  29474. * | Value | Type | Description |
  29475. * | --- | --- | --- |
  29476. * | 0 | BILLBOARDMODE_NONE | |
  29477. * | 1 | BILLBOARDMODE_X | |
  29478. * | 2 | BILLBOARDMODE_Y | |
  29479. * | 4 | BILLBOARDMODE_Z | |
  29480. * | 7 | BILLBOARDMODE_ALL | |
  29481. *
  29482. */
  29483. billboardMode: number;
  29484. /**
  29485. * 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
  29486. */
  29487. scalingDeterminant: number;
  29488. /**
  29489. * Sets the distance of the object to max, often used by skybox
  29490. */
  29491. infiniteDistance: boolean;
  29492. /**
  29493. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  29494. * By default the system will update normals to compensate
  29495. */
  29496. ignoreNonUniformScaling: boolean;
  29497. /** @hidden */
  29498. _poseMatrix: Matrix;
  29499. private _localWorld;
  29500. private _absolutePosition;
  29501. private _pivotMatrix;
  29502. private _pivotMatrixInverse;
  29503. protected _postMultiplyPivotMatrix: boolean;
  29504. protected _isWorldMatrixFrozen: boolean;
  29505. /** @hidden */
  29506. _indexInSceneTransformNodesArray: number;
  29507. /**
  29508. * An event triggered after the world matrix is updated
  29509. */
  29510. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  29511. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  29512. /**
  29513. * Gets a string identifying the name of the class
  29514. * @returns "TransformNode" string
  29515. */
  29516. getClassName(): string;
  29517. /**
  29518. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  29519. */
  29520. position: Vector3;
  29521. /**
  29522. * 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)).
  29523. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  29524. */
  29525. rotation: Vector3;
  29526. /**
  29527. * 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)).
  29528. */
  29529. scaling: Vector3;
  29530. /**
  29531. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
  29532. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  29533. */
  29534. rotationQuaternion: Nullable<Quaternion>;
  29535. /**
  29536. * The forward direction of that transform in world space.
  29537. */
  29538. readonly forward: Vector3;
  29539. /**
  29540. * The up direction of that transform in world space.
  29541. */
  29542. readonly up: Vector3;
  29543. /**
  29544. * The right direction of that transform in world space.
  29545. */
  29546. readonly right: Vector3;
  29547. /**
  29548. * Copies the parameter passed Matrix into the mesh Pose matrix.
  29549. * @param matrix the matrix to copy the pose from
  29550. * @returns this TransformNode.
  29551. */
  29552. updatePoseMatrix(matrix: Matrix): TransformNode;
  29553. /**
  29554. * Returns the mesh Pose matrix.
  29555. * @returns the pose matrix
  29556. */
  29557. getPoseMatrix(): Matrix;
  29558. /** @hidden */
  29559. _isSynchronized(): boolean;
  29560. /** @hidden */
  29561. _initCache(): void;
  29562. /**
  29563. * Flag the transform node as dirty (Forcing it to update everything)
  29564. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  29565. * @returns this transform node
  29566. */
  29567. markAsDirty(property: string): TransformNode;
  29568. /**
  29569. * Returns the current mesh absolute position.
  29570. * Returns a Vector3.
  29571. */
  29572. readonly absolutePosition: Vector3;
  29573. /**
  29574. * Sets a new matrix to apply before all other transformation
  29575. * @param matrix defines the transform matrix
  29576. * @returns the current TransformNode
  29577. */
  29578. setPreTransformMatrix(matrix: Matrix): TransformNode;
  29579. /**
  29580. * Sets a new pivot matrix to the current node
  29581. * @param matrix defines the new pivot matrix to use
  29582. * @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
  29583. * @returns the current TransformNode
  29584. */
  29585. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  29586. /**
  29587. * Returns the mesh pivot matrix.
  29588. * Default : Identity.
  29589. * @returns the matrix
  29590. */
  29591. getPivotMatrix(): Matrix;
  29592. /**
  29593. * Prevents the World matrix to be computed any longer.
  29594. * @returns the TransformNode.
  29595. */
  29596. freezeWorldMatrix(): TransformNode;
  29597. /**
  29598. * Allows back the World matrix computation.
  29599. * @returns the TransformNode.
  29600. */
  29601. unfreezeWorldMatrix(): this;
  29602. /**
  29603. * True if the World matrix has been frozen.
  29604. */
  29605. readonly isWorldMatrixFrozen: boolean;
  29606. /**
  29607. * Retuns the mesh absolute position in the World.
  29608. * @returns a Vector3.
  29609. */
  29610. getAbsolutePosition(): Vector3;
  29611. /**
  29612. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  29613. * @param absolutePosition the absolute position to set
  29614. * @returns the TransformNode.
  29615. */
  29616. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  29617. /**
  29618. * Sets the mesh position in its local space.
  29619. * @param vector3 the position to set in localspace
  29620. * @returns the TransformNode.
  29621. */
  29622. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  29623. /**
  29624. * Returns the mesh position in the local space from the current World matrix values.
  29625. * @returns a new Vector3.
  29626. */
  29627. getPositionExpressedInLocalSpace(): Vector3;
  29628. /**
  29629. * Translates the mesh along the passed Vector3 in its local space.
  29630. * @param vector3 the distance to translate in localspace
  29631. * @returns the TransformNode.
  29632. */
  29633. locallyTranslate(vector3: Vector3): TransformNode;
  29634. private static _lookAtVectorCache;
  29635. /**
  29636. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  29637. * @param targetPoint the position (must be in same space as current mesh) to look at
  29638. * @param yawCor optional yaw (y-axis) correction in radians
  29639. * @param pitchCor optional pitch (x-axis) correction in radians
  29640. * @param rollCor optional roll (z-axis) correction in radians
  29641. * @param space the choosen space of the target
  29642. * @returns the TransformNode.
  29643. */
  29644. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  29645. /**
  29646. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29647. * This Vector3 is expressed in the World space.
  29648. * @param localAxis axis to rotate
  29649. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  29650. */
  29651. getDirection(localAxis: Vector3): Vector3;
  29652. /**
  29653. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  29654. * localAxis is expressed in the mesh local space.
  29655. * result is computed in the Wordl space from the mesh World matrix.
  29656. * @param localAxis axis to rotate
  29657. * @param result the resulting transformnode
  29658. * @returns this TransformNode.
  29659. */
  29660. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  29661. /**
  29662. * Sets a new pivot point to the current node
  29663. * @param point defines the new pivot point to use
  29664. * @param space defines if the point is in world or local space (local by default)
  29665. * @returns the current TransformNode
  29666. */
  29667. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  29668. /**
  29669. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  29670. * @returns the pivot point
  29671. */
  29672. getPivotPoint(): Vector3;
  29673. /**
  29674. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  29675. * @param result the vector3 to store the result
  29676. * @returns this TransformNode.
  29677. */
  29678. getPivotPointToRef(result: Vector3): TransformNode;
  29679. /**
  29680. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  29681. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  29682. */
  29683. getAbsolutePivotPoint(): Vector3;
  29684. /**
  29685. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  29686. * @param result vector3 to store the result
  29687. * @returns this TransformNode.
  29688. */
  29689. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  29690. /**
  29691. * Defines the passed node as the parent of the current node.
  29692. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  29693. * @param node the node ot set as the parent
  29694. * @returns this TransformNode.
  29695. */
  29696. setParent(node: Nullable<Node>): TransformNode;
  29697. private _nonUniformScaling;
  29698. /**
  29699. * True if the scaling property of this object is non uniform eg. (1,2,1)
  29700. */
  29701. readonly nonUniformScaling: boolean;
  29702. /** @hidden */
  29703. _updateNonUniformScalingState(value: boolean): boolean;
  29704. /**
  29705. * Attach the current TransformNode to another TransformNode associated with a bone
  29706. * @param bone Bone affecting the TransformNode
  29707. * @param affectedTransformNode TransformNode associated with the bone
  29708. * @returns this object
  29709. */
  29710. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  29711. /**
  29712. * Detach the transform node if its associated with a bone
  29713. * @returns this object
  29714. */
  29715. detachFromBone(): TransformNode;
  29716. private static _rotationAxisCache;
  29717. /**
  29718. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  29719. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29720. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29721. * The passed axis is also normalized.
  29722. * @param axis the axis to rotate around
  29723. * @param amount the amount to rotate in radians
  29724. * @param space Space to rotate in (Default: local)
  29725. * @returns the TransformNode.
  29726. */
  29727. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  29728. /**
  29729. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  29730. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  29731. * The passed axis is also normalized. .
  29732. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  29733. * @param point the point to rotate around
  29734. * @param axis the axis to rotate around
  29735. * @param amount the amount to rotate in radians
  29736. * @returns the TransformNode
  29737. */
  29738. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  29739. /**
  29740. * Translates the mesh along the axis vector for the passed distance in the given space.
  29741. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  29742. * @param axis the axis to translate in
  29743. * @param distance the distance to translate
  29744. * @param space Space to rotate in (Default: local)
  29745. * @returns the TransformNode.
  29746. */
  29747. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  29748. /**
  29749. * Adds a rotation step to the mesh current rotation.
  29750. * x, y, z are Euler angles expressed in radians.
  29751. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  29752. * This means this rotation is made in the mesh local space only.
  29753. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  29754. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  29755. * ```javascript
  29756. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  29757. * ```
  29758. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  29759. * 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.
  29760. * @param x Rotation to add
  29761. * @param y Rotation to add
  29762. * @param z Rotation to add
  29763. * @returns the TransformNode.
  29764. */
  29765. addRotation(x: number, y: number, z: number): TransformNode;
  29766. /**
  29767. * Computes the world matrix of the node
  29768. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29769. * @returns the world matrix
  29770. */
  29771. computeWorldMatrix(force?: boolean): Matrix;
  29772. protected _afterComputeWorldMatrix(): void;
  29773. /**
  29774. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  29775. * @param func callback function to add
  29776. *
  29777. * @returns the TransformNode.
  29778. */
  29779. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29780. /**
  29781. * Removes a registered callback function.
  29782. * @param func callback function to remove
  29783. * @returns the TransformNode.
  29784. */
  29785. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  29786. /**
  29787. * Gets the position of the current mesh in camera space
  29788. * @param camera defines the camera to use
  29789. * @returns a position
  29790. */
  29791. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  29792. /**
  29793. * Returns the distance from the mesh to the active camera
  29794. * @param camera defines the camera to use
  29795. * @returns the distance
  29796. */
  29797. getDistanceToCamera(camera?: Nullable<Camera>): number;
  29798. /**
  29799. * Clone the current transform node
  29800. * @param name Name of the new clone
  29801. * @param newParent New parent for the clone
  29802. * @param doNotCloneChildren Do not clone children hierarchy
  29803. * @returns the new transform node
  29804. */
  29805. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  29806. /**
  29807. * Serializes the objects information.
  29808. * @param currentSerializationObject defines the object to serialize in
  29809. * @returns the serialized object
  29810. */
  29811. serialize(currentSerializationObject?: any): any;
  29812. /**
  29813. * Returns a new TransformNode object parsed from the source provided.
  29814. * @param parsedTransformNode is the source.
  29815. * @param scene the scne the object belongs to
  29816. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  29817. * @returns a new TransformNode object parsed from the source provided.
  29818. */
  29819. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  29820. /**
  29821. * Releases resources associated with this transform node.
  29822. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29823. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29824. */
  29825. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29826. }
  29827. }
  29828. declare module BABYLON {
  29829. /**
  29830. * Specialized buffer used to store vertex data
  29831. */
  29832. class VertexBuffer {
  29833. /** @hidden */
  29834. _buffer: Buffer;
  29835. private _kind;
  29836. private _size;
  29837. private _ownsBuffer;
  29838. private _instanced;
  29839. private _instanceDivisor;
  29840. /**
  29841. * The byte type.
  29842. */
  29843. static readonly BYTE: number;
  29844. /**
  29845. * The unsigned byte type.
  29846. */
  29847. static readonly UNSIGNED_BYTE: number;
  29848. /**
  29849. * The short type.
  29850. */
  29851. static readonly SHORT: number;
  29852. /**
  29853. * The unsigned short type.
  29854. */
  29855. static readonly UNSIGNED_SHORT: number;
  29856. /**
  29857. * The integer type.
  29858. */
  29859. static readonly INT: number;
  29860. /**
  29861. * The unsigned integer type.
  29862. */
  29863. static readonly UNSIGNED_INT: number;
  29864. /**
  29865. * The float type.
  29866. */
  29867. static readonly FLOAT: number;
  29868. /**
  29869. * Gets or sets the instance divisor when in instanced mode
  29870. */
  29871. instanceDivisor: number;
  29872. /**
  29873. * Gets the byte stride.
  29874. */
  29875. readonly byteStride: number;
  29876. /**
  29877. * Gets the byte offset.
  29878. */
  29879. readonly byteOffset: number;
  29880. /**
  29881. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  29882. */
  29883. readonly normalized: boolean;
  29884. /**
  29885. * Gets the data type of each component in the array.
  29886. */
  29887. readonly type: number;
  29888. /**
  29889. * Constructor
  29890. * @param engine the engine
  29891. * @param data the data to use for this vertex buffer
  29892. * @param kind the vertex buffer kind
  29893. * @param updatable whether the data is updatable
  29894. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  29895. * @param stride the stride (optional)
  29896. * @param instanced whether the buffer is instanced (optional)
  29897. * @param offset the offset of the data (optional)
  29898. * @param size the number of components (optional)
  29899. * @param type the type of the component (optional)
  29900. * @param normalized whether the data contains normalized data (optional)
  29901. * @param useBytes set to true if stride and offset are in bytes (optional)
  29902. */
  29903. 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);
  29904. /** @hidden */
  29905. _rebuild(): void;
  29906. /**
  29907. * Returns the kind of the VertexBuffer (string)
  29908. * @returns a string
  29909. */
  29910. getKind(): string;
  29911. /**
  29912. * Gets a boolean indicating if the VertexBuffer is updatable?
  29913. * @returns true if the buffer is updatable
  29914. */
  29915. isUpdatable(): boolean;
  29916. /**
  29917. * Gets current buffer's data
  29918. * @returns a DataArray or null
  29919. */
  29920. getData(): Nullable<DataArray>;
  29921. /**
  29922. * Gets underlying native buffer
  29923. * @returns underlying native buffer
  29924. */
  29925. getBuffer(): Nullable<WebGLBuffer>;
  29926. /**
  29927. * Gets the stride in float32 units (i.e. byte stride / 4).
  29928. * May not be an integer if the byte stride is not divisible by 4.
  29929. * DEPRECATED. Use byteStride instead.
  29930. * @returns the stride in float32 units
  29931. */
  29932. getStrideSize(): number;
  29933. /**
  29934. * Returns the offset as a multiple of the type byte length.
  29935. * DEPRECATED. Use byteOffset instead.
  29936. * @returns the offset in bytes
  29937. */
  29938. getOffset(): number;
  29939. /**
  29940. * Returns the number of components per vertex attribute (integer)
  29941. * @returns the size in float
  29942. */
  29943. getSize(): number;
  29944. /**
  29945. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  29946. * @returns true if this buffer is instanced
  29947. */
  29948. getIsInstanced(): boolean;
  29949. /**
  29950. * Returns the instancing divisor, zero for non-instanced (integer).
  29951. * @returns a number
  29952. */
  29953. getInstanceDivisor(): number;
  29954. /**
  29955. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  29956. * @param data defines the data to store
  29957. */
  29958. create(data?: DataArray): void;
  29959. /**
  29960. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  29961. * This function will create a new buffer if the current one is not updatable
  29962. * @param data defines the data to store
  29963. */
  29964. update(data: DataArray): void;
  29965. /**
  29966. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  29967. * Returns the directly updated WebGLBuffer.
  29968. * @param data the new data
  29969. * @param offset the new offset
  29970. * @param useBytes set to true if the offset is in bytes
  29971. */
  29972. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  29973. /**
  29974. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  29975. */
  29976. dispose(): void;
  29977. /**
  29978. * Enumerates each value of this vertex buffer as numbers.
  29979. * @param count the number of values to enumerate
  29980. * @param callback the callback function called for each value
  29981. */
  29982. forEach(count: number, callback: (value: number, index: number) => void): void;
  29983. /**
  29984. * Positions
  29985. */
  29986. static readonly PositionKind: string;
  29987. /**
  29988. * Normals
  29989. */
  29990. static readonly NormalKind: string;
  29991. /**
  29992. * Tangents
  29993. */
  29994. static readonly TangentKind: string;
  29995. /**
  29996. * Texture coordinates
  29997. */
  29998. static readonly UVKind: string;
  29999. /**
  30000. * Texture coordinates 2
  30001. */
  30002. static readonly UV2Kind: string;
  30003. /**
  30004. * Texture coordinates 3
  30005. */
  30006. static readonly UV3Kind: string;
  30007. /**
  30008. * Texture coordinates 4
  30009. */
  30010. static readonly UV4Kind: string;
  30011. /**
  30012. * Texture coordinates 5
  30013. */
  30014. static readonly UV5Kind: string;
  30015. /**
  30016. * Texture coordinates 6
  30017. */
  30018. static readonly UV6Kind: string;
  30019. /**
  30020. * Colors
  30021. */
  30022. static readonly ColorKind: string;
  30023. /**
  30024. * Matrix indices (for bones)
  30025. */
  30026. static readonly MatricesIndicesKind: string;
  30027. /**
  30028. * Matrix weights (for bones)
  30029. */
  30030. static readonly MatricesWeightsKind: string;
  30031. /**
  30032. * Additional matrix indices (for bones)
  30033. */
  30034. static readonly MatricesIndicesExtraKind: string;
  30035. /**
  30036. * Additional matrix weights (for bones)
  30037. */
  30038. static readonly MatricesWeightsExtraKind: string;
  30039. /**
  30040. * Deduces the stride given a kind.
  30041. * @param kind The kind string to deduce
  30042. * @returns The deduced stride
  30043. */
  30044. static DeduceStride(kind: string): number;
  30045. /**
  30046. * Gets the byte length of the given type.
  30047. * @param type the type
  30048. * @returns the number of bytes
  30049. */
  30050. static GetTypeByteLength(type: number): number;
  30051. /**
  30052. * Enumerates each value of the given parameters as numbers.
  30053. * @param data the data to enumerate
  30054. * @param byteOffset the byte offset of the data
  30055. * @param byteStride the byte stride of the data
  30056. * @param componentCount the number of components per element
  30057. * @param componentType the type of the component
  30058. * @param count the total number of components
  30059. * @param normalized whether the data is normalized
  30060. * @param callback the callback function called for each value
  30061. */
  30062. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  30063. private static _GetFloatValue;
  30064. }
  30065. }
  30066. declare module BABYLON {
  30067. /**
  30068. * Class used to enable access to IndexedDB
  30069. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30070. */
  30071. class Database implements IOfflineProvider {
  30072. private _callbackManifestChecked;
  30073. private _currentSceneUrl;
  30074. private _db;
  30075. private _enableSceneOffline;
  30076. private _enableTexturesOffline;
  30077. private _manifestVersionFound;
  30078. private _mustUpdateRessources;
  30079. private _hasReachedQuota;
  30080. private _isSupported;
  30081. private _idbFactory;
  30082. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  30083. private static IsUASupportingBlobStorage;
  30084. /**
  30085. * Gets a boolean indicating if Database storate is enabled (off by default)
  30086. */
  30087. static IDBStorageEnabled: boolean;
  30088. /**
  30089. * Gets a boolean indicating if scene must be saved in the database
  30090. */
  30091. readonly enableSceneOffline: boolean;
  30092. /**
  30093. * Gets a boolean indicating if textures must be saved in the database
  30094. */
  30095. readonly enableTexturesOffline: boolean;
  30096. /**
  30097. * Creates a new Database
  30098. * @param urlToScene defines the url to load the scene
  30099. * @param callbackManifestChecked defines the callback to use when manifest is checked
  30100. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  30101. */
  30102. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  30103. private static _ParseURL;
  30104. private static _ReturnFullUrlLocation;
  30105. private _checkManifestFile;
  30106. /**
  30107. * Open the database and make it available
  30108. * @param successCallback defines the callback to call on success
  30109. * @param errorCallback defines the callback to call on error
  30110. */
  30111. open(successCallback: () => void, errorCallback: () => void): void;
  30112. /**
  30113. * Loads an image from the database
  30114. * @param url defines the url to load from
  30115. * @param image defines the target DOM image
  30116. */
  30117. loadImage(url: string, image: HTMLImageElement): void;
  30118. private _loadImageFromDBAsync;
  30119. private _saveImageIntoDBAsync;
  30120. private _checkVersionFromDB;
  30121. private _loadVersionFromDBAsync;
  30122. private _saveVersionIntoDBAsync;
  30123. /**
  30124. * Loads a file from database
  30125. * @param url defines the URL to load from
  30126. * @param sceneLoaded defines a callback to call on success
  30127. * @param progressCallBack defines a callback to call when progress changed
  30128. * @param errorCallback defines a callback to call on error
  30129. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30130. */
  30131. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30132. private _loadFileAsync;
  30133. private _saveFileAsync;
  30134. }
  30135. }
  30136. declare module BABYLON {
  30137. /**
  30138. * Class used to enable access to offline support
  30139. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  30140. */
  30141. interface IOfflineProvider {
  30142. /**
  30143. * Gets a boolean indicating if scene must be saved in the database
  30144. */
  30145. enableSceneOffline: boolean;
  30146. /**
  30147. * Gets a boolean indicating if textures must be saved in the database
  30148. */
  30149. enableTexturesOffline: boolean;
  30150. /**
  30151. * Open the offline support and make it available
  30152. * @param successCallback defines the callback to call on success
  30153. * @param errorCallback defines the callback to call on error
  30154. */
  30155. open(successCallback: () => void, errorCallback: () => void): void;
  30156. /**
  30157. * Loads an image from the offline support
  30158. * @param url defines the url to load from
  30159. * @param image defines the target DOM image
  30160. */
  30161. loadImage(url: string, image: HTMLImageElement): void;
  30162. /**
  30163. * Loads a file from offline support
  30164. * @param url defines the URL to load from
  30165. * @param sceneLoaded defines a callback to call on success
  30166. * @param progressCallBack defines a callback to call when progress changed
  30167. * @param errorCallback defines a callback to call on error
  30168. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  30169. */
  30170. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  30171. }
  30172. }
  30173. declare module BABYLON {
  30174. /**
  30175. * This represents the base class for particle system in Babylon.
  30176. * 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.
  30177. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  30178. * @example https://doc.babylonjs.com/babylon101/particles
  30179. */
  30180. class BaseParticleSystem {
  30181. /**
  30182. * Source color is added to the destination color without alpha affecting the result
  30183. */
  30184. static BLENDMODE_ONEONE: number;
  30185. /**
  30186. * Blend current color and particle color using particle’s alpha
  30187. */
  30188. static BLENDMODE_STANDARD: number;
  30189. /**
  30190. * Add current color and particle color multiplied by particle’s alpha
  30191. */
  30192. static BLENDMODE_ADD: number;
  30193. /**
  30194. * Multiply current color with particle color
  30195. */
  30196. static BLENDMODE_MULTIPLY: number;
  30197. /**
  30198. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  30199. */
  30200. static BLENDMODE_MULTIPLYADD: number;
  30201. /**
  30202. * List of animations used by the particle system.
  30203. */
  30204. animations: Animation[];
  30205. /**
  30206. * The id of the Particle system.
  30207. */
  30208. id: string;
  30209. /**
  30210. * The friendly name of the Particle system.
  30211. */
  30212. name: string;
  30213. /**
  30214. * The rendering group used by the Particle system to chose when to render.
  30215. */
  30216. renderingGroupId: number;
  30217. /**
  30218. * The emitter represents the Mesh or position we are attaching the particle system to.
  30219. */
  30220. emitter: Nullable<AbstractMesh | Vector3>;
  30221. /**
  30222. * The maximum number of particles to emit per frame
  30223. */
  30224. emitRate: number;
  30225. /**
  30226. * If you want to launch only a few particles at once, that can be done, as well.
  30227. */
  30228. manualEmitCount: number;
  30229. /**
  30230. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  30231. */
  30232. updateSpeed: number;
  30233. /**
  30234. * The amount of time the particle system is running (depends of the overall update speed).
  30235. */
  30236. targetStopDuration: number;
  30237. /**
  30238. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  30239. */
  30240. disposeOnStop: boolean;
  30241. /**
  30242. * Minimum power of emitting particles.
  30243. */
  30244. minEmitPower: number;
  30245. /**
  30246. * Maximum power of emitting particles.
  30247. */
  30248. maxEmitPower: number;
  30249. /**
  30250. * Minimum life time of emitting particles.
  30251. */
  30252. minLifeTime: number;
  30253. /**
  30254. * Maximum life time of emitting particles.
  30255. */
  30256. maxLifeTime: number;
  30257. /**
  30258. * Minimum Size of emitting particles.
  30259. */
  30260. minSize: number;
  30261. /**
  30262. * Maximum Size of emitting particles.
  30263. */
  30264. maxSize: number;
  30265. /**
  30266. * Minimum scale of emitting particles on X axis.
  30267. */
  30268. minScaleX: number;
  30269. /**
  30270. * Maximum scale of emitting particles on X axis.
  30271. */
  30272. maxScaleX: number;
  30273. /**
  30274. * Minimum scale of emitting particles on Y axis.
  30275. */
  30276. minScaleY: number;
  30277. /**
  30278. * Maximum scale of emitting particles on Y axis.
  30279. */
  30280. maxScaleY: number;
  30281. /**
  30282. * Gets or sets the minimal initial rotation in radians.
  30283. */
  30284. minInitialRotation: number;
  30285. /**
  30286. * Gets or sets the maximal initial rotation in radians.
  30287. */
  30288. maxInitialRotation: number;
  30289. /**
  30290. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  30291. */
  30292. minAngularSpeed: number;
  30293. /**
  30294. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  30295. */
  30296. maxAngularSpeed: number;
  30297. /**
  30298. * The texture used to render each particle. (this can be a spritesheet)
  30299. */
  30300. particleTexture: Nullable<Texture>;
  30301. /**
  30302. * The layer mask we are rendering the particles through.
  30303. */
  30304. layerMask: number;
  30305. /**
  30306. * This can help using your own shader to render the particle system.
  30307. * The according effect will be created
  30308. */
  30309. customShader: any;
  30310. /**
  30311. * By default particle system starts as soon as they are created. This prevents the
  30312. * automatic start to happen and let you decide when to start emitting particles.
  30313. */
  30314. preventAutoStart: boolean;
  30315. /**
  30316. * Gets or sets a texture used to add random noise to particle positions
  30317. */
  30318. noiseTexture: Nullable<ProceduralTexture>;
  30319. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  30320. noiseStrength: Vector3;
  30321. /**
  30322. * Callback triggered when the particle animation is ending.
  30323. */
  30324. onAnimationEnd: Nullable<() => void>;
  30325. /**
  30326. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  30327. */
  30328. blendMode: number;
  30329. /**
  30330. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30331. * to override the particles.
  30332. */
  30333. forceDepthWrite: boolean;
  30334. /** 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 */
  30335. preWarmCycles: number;
  30336. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  30337. preWarmStepOffset: number;
  30338. /**
  30339. * 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)
  30340. */
  30341. spriteCellChangeSpeed: number;
  30342. /**
  30343. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  30344. */
  30345. startSpriteCellID: number;
  30346. /**
  30347. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  30348. */
  30349. endSpriteCellID: number;
  30350. /**
  30351. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  30352. */
  30353. spriteCellWidth: number;
  30354. /**
  30355. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  30356. */
  30357. spriteCellHeight: number;
  30358. /**
  30359. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  30360. */
  30361. spriteRandomStartCell: boolean;
  30362. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  30363. translationPivot: Vector2;
  30364. /** @hidden */
  30365. protected _isAnimationSheetEnabled: boolean;
  30366. /**
  30367. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  30368. */
  30369. beginAnimationOnStart: boolean;
  30370. /**
  30371. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  30372. */
  30373. beginAnimationFrom: number;
  30374. /**
  30375. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  30376. */
  30377. beginAnimationTo: number;
  30378. /**
  30379. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  30380. */
  30381. beginAnimationLoop: boolean;
  30382. /**
  30383. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  30384. */
  30385. isAnimationSheetEnabled: boolean;
  30386. /**
  30387. * Get hosting scene
  30388. * @returns the scene
  30389. */
  30390. getScene(): Scene;
  30391. /**
  30392. * You can use gravity if you want to give an orientation to your particles.
  30393. */
  30394. gravity: Vector3;
  30395. protected _colorGradients: Nullable<Array<ColorGradient>>;
  30396. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  30397. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  30398. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  30399. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  30400. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  30401. protected _dragGradients: Nullable<Array<FactorGradient>>;
  30402. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  30403. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  30404. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  30405. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  30406. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  30407. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  30408. /**
  30409. * Defines the delay in milliseconds before starting the system (0 by default)
  30410. */
  30411. startDelay: number;
  30412. /**
  30413. * Gets the current list of drag gradients.
  30414. * You must use addDragGradient and removeDragGradient to udpate this list
  30415. * @returns the list of drag gradients
  30416. */
  30417. getDragGradients(): Nullable<Array<FactorGradient>>;
  30418. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  30419. limitVelocityDamping: number;
  30420. /**
  30421. * Gets the current list of limit velocity gradients.
  30422. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  30423. * @returns the list of limit velocity gradients
  30424. */
  30425. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  30426. /**
  30427. * Gets the current list of color gradients.
  30428. * You must use addColorGradient and removeColorGradient to udpate this list
  30429. * @returns the list of color gradients
  30430. */
  30431. getColorGradients(): Nullable<Array<ColorGradient>>;
  30432. /**
  30433. * Gets the current list of size gradients.
  30434. * You must use addSizeGradient and removeSizeGradient to udpate this list
  30435. * @returns the list of size gradients
  30436. */
  30437. getSizeGradients(): Nullable<Array<FactorGradient>>;
  30438. /**
  30439. * Gets the current list of color remap gradients.
  30440. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  30441. * @returns the list of color remap gradients
  30442. */
  30443. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  30444. /**
  30445. * Gets the current list of alpha remap gradients.
  30446. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  30447. * @returns the list of alpha remap gradients
  30448. */
  30449. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  30450. /**
  30451. * Gets the current list of life time gradients.
  30452. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  30453. * @returns the list of life time gradients
  30454. */
  30455. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  30456. /**
  30457. * Gets the current list of angular speed gradients.
  30458. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  30459. * @returns the list of angular speed gradients
  30460. */
  30461. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  30462. /**
  30463. * Gets the current list of velocity gradients.
  30464. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  30465. * @returns the list of velocity gradients
  30466. */
  30467. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  30468. /**
  30469. * Gets the current list of start size gradients.
  30470. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  30471. * @returns the list of start size gradients
  30472. */
  30473. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  30474. /**
  30475. * Gets the current list of emit rate gradients.
  30476. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  30477. * @returns the list of emit rate gradients
  30478. */
  30479. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  30480. /**
  30481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30483. */
  30484. direction1: Vector3;
  30485. /**
  30486. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  30487. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30488. */
  30489. direction2: Vector3;
  30490. /**
  30491. * 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.
  30492. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30493. */
  30494. minEmitBox: Vector3;
  30495. /**
  30496. * 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.
  30497. * This only works when particleEmitterTyps is a BoxParticleEmitter
  30498. */
  30499. maxEmitBox: Vector3;
  30500. /**
  30501. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30502. */
  30503. color1: Color4;
  30504. /**
  30505. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  30506. */
  30507. color2: Color4;
  30508. /**
  30509. * Color the particle will have at the end of its lifetime
  30510. */
  30511. colorDead: Color4;
  30512. /**
  30513. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  30514. */
  30515. textureMask: Color4;
  30516. /**
  30517. * The particle emitter type defines the emitter used by the particle system.
  30518. * It can be for example box, sphere, or cone...
  30519. */
  30520. particleEmitterType: IParticleEmitterType;
  30521. /** @hidden */
  30522. _isSubEmitter: boolean;
  30523. /**
  30524. * Gets or sets the billboard mode to use when isBillboardBased = true.
  30525. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  30526. */
  30527. billboardMode: number;
  30528. protected _isBillboardBased: boolean;
  30529. /**
  30530. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  30531. */
  30532. isBillboardBased: boolean;
  30533. /**
  30534. * The scene the particle system belongs to.
  30535. */
  30536. protected _scene: Scene;
  30537. /**
  30538. * Local cache of defines for image processing.
  30539. */
  30540. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  30541. /**
  30542. * Default configuration related to image processing available in the standard Material.
  30543. */
  30544. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30545. /**
  30546. * Gets the image processing configuration used either in this material.
  30547. */
  30548. /**
  30549. * Sets the Default image processing configuration used either in the this material.
  30550. *
  30551. * If sets to null, the scene one is in use.
  30552. */
  30553. imageProcessingConfiguration: ImageProcessingConfiguration;
  30554. /**
  30555. * Attaches a new image processing configuration to the Standard Material.
  30556. * @param configuration
  30557. */
  30558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30559. /** @hidden */
  30560. protected _reset(): void;
  30561. /** @hidden */
  30562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  30563. /**
  30564. * Instantiates a particle system.
  30565. * 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.
  30566. * @param name The name of the particle system
  30567. */
  30568. constructor(name: string);
  30569. /**
  30570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  30571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30573. * @returns the emitter
  30574. */
  30575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  30576. /**
  30577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  30578. * @param radius The radius of the hemisphere to emit from
  30579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30580. * @returns the emitter
  30581. */
  30582. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  30583. /**
  30584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  30585. * @param radius The radius of the sphere to emit from
  30586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  30587. * @returns the emitter
  30588. */
  30589. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  30590. /**
  30591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  30592. * @param radius The radius of the sphere to emit from
  30593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  30594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  30595. * @returns the emitter
  30596. */
  30597. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  30598. /**
  30599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  30600. * @param radius The radius of the emission cylinder
  30601. * @param height The height of the emission cylinder
  30602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  30603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  30604. * @returns the emitter
  30605. */
  30606. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  30607. /**
  30608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  30609. * @param radius The radius of the cylinder to emit from
  30610. * @param height The height of the emission cylinder
  30611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  30612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  30613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  30614. * @returns the emitter
  30615. */
  30616. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  30617. /**
  30618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  30619. * @param radius The radius of the cone to emit from
  30620. * @param angle The base angle of the cone
  30621. * @returns the emitter
  30622. */
  30623. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  30624. /**
  30625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  30626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  30627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  30628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  30630. * @returns the emitter
  30631. */
  30632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  30633. }
  30634. }
  30635. declare module BABYLON {
  30636. /**
  30637. * This represents a GPU particle system in Babylon
  30638. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  30639. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  30640. */
  30641. class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  30642. /**
  30643. * The layer mask we are rendering the particles through.
  30644. */
  30645. layerMask: number;
  30646. private _capacity;
  30647. private _activeCount;
  30648. private _currentActiveCount;
  30649. private _accumulatedCount;
  30650. private _renderEffect;
  30651. private _updateEffect;
  30652. private _buffer0;
  30653. private _buffer1;
  30654. private _spriteBuffer;
  30655. private _updateVAO;
  30656. private _renderVAO;
  30657. private _targetIndex;
  30658. private _sourceBuffer;
  30659. private _targetBuffer;
  30660. private _engine;
  30661. private _currentRenderId;
  30662. private _started;
  30663. private _stopped;
  30664. private _timeDelta;
  30665. private _randomTexture;
  30666. private _randomTexture2;
  30667. private _attributesStrideSize;
  30668. private _updateEffectOptions;
  30669. private _randomTextureSize;
  30670. private _actualFrame;
  30671. private readonly _rawTextureWidth;
  30672. /**
  30673. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  30674. */
  30675. static readonly IsSupported: boolean;
  30676. /**
  30677. * An event triggered when the system is disposed.
  30678. */
  30679. onDisposeObservable: Observable<GPUParticleSystem>;
  30680. /**
  30681. * Gets the maximum number of particles active at the same time.
  30682. * @returns The max number of active particles.
  30683. */
  30684. getCapacity(): number;
  30685. /**
  30686. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  30687. * to override the particles.
  30688. */
  30689. forceDepthWrite: boolean;
  30690. /**
  30691. * Gets or set the number of active particles
  30692. */
  30693. activeParticleCount: number;
  30694. private _preWarmDone;
  30695. /**
  30696. * Is this system ready to be used/rendered
  30697. * @return true if the system is ready
  30698. */
  30699. isReady(): boolean;
  30700. /**
  30701. * Gets if the system has been started. (Note: this will still be true after stop is called)
  30702. * @returns True if it has been started, otherwise false.
  30703. */
  30704. isStarted(): boolean;
  30705. /**
  30706. * Starts the particle system and begins to emit
  30707. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  30708. */
  30709. start(delay?: number): void;
  30710. /**
  30711. * Stops the particle system.
  30712. */
  30713. stop(): void;
  30714. /**
  30715. * Remove all active particles
  30716. */
  30717. reset(): void;
  30718. /**
  30719. * Returns the string "GPUParticleSystem"
  30720. * @returns a string containing the class name
  30721. */
  30722. getClassName(): string;
  30723. private _colorGradientsTexture;
  30724. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  30725. /**
  30726. * Adds a new color gradient
  30727. * @param gradient defines the gradient to use (between 0 and 1)
  30728. * @param color1 defines the color to affect to the specified gradient
  30729. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  30730. * @returns the current particle system
  30731. */
  30732. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  30733. /**
  30734. * Remove a specific color gradient
  30735. * @param gradient defines the gradient to remove
  30736. * @returns the current particle system
  30737. */
  30738. removeColorGradient(gradient: number): GPUParticleSystem;
  30739. private _angularSpeedGradientsTexture;
  30740. private _sizeGradientsTexture;
  30741. private _velocityGradientsTexture;
  30742. private _limitVelocityGradientsTexture;
  30743. private _dragGradientsTexture;
  30744. private _addFactorGradient;
  30745. /**
  30746. * Adds a new size gradient
  30747. * @param gradient defines the gradient to use (between 0 and 1)
  30748. * @param factor defines the size factor to affect to the specified gradient
  30749. * @returns the current particle system
  30750. */
  30751. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  30752. /**
  30753. * Remove a specific size gradient
  30754. * @param gradient defines the gradient to remove
  30755. * @returns the current particle system
  30756. */
  30757. removeSizeGradient(gradient: number): GPUParticleSystem;
  30758. /**
  30759. * Adds a new angular speed gradient
  30760. * @param gradient defines the gradient to use (between 0 and 1)
  30761. * @param factor defines the angular speed to affect to the specified gradient
  30762. * @returns the current particle system
  30763. */
  30764. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  30765. /**
  30766. * Remove a specific angular speed gradient
  30767. * @param gradient defines the gradient to remove
  30768. * @returns the current particle system
  30769. */
  30770. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  30771. /**
  30772. * Adds a new velocity gradient
  30773. * @param gradient defines the gradient to use (between 0 and 1)
  30774. * @param factor defines the velocity to affect to the specified gradient
  30775. * @returns the current particle system
  30776. */
  30777. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30778. /**
  30779. * Remove a specific velocity gradient
  30780. * @param gradient defines the gradient to remove
  30781. * @returns the current particle system
  30782. */
  30783. removeVelocityGradient(gradient: number): GPUParticleSystem;
  30784. /**
  30785. * Adds a new limit velocity gradient
  30786. * @param gradient defines the gradient to use (between 0 and 1)
  30787. * @param factor defines the limit velocity value to affect to the specified gradient
  30788. * @returns the current particle system
  30789. */
  30790. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  30791. /**
  30792. * Remove a specific limit velocity gradient
  30793. * @param gradient defines the gradient to remove
  30794. * @returns the current particle system
  30795. */
  30796. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  30797. /**
  30798. * Adds a new drag gradient
  30799. * @param gradient defines the gradient to use (between 0 and 1)
  30800. * @param factor defines the drag value to affect to the specified gradient
  30801. * @returns the current particle system
  30802. */
  30803. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  30804. /**
  30805. * Remove a specific drag gradient
  30806. * @param gradient defines the gradient to remove
  30807. * @returns the current particle system
  30808. */
  30809. removeDragGradient(gradient: number): GPUParticleSystem;
  30810. /**
  30811. * Not supported by GPUParticleSystem
  30812. * @param gradient defines the gradient to use (between 0 and 1)
  30813. * @param factor defines the emit rate value to affect to the specified gradient
  30814. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30815. * @returns the current particle system
  30816. */
  30817. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30818. /**
  30819. * Not supported by GPUParticleSystem
  30820. * @param gradient defines the gradient to remove
  30821. * @returns the current particle system
  30822. */
  30823. removeEmitRateGradient(gradient: number): IParticleSystem;
  30824. /**
  30825. * Not supported by GPUParticleSystem
  30826. * @param gradient defines the gradient to use (between 0 and 1)
  30827. * @param factor defines the start size value to affect to the specified gradient
  30828. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30829. * @returns the current particle system
  30830. */
  30831. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30832. /**
  30833. * Not supported by GPUParticleSystem
  30834. * @param gradient defines the gradient to remove
  30835. * @returns the current particle system
  30836. */
  30837. removeStartSizeGradient(gradient: number): IParticleSystem;
  30838. /**
  30839. * Not supported by GPUParticleSystem
  30840. * @param gradient defines the gradient to use (between 0 and 1)
  30841. * @param min defines the color remap minimal range
  30842. * @param max defines the color remap maximal range
  30843. * @returns the current particle system
  30844. */
  30845. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30846. /**
  30847. * Not supported by GPUParticleSystem
  30848. * @param gradient defines the gradient to remove
  30849. * @returns the current particle system
  30850. */
  30851. removeColorRemapGradient(gradient: number): IParticleSystem;
  30852. /**
  30853. * Not supported by GPUParticleSystem
  30854. * @param gradient defines the gradient to use (between 0 and 1)
  30855. * @param min defines the alpha remap minimal range
  30856. * @param max defines the alpha remap maximal range
  30857. * @returns the current particle system
  30858. */
  30859. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  30860. /**
  30861. * Not supported by GPUParticleSystem
  30862. * @param gradient defines the gradient to remove
  30863. * @returns the current particle system
  30864. */
  30865. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  30866. /**
  30867. * Not supported by GPUParticleSystem
  30868. * @param gradient defines the gradient to use (between 0 and 1)
  30869. * @param color defines the color to affect to the specified gradient
  30870. * @returns the current particle system
  30871. */
  30872. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  30873. /**
  30874. * Not supported by GPUParticleSystem
  30875. * @param gradient defines the gradient to remove
  30876. * @returns the current particle system
  30877. */
  30878. removeRampGradient(gradient: number): IParticleSystem;
  30879. /**
  30880. * Not supported by GPUParticleSystem
  30881. * @returns the list of ramp gradients
  30882. */
  30883. getRampGradients(): Nullable<Array<Color3Gradient>>;
  30884. /**
  30885. * Not supported by GPUParticleSystem
  30886. * Gets or sets a boolean indicating that ramp gradients must be used
  30887. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  30888. */
  30889. useRampGradients: boolean;
  30890. /**
  30891. * Not supported by GPUParticleSystem
  30892. * @param gradient defines the gradient to use (between 0 and 1)
  30893. * @param factor defines the life time factor to affect to the specified gradient
  30894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  30895. * @returns the current particle system
  30896. */
  30897. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  30898. /**
  30899. * Not supported by GPUParticleSystem
  30900. * @param gradient defines the gradient to remove
  30901. * @returns the current particle system
  30902. */
  30903. removeLifeTimeGradient(gradient: number): IParticleSystem;
  30904. /**
  30905. * Instantiates a GPU particle system.
  30906. * 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.
  30907. * @param name The name of the particle system
  30908. * @param options The options used to create the system
  30909. * @param scene The scene the particle system belongs to
  30910. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  30911. */
  30912. constructor(name: string, options: Partial<{
  30913. capacity: number;
  30914. randomTextureSize: number;
  30915. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  30916. protected _reset(): void;
  30917. private _createUpdateVAO;
  30918. private _createRenderVAO;
  30919. private _initialize;
  30920. /** @hidden */
  30921. _recreateUpdateEffect(): void;
  30922. /** @hidden */
  30923. _recreateRenderEffect(): void;
  30924. /**
  30925. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  30926. * @param preWarm defines if we are in the pre-warmimg phase
  30927. */
  30928. animate(preWarm?: boolean): void;
  30929. private _createFactorGradientTexture;
  30930. private _createSizeGradientTexture;
  30931. private _createAngularSpeedGradientTexture;
  30932. private _createVelocityGradientTexture;
  30933. private _createLimitVelocityGradientTexture;
  30934. private _createDragGradientTexture;
  30935. private _createColorGradientTexture;
  30936. /**
  30937. * Renders the particle system in its current state
  30938. * @param preWarm defines if the system should only update the particles but not render them
  30939. * @returns the current number of particles
  30940. */
  30941. render(preWarm?: boolean): number;
  30942. /**
  30943. * Rebuilds the particle system
  30944. */
  30945. rebuild(): void;
  30946. private _releaseBuffers;
  30947. private _releaseVAOs;
  30948. /**
  30949. * Disposes the particle system and free the associated resources
  30950. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  30951. */
  30952. dispose(disposeTexture?: boolean): void;
  30953. /**
  30954. * Clones the particle system.
  30955. * @param name The name of the cloned object
  30956. * @param newEmitter The new emitter to use
  30957. * @returns the cloned particle system
  30958. */
  30959. clone(name: string, newEmitter: any): GPUParticleSystem;
  30960. /**
  30961. * Serializes the particle system to a JSON object.
  30962. * @returns the JSON object
  30963. */
  30964. serialize(): any;
  30965. /**
  30966. * Parses a JSON object to create a GPU particle system.
  30967. * @param parsedParticleSystem The JSON object to parse
  30968. * @param scene The scene to create the particle system in
  30969. * @param rootUrl The root url to use to load external dependencies like texture
  30970. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  30971. * @returns the parsed GPU particle system
  30972. */
  30973. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  30974. }
  30975. }
  30976. declare module BABYLON {
  30977. /**
  30978. * Interface representing a particle system in Babylon.js.
  30979. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  30980. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  30981. */
  30982. interface IParticleSystem {
  30983. /**
  30984. * List of animations used by the particle system.
  30985. */
  30986. animations: Animation[];
  30987. /**
  30988. * The id of the Particle system.
  30989. */
  30990. id: string;
  30991. /**
  30992. * The name of the Particle system.
  30993. */
  30994. name: string;
  30995. /**
  30996. * The emitter represents the Mesh or position we are attaching the particle system to.
  30997. */
  30998. emitter: Nullable<AbstractMesh | Vector3>;
  30999. /**
  31000. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  31001. */
  31002. isBillboardBased: boolean;
  31003. /**
  31004. * The rendering group used by the Particle system to chose when to render.
  31005. */
  31006. renderingGroupId: number;
  31007. /**
  31008. * The layer mask we are rendering the particles through.
  31009. */
  31010. layerMask: number;
  31011. /**
  31012. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  31013. */
  31014. updateSpeed: number;
  31015. /**
  31016. * The amount of time the particle system is running (depends of the overall update speed).
  31017. */
  31018. targetStopDuration: number;
  31019. /**
  31020. * The texture used to render each particle. (this can be a spritesheet)
  31021. */
  31022. particleTexture: Nullable<Texture>;
  31023. /**
  31024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  31025. */
  31026. blendMode: number;
  31027. /**
  31028. * Minimum life time of emitting particles.
  31029. */
  31030. minLifeTime: number;
  31031. /**
  31032. * Maximum life time of emitting particles.
  31033. */
  31034. maxLifeTime: number;
  31035. /**
  31036. * Minimum Size of emitting particles.
  31037. */
  31038. minSize: number;
  31039. /**
  31040. * Maximum Size of emitting particles.
  31041. */
  31042. maxSize: number;
  31043. /**
  31044. * Minimum scale of emitting particles on X axis.
  31045. */
  31046. minScaleX: number;
  31047. /**
  31048. * Maximum scale of emitting particles on X axis.
  31049. */
  31050. maxScaleX: number;
  31051. /**
  31052. * Minimum scale of emitting particles on Y axis.
  31053. */
  31054. minScaleY: number;
  31055. /**
  31056. * Maximum scale of emitting particles on Y axis.
  31057. */
  31058. maxScaleY: number;
  31059. /**
  31060. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31061. */
  31062. color1: Color4;
  31063. /**
  31064. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  31065. */
  31066. color2: Color4;
  31067. /**
  31068. * Color the particle will have at the end of its lifetime.
  31069. */
  31070. colorDead: Color4;
  31071. /**
  31072. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  31073. */
  31074. emitRate: number;
  31075. /**
  31076. * You can use gravity if you want to give an orientation to your particles.
  31077. */
  31078. gravity: Vector3;
  31079. /**
  31080. * Minimum power of emitting particles.
  31081. */
  31082. minEmitPower: number;
  31083. /**
  31084. * Maximum power of emitting particles.
  31085. */
  31086. maxEmitPower: number;
  31087. /**
  31088. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  31089. */
  31090. minAngularSpeed: number;
  31091. /**
  31092. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  31093. */
  31094. maxAngularSpeed: number;
  31095. /**
  31096. * Gets or sets the minimal initial rotation in radians.
  31097. */
  31098. minInitialRotation: number;
  31099. /**
  31100. * Gets or sets the maximal initial rotation in radians.
  31101. */
  31102. maxInitialRotation: number;
  31103. /**
  31104. * The particle emitter type defines the emitter used by the particle system.
  31105. * It can be for example box, sphere, or cone...
  31106. */
  31107. particleEmitterType: Nullable<IParticleEmitterType>;
  31108. /**
  31109. * Defines the delay in milliseconds before starting the system (0 by default)
  31110. */
  31111. startDelay: number;
  31112. /**
  31113. * 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
  31114. */
  31115. preWarmCycles: number;
  31116. /**
  31117. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  31118. */
  31119. preWarmStepOffset: number;
  31120. /**
  31121. * 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)
  31122. */
  31123. spriteCellChangeSpeed: number;
  31124. /**
  31125. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  31126. */
  31127. startSpriteCellID: number;
  31128. /**
  31129. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  31130. */
  31131. endSpriteCellID: number;
  31132. /**
  31133. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  31134. */
  31135. spriteCellWidth: number;
  31136. /**
  31137. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  31138. */
  31139. spriteCellHeight: number;
  31140. /**
  31141. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  31142. */
  31143. spriteRandomStartCell: boolean;
  31144. /**
  31145. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  31146. */
  31147. isAnimationSheetEnabled: boolean;
  31148. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  31149. translationPivot: Vector2;
  31150. /**
  31151. * Gets or sets a texture used to add random noise to particle positions
  31152. */
  31153. noiseTexture: Nullable<BaseTexture>;
  31154. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  31155. noiseStrength: Vector3;
  31156. /**
  31157. * Gets or sets the billboard mode to use when isBillboardBased = true.
  31158. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  31159. */
  31160. billboardMode: number;
  31161. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  31162. limitVelocityDamping: number;
  31163. /**
  31164. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  31165. */
  31166. beginAnimationOnStart: boolean;
  31167. /**
  31168. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  31169. */
  31170. beginAnimationFrom: number;
  31171. /**
  31172. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  31173. */
  31174. beginAnimationTo: number;
  31175. /**
  31176. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  31177. */
  31178. beginAnimationLoop: boolean;
  31179. /**
  31180. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  31181. */
  31182. disposeOnStop: boolean;
  31183. /**
  31184. * Gets the maximum number of particles active at the same time.
  31185. * @returns The max number of active particles.
  31186. */
  31187. getCapacity(): number;
  31188. /**
  31189. * Gets if the system has been started. (Note: this will still be true after stop is called)
  31190. * @returns True if it has been started, otherwise false.
  31191. */
  31192. isStarted(): boolean;
  31193. /**
  31194. * Animates the particle system for this frame.
  31195. */
  31196. animate(): void;
  31197. /**
  31198. * Renders the particle system in its current state.
  31199. * @returns the current number of particles
  31200. */
  31201. render(): number;
  31202. /**
  31203. * Dispose the particle system and frees its associated resources.
  31204. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  31205. */
  31206. dispose(disposeTexture?: boolean): void;
  31207. /**
  31208. * Clones the particle system.
  31209. * @param name The name of the cloned object
  31210. * @param newEmitter The new emitter to use
  31211. * @returns the cloned particle system
  31212. */
  31213. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  31214. /**
  31215. * Serializes the particle system to a JSON object.
  31216. * @returns the JSON object
  31217. */
  31218. serialize(): any;
  31219. /**
  31220. * Rebuild the particle system
  31221. */
  31222. rebuild(): void;
  31223. /**
  31224. * Starts the particle system and begins to emit
  31225. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  31226. */
  31227. start(delay?: number): void;
  31228. /**
  31229. * Stops the particle system.
  31230. */
  31231. stop(): void;
  31232. /**
  31233. * Remove all active particles
  31234. */
  31235. reset(): void;
  31236. /**
  31237. * Is this system ready to be used/rendered
  31238. * @return true if the system is ready
  31239. */
  31240. isReady(): boolean;
  31241. /**
  31242. * Adds a new color gradient
  31243. * @param gradient defines the gradient to use (between 0 and 1)
  31244. * @param color1 defines the color to affect to the specified gradient
  31245. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  31246. * @returns the current particle system
  31247. */
  31248. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  31249. /**
  31250. * Remove a specific color gradient
  31251. * @param gradient defines the gradient to remove
  31252. * @returns the current particle system
  31253. */
  31254. removeColorGradient(gradient: number): IParticleSystem;
  31255. /**
  31256. * Adds a new size gradient
  31257. * @param gradient defines the gradient to use (between 0 and 1)
  31258. * @param factor defines the size factor to affect to the specified gradient
  31259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31260. * @returns the current particle system
  31261. */
  31262. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31263. /**
  31264. * Remove a specific size gradient
  31265. * @param gradient defines the gradient to remove
  31266. * @returns the current particle system
  31267. */
  31268. removeSizeGradient(gradient: number): IParticleSystem;
  31269. /**
  31270. * Gets the current list of color gradients.
  31271. * You must use addColorGradient and removeColorGradient to udpate this list
  31272. * @returns the list of color gradients
  31273. */
  31274. getColorGradients(): Nullable<Array<ColorGradient>>;
  31275. /**
  31276. * Gets the current list of size gradients.
  31277. * You must use addSizeGradient and removeSizeGradient to udpate this list
  31278. * @returns the list of size gradients
  31279. */
  31280. getSizeGradients(): Nullable<Array<FactorGradient>>;
  31281. /**
  31282. * Gets the current list of angular speed gradients.
  31283. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  31284. * @returns the list of angular speed gradients
  31285. */
  31286. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  31287. /**
  31288. * Adds a new angular speed gradient
  31289. * @param gradient defines the gradient to use (between 0 and 1)
  31290. * @param factor defines the angular speed to affect to the specified gradient
  31291. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31292. * @returns the current particle system
  31293. */
  31294. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31295. /**
  31296. * Remove a specific angular speed gradient
  31297. * @param gradient defines the gradient to remove
  31298. * @returns the current particle system
  31299. */
  31300. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31301. /**
  31302. * Gets the current list of velocity gradients.
  31303. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  31304. * @returns the list of velocity gradients
  31305. */
  31306. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  31307. /**
  31308. * Adds a new velocity gradient
  31309. * @param gradient defines the gradient to use (between 0 and 1)
  31310. * @param factor defines the velocity to affect to the specified gradient
  31311. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31312. * @returns the current particle system
  31313. */
  31314. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31315. /**
  31316. * Remove a specific velocity gradient
  31317. * @param gradient defines the gradient to remove
  31318. * @returns the current particle system
  31319. */
  31320. removeVelocityGradient(gradient: number): IParticleSystem;
  31321. /**
  31322. * Gets the current list of limit velocity gradients.
  31323. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  31324. * @returns the list of limit velocity gradients
  31325. */
  31326. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  31327. /**
  31328. * Adds a new limit velocity gradient
  31329. * @param gradient defines the gradient to use (between 0 and 1)
  31330. * @param factor defines the limit velocity to affect to the specified gradient
  31331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31332. * @returns the current particle system
  31333. */
  31334. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31335. /**
  31336. * Remove a specific limit velocity gradient
  31337. * @param gradient defines the gradient to remove
  31338. * @returns the current particle system
  31339. */
  31340. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31341. /**
  31342. * Adds a new drag gradient
  31343. * @param gradient defines the gradient to use (between 0 and 1)
  31344. * @param factor defines the drag to affect to the specified gradient
  31345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31346. * @returns the current particle system
  31347. */
  31348. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31349. /**
  31350. * Remove a specific drag gradient
  31351. * @param gradient defines the gradient to remove
  31352. * @returns the current particle system
  31353. */
  31354. removeDragGradient(gradient: number): IParticleSystem;
  31355. /**
  31356. * Gets the current list of drag gradients.
  31357. * You must use addDragGradient and removeDragGradient to udpate this list
  31358. * @returns the list of drag gradients
  31359. */
  31360. getDragGradients(): Nullable<Array<FactorGradient>>;
  31361. /**
  31362. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31363. * @param gradient defines the gradient to use (between 0 and 1)
  31364. * @param factor defines the emit rate to affect to the specified gradient
  31365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31366. * @returns the current particle system
  31367. */
  31368. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31369. /**
  31370. * Remove a specific emit rate gradient
  31371. * @param gradient defines the gradient to remove
  31372. * @returns the current particle system
  31373. */
  31374. removeEmitRateGradient(gradient: number): IParticleSystem;
  31375. /**
  31376. * Gets the current list of emit rate gradients.
  31377. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  31378. * @returns the list of emit rate gradients
  31379. */
  31380. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  31381. /**
  31382. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31383. * @param gradient defines the gradient to use (between 0 and 1)
  31384. * @param factor defines the start size to affect to the specified gradient
  31385. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31386. * @returns the current particle system
  31387. */
  31388. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31389. /**
  31390. * Remove a specific start size gradient
  31391. * @param gradient defines the gradient to remove
  31392. * @returns the current particle system
  31393. */
  31394. removeStartSizeGradient(gradient: number): IParticleSystem;
  31395. /**
  31396. * Gets the current list of start size gradients.
  31397. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  31398. * @returns the list of start size gradients
  31399. */
  31400. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  31401. /**
  31402. * Adds a new life time gradient
  31403. * @param gradient defines the gradient to use (between 0 and 1)
  31404. * @param factor defines the life time factor to affect to the specified gradient
  31405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31406. * @returns the current particle system
  31407. */
  31408. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31409. /**
  31410. * Remove a specific life time gradient
  31411. * @param gradient defines the gradient to remove
  31412. * @returns the current particle system
  31413. */
  31414. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31415. /**
  31416. * Gets the current list of life time gradients.
  31417. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  31418. * @returns the list of life time gradients
  31419. */
  31420. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  31421. /**
  31422. * Gets the current list of color gradients.
  31423. * You must use addColorGradient and removeColorGradient to udpate this list
  31424. * @returns the list of color gradients
  31425. */
  31426. getColorGradients(): Nullable<Array<ColorGradient>>;
  31427. /**
  31428. * Adds a new ramp gradient used to remap particle colors
  31429. * @param gradient defines the gradient to use (between 0 and 1)
  31430. * @param color defines the color to affect to the specified gradient
  31431. * @returns the current particle system
  31432. */
  31433. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  31434. /**
  31435. * Gets the current list of ramp gradients.
  31436. * You must use addRampGradient and removeRampGradient to udpate this list
  31437. * @returns the list of ramp gradients
  31438. */
  31439. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31440. /** Gets or sets a boolean indicating that ramp gradients must be used
  31441. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31442. */
  31443. useRampGradients: boolean;
  31444. /**
  31445. * Adds a new color remap gradient
  31446. * @param gradient defines the gradient to use (between 0 and 1)
  31447. * @param min defines the color remap minimal range
  31448. * @param max defines the color remap maximal range
  31449. * @returns the current particle system
  31450. */
  31451. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31452. /**
  31453. * Gets the current list of color remap gradients.
  31454. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  31455. * @returns the list of color remap gradients
  31456. */
  31457. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  31458. /**
  31459. * Adds a new alpha remap gradient
  31460. * @param gradient defines the gradient to use (between 0 and 1)
  31461. * @param min defines the alpha remap minimal range
  31462. * @param max defines the alpha remap maximal range
  31463. * @returns the current particle system
  31464. */
  31465. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31466. /**
  31467. * Gets the current list of alpha remap gradients.
  31468. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  31469. * @returns the list of alpha remap gradients
  31470. */
  31471. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  31472. /**
  31473. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  31474. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31475. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31476. * @returns the emitter
  31477. */
  31478. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  31479. /**
  31480. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  31481. * @param radius The radius of the hemisphere to emit from
  31482. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31483. * @returns the emitter
  31484. */
  31485. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  31486. /**
  31487. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  31488. * @param radius The radius of the sphere to emit from
  31489. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  31490. * @returns the emitter
  31491. */
  31492. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  31493. /**
  31494. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  31495. * @param radius The radius of the sphere to emit from
  31496. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  31497. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  31498. * @returns the emitter
  31499. */
  31500. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31501. /**
  31502. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  31503. * @param radius The radius of the emission cylinder
  31504. * @param height The height of the emission cylinder
  31505. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  31506. * @param directionRandomizer How much to randomize the particle direction [0-1]
  31507. * @returns the emitter
  31508. */
  31509. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  31510. /**
  31511. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  31512. * @param radius The radius of the cylinder to emit from
  31513. * @param height The height of the emission cylinder
  31514. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  31515. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  31516. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  31517. * @returns the emitter
  31518. */
  31519. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  31520. /**
  31521. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  31522. * @param radius The radius of the cone to emit from
  31523. * @param angle The base angle of the cone
  31524. * @returns the emitter
  31525. */
  31526. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  31527. /**
  31528. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  31529. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  31530. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  31531. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31532. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  31533. * @returns the emitter
  31534. */
  31535. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  31536. /**
  31537. * Get hosting scene
  31538. * @returns the scene
  31539. */
  31540. getScene(): Scene;
  31541. }
  31542. }
  31543. declare module BABYLON {
  31544. /**
  31545. * A particle represents one of the element emitted by a particle system.
  31546. * This is mainly define by its coordinates, direction, velocity and age.
  31547. */
  31548. class Particle {
  31549. /**
  31550. * The particle system the particle belongs to.
  31551. */
  31552. particleSystem: ParticleSystem;
  31553. private static _Count;
  31554. /**
  31555. * Unique ID of the particle
  31556. */
  31557. id: number;
  31558. /**
  31559. * The world position of the particle in the scene.
  31560. */
  31561. position: Vector3;
  31562. /**
  31563. * The world direction of the particle in the scene.
  31564. */
  31565. direction: Vector3;
  31566. /**
  31567. * The color of the particle.
  31568. */
  31569. color: Color4;
  31570. /**
  31571. * The color change of the particle per step.
  31572. */
  31573. colorStep: Color4;
  31574. /**
  31575. * Defines how long will the life of the particle be.
  31576. */
  31577. lifeTime: number;
  31578. /**
  31579. * The current age of the particle.
  31580. */
  31581. age: number;
  31582. /**
  31583. * The current size of the particle.
  31584. */
  31585. size: number;
  31586. /**
  31587. * The current scale of the particle.
  31588. */
  31589. scale: Vector2;
  31590. /**
  31591. * The current angle of the particle.
  31592. */
  31593. angle: number;
  31594. /**
  31595. * Defines how fast is the angle changing.
  31596. */
  31597. angularSpeed: number;
  31598. /**
  31599. * Defines the cell index used by the particle to be rendered from a sprite.
  31600. */
  31601. cellIndex: number;
  31602. /**
  31603. * The information required to support color remapping
  31604. */
  31605. remapData: Vector4;
  31606. /** @hidden */
  31607. _randomCellOffset?: number;
  31608. /** @hidden */
  31609. _initialDirection: Nullable<Vector3>;
  31610. /** @hidden */
  31611. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  31612. /** @hidden */
  31613. _initialStartSpriteCellID: number;
  31614. /** @hidden */
  31615. _initialEndSpriteCellID: number;
  31616. /** @hidden */
  31617. _currentColorGradient: Nullable<ColorGradient>;
  31618. /** @hidden */
  31619. _currentColor1: Color4;
  31620. /** @hidden */
  31621. _currentColor2: Color4;
  31622. /** @hidden */
  31623. _currentSizeGradient: Nullable<FactorGradient>;
  31624. /** @hidden */
  31625. _currentSize1: number;
  31626. /** @hidden */
  31627. _currentSize2: number;
  31628. /** @hidden */
  31629. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  31630. /** @hidden */
  31631. _currentAngularSpeed1: number;
  31632. /** @hidden */
  31633. _currentAngularSpeed2: number;
  31634. /** @hidden */
  31635. _currentVelocityGradient: Nullable<FactorGradient>;
  31636. /** @hidden */
  31637. _currentVelocity1: number;
  31638. /** @hidden */
  31639. _currentVelocity2: number;
  31640. /** @hidden */
  31641. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  31642. /** @hidden */
  31643. _currentLimitVelocity1: number;
  31644. /** @hidden */
  31645. _currentLimitVelocity2: number;
  31646. /** @hidden */
  31647. _currentDragGradient: Nullable<FactorGradient>;
  31648. /** @hidden */
  31649. _currentDrag1: number;
  31650. /** @hidden */
  31651. _currentDrag2: number;
  31652. /** @hidden */
  31653. _randomNoiseCoordinates1: Vector3;
  31654. /** @hidden */
  31655. _randomNoiseCoordinates2: Vector3;
  31656. /**
  31657. * Creates a new instance Particle
  31658. * @param particleSystem the particle system the particle belongs to
  31659. */
  31660. constructor(
  31661. /**
  31662. * The particle system the particle belongs to.
  31663. */
  31664. particleSystem: ParticleSystem);
  31665. private updateCellInfoFromSystem;
  31666. /**
  31667. * Defines how the sprite cell index is updated for the particle
  31668. */
  31669. updateCellIndex(): void;
  31670. /** @hidden */
  31671. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  31672. /** @hidden */
  31673. _inheritParticleInfoToSubEmitters(): void;
  31674. /** @hidden */
  31675. _reset(): void;
  31676. /**
  31677. * Copy the properties of particle to another one.
  31678. * @param other the particle to copy the information to.
  31679. */
  31680. copyTo(other: Particle): void;
  31681. }
  31682. }
  31683. declare module BABYLON {
  31684. /**
  31685. * This class is made for on one-liner static method to help creating particle system set.
  31686. */
  31687. class ParticleHelper {
  31688. /**
  31689. * Gets or sets base Assets URL
  31690. */
  31691. static BaseAssetsUrl: string;
  31692. /**
  31693. * Create a default particle system that you can tweak
  31694. * @param emitter defines the emitter to use
  31695. * @param capacity defines the system capacity (default is 500 particles)
  31696. * @param scene defines the hosting scene
  31697. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  31698. * @returns the new Particle system
  31699. */
  31700. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  31701. /**
  31702. * This is the main static method (one-liner) of this helper to create different particle systems
  31703. * @param type This string represents the type to the particle system to create
  31704. * @param scene The scene where the particle system should live
  31705. * @param gpu If the system will use gpu
  31706. * @returns the ParticleSystemSet created
  31707. */
  31708. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  31709. /**
  31710. * Static function used to export a particle system to a ParticleSystemSet variable.
  31711. * Please note that the emitter shape is not exported
  31712. * @param systems defines the particle systems to export
  31713. * @returns the created particle system set
  31714. */
  31715. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  31716. }
  31717. }
  31718. declare module BABYLON {
  31719. /**
  31720. * This represents a particle system in Babylon.
  31721. * 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.
  31722. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  31723. * @example https://doc.babylonjs.com/babylon101/particles
  31724. */
  31725. class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  31726. /**
  31727. * Billboard mode will only apply to Y axis
  31728. */
  31729. static readonly BILLBOARDMODE_Y: number;
  31730. /**
  31731. * Billboard mode will apply to all axes
  31732. */
  31733. static readonly BILLBOARDMODE_ALL: number;
  31734. /**
  31735. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  31736. */
  31737. static readonly BILLBOARDMODE_STRETCHED: number;
  31738. /**
  31739. * This function can be defined to provide custom update for active particles.
  31740. * This function will be called instead of regular update (age, position, color, etc.).
  31741. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  31742. */
  31743. updateFunction: (particles: Particle[]) => void;
  31744. private _emitterWorldMatrix;
  31745. /**
  31746. * This function can be defined to specify initial direction for every new particle.
  31747. * It by default use the emitterType defined function
  31748. */
  31749. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  31750. /**
  31751. * This function can be defined to specify initial position for every new particle.
  31752. * It by default use the emitterType defined function
  31753. */
  31754. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  31755. /**
  31756. * @hidden
  31757. */
  31758. _inheritedVelocityOffset: Vector3;
  31759. /**
  31760. * An event triggered when the system is disposed
  31761. */
  31762. onDisposeObservable: Observable<ParticleSystem>;
  31763. private _onDisposeObserver;
  31764. /**
  31765. * Sets a callback that will be triggered when the system is disposed
  31766. */
  31767. onDispose: () => void;
  31768. private _particles;
  31769. private _epsilon;
  31770. private _capacity;
  31771. private _stockParticles;
  31772. private _newPartsExcess;
  31773. private _vertexData;
  31774. private _vertexBuffer;
  31775. private _vertexBuffers;
  31776. private _spriteBuffer;
  31777. private _indexBuffer;
  31778. private _effect;
  31779. private _customEffect;
  31780. private _cachedDefines;
  31781. private _scaledColorStep;
  31782. private _colorDiff;
  31783. private _scaledDirection;
  31784. private _scaledGravity;
  31785. private _currentRenderId;
  31786. private _alive;
  31787. private _useInstancing;
  31788. private _started;
  31789. private _stopped;
  31790. private _actualFrame;
  31791. private _scaledUpdateSpeed;
  31792. private _vertexBufferSize;
  31793. /** @hidden */
  31794. _currentEmitRateGradient: Nullable<FactorGradient>;
  31795. /** @hidden */
  31796. _currentEmitRate1: number;
  31797. /** @hidden */
  31798. _currentEmitRate2: number;
  31799. /** @hidden */
  31800. _currentStartSizeGradient: Nullable<FactorGradient>;
  31801. /** @hidden */
  31802. _currentStartSize1: number;
  31803. /** @hidden */
  31804. _currentStartSize2: number;
  31805. private readonly _rawTextureWidth;
  31806. private _rampGradientsTexture;
  31807. private _useRampGradients;
  31808. /** Gets or sets a boolean indicating that ramp gradients must be used
  31809. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  31810. */
  31811. useRampGradients: boolean;
  31812. /**
  31813. * 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.
  31814. * 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: [])
  31815. */
  31816. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  31817. private _subEmitters;
  31818. /**
  31819. * @hidden
  31820. * If the particle systems emitter should be disposed when the particle system is disposed
  31821. */
  31822. _disposeEmitterOnDispose: boolean;
  31823. /**
  31824. * The current active Sub-systems, this property is used by the root particle system only.
  31825. */
  31826. activeSubSystems: Array<ParticleSystem>;
  31827. private _rootParticleSystem;
  31828. /**
  31829. * Gets the current list of active particles
  31830. */
  31831. readonly particles: Particle[];
  31832. /**
  31833. * Returns the string "ParticleSystem"
  31834. * @returns a string containing the class name
  31835. */
  31836. getClassName(): string;
  31837. /**
  31838. * Instantiates a particle system.
  31839. * 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.
  31840. * @param name The name of the particle system
  31841. * @param capacity The max number of particles alive at the same time
  31842. * @param scene The scene the particle system belongs to
  31843. * @param customEffect a custom effect used to change the way particles are rendered by default
  31844. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  31845. * @param epsilon Offset used to render the particles
  31846. */
  31847. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  31848. private _addFactorGradient;
  31849. private _removeFactorGradient;
  31850. /**
  31851. * Adds a new life time gradient
  31852. * @param gradient defines the gradient to use (between 0 and 1)
  31853. * @param factor defines the life time factor to affect to the specified gradient
  31854. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31855. * @returns the current particle system
  31856. */
  31857. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31858. /**
  31859. * Remove a specific life time gradient
  31860. * @param gradient defines the gradient to remove
  31861. * @returns the current particle system
  31862. */
  31863. removeLifeTimeGradient(gradient: number): IParticleSystem;
  31864. /**
  31865. * Adds a new size gradient
  31866. * @param gradient defines the gradient to use (between 0 and 1)
  31867. * @param factor defines the size factor to affect to the specified gradient
  31868. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31869. * @returns the current particle system
  31870. */
  31871. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31872. /**
  31873. * Remove a specific size gradient
  31874. * @param gradient defines the gradient to remove
  31875. * @returns the current particle system
  31876. */
  31877. removeSizeGradient(gradient: number): IParticleSystem;
  31878. /**
  31879. * Adds a new color remap gradient
  31880. * @param gradient defines the gradient to use (between 0 and 1)
  31881. * @param min defines the color remap minimal range
  31882. * @param max defines the color remap maximal range
  31883. * @returns the current particle system
  31884. */
  31885. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31886. /**
  31887. * Remove a specific color remap gradient
  31888. * @param gradient defines the gradient to remove
  31889. * @returns the current particle system
  31890. */
  31891. removeColorRemapGradient(gradient: number): IParticleSystem;
  31892. /**
  31893. * Adds a new alpha remap gradient
  31894. * @param gradient defines the gradient to use (between 0 and 1)
  31895. * @param min defines the alpha remap minimal range
  31896. * @param max defines the alpha remap maximal range
  31897. * @returns the current particle system
  31898. */
  31899. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  31900. /**
  31901. * Remove a specific alpha remap gradient
  31902. * @param gradient defines the gradient to remove
  31903. * @returns the current particle system
  31904. */
  31905. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  31906. /**
  31907. * Adds a new angular speed gradient
  31908. * @param gradient defines the gradient to use (between 0 and 1)
  31909. * @param factor defines the angular speed to affect to the specified gradient
  31910. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31911. * @returns the current particle system
  31912. */
  31913. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31914. /**
  31915. * Remove a specific angular speed gradient
  31916. * @param gradient defines the gradient to remove
  31917. * @returns the current particle system
  31918. */
  31919. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  31920. /**
  31921. * Adds a new velocity gradient
  31922. * @param gradient defines the gradient to use (between 0 and 1)
  31923. * @param factor defines the velocity to affect to the specified gradient
  31924. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31925. * @returns the current particle system
  31926. */
  31927. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31928. /**
  31929. * Remove a specific velocity gradient
  31930. * @param gradient defines the gradient to remove
  31931. * @returns the current particle system
  31932. */
  31933. removeVelocityGradient(gradient: number): IParticleSystem;
  31934. /**
  31935. * Adds a new limit velocity gradient
  31936. * @param gradient defines the gradient to use (between 0 and 1)
  31937. * @param factor defines the limit velocity value to affect to the specified gradient
  31938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31939. * @returns the current particle system
  31940. */
  31941. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31942. /**
  31943. * Remove a specific limit velocity gradient
  31944. * @param gradient defines the gradient to remove
  31945. * @returns the current particle system
  31946. */
  31947. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  31948. /**
  31949. * Adds a new drag gradient
  31950. * @param gradient defines the gradient to use (between 0 and 1)
  31951. * @param factor defines the drag value to affect to the specified gradient
  31952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31953. * @returns the current particle system
  31954. */
  31955. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31956. /**
  31957. * Remove a specific drag gradient
  31958. * @param gradient defines the gradient to remove
  31959. * @returns the current particle system
  31960. */
  31961. removeDragGradient(gradient: number): IParticleSystem;
  31962. /**
  31963. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  31964. * @param gradient defines the gradient to use (between 0 and 1)
  31965. * @param factor defines the emit rate value to affect to the specified gradient
  31966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31967. * @returns the current particle system
  31968. */
  31969. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31970. /**
  31971. * Remove a specific emit rate gradient
  31972. * @param gradient defines the gradient to remove
  31973. * @returns the current particle system
  31974. */
  31975. removeEmitRateGradient(gradient: number): IParticleSystem;
  31976. /**
  31977. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  31978. * @param gradient defines the gradient to use (between 0 and 1)
  31979. * @param factor defines the start size value to affect to the specified gradient
  31980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  31981. * @returns the current particle system
  31982. */
  31983. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  31984. /**
  31985. * Remove a specific start size gradient
  31986. * @param gradient defines the gradient to remove
  31987. * @returns the current particle system
  31988. */
  31989. removeStartSizeGradient(gradient: number): IParticleSystem;
  31990. private _createRampGradientTexture;
  31991. /**
  31992. * Gets the current list of ramp gradients.
  31993. * You must use addRampGradient and removeRampGradient to udpate this list
  31994. * @returns the list of ramp gradients
  31995. */
  31996. getRampGradients(): Nullable<Array<Color3Gradient>>;
  31997. /**
  31998. * Adds a new ramp gradient used to remap particle colors
  31999. * @param gradient defines the gradient to use (between 0 and 1)
  32000. * @param color defines the color to affect to the specified gradient
  32001. * @returns the current particle system
  32002. */
  32003. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  32004. /**
  32005. * Remove a specific ramp gradient
  32006. * @param gradient defines the gradient to remove
  32007. * @returns the current particle system
  32008. */
  32009. removeRampGradient(gradient: number): ParticleSystem;
  32010. /**
  32011. * Adds a new color gradient
  32012. * @param gradient defines the gradient to use (between 0 and 1)
  32013. * @param color1 defines the color to affect to the specified gradient
  32014. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  32015. * @returns this particle system
  32016. */
  32017. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  32018. /**
  32019. * Remove a specific color gradient
  32020. * @param gradient defines the gradient to remove
  32021. * @returns this particle system
  32022. */
  32023. removeColorGradient(gradient: number): IParticleSystem;
  32024. private _fetchR;
  32025. protected _reset(): void;
  32026. private _resetEffect;
  32027. private _createVertexBuffers;
  32028. private _createIndexBuffer;
  32029. /**
  32030. * Gets the maximum number of particles active at the same time.
  32031. * @returns The max number of active particles.
  32032. */
  32033. getCapacity(): number;
  32034. /**
  32035. * Gets whether there are still active particles in the system.
  32036. * @returns True if it is alive, otherwise false.
  32037. */
  32038. isAlive(): boolean;
  32039. /**
  32040. * Gets if the system has been started. (Note: this will still be true after stop is called)
  32041. * @returns True if it has been started, otherwise false.
  32042. */
  32043. isStarted(): boolean;
  32044. private _prepareSubEmitterInternalArray;
  32045. /**
  32046. * Starts the particle system and begins to emit
  32047. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  32048. */
  32049. start(delay?: number): void;
  32050. /**
  32051. * Stops the particle system.
  32052. * @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.
  32053. */
  32054. stop(stopSubEmitters?: boolean): void;
  32055. /**
  32056. * Remove all active particles
  32057. */
  32058. reset(): void;
  32059. /**
  32060. * @hidden (for internal use only)
  32061. */
  32062. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  32063. /**
  32064. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  32065. * Its lifetime will start back at 0.
  32066. */
  32067. recycleParticle: (particle: Particle) => void;
  32068. private _stopSubEmitters;
  32069. private _createParticle;
  32070. private _removeFromRoot;
  32071. private _emitFromParticle;
  32072. private _update;
  32073. /** @hidden */
  32074. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  32075. /** @hidden */
  32076. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  32077. /** @hidden */
  32078. private _getEffect;
  32079. /**
  32080. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  32081. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  32082. */
  32083. animate(preWarmOnly?: boolean): void;
  32084. private _appendParticleVertices;
  32085. /**
  32086. * Rebuilds the particle system.
  32087. */
  32088. rebuild(): void;
  32089. /**
  32090. * Is this system ready to be used/rendered
  32091. * @return true if the system is ready
  32092. */
  32093. isReady(): boolean;
  32094. private _render;
  32095. /**
  32096. * Renders the particle system in its current state.
  32097. * @returns the current number of particles
  32098. */
  32099. render(): number;
  32100. /**
  32101. * Disposes the particle system and free the associated resources
  32102. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  32103. */
  32104. dispose(disposeTexture?: boolean): void;
  32105. /**
  32106. * Clones the particle system.
  32107. * @param name The name of the cloned object
  32108. * @param newEmitter The new emitter to use
  32109. * @returns the cloned particle system
  32110. */
  32111. clone(name: string, newEmitter: any): ParticleSystem;
  32112. /**
  32113. * Serializes the particle system to a JSON object.
  32114. * @returns the JSON object
  32115. */
  32116. serialize(): any;
  32117. /** @hidden */
  32118. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  32119. /** @hidden */
  32120. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  32121. /**
  32122. * Parses a JSON object to create a particle system.
  32123. * @param parsedParticleSystem The JSON object to parse
  32124. * @param scene The scene to create the particle system in
  32125. * @param rootUrl The root url to use to load external dependencies like texture
  32126. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  32127. * @returns the Parsed particle system
  32128. */
  32129. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  32130. }
  32131. }
  32132. declare module BABYLON {
  32133. interface Engine {
  32134. /**
  32135. * Create an effect to use with particle systems.
  32136. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  32137. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  32138. * @param uniformsNames defines a list of attribute names
  32139. * @param samplers defines an array of string used to represent textures
  32140. * @param defines defines the string containing the defines to use to compile the shaders
  32141. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32142. * @param onCompiled defines a function to call when the effect creation is successful
  32143. * @param onError defines a function to call when the effect creation has failed
  32144. * @returns the new Effect
  32145. */
  32146. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  32147. }
  32148. interface Mesh {
  32149. /**
  32150. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  32151. * @returns an array of IParticleSystem
  32152. */
  32153. getEmittedParticleSystems(): IParticleSystem[];
  32154. /**
  32155. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  32156. * @returns an array of IParticleSystem
  32157. */
  32158. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  32159. }
  32160. }
  32161. declare module BABYLON {
  32162. /**
  32163. * Represents a set of particle systems working together to create a specific effect
  32164. */
  32165. class ParticleSystemSet implements IDisposable {
  32166. private _emitterCreationOptions;
  32167. private _emitterNode;
  32168. /**
  32169. * Gets the particle system list
  32170. */
  32171. systems: IParticleSystem[];
  32172. /**
  32173. * Gets the emitter node used with this set
  32174. */
  32175. readonly emitterNode: Nullable<TransformNode>;
  32176. /**
  32177. * Creates a new emitter mesh as a sphere
  32178. * @param options defines the options used to create the sphere
  32179. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  32180. * @param scene defines the hosting scene
  32181. */
  32182. setEmitterAsSphere(options: {
  32183. diameter: number;
  32184. segments: number;
  32185. color: Color3;
  32186. }, renderingGroupId: number, scene: Scene): void;
  32187. /**
  32188. * Starts all particle systems of the set
  32189. * @param emitter defines an optional mesh to use as emitter for the particle systems
  32190. */
  32191. start(emitter?: AbstractMesh): void;
  32192. /**
  32193. * Release all associated resources
  32194. */
  32195. dispose(): void;
  32196. /**
  32197. * Serialize the set into a JSON compatible object
  32198. * @returns a JSON compatible representation of the set
  32199. */
  32200. serialize(): any;
  32201. /**
  32202. * Parse a new ParticleSystemSet from a serialized source
  32203. * @param data defines a JSON compatible representation of the set
  32204. * @param scene defines the hosting scene
  32205. * @param gpu defines if we want GPU particles or CPU particles
  32206. * @returns a new ParticleSystemSet
  32207. */
  32208. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  32209. }
  32210. }
  32211. declare module BABYLON {
  32212. /**
  32213. * Represents one particle of a solid particle system.
  32214. */
  32215. class SolidParticle {
  32216. /**
  32217. * particle global index
  32218. */
  32219. idx: number;
  32220. /**
  32221. * The color of the particle
  32222. */
  32223. color: Nullable<Color4>;
  32224. /**
  32225. * The world space position of the particle.
  32226. */
  32227. position: Vector3;
  32228. /**
  32229. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32230. */
  32231. rotation: Vector3;
  32232. /**
  32233. * The world space rotation quaternion of the particle.
  32234. */
  32235. rotationQuaternion: Nullable<Quaternion>;
  32236. /**
  32237. * The scaling of the particle.
  32238. */
  32239. scaling: Vector3;
  32240. /**
  32241. * The uvs of the particle.
  32242. */
  32243. uvs: Vector4;
  32244. /**
  32245. * The current speed of the particle.
  32246. */
  32247. velocity: Vector3;
  32248. /**
  32249. * The pivot point in the particle local space.
  32250. */
  32251. pivot: Vector3;
  32252. /**
  32253. * Must the particle be translated from its pivot point in its local space ?
  32254. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32255. * Default : false
  32256. */
  32257. translateFromPivot: boolean;
  32258. /**
  32259. * Is the particle active or not ?
  32260. */
  32261. alive: boolean;
  32262. /**
  32263. * Is the particle visible or not ?
  32264. */
  32265. isVisible: boolean;
  32266. /**
  32267. * Index of this particle in the global "positions" array (Internal use)
  32268. * @hidden
  32269. */
  32270. _pos: number;
  32271. /**
  32272. * @hidden Index of this particle in the global "indices" array (Internal use)
  32273. */
  32274. _ind: number;
  32275. /**
  32276. * @hidden ModelShape of this particle (Internal use)
  32277. */
  32278. _model: ModelShape;
  32279. /**
  32280. * ModelShape id of this particle
  32281. */
  32282. shapeId: number;
  32283. /**
  32284. * Index of the particle in its shape id (Internal use)
  32285. */
  32286. idxInShape: number;
  32287. /**
  32288. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32289. */
  32290. _modelBoundingInfo: BoundingInfo;
  32291. /**
  32292. * @hidden Particle BoundingInfo object (Internal use)
  32293. */
  32294. _boundingInfo: BoundingInfo;
  32295. /**
  32296. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32297. */
  32298. _sps: SolidParticleSystem;
  32299. /**
  32300. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32301. */
  32302. _stillInvisible: boolean;
  32303. /**
  32304. * @hidden Last computed particle rotation matrix
  32305. */
  32306. _rotationMatrix: number[];
  32307. /**
  32308. * Parent particle Id, if any.
  32309. * Default null.
  32310. */
  32311. parentId: Nullable<number>;
  32312. /**
  32313. * @hidden Internal global position in the SPS.
  32314. */
  32315. _globalPosition: Vector3;
  32316. /**
  32317. * Creates a Solid Particle object.
  32318. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32319. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  32320. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32321. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32322. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32323. * @param shapeId (integer) is the model shape identifier in the SPS.
  32324. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32325. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32326. */
  32327. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  32328. /**
  32329. * Legacy support, changed scale to scaling
  32330. */
  32331. /**
  32332. * Legacy support, changed scale to scaling
  32333. */
  32334. scale: Vector3;
  32335. /**
  32336. * Legacy support, changed quaternion to rotationQuaternion
  32337. */
  32338. /**
  32339. * Legacy support, changed quaternion to rotationQuaternion
  32340. */
  32341. quaternion: Nullable<Quaternion>;
  32342. /**
  32343. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32344. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32345. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32346. * @returns true if it intersects
  32347. */
  32348. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32349. /**
  32350. * get the rotation matrix of the particle
  32351. * @hidden
  32352. */
  32353. getRotationMatrix(m: Matrix): void;
  32354. }
  32355. /**
  32356. * Represents the shape of the model used by one particle of a solid particle system.
  32357. * SPS internal tool, don't use it manually.
  32358. */
  32359. class ModelShape {
  32360. /**
  32361. * The shape id
  32362. * @hidden
  32363. */
  32364. shapeID: number;
  32365. /**
  32366. * flat array of model positions (internal use)
  32367. * @hidden
  32368. */
  32369. _shape: Vector3[];
  32370. /**
  32371. * flat array of model UVs (internal use)
  32372. * @hidden
  32373. */
  32374. _shapeUV: number[];
  32375. /**
  32376. * length of the shape in the model indices array (internal use)
  32377. * @hidden
  32378. */
  32379. _indicesLength: number;
  32380. /**
  32381. * Custom position function (internal use)
  32382. * @hidden
  32383. */
  32384. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32385. /**
  32386. * Custom vertex function (internal use)
  32387. * @hidden
  32388. */
  32389. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32390. /**
  32391. * 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.
  32392. * SPS internal tool, don't use it manually.
  32393. * @hidden
  32394. */
  32395. 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>);
  32396. }
  32397. /**
  32398. * Represents a Depth Sorted Particle in the solid particle system.
  32399. */
  32400. class DepthSortedParticle {
  32401. /**
  32402. * Index of the particle in the "indices" array
  32403. */
  32404. ind: number;
  32405. /**
  32406. * Length of the particle shape in the "indices" array
  32407. */
  32408. indicesLength: number;
  32409. /**
  32410. * Squared distance from the particle to the camera
  32411. */
  32412. sqDistance: number;
  32413. }
  32414. }
  32415. declare module BABYLON {
  32416. /**
  32417. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32418. *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.
  32419. * The SPS is also a particle system. It provides some methods to manage the particles.
  32420. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32421. *
  32422. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  32423. */
  32424. class SolidParticleSystem implements IDisposable {
  32425. /**
  32426. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32427. * Example : var p = SPS.particles[i];
  32428. */
  32429. particles: SolidParticle[];
  32430. /**
  32431. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32432. */
  32433. nbParticles: number;
  32434. /**
  32435. * If the particles must ever face the camera (default false). Useful for planar particles.
  32436. */
  32437. billboard: boolean;
  32438. /**
  32439. * Recompute normals when adding a shape
  32440. */
  32441. recomputeNormals: boolean;
  32442. /**
  32443. * This a counter ofr your own usage. It's not set by any SPS functions.
  32444. */
  32445. counter: number;
  32446. /**
  32447. * The SPS name. This name is also given to the underlying mesh.
  32448. */
  32449. name: string;
  32450. /**
  32451. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32452. */
  32453. mesh: Mesh;
  32454. /**
  32455. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32456. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  32457. */
  32458. vars: any;
  32459. /**
  32460. * This array is populated when the SPS is set as 'pickable'.
  32461. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32462. * Each element of this array is an object `{idx: int, faceId: int}`.
  32463. * `idx` is the picked particle index in the `SPS.particles` array
  32464. * `faceId` is the picked face index counted within this particle.
  32465. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  32466. */
  32467. pickedParticles: {
  32468. idx: number;
  32469. faceId: number;
  32470. }[];
  32471. /**
  32472. * This array is populated when `enableDepthSort` is set to true.
  32473. * Each element of this array is an instance of the class DepthSortedParticle.
  32474. */
  32475. depthSortedParticles: DepthSortedParticle[];
  32476. /**
  32477. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32478. * @hidden
  32479. */
  32480. _bSphereOnly: boolean;
  32481. /**
  32482. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32483. * @hidden
  32484. */
  32485. _bSphereRadiusFactor: number;
  32486. private _scene;
  32487. private _positions;
  32488. private _indices;
  32489. private _normals;
  32490. private _colors;
  32491. private _uvs;
  32492. private _indices32;
  32493. private _positions32;
  32494. private _normals32;
  32495. private _fixedNormal32;
  32496. private _colors32;
  32497. private _uvs32;
  32498. private _index;
  32499. private _updatable;
  32500. private _pickable;
  32501. private _isVisibilityBoxLocked;
  32502. private _alwaysVisible;
  32503. private _depthSort;
  32504. private _shapeCounter;
  32505. private _copy;
  32506. private _color;
  32507. private _computeParticleColor;
  32508. private _computeParticleTexture;
  32509. private _computeParticleRotation;
  32510. private _computeParticleVertex;
  32511. private _computeBoundingBox;
  32512. private _depthSortParticles;
  32513. private _camera;
  32514. private _mustUnrotateFixedNormals;
  32515. private _particlesIntersect;
  32516. private _needs32Bits;
  32517. /**
  32518. * Creates a SPS (Solid Particle System) object.
  32519. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32520. * @param scene (Scene) is the scene in which the SPS is added.
  32521. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32522. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32523. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32524. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32525. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32526. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32527. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32528. */
  32529. constructor(name: string, scene: Scene, options?: {
  32530. updatable?: boolean;
  32531. isPickable?: boolean;
  32532. enableDepthSort?: boolean;
  32533. particleIntersection?: boolean;
  32534. boundingSphereOnly?: boolean;
  32535. bSphereRadiusFactor?: number;
  32536. });
  32537. /**
  32538. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32539. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32540. * @returns the created mesh
  32541. */
  32542. buildMesh(): Mesh;
  32543. /**
  32544. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32545. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32546. * Thus the particles generated from `digest()` have their property `position` set yet.
  32547. * @param mesh ( Mesh ) is the mesh to be digested
  32548. * @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
  32549. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32550. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32551. * @returns the current SPS
  32552. */
  32553. digest(mesh: Mesh, options?: {
  32554. facetNb?: number;
  32555. number?: number;
  32556. delta?: number;
  32557. }): SolidParticleSystem;
  32558. private _unrotateFixedNormals;
  32559. private _resetCopy;
  32560. private _meshBuilder;
  32561. private _posToShape;
  32562. private _uvsToShapeUV;
  32563. private _addParticle;
  32564. /**
  32565. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32566. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  32567. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32568. * @param nb (positive integer) the number of particles to be created from this model
  32569. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32570. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32571. * @returns the number of shapes in the system
  32572. */
  32573. addShape(mesh: Mesh, nb: number, options?: {
  32574. positionFunction?: any;
  32575. vertexFunction?: any;
  32576. }): number;
  32577. private _rebuildParticle;
  32578. /**
  32579. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32580. * @returns the SPS.
  32581. */
  32582. rebuildMesh(): SolidParticleSystem;
  32583. /**
  32584. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32585. * This method calls `updateParticle()` for each particle of the SPS.
  32586. * For an animated SPS, it is usually called within the render loop.
  32587. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32588. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32589. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32590. * @returns the SPS.
  32591. */
  32592. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32593. /**
  32594. * Disposes the SPS.
  32595. */
  32596. dispose(): void;
  32597. /**
  32598. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32599. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32600. * @returns the SPS.
  32601. */
  32602. refreshVisibleSize(): SolidParticleSystem;
  32603. /**
  32604. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32605. * @param size the size (float) of the visibility box
  32606. * note : this doesn't lock the SPS mesh bounding box.
  32607. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32608. */
  32609. setVisibilityBox(size: number): void;
  32610. /**
  32611. * Gets whether the SPS as always visible or not
  32612. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32613. */
  32614. /**
  32615. * Sets the SPS as always visible or not
  32616. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32617. */
  32618. isAlwaysVisible: boolean;
  32619. /**
  32620. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32621. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32622. */
  32623. /**
  32624. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32625. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  32626. */
  32627. isVisibilityBoxLocked: boolean;
  32628. /**
  32629. * Tells to `setParticles()` to compute the particle rotations or not.
  32630. * Default value : true. The SPS is faster when it's set to false.
  32631. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32632. */
  32633. /**
  32634. * Gets if `setParticles()` computes the particle rotations or not.
  32635. * Default value : true. The SPS is faster when it's set to false.
  32636. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32637. */
  32638. computeParticleRotation: boolean;
  32639. /**
  32640. * Tells to `setParticles()` to compute the particle colors or not.
  32641. * Default value : true. The SPS is faster when it's set to false.
  32642. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32643. */
  32644. /**
  32645. * Gets if `setParticles()` computes the particle colors or not.
  32646. * Default value : true. The SPS is faster when it's set to false.
  32647. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32648. */
  32649. computeParticleColor: boolean;
  32650. /**
  32651. * Gets if `setParticles()` computes the particle textures or not.
  32652. * Default value : true. The SPS is faster when it's set to false.
  32653. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32654. */
  32655. computeParticleTexture: boolean;
  32656. /**
  32657. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32658. * Default value : false. The SPS is faster when it's set to false.
  32659. * Note : the particle custom vertex positions aren't stored values.
  32660. */
  32661. /**
  32662. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32663. * Default value : false. The SPS is faster when it's set to false.
  32664. * Note : the particle custom vertex positions aren't stored values.
  32665. */
  32666. computeParticleVertex: boolean;
  32667. /**
  32668. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32669. */
  32670. /**
  32671. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32672. */
  32673. computeBoundingBox: boolean;
  32674. /**
  32675. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32676. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32677. * Default : `true`
  32678. */
  32679. /**
  32680. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32681. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32682. * Default : `true`
  32683. */
  32684. depthSortParticles: boolean;
  32685. /**
  32686. * This function does nothing. It may be overwritten to set all the particle first values.
  32687. * The SPS doesn't call this function, you may have to call it by your own.
  32688. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32689. */
  32690. initParticles(): void;
  32691. /**
  32692. * This function does nothing. It may be overwritten to recycle a particle.
  32693. * The SPS doesn't call this function, you may have to call it by your own.
  32694. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32695. * @param particle The particle to recycle
  32696. * @returns the recycled particle
  32697. */
  32698. recycleParticle(particle: SolidParticle): SolidParticle;
  32699. /**
  32700. * Updates a particle : this function should be overwritten by the user.
  32701. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32702. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  32703. * @example : just set a particle position or velocity and recycle conditions
  32704. * @param particle The particle to update
  32705. * @returns the updated particle
  32706. */
  32707. updateParticle(particle: SolidParticle): SolidParticle;
  32708. /**
  32709. * Updates a vertex of a particle : it can be overwritten by the user.
  32710. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32711. * @param particle the current particle
  32712. * @param vertex the current index of the current particle
  32713. * @param pt the index of the current vertex in the particle shape
  32714. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  32715. * @example : just set a vertex particle position
  32716. * @returns the updated vertex
  32717. */
  32718. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  32719. /**
  32720. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32721. * This does nothing and may be overwritten by the user.
  32722. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32723. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32724. * @param update the boolean update value actually passed to setParticles()
  32725. */
  32726. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32727. /**
  32728. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32729. * This will be passed three parameters.
  32730. * This does nothing and may be overwritten by the user.
  32731. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32732. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32733. * @param update the boolean update value actually passed to setParticles()
  32734. */
  32735. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32736. }
  32737. }
  32738. declare module BABYLON {
  32739. /**
  32740. * Type of sub emitter
  32741. */
  32742. enum SubEmitterType {
  32743. /**
  32744. * Attached to the particle over it's lifetime
  32745. */
  32746. ATTACHED = 0,
  32747. /**
  32748. * Created when the particle dies
  32749. */
  32750. END = 1
  32751. }
  32752. /**
  32753. * Sub emitter class used to emit particles from an existing particle
  32754. */
  32755. class SubEmitter {
  32756. /**
  32757. * the particle system to be used by the sub emitter
  32758. */
  32759. particleSystem: ParticleSystem;
  32760. /**
  32761. * Type of the submitter (Default: END)
  32762. */
  32763. type: SubEmitterType;
  32764. /**
  32765. * 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)
  32766. * Note: This only is supported when using an emitter of type Mesh
  32767. */
  32768. inheritDirection: boolean;
  32769. /**
  32770. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  32771. */
  32772. inheritedVelocityAmount: number;
  32773. /**
  32774. * Creates a sub emitter
  32775. * @param particleSystem the particle system to be used by the sub emitter
  32776. */
  32777. constructor(
  32778. /**
  32779. * the particle system to be used by the sub emitter
  32780. */
  32781. particleSystem: ParticleSystem);
  32782. /**
  32783. * Clones the sub emitter
  32784. * @returns the cloned sub emitter
  32785. */
  32786. clone(): SubEmitter;
  32787. /**
  32788. * Serialize current object to a JSON object
  32789. * @returns the serialized object
  32790. */
  32791. serialize(): any;
  32792. /**
  32793. * Creates a new SubEmitter from a serialized JSON version
  32794. * @param serializationObject defines the JSON object to read from
  32795. * @param scene defines the hosting scene
  32796. * @param rootUrl defines the rootUrl for data loading
  32797. * @returns a new SubEmitter
  32798. */
  32799. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  32800. /** Release associated resources */
  32801. dispose(): void;
  32802. }
  32803. }
  32804. declare module BABYLON {
  32805. /**
  32806. * Interface used to describe a physics joint
  32807. */
  32808. interface PhysicsImpostorJoint {
  32809. /** Defines the main impostor to which the joint is linked */
  32810. mainImpostor: PhysicsImpostor;
  32811. /** Defines the impostor that is connected to the main impostor using this joint */
  32812. connectedImpostor: PhysicsImpostor;
  32813. /** Defines the joint itself */
  32814. joint: PhysicsJoint;
  32815. }
  32816. /** @hidden */
  32817. interface IPhysicsEnginePlugin {
  32818. world: any;
  32819. name: string;
  32820. setGravity(gravity: Vector3): void;
  32821. setTimeStep(timeStep: number): void;
  32822. getTimeStep(): number;
  32823. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32824. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32825. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32826. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32827. removePhysicsBody(impostor: PhysicsImpostor): void;
  32828. generateJoint(joint: PhysicsImpostorJoint): void;
  32829. removeJoint(joint: PhysicsImpostorJoint): void;
  32830. isSupported(): boolean;
  32831. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32832. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32833. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32834. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32835. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32836. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32837. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32838. getBodyMass(impostor: PhysicsImpostor): number;
  32839. getBodyFriction(impostor: PhysicsImpostor): number;
  32840. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32841. getBodyRestitution(impostor: PhysicsImpostor): number;
  32842. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32843. sleepBody(impostor: PhysicsImpostor): void;
  32844. wakeUpBody(impostor: PhysicsImpostor): void;
  32845. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32846. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32847. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32848. getRadius(impostor: PhysicsImpostor): number;
  32849. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32850. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32851. dispose(): void;
  32852. }
  32853. /**
  32854. * Interface used to define a physics engine
  32855. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32856. */
  32857. interface IPhysicsEngine {
  32858. /**
  32859. * Gets the gravity vector used by the simulation
  32860. */
  32861. gravity: Vector3;
  32862. /**
  32863. * Sets the gravity vector used by the simulation
  32864. * @param gravity defines the gravity vector to use
  32865. */
  32866. setGravity(gravity: Vector3): void;
  32867. /**
  32868. * Set the time step of the physics engine.
  32869. * Default is 1/60.
  32870. * To slow it down, enter 1/600 for example.
  32871. * To speed it up, 1/30
  32872. * @param newTimeStep the new timestep to apply to this world.
  32873. */
  32874. setTimeStep(newTimeStep: number): void;
  32875. /**
  32876. * Get the time step of the physics engine.
  32877. * @returns the current time step
  32878. */
  32879. getTimeStep(): number;
  32880. /**
  32881. * Release all resources
  32882. */
  32883. dispose(): void;
  32884. /**
  32885. * Gets the name of the current physics plugin
  32886. * @returns the name of the plugin
  32887. */
  32888. getPhysicsPluginName(): string;
  32889. /**
  32890. * Adding a new impostor for the impostor tracking.
  32891. * This will be done by the impostor itself.
  32892. * @param impostor the impostor to add
  32893. */
  32894. addImpostor(impostor: PhysicsImpostor): void;
  32895. /**
  32896. * Remove an impostor from the engine.
  32897. * This impostor and its mesh will not longer be updated by the physics engine.
  32898. * @param impostor the impostor to remove
  32899. */
  32900. removeImpostor(impostor: PhysicsImpostor): void;
  32901. /**
  32902. * Add a joint to the physics engine
  32903. * @param mainImpostor defines the main impostor to which the joint is added.
  32904. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32905. * @param joint defines the joint that will connect both impostors.
  32906. */
  32907. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32908. /**
  32909. * Removes a joint from the simulation
  32910. * @param mainImpostor defines the impostor used with the joint
  32911. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32912. * @param joint defines the joint to remove
  32913. */
  32914. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32915. /**
  32916. * Gets the current plugin used to run the simulation
  32917. * @returns current plugin
  32918. */
  32919. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32920. /**
  32921. * Gets the list of physic impostors
  32922. * @returns an array of PhysicsImpostor
  32923. */
  32924. getImpostors(): Array<PhysicsImpostor>;
  32925. /**
  32926. * Gets the impostor for a physics enabled object
  32927. * @param object defines the object impersonated by the impostor
  32928. * @returns the PhysicsImpostor or null if not found
  32929. */
  32930. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32931. /**
  32932. * Gets the impostor for a physics body object
  32933. * @param body defines physics body used by the impostor
  32934. * @returns the PhysicsImpostor or null if not found
  32935. */
  32936. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32937. /**
  32938. * Called by the scene. No need to call it.
  32939. * @param delta defines the timespam between frames
  32940. */
  32941. _step(delta: number): void;
  32942. }
  32943. }
  32944. declare module BABYLON {
  32945. /**
  32946. * Class used to control physics engine
  32947. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  32948. */
  32949. class PhysicsEngine implements IPhysicsEngine {
  32950. private _physicsPlugin;
  32951. /**
  32952. * Global value used to control the smallest number supported by the simulation
  32953. */
  32954. static Epsilon: number;
  32955. private _impostors;
  32956. private _joints;
  32957. /**
  32958. * Gets the gravity vector used by the simulation
  32959. */
  32960. gravity: Vector3;
  32961. /**
  32962. * Creates a new Physics Engine
  32963. * @param gravity defines the gravity vector used by the simulation
  32964. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  32965. */
  32966. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  32967. /**
  32968. * Sets the gravity vector used by the simulation
  32969. * @param gravity defines the gravity vector to use
  32970. */
  32971. setGravity(gravity: Vector3): void;
  32972. /**
  32973. * Set the time step of the physics engine.
  32974. * Default is 1/60.
  32975. * To slow it down, enter 1/600 for example.
  32976. * To speed it up, 1/30
  32977. * @param newTimeStep defines the new timestep to apply to this world.
  32978. */
  32979. setTimeStep(newTimeStep?: number): void;
  32980. /**
  32981. * Get the time step of the physics engine.
  32982. * @returns the current time step
  32983. */
  32984. getTimeStep(): number;
  32985. /**
  32986. * Release all resources
  32987. */
  32988. dispose(): void;
  32989. /**
  32990. * Gets the name of the current physics plugin
  32991. * @returns the name of the plugin
  32992. */
  32993. getPhysicsPluginName(): string;
  32994. /**
  32995. * Adding a new impostor for the impostor tracking.
  32996. * This will be done by the impostor itself.
  32997. * @param impostor the impostor to add
  32998. */
  32999. addImpostor(impostor: PhysicsImpostor): void;
  33000. /**
  33001. * Remove an impostor from the engine.
  33002. * This impostor and its mesh will not longer be updated by the physics engine.
  33003. * @param impostor the impostor to remove
  33004. */
  33005. removeImpostor(impostor: PhysicsImpostor): void;
  33006. /**
  33007. * Add a joint to the physics engine
  33008. * @param mainImpostor defines the main impostor to which the joint is added.
  33009. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33010. * @param joint defines the joint that will connect both impostors.
  33011. */
  33012. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33013. /**
  33014. * Removes a joint from the simulation
  33015. * @param mainImpostor defines the impostor used with the joint
  33016. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33017. * @param joint defines the joint to remove
  33018. */
  33019. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33020. /**
  33021. * Called by the scene. No need to call it.
  33022. * @param delta defines the timespam between frames
  33023. */
  33024. _step(delta: number): void;
  33025. /**
  33026. * Gets the current plugin used to run the simulation
  33027. * @returns current plugin
  33028. */
  33029. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33030. /**
  33031. * Gets the list of physic impostors
  33032. * @returns an array of PhysicsImpostor
  33033. */
  33034. getImpostors(): Array<PhysicsImpostor>;
  33035. /**
  33036. * Gets the impostor for a physics enabled object
  33037. * @param object defines the object impersonated by the impostor
  33038. * @returns the PhysicsImpostor or null if not found
  33039. */
  33040. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33041. /**
  33042. * Gets the impostor for a physics body object
  33043. * @param body defines physics body used by the impostor
  33044. * @returns the PhysicsImpostor or null if not found
  33045. */
  33046. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33047. }
  33048. }
  33049. declare module BABYLON {
  33050. interface Scene {
  33051. /** @hidden (Backing field) */
  33052. _physicsEngine: Nullable<IPhysicsEngine>;
  33053. /**
  33054. * Gets the current physics engine
  33055. * @returns a IPhysicsEngine or null if none attached
  33056. */
  33057. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  33058. /**
  33059. * Enables physics to the current scene
  33060. * @param gravity defines the scene's gravity for the physics engine
  33061. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  33062. * @return a boolean indicating if the physics engine was initialized
  33063. */
  33064. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  33065. /**
  33066. * Disables and disposes the physics engine associated with the scene
  33067. */
  33068. disablePhysicsEngine(): void;
  33069. /**
  33070. * Gets a boolean indicating if there is an active physics engine
  33071. * @returns a boolean indicating if there is an active physics engine
  33072. */
  33073. isPhysicsEnabled(): boolean;
  33074. /**
  33075. * Deletes a physics compound impostor
  33076. * @param compound defines the compound to delete
  33077. */
  33078. deleteCompoundImpostor(compound: any): void;
  33079. /**
  33080. * An event triggered when physic simulation is about to be run
  33081. */
  33082. onBeforePhysicsObservable: Observable<Scene>;
  33083. /**
  33084. * An event triggered when physic simulation has been done
  33085. */
  33086. onAfterPhysicsObservable: Observable<Scene>;
  33087. }
  33088. interface AbstractMesh {
  33089. /** @hidden */
  33090. _physicsImpostor: Nullable<PhysicsImpostor>;
  33091. /**
  33092. * Gets or sets impostor used for physic simulation
  33093. * @see http://doc.babylonjs.com/features/physics_engine
  33094. */
  33095. physicsImpostor: Nullable<PhysicsImpostor>;
  33096. /**
  33097. * Gets the current physics impostor
  33098. * @see http://doc.babylonjs.com/features/physics_engine
  33099. * @returns a physics impostor or null
  33100. */
  33101. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  33102. /** Apply a physic impulse to the mesh
  33103. * @param force defines the force to apply
  33104. * @param contactPoint defines where to apply the force
  33105. * @returns the current mesh
  33106. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  33107. */
  33108. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  33109. /**
  33110. * Creates a physic joint between two meshes
  33111. * @param otherMesh defines the other mesh to use
  33112. * @param pivot1 defines the pivot to use on this mesh
  33113. * @param pivot2 defines the pivot to use on the other mesh
  33114. * @param options defines additional options (can be plugin dependent)
  33115. * @returns the current mesh
  33116. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  33117. */
  33118. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  33119. /** @hidden */
  33120. _disposePhysicsObserver: Nullable<Observer<Node>>;
  33121. }
  33122. /**
  33123. * Defines the physics engine scene component responsible to manage a physics engine
  33124. */
  33125. class PhysicsEngineSceneComponent implements ISceneComponent {
  33126. /**
  33127. * The component name helpful to identify the component in the list of scene components.
  33128. */
  33129. readonly name: string;
  33130. /**
  33131. * The scene the component belongs to.
  33132. */
  33133. scene: Scene;
  33134. /**
  33135. * Creates a new instance of the component for the given scene
  33136. * @param scene Defines the scene to register the component in
  33137. */
  33138. constructor(scene: Scene);
  33139. /**
  33140. * Registers the component in a given scene
  33141. */
  33142. register(): void;
  33143. /**
  33144. * Rebuilds the elements related to this component in case of
  33145. * context lost for instance.
  33146. */
  33147. rebuild(): void;
  33148. /**
  33149. * Disposes the component and the associated ressources
  33150. */
  33151. dispose(): void;
  33152. }
  33153. }
  33154. declare module BABYLON {
  33155. /**
  33156. * A helper for physics simulations
  33157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33158. */
  33159. class PhysicsHelper {
  33160. private _scene;
  33161. private _physicsEngine;
  33162. /**
  33163. * Initializes the Physics helper
  33164. * @param scene Babylon.js scene
  33165. */
  33166. constructor(scene: Scene);
  33167. /**
  33168. * Applies a radial explosion impulse
  33169. * @param origin the origin of the explosion
  33170. * @param radius the explosion radius
  33171. * @param strength the explosion strength
  33172. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33173. * @returns A physics radial explosion event, or null
  33174. */
  33175. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33176. /**
  33177. * Applies a radial explosion force
  33178. * @param origin the origin of the explosion
  33179. * @param radius the explosion radius
  33180. * @param strength the explosion strength
  33181. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33182. * @returns A physics radial explosion event, or null
  33183. */
  33184. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  33185. /**
  33186. * Creates a gravitational field
  33187. * @param origin the origin of the explosion
  33188. * @param radius the explosion radius
  33189. * @param strength the explosion strength
  33190. * @param falloff possible options: Constant & Linear. Defaults to Constant
  33191. * @returns A physics gravitational field event, or null
  33192. */
  33193. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  33194. /**
  33195. * Creates a physics updraft event
  33196. * @param origin the origin of the updraft
  33197. * @param radius the radius of the updraft
  33198. * @param strength the strength of the updraft
  33199. * @param height the height of the updraft
  33200. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  33201. * @returns A physics updraft event, or null
  33202. */
  33203. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  33204. /**
  33205. * Creates a physics vortex event
  33206. * @param origin the of the vortex
  33207. * @param radius the radius of the vortex
  33208. * @param strength the strength of the vortex
  33209. * @param height the height of the vortex
  33210. * @returns a Physics vortex event, or null
  33211. * A physics vortex event or null
  33212. */
  33213. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  33214. }
  33215. /**
  33216. * Represents a physics radial explosion event
  33217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33218. */
  33219. class PhysicsRadialExplosionEvent {
  33220. private _scene;
  33221. private _sphere;
  33222. private _sphereOptions;
  33223. private _rays;
  33224. private _dataFetched;
  33225. /**
  33226. * Initializes a radial explosioin event
  33227. * @param scene BabylonJS scene
  33228. */
  33229. constructor(scene: Scene);
  33230. /**
  33231. * Returns the data related to the radial explosion event (sphere & rays).
  33232. * @returns The radial explosion event data
  33233. */
  33234. getData(): PhysicsRadialExplosionEventData;
  33235. /**
  33236. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  33237. * @param impostor A physics imposter
  33238. * @param origin the origin of the explosion
  33239. * @param radius the explosion radius
  33240. * @param strength the explosion strength
  33241. * @param falloff possible options: Constant & Linear
  33242. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  33243. */
  33244. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  33245. /**
  33246. * Disposes the sphere.
  33247. * @param force Specifies if the sphere should be disposed by force
  33248. */
  33249. dispose(force?: boolean): void;
  33250. /*** Helpers ***/
  33251. private _prepareSphere;
  33252. private _intersectsWithSphere;
  33253. }
  33254. /**
  33255. * Represents a gravitational field event
  33256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33257. */
  33258. class PhysicsGravitationalFieldEvent {
  33259. private _physicsHelper;
  33260. private _scene;
  33261. private _origin;
  33262. private _radius;
  33263. private _strength;
  33264. private _falloff;
  33265. private _tickCallback;
  33266. private _sphere;
  33267. private _dataFetched;
  33268. /**
  33269. * Initializes the physics gravitational field event
  33270. * @param physicsHelper A physics helper
  33271. * @param scene BabylonJS scene
  33272. * @param origin The origin position of the gravitational field event
  33273. * @param radius The radius of the gravitational field event
  33274. * @param strength The strength of the gravitational field event
  33275. * @param falloff The falloff for the gravitational field event
  33276. */
  33277. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  33278. /**
  33279. * Returns the data related to the gravitational field event (sphere).
  33280. * @returns A gravitational field event
  33281. */
  33282. getData(): PhysicsGravitationalFieldEventData;
  33283. /**
  33284. * Enables the gravitational field.
  33285. */
  33286. enable(): void;
  33287. /**
  33288. * Disables the gravitational field.
  33289. */
  33290. disable(): void;
  33291. /**
  33292. * Disposes the sphere.
  33293. * @param force The force to dispose from the gravitational field event
  33294. */
  33295. dispose(force?: boolean): void;
  33296. private _tick;
  33297. }
  33298. /**
  33299. * Represents a physics updraft event
  33300. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33301. */
  33302. class PhysicsUpdraftEvent {
  33303. private _scene;
  33304. private _origin;
  33305. private _radius;
  33306. private _strength;
  33307. private _height;
  33308. private _updraftMode;
  33309. private _physicsEngine;
  33310. private _originTop;
  33311. private _originDirection;
  33312. private _tickCallback;
  33313. private _cylinder;
  33314. private _cylinderPosition;
  33315. private _dataFetched;
  33316. /**
  33317. * Initializes the physics updraft event
  33318. * @param _scene BabylonJS scene
  33319. * @param _origin The origin position of the updraft
  33320. * @param _radius The radius of the updraft
  33321. * @param _strength The strength of the updraft
  33322. * @param _height The height of the updraft
  33323. * @param _updraftMode The mode of the updraft
  33324. */
  33325. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  33326. /**
  33327. * Returns the data related to the updraft event (cylinder).
  33328. * @returns A physics updraft event
  33329. */
  33330. getData(): PhysicsUpdraftEventData;
  33331. /**
  33332. * Enables the updraft.
  33333. */
  33334. enable(): void;
  33335. /**
  33336. * Disables the cortex.
  33337. */
  33338. disable(): void;
  33339. /**
  33340. * Disposes the sphere.
  33341. * @param force Specifies if the updraft should be disposed by force
  33342. */
  33343. dispose(force?: boolean): void;
  33344. private getImpostorForceAndContactPoint;
  33345. private _tick;
  33346. /*** Helpers ***/
  33347. private _prepareCylinder;
  33348. private _intersectsWithCylinder;
  33349. }
  33350. /**
  33351. * Represents a physics vortex event
  33352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33353. */
  33354. class PhysicsVortexEvent {
  33355. private _scene;
  33356. private _origin;
  33357. private _radius;
  33358. private _strength;
  33359. private _height;
  33360. private _physicsEngine;
  33361. private _originTop;
  33362. private _centripetalForceThreshold;
  33363. private _updraftMultiplier;
  33364. private _tickCallback;
  33365. private _cylinder;
  33366. private _cylinderPosition;
  33367. private _dataFetched;
  33368. /**
  33369. * Initializes the physics vortex event
  33370. * @param _scene The BabylonJS scene
  33371. * @param _origin The origin position of the vortex
  33372. * @param _radius The radius of the vortex
  33373. * @param _strength The strength of the vortex
  33374. * @param _height The height of the vortex
  33375. */
  33376. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  33377. /**
  33378. * Returns the data related to the vortex event (cylinder).
  33379. * @returns The physics vortex event data
  33380. */
  33381. getData(): PhysicsVortexEventData;
  33382. /**
  33383. * Enables the vortex.
  33384. */
  33385. enable(): void;
  33386. /**
  33387. * Disables the cortex.
  33388. */
  33389. disable(): void;
  33390. /**
  33391. * Disposes the sphere.
  33392. * @param force
  33393. */
  33394. dispose(force?: boolean): void;
  33395. private getImpostorForceAndContactPoint;
  33396. private _tick;
  33397. /*** Helpers ***/
  33398. private _prepareCylinder;
  33399. private _intersectsWithCylinder;
  33400. }
  33401. /**
  33402. * The strenght of the force in correspondence to the distance of the affected object
  33403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33404. */
  33405. enum PhysicsRadialImpulseFalloff {
  33406. /** Defines that impulse is constant in strength across it's whole radius */
  33407. Constant = 0,
  33408. /** DEfines that impulse gets weaker if it's further from the origin */
  33409. Linear = 1
  33410. }
  33411. /**
  33412. * The strength of the force in correspondence to the distance of the affected object
  33413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33414. */
  33415. enum PhysicsUpdraftMode {
  33416. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  33417. Center = 0,
  33418. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  33419. Perpendicular = 1
  33420. }
  33421. /**
  33422. * Interface for a physics force and contact point
  33423. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33424. */
  33425. interface PhysicsForceAndContactPoint {
  33426. /**
  33427. * The force applied at the contact point
  33428. */
  33429. force: Vector3;
  33430. /**
  33431. * The contact point
  33432. */
  33433. contactPoint: Vector3;
  33434. }
  33435. /**
  33436. * Interface for radial explosion event data
  33437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33438. */
  33439. interface PhysicsRadialExplosionEventData {
  33440. /**
  33441. * A sphere used for the radial explosion event
  33442. */
  33443. sphere: Mesh;
  33444. /**
  33445. * An array of rays for the radial explosion event
  33446. */
  33447. rays: Array<Ray>;
  33448. }
  33449. /**
  33450. * Interface for gravitational field event data
  33451. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33452. */
  33453. interface PhysicsGravitationalFieldEventData {
  33454. /**
  33455. * A sphere mesh used for the gravitational field event
  33456. */
  33457. sphere: Mesh;
  33458. }
  33459. /**
  33460. * Interface for updraft event data
  33461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33462. */
  33463. interface PhysicsUpdraftEventData {
  33464. /**
  33465. * A cylinder used for the updraft event
  33466. */
  33467. cylinder: Mesh;
  33468. }
  33469. /**
  33470. * Interface for vortex event data
  33471. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33472. */
  33473. interface PhysicsVortexEventData {
  33474. /**
  33475. * A cylinder used for the vortex event
  33476. */
  33477. cylinder: Mesh;
  33478. }
  33479. }
  33480. declare module BABYLON {
  33481. /**
  33482. * The interface for the physics imposter parameters
  33483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33484. */
  33485. interface PhysicsImpostorParameters {
  33486. /**
  33487. * The mass of the physics imposter
  33488. */
  33489. mass: number;
  33490. /**
  33491. * The friction of the physics imposter
  33492. */
  33493. friction?: number;
  33494. /**
  33495. * The coefficient of restitution of the physics imposter
  33496. */
  33497. restitution?: number;
  33498. /**
  33499. * The native options of the physics imposter
  33500. */
  33501. nativeOptions?: any;
  33502. /**
  33503. * Specifies if the parent should be ignored
  33504. */
  33505. ignoreParent?: boolean;
  33506. /**
  33507. * Specifies if bi-directional transformations should be disabled
  33508. */
  33509. disableBidirectionalTransformation?: boolean;
  33510. }
  33511. /**
  33512. * Interface for a physics-enabled object
  33513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33514. */
  33515. interface IPhysicsEnabledObject {
  33516. /**
  33517. * The position of the physics-enabled object
  33518. */
  33519. position: Vector3;
  33520. /**
  33521. * The rotation of the physics-enabled object
  33522. */
  33523. rotationQuaternion: Nullable<Quaternion>;
  33524. /**
  33525. * The scale of the physics-enabled object
  33526. */
  33527. scaling: Vector3;
  33528. /**
  33529. * The rotation of the physics-enabled object
  33530. */
  33531. rotation?: Vector3;
  33532. /**
  33533. * The parent of the physics-enabled object
  33534. */
  33535. parent?: any;
  33536. /**
  33537. * The bounding info of the physics-enabled object
  33538. * @returns The bounding info of the physics-enabled object
  33539. */
  33540. getBoundingInfo(): BoundingInfo;
  33541. /**
  33542. * Computes the world matrix
  33543. * @param force Specifies if the world matrix should be computed by force
  33544. * @returns A world matrix
  33545. */
  33546. computeWorldMatrix(force: boolean): Matrix;
  33547. /**
  33548. * Gets the world matrix
  33549. * @returns A world matrix
  33550. */
  33551. getWorldMatrix?(): Matrix;
  33552. /**
  33553. * Gets the child meshes
  33554. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33555. * @returns An array of abstract meshes
  33556. */
  33557. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33558. /**
  33559. * Gets the vertex data
  33560. * @param kind The type of vertex data
  33561. * @returns A nullable array of numbers, or a float32 array
  33562. */
  33563. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33564. /**
  33565. * Gets the indices from the mesh
  33566. * @returns A nullable array of index arrays
  33567. */
  33568. getIndices?(): Nullable<IndicesArray>;
  33569. /**
  33570. * Gets the scene from the mesh
  33571. * @returns the indices array or null
  33572. */
  33573. getScene?(): Scene;
  33574. /**
  33575. * Gets the absolute position from the mesh
  33576. * @returns the absolute position
  33577. */
  33578. getAbsolutePosition(): Vector3;
  33579. /**
  33580. * Gets the absolute pivot point from the mesh
  33581. * @returns the absolute pivot point
  33582. */
  33583. getAbsolutePivotPoint(): Vector3;
  33584. /**
  33585. * Rotates the mesh
  33586. * @param axis The axis of rotation
  33587. * @param amount The amount of rotation
  33588. * @param space The space of the rotation
  33589. * @returns The rotation transform node
  33590. */
  33591. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33592. /**
  33593. * Translates the mesh
  33594. * @param axis The axis of translation
  33595. * @param distance The distance of translation
  33596. * @param space The space of the translation
  33597. * @returns The transform node
  33598. */
  33599. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33600. /**
  33601. * Sets the absolute position of the mesh
  33602. * @param absolutePosition The absolute position of the mesh
  33603. * @returns The transform node
  33604. */
  33605. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33606. /**
  33607. * Gets the class name of the mesh
  33608. * @returns The class name
  33609. */
  33610. getClassName(): string;
  33611. }
  33612. /**
  33613. * Represents a physics imposter
  33614. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33615. */
  33616. class PhysicsImpostor {
  33617. /**
  33618. * The physics-enabled object used as the physics imposter
  33619. */
  33620. object: IPhysicsEnabledObject;
  33621. /**
  33622. * The type of the physics imposter
  33623. */
  33624. type: number;
  33625. private _options;
  33626. private _scene?;
  33627. /**
  33628. * The default object size of the imposter
  33629. */
  33630. static DEFAULT_OBJECT_SIZE: Vector3;
  33631. /**
  33632. * The identity quaternion of the imposter
  33633. */
  33634. static IDENTITY_QUATERNION: Quaternion;
  33635. private _physicsEngine;
  33636. private _physicsBody;
  33637. private _bodyUpdateRequired;
  33638. private _onBeforePhysicsStepCallbacks;
  33639. private _onAfterPhysicsStepCallbacks;
  33640. private _onPhysicsCollideCallbacks;
  33641. private _deltaPosition;
  33642. private _deltaRotation;
  33643. private _deltaRotationConjugated;
  33644. private _parent;
  33645. private _isDisposed;
  33646. private static _tmpVecs;
  33647. private static _tmpQuat;
  33648. /**
  33649. * Specifies if the physics imposter is disposed
  33650. */
  33651. readonly isDisposed: boolean;
  33652. /**
  33653. * Gets the mass of the physics imposter
  33654. */
  33655. mass: number;
  33656. /**
  33657. * Gets the coefficient of friction
  33658. */
  33659. /**
  33660. * Sets the coefficient of friction
  33661. */
  33662. friction: number;
  33663. /**
  33664. * Gets the coefficient of restitution
  33665. */
  33666. /**
  33667. * Sets the coefficient of restitution
  33668. */
  33669. restitution: number;
  33670. /**
  33671. * The unique id of the physics imposter
  33672. * set by the physics engine when adding this impostor to the array
  33673. */
  33674. uniqueId: number;
  33675. private _joints;
  33676. /**
  33677. * Initializes the physics imposter
  33678. * @param object The physics-enabled object used as the physics imposter
  33679. * @param type The type of the physics imposter
  33680. * @param _options The options for the physics imposter
  33681. * @param _scene The Babylon scene
  33682. */
  33683. constructor(
  33684. /**
  33685. * The physics-enabled object used as the physics imposter
  33686. */
  33687. object: IPhysicsEnabledObject,
  33688. /**
  33689. * The type of the physics imposter
  33690. */
  33691. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33692. /**
  33693. * This function will completly initialize this impostor.
  33694. * It will create a new body - but only if this mesh has no parent.
  33695. * If it has, this impostor will not be used other than to define the impostor
  33696. * of the child mesh.
  33697. * @hidden
  33698. */
  33699. _init(): void;
  33700. private _getPhysicsParent;
  33701. /**
  33702. * Should a new body be generated.
  33703. * @returns boolean specifying if body initialization is required
  33704. */
  33705. isBodyInitRequired(): boolean;
  33706. /**
  33707. * Sets the updated scaling
  33708. * @param updated Specifies if the scaling is updated
  33709. */
  33710. setScalingUpdated(updated: boolean): void;
  33711. /**
  33712. * Force a regeneration of this or the parent's impostor's body.
  33713. * Use under cautious - This will remove all joints already implemented.
  33714. */
  33715. forceUpdate(): void;
  33716. /**
  33717. * Gets the body that holds this impostor. Either its own, or its parent.
  33718. */
  33719. /**
  33720. * Set the physics body. Used mainly by the physics engine/plugin
  33721. */
  33722. physicsBody: any;
  33723. /**
  33724. * Get the parent of the physics imposter
  33725. * @returns Physics imposter or null
  33726. */
  33727. /**
  33728. * Sets the parent of the physics imposter
  33729. */
  33730. parent: Nullable<PhysicsImpostor>;
  33731. /**
  33732. * Resets the update flags
  33733. */
  33734. resetUpdateFlags(): void;
  33735. /**
  33736. * Gets the object extend size
  33737. * @returns the object extend size
  33738. */
  33739. getObjectExtendSize(): Vector3;
  33740. /**
  33741. * Gets the object center
  33742. * @returns The object center
  33743. */
  33744. getObjectCenter(): Vector3;
  33745. /**
  33746. * Get a specific parametes from the options parameter
  33747. * @param paramName The object parameter name
  33748. * @returns The object parameter
  33749. */
  33750. getParam(paramName: string): any;
  33751. /**
  33752. * Sets a specific parameter in the options given to the physics plugin
  33753. * @param paramName The parameter name
  33754. * @param value The value of the parameter
  33755. */
  33756. setParam(paramName: string, value: number): void;
  33757. /**
  33758. * Specifically change the body's mass option. Won't recreate the physics body object
  33759. * @param mass The mass of the physics imposter
  33760. */
  33761. setMass(mass: number): void;
  33762. /**
  33763. * Gets the linear velocity
  33764. * @returns linear velocity or null
  33765. */
  33766. getLinearVelocity(): Nullable<Vector3>;
  33767. /**
  33768. * Sets the linear velocity
  33769. * @param velocity linear velocity or null
  33770. */
  33771. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33772. /**
  33773. * Gets the angular velocity
  33774. * @returns angular velocity or null
  33775. */
  33776. getAngularVelocity(): Nullable<Vector3>;
  33777. /**
  33778. * Sets the angular velocity
  33779. * @param velocity The velocity or null
  33780. */
  33781. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33782. /**
  33783. * Execute a function with the physics plugin native code
  33784. * Provide a function the will have two variables - the world object and the physics body object
  33785. * @param func The function to execute with the physics plugin native code
  33786. */
  33787. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33788. /**
  33789. * Register a function that will be executed before the physics world is stepping forward
  33790. * @param func The function to execute before the physics world is stepped forward
  33791. */
  33792. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33793. /**
  33794. * Unregister a function that will be executed before the physics world is stepping forward
  33795. * @param func The function to execute before the physics world is stepped forward
  33796. */
  33797. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33798. /**
  33799. * Register a function that will be executed after the physics step
  33800. * @param func The function to execute after physics step
  33801. */
  33802. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33803. /**
  33804. * Unregisters a function that will be executed after the physics step
  33805. * @param func The function to execute after physics step
  33806. */
  33807. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33808. /**
  33809. * register a function that will be executed when this impostor collides against a different body
  33810. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33811. * @param func Callback that is executed on collision
  33812. */
  33813. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33814. /**
  33815. * Unregisters the physics imposter on contact
  33816. * @param collideAgainst The physics object to collide against
  33817. * @param func Callback to execute on collision
  33818. */
  33819. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33820. private _tmpQuat;
  33821. private _tmpQuat2;
  33822. /**
  33823. * Get the parent rotation
  33824. * @returns The parent rotation
  33825. */
  33826. getParentsRotation(): Quaternion;
  33827. /**
  33828. * this function is executed by the physics engine.
  33829. */
  33830. beforeStep: () => void;
  33831. /**
  33832. * this function is executed by the physics engine
  33833. */
  33834. afterStep: () => void;
  33835. /**
  33836. * Legacy collision detection event support
  33837. */
  33838. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33839. /**
  33840. * event and body object due to cannon's event-based architecture.
  33841. */
  33842. onCollide: (e: {
  33843. body: any;
  33844. }) => void;
  33845. /**
  33846. * Apply a force
  33847. * @param force The force to apply
  33848. * @param contactPoint The contact point for the force
  33849. * @returns The physics imposter
  33850. */
  33851. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33852. /**
  33853. * Apply an impulse
  33854. * @param force The impulse force
  33855. * @param contactPoint The contact point for the impulse force
  33856. * @returns The physics imposter
  33857. */
  33858. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33859. /**
  33860. * A help function to create a joint
  33861. * @param otherImpostor A physics imposter used to create a joint
  33862. * @param jointType The type of joint
  33863. * @param jointData The data for the joint
  33864. * @returns The physics imposter
  33865. */
  33866. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33867. /**
  33868. * Add a joint to this impostor with a different impostor
  33869. * @param otherImpostor A physics imposter used to add a joint
  33870. * @param joint The joint to add
  33871. * @returns The physics imposter
  33872. */
  33873. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33874. /**
  33875. * Will keep this body still, in a sleep mode.
  33876. * @returns the physics imposter
  33877. */
  33878. sleep(): PhysicsImpostor;
  33879. /**
  33880. * Wake the body up.
  33881. * @returns The physics imposter
  33882. */
  33883. wakeUp(): PhysicsImpostor;
  33884. /**
  33885. * Clones the physics imposter
  33886. * @param newObject The physics imposter clones to this physics-enabled object
  33887. * @returns A nullable physics imposter
  33888. */
  33889. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33890. /**
  33891. * Disposes the physics imposter
  33892. */
  33893. dispose(): void;
  33894. /**
  33895. * Sets the delta position
  33896. * @param position The delta position amount
  33897. */
  33898. setDeltaPosition(position: Vector3): void;
  33899. /**
  33900. * Sets the delta rotation
  33901. * @param rotation The delta rotation amount
  33902. */
  33903. setDeltaRotation(rotation: Quaternion): void;
  33904. /**
  33905. * Gets the box size of the physics imposter and stores the result in the input parameter
  33906. * @param result Stores the box size
  33907. * @returns The physics imposter
  33908. */
  33909. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33910. /**
  33911. * Gets the radius of the physics imposter
  33912. * @returns Radius of the physics imposter
  33913. */
  33914. getRadius(): number;
  33915. /**
  33916. * Sync a bone with this impostor
  33917. * @param bone The bone to sync to the impostor.
  33918. * @param boneMesh The mesh that the bone is influencing.
  33919. * @param jointPivot The pivot of the joint / bone in local space.
  33920. * @param distToJoint Optional distance from the impostor to the joint.
  33921. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33922. */
  33923. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33924. /**
  33925. * Sync impostor to a bone
  33926. * @param bone The bone that the impostor will be synced to.
  33927. * @param boneMesh The mesh that the bone is influencing.
  33928. * @param jointPivot The pivot of the joint / bone in local space.
  33929. * @param distToJoint Optional distance from the impostor to the joint.
  33930. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33931. * @param boneAxis Optional vector3 axis the bone is aligned with
  33932. */
  33933. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33934. /**
  33935. * No-Imposter type
  33936. */
  33937. static NoImpostor: number;
  33938. /**
  33939. * Sphere-Imposter type
  33940. */
  33941. static SphereImpostor: number;
  33942. /**
  33943. * Box-Imposter type
  33944. */
  33945. static BoxImpostor: number;
  33946. /**
  33947. * Plane-Imposter type
  33948. */
  33949. static PlaneImpostor: number;
  33950. /**
  33951. * Mesh-imposter type
  33952. */
  33953. static MeshImpostor: number;
  33954. /**
  33955. * Cylinder-Imposter type
  33956. */
  33957. static CylinderImpostor: number;
  33958. /**
  33959. * Particle-Imposter type
  33960. */
  33961. static ParticleImpostor: number;
  33962. /**
  33963. * Heightmap-Imposter type
  33964. */
  33965. static HeightmapImpostor: number;
  33966. }
  33967. }
  33968. declare module BABYLON {
  33969. /**
  33970. * Interface for Physics-Joint data
  33971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33972. */
  33973. interface PhysicsJointData {
  33974. /**
  33975. * The main pivot of the joint
  33976. */
  33977. mainPivot?: Vector3;
  33978. /**
  33979. * The connected pivot of the joint
  33980. */
  33981. connectedPivot?: Vector3;
  33982. /**
  33983. * The main axis of the joint
  33984. */
  33985. mainAxis?: Vector3;
  33986. /**
  33987. * The connected axis of the joint
  33988. */
  33989. connectedAxis?: Vector3;
  33990. /**
  33991. * The collision of the joint
  33992. */
  33993. collision?: boolean;
  33994. /**
  33995. * Native Oimo/Cannon/Energy data
  33996. */
  33997. nativeParams?: any;
  33998. }
  33999. /**
  34000. * This is a holder class for the physics joint created by the physics plugin
  34001. * It holds a set of functions to control the underlying joint
  34002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34003. */
  34004. class PhysicsJoint {
  34005. /**
  34006. * The type of the physics joint
  34007. */
  34008. type: number;
  34009. /**
  34010. * The data for the physics joint
  34011. */
  34012. jointData: PhysicsJointData;
  34013. private _physicsJoint;
  34014. protected _physicsPlugin: IPhysicsEnginePlugin;
  34015. /**
  34016. * Initializes the physics joint
  34017. * @param type The type of the physics joint
  34018. * @param jointData The data for the physics joint
  34019. */
  34020. constructor(
  34021. /**
  34022. * The type of the physics joint
  34023. */
  34024. type: number,
  34025. /**
  34026. * The data for the physics joint
  34027. */
  34028. jointData: PhysicsJointData);
  34029. /**
  34030. * Gets the physics joint
  34031. */
  34032. /**
  34033. * Sets the physics joint
  34034. */
  34035. physicsJoint: any;
  34036. /**
  34037. * Sets the physics plugin
  34038. */
  34039. physicsPlugin: IPhysicsEnginePlugin;
  34040. /**
  34041. * Execute a function that is physics-plugin specific.
  34042. * @param {Function} func the function that will be executed.
  34043. * It accepts two parameters: the physics world and the physics joint
  34044. */
  34045. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  34046. /**
  34047. * Distance-Joint type
  34048. */
  34049. static DistanceJoint: number;
  34050. /**
  34051. * Hinge-Joint type
  34052. */
  34053. static HingeJoint: number;
  34054. /**
  34055. * Ball-and-Socket joint type
  34056. */
  34057. static BallAndSocketJoint: number;
  34058. /**
  34059. * Wheel-Joint type
  34060. */
  34061. static WheelJoint: number;
  34062. /**
  34063. * Slider-Joint type
  34064. */
  34065. static SliderJoint: number;
  34066. /**
  34067. * Prismatic-Joint type
  34068. */
  34069. static PrismaticJoint: number;
  34070. /**
  34071. * Universal-Joint type
  34072. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  34073. */
  34074. static UniversalJoint: number;
  34075. /**
  34076. * Hinge-Joint 2 type
  34077. */
  34078. static Hinge2Joint: number;
  34079. /**
  34080. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  34081. */
  34082. static PointToPointJoint: number;
  34083. /**
  34084. * Spring-Joint type
  34085. */
  34086. static SpringJoint: number;
  34087. /**
  34088. * Lock-Joint type
  34089. */
  34090. static LockJoint: number;
  34091. }
  34092. /**
  34093. * A class representing a physics distance joint
  34094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34095. */
  34096. class DistanceJoint extends PhysicsJoint {
  34097. /**
  34098. *
  34099. * @param jointData The data for the Distance-Joint
  34100. */
  34101. constructor(jointData: DistanceJointData);
  34102. /**
  34103. * Update the predefined distance.
  34104. * @param maxDistance The maximum preferred distance
  34105. * @param minDistance The minimum preferred distance
  34106. */
  34107. updateDistance(maxDistance: number, minDistance?: number): void;
  34108. }
  34109. /**
  34110. * Represents a Motor-Enabled Joint
  34111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34112. */
  34113. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  34114. /**
  34115. * Initializes the Motor-Enabled Joint
  34116. * @param type The type of the joint
  34117. * @param jointData The physica joint data for the joint
  34118. */
  34119. constructor(type: number, jointData: PhysicsJointData);
  34120. /**
  34121. * Set the motor values.
  34122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34123. * @param force the force to apply
  34124. * @param maxForce max force for this motor.
  34125. */
  34126. setMotor(force?: number, maxForce?: number): void;
  34127. /**
  34128. * Set the motor's limits.
  34129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34130. * @param upperLimit The upper limit of the motor
  34131. * @param lowerLimit The lower limit of the motor
  34132. */
  34133. setLimit(upperLimit: number, lowerLimit?: number): void;
  34134. }
  34135. /**
  34136. * This class represents a single physics Hinge-Joint
  34137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34138. */
  34139. class HingeJoint extends MotorEnabledJoint {
  34140. /**
  34141. * Initializes the Hinge-Joint
  34142. * @param jointData The joint data for the Hinge-Joint
  34143. */
  34144. constructor(jointData: PhysicsJointData);
  34145. /**
  34146. * Set the motor values.
  34147. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34148. * @param {number} force the force to apply
  34149. * @param {number} maxForce max force for this motor.
  34150. */
  34151. setMotor(force?: number, maxForce?: number): void;
  34152. /**
  34153. * Set the motor's limits.
  34154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34155. * @param upperLimit The upper limit of the motor
  34156. * @param lowerLimit The lower limit of the motor
  34157. */
  34158. setLimit(upperLimit: number, lowerLimit?: number): void;
  34159. }
  34160. /**
  34161. * This class represents a dual hinge physics joint (same as wheel joint)
  34162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34163. */
  34164. class Hinge2Joint extends MotorEnabledJoint {
  34165. /**
  34166. * Initializes the Hinge2-Joint
  34167. * @param jointData The joint data for the Hinge2-Joint
  34168. */
  34169. constructor(jointData: PhysicsJointData);
  34170. /**
  34171. * Set the motor values.
  34172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34173. * @param {number} force the force to apply
  34174. * @param {number} maxForce max force for this motor.
  34175. * @param {motorIndex} the motor's index, 0 or 1.
  34176. */
  34177. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34178. /**
  34179. * Set the motor limits.
  34180. * Attention, this function is plugin specific. Engines won't react 100% the same.
  34181. * @param {number} upperLimit the upper limit
  34182. * @param {number} lowerLimit lower limit
  34183. * @param {motorIndex} the motor's index, 0 or 1.
  34184. */
  34185. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34186. }
  34187. /**
  34188. * Interface for a motor enabled joint
  34189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34190. */
  34191. interface IMotorEnabledJoint {
  34192. /**
  34193. * Physics joint
  34194. */
  34195. physicsJoint: any;
  34196. /**
  34197. * Sets the motor of the motor-enabled joint
  34198. * @param force The force of the motor
  34199. * @param maxForce The maximum force of the motor
  34200. * @param motorIndex The index of the motor
  34201. */
  34202. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  34203. /**
  34204. * Sets the limit of the motor
  34205. * @param upperLimit The upper limit of the motor
  34206. * @param lowerLimit The lower limit of the motor
  34207. * @param motorIndex The index of the motor
  34208. */
  34209. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  34210. }
  34211. /**
  34212. * Joint data for a Distance-Joint
  34213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34214. */
  34215. interface DistanceJointData extends PhysicsJointData {
  34216. /**
  34217. * Max distance the 2 joint objects can be apart
  34218. */
  34219. maxDistance: number;
  34220. }
  34221. /**
  34222. * Joint data from a spring joint
  34223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  34224. */
  34225. interface SpringJointData extends PhysicsJointData {
  34226. /**
  34227. * Length of the spring
  34228. */
  34229. length: number;
  34230. /**
  34231. * Stiffness of the spring
  34232. */
  34233. stiffness: number;
  34234. /**
  34235. * Damping of the spring
  34236. */
  34237. damping: number;
  34238. /** this callback will be called when applying the force to the impostors. */
  34239. forceApplicationCallback: () => void;
  34240. }
  34241. }
  34242. declare module BABYLON {
  34243. interface Scene {
  34244. /**
  34245. * The list of reflection probes added to the scene
  34246. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34247. */
  34248. reflectionProbes: Array<ReflectionProbe>;
  34249. }
  34250. /**
  34251. * Class used to generate realtime reflection / refraction cube textures
  34252. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  34253. */
  34254. class ReflectionProbe {
  34255. /** defines the name of the probe */
  34256. name: string;
  34257. private _scene;
  34258. private _renderTargetTexture;
  34259. private _projectionMatrix;
  34260. private _viewMatrix;
  34261. private _target;
  34262. private _add;
  34263. private _attachedMesh;
  34264. private _invertYAxis;
  34265. /** Gets or sets probe position (center of the cube map) */
  34266. position: Vector3;
  34267. /**
  34268. * Creates a new reflection probe
  34269. * @param name defines the name of the probe
  34270. * @param size defines the texture resolution (for each face)
  34271. * @param scene defines the hosting scene
  34272. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  34273. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  34274. */
  34275. constructor(
  34276. /** defines the name of the probe */
  34277. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  34278. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  34279. samples: number;
  34280. /** Gets or sets the refresh rate to use (on every frame by default) */
  34281. refreshRate: number;
  34282. /**
  34283. * Gets the hosting scene
  34284. * @returns a Scene
  34285. */
  34286. getScene(): Scene;
  34287. /** Gets the internal CubeTexture used to render to */
  34288. readonly cubeTexture: RenderTargetTexture;
  34289. /** Gets the list of meshes to render */
  34290. readonly renderList: Nullable<AbstractMesh[]>;
  34291. /**
  34292. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  34293. * @param mesh defines the mesh to attach to
  34294. */
  34295. attachToMesh(mesh: AbstractMesh): void;
  34296. /**
  34297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  34298. * @param renderingGroupId The rendering group id corresponding to its index
  34299. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34300. */
  34301. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  34302. /**
  34303. * Clean all associated resources
  34304. */
  34305. dispose(): void;
  34306. }
  34307. }
  34308. declare module BABYLON {
  34309. interface Scene {
  34310. /** @hidden (Backing field) */
  34311. _boundingBoxRenderer: BoundingBoxRenderer;
  34312. /** @hidden (Backing field) */
  34313. _forceShowBoundingBoxes: boolean;
  34314. /**
  34315. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  34316. */
  34317. forceShowBoundingBoxes: boolean;
  34318. /**
  34319. * Gets the bounding box renderer associated with the scene
  34320. * @returns a BoundingBoxRenderer
  34321. */
  34322. getBoundingBoxRenderer(): BoundingBoxRenderer;
  34323. }
  34324. interface AbstractMesh {
  34325. /** @hidden (Backing field) */
  34326. _showBoundingBox: boolean;
  34327. /**
  34328. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  34329. */
  34330. showBoundingBox: boolean;
  34331. }
  34332. /**
  34333. * Component responsible of rendering the bounding box of the meshes in a scene.
  34334. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  34335. */
  34336. class BoundingBoxRenderer implements ISceneComponent {
  34337. /**
  34338. * The component name helpfull to identify the component in the list of scene components.
  34339. */
  34340. readonly name: string;
  34341. /**
  34342. * The scene the component belongs to.
  34343. */
  34344. scene: Scene;
  34345. /**
  34346. * Color of the bounding box lines placed in front of an object
  34347. */
  34348. frontColor: Color3;
  34349. /**
  34350. * Color of the bounding box lines placed behind an object
  34351. */
  34352. backColor: Color3;
  34353. /**
  34354. * Defines if the renderer should show the back lines or not
  34355. */
  34356. showBackLines: boolean;
  34357. /**
  34358. * @hidden
  34359. */
  34360. renderList: SmartArray<BoundingBox>;
  34361. private _colorShader;
  34362. private _vertexBuffers;
  34363. private _indexBuffer;
  34364. /**
  34365. * Instantiates a new bounding box renderer in a scene.
  34366. * @param scene the scene the renderer renders in
  34367. */
  34368. constructor(scene: Scene);
  34369. /**
  34370. * Registers the component in a given scene
  34371. */
  34372. register(): void;
  34373. private _evaluateSubMesh;
  34374. private _activeMesh;
  34375. private _prepareRessources;
  34376. private _createIndexBuffer;
  34377. /**
  34378. * Rebuilds the elements related to this component in case of
  34379. * context lost for instance.
  34380. */
  34381. rebuild(): void;
  34382. /**
  34383. * @hidden
  34384. */
  34385. reset(): void;
  34386. /**
  34387. * Render the bounding boxes of a specific rendering group
  34388. * @param renderingGroupId defines the rendering group to render
  34389. */
  34390. render(renderingGroupId: number): void;
  34391. /**
  34392. * In case of occlusion queries, we can render the occlusion bounding box through this method
  34393. * @param mesh Define the mesh to render the occlusion bounding box for
  34394. */
  34395. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  34396. /**
  34397. * Dispose and release the resources attached to this renderer.
  34398. */
  34399. dispose(): void;
  34400. }
  34401. }
  34402. declare module BABYLON {
  34403. /**
  34404. * This represents a depth renderer in Babylon.
  34405. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  34406. */
  34407. class DepthRenderer {
  34408. private _scene;
  34409. private _depthMap;
  34410. private _effect;
  34411. private _cachedDefines;
  34412. private _camera;
  34413. /**
  34414. * Specifiess that the depth renderer will only be used within
  34415. * the camera it is created for.
  34416. * This can help forcing its rendering during the camera processing.
  34417. */
  34418. useOnlyInActiveCamera: boolean;
  34419. /**
  34420. * Instantiates a depth renderer
  34421. * @param scene The scene the renderer belongs to
  34422. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  34423. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  34424. */
  34425. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  34426. /**
  34427. * Creates the depth rendering effect and checks if the effect is ready.
  34428. * @param subMesh The submesh to be used to render the depth map of
  34429. * @param useInstances If multiple world instances should be used
  34430. * @returns if the depth renderer is ready to render the depth map
  34431. */
  34432. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34433. /**
  34434. * Gets the texture which the depth map will be written to.
  34435. * @returns The depth map texture
  34436. */
  34437. getDepthMap(): RenderTargetTexture;
  34438. /**
  34439. * Disposes of the depth renderer.
  34440. */
  34441. dispose(): void;
  34442. }
  34443. }
  34444. declare module BABYLON {
  34445. interface Scene {
  34446. /** @hidden (Backing field) */
  34447. _depthRenderer: {
  34448. [id: string]: DepthRenderer;
  34449. };
  34450. /**
  34451. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  34452. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  34453. * @returns the created depth renderer
  34454. */
  34455. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  34456. /**
  34457. * Disables a depth renderer for a given camera
  34458. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  34459. */
  34460. disableDepthRenderer(camera?: Nullable<Camera>): void;
  34461. }
  34462. /**
  34463. * Defines the Depth Renderer scene component responsible to manage a depth buffer usefull
  34464. * in several rendering techniques.
  34465. */
  34466. class DepthRendererSceneComponent implements ISceneComponent {
  34467. /**
  34468. * The component name helpfull to identify the component in the list of scene components.
  34469. */
  34470. readonly name: string;
  34471. /**
  34472. * The scene the component belongs to.
  34473. */
  34474. scene: Scene;
  34475. /**
  34476. * Creates a new instance of the component for the given scene
  34477. * @param scene Defines the scene to register the component in
  34478. */
  34479. constructor(scene: Scene);
  34480. /**
  34481. * Registers the component in a given scene
  34482. */
  34483. register(): void;
  34484. /**
  34485. * Rebuilds the elements related to this component in case of
  34486. * context lost for instance.
  34487. */
  34488. rebuild(): void;
  34489. /**
  34490. * Disposes the component and the associated ressources
  34491. */
  34492. dispose(): void;
  34493. private _gatherRenderTargets;
  34494. private _gatherActiveCameraRenderTargets;
  34495. }
  34496. }
  34497. declare module BABYLON {
  34498. interface AbstractMesh {
  34499. /**
  34500. * Disables the mesh edge rendering mode
  34501. * @returns the currentAbstractMesh
  34502. */
  34503. disableEdgesRendering(): AbstractMesh;
  34504. /**
  34505. * Enables the edge rendering mode on the mesh.
  34506. * This mode makes the mesh edges visible
  34507. * @param epsilon defines the maximal distance between two angles to detect a face
  34508. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34509. * @returns the currentAbstractMesh
  34510. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34511. */
  34512. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34513. /**
  34514. * Gets the edgesRenderer associated with the mesh
  34515. */
  34516. edgesRenderer: Nullable<EdgesRenderer>;
  34517. }
  34518. interface LinesMesh {
  34519. /**
  34520. * Enables the edge rendering mode on the mesh.
  34521. * This mode makes the mesh edges visible
  34522. * @param epsilon defines the maximal distance between two angles to detect a face
  34523. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34524. * @returns the currentAbstractMesh
  34525. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34526. */
  34527. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34528. }
  34529. interface InstancedLinesMesh {
  34530. /**
  34531. * Enables the edge rendering mode on the mesh.
  34532. * This mode makes the mesh edges visible
  34533. * @param epsilon defines the maximal distance between two angles to detect a face
  34534. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34535. * @returns the current InstancedLinesMesh
  34536. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34537. */
  34538. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  34539. }
  34540. /**
  34541. * Defines the minimum contract an Edges renderer should follow.
  34542. */
  34543. interface IEdgesRenderer extends IDisposable {
  34544. /**
  34545. * Gets or sets a boolean indicating if the edgesRenderer is active
  34546. */
  34547. isEnabled: boolean;
  34548. /**
  34549. * Renders the edges of the attached mesh,
  34550. */
  34551. render(): void;
  34552. /**
  34553. * Checks wether or not the edges renderer is ready to render.
  34554. * @return true if ready, otherwise false.
  34555. */
  34556. isReady(): boolean;
  34557. }
  34558. /**
  34559. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  34560. */
  34561. class EdgesRenderer implements IEdgesRenderer {
  34562. /**
  34563. * Define the size of the edges with an orthographic camera
  34564. */
  34565. edgesWidthScalerForOrthographic: number;
  34566. /**
  34567. * Define the size of the edges with a perspective camera
  34568. */
  34569. edgesWidthScalerForPerspective: number;
  34570. protected _source: AbstractMesh;
  34571. protected _linesPositions: number[];
  34572. protected _linesNormals: number[];
  34573. protected _linesIndices: number[];
  34574. protected _epsilon: number;
  34575. protected _indicesCount: number;
  34576. protected _lineShader: ShaderMaterial;
  34577. protected _ib: WebGLBuffer;
  34578. protected _buffers: {
  34579. [key: string]: Nullable<VertexBuffer>;
  34580. };
  34581. protected _checkVerticesInsteadOfIndices: boolean;
  34582. private _meshRebuildObserver;
  34583. private _meshDisposeObserver;
  34584. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  34585. isEnabled: boolean;
  34586. /**
  34587. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  34588. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  34589. * @param source Mesh used to create edges
  34590. * @param epsilon sum of angles in adjacency to check for edge
  34591. * @param checkVerticesInsteadOfIndices
  34592. * @param generateEdgesLines - should generate Lines or only prepare resources.
  34593. */
  34594. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  34595. protected _prepareRessources(): void;
  34596. /** @hidden */
  34597. _rebuild(): void;
  34598. /**
  34599. * Releases the required resources for the edges renderer
  34600. */
  34601. dispose(): void;
  34602. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  34603. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  34604. /**
  34605. * Checks if the pair of p0 and p1 is en edge
  34606. * @param faceIndex
  34607. * @param edge
  34608. * @param faceNormals
  34609. * @param p0
  34610. * @param p1
  34611. * @private
  34612. */
  34613. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  34614. /**
  34615. * push line into the position, normal and index buffer
  34616. * @protected
  34617. */
  34618. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  34619. /**
  34620. * Generates lines edges from adjacencjes
  34621. * @private
  34622. */
  34623. _generateEdgesLines(): void;
  34624. /**
  34625. * Checks wether or not the edges renderer is ready to render.
  34626. * @return true if ready, otherwise false.
  34627. */
  34628. isReady(): boolean;
  34629. /**
  34630. * Renders the edges of the attached mesh,
  34631. */
  34632. render(): void;
  34633. }
  34634. }
  34635. declare module BABYLON {
  34636. /**
  34637. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  34638. */
  34639. class GeometryBufferRenderer {
  34640. /**
  34641. * Constant used to retrieve the position texture index in the G-Buffer textures array
  34642. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  34643. */
  34644. static readonly POSITION_TEXTURE_TYPE: number;
  34645. /**
  34646. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  34647. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  34648. */
  34649. static readonly VELOCITY_TEXTURE_TYPE: number;
  34650. /**
  34651. * Dictionary used to store the previous transformation matrices of each rendered mesh
  34652. * in order to compute objects velocities when enableVelocity is set to "true"
  34653. * @hidden
  34654. */
  34655. _previousTransformationMatrices: {
  34656. [index: number]: Matrix;
  34657. };
  34658. private _scene;
  34659. private _multiRenderTarget;
  34660. private _ratio;
  34661. private _enablePosition;
  34662. private _enableVelocity;
  34663. private _positionIndex;
  34664. private _velocityIndex;
  34665. protected _effect: Effect;
  34666. protected _cachedDefines: string;
  34667. /**
  34668. * Set the render list (meshes to be rendered) used in the G buffer.
  34669. */
  34670. renderList: Mesh[];
  34671. /**
  34672. * Gets wether or not G buffer are supported by the running hardware.
  34673. * This requires draw buffer supports
  34674. */
  34675. readonly isSupported: boolean;
  34676. /**
  34677. * Returns the index of the given texture type in the G-Buffer textures array
  34678. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  34679. * @returns the index of the given texture type in the G-Buffer textures array
  34680. */
  34681. getTextureIndex(textureType: number): number;
  34682. /**
  34683. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  34684. */
  34685. /**
  34686. * Sets whether or not objects positions are enabled for the G buffer.
  34687. */
  34688. enablePosition: boolean;
  34689. /**
  34690. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  34691. */
  34692. /**
  34693. * Sets wether or not objects velocities are enabled for the G buffer.
  34694. */
  34695. enableVelocity: boolean;
  34696. /**
  34697. * Gets the scene associated with the buffer.
  34698. */
  34699. readonly scene: Scene;
  34700. /**
  34701. * Gets the ratio used by the buffer during its creation.
  34702. * How big is the buffer related to the main canvas.
  34703. */
  34704. readonly ratio: number;
  34705. /**
  34706. * Creates a new G Buffer for the scene
  34707. * @param scene The scene the buffer belongs to
  34708. * @param ratio How big is the buffer related to the main canvas.
  34709. */
  34710. constructor(scene: Scene, ratio?: number);
  34711. /**
  34712. * Checks wether everything is ready to render a submesh to the G buffer.
  34713. * @param subMesh the submesh to check readiness for
  34714. * @param useInstances is the mesh drawn using instance or not
  34715. * @returns true if ready otherwise false
  34716. */
  34717. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34718. /**
  34719. * Gets the current underlying G Buffer.
  34720. * @returns the buffer
  34721. */
  34722. getGBuffer(): MultiRenderTarget;
  34723. /**
  34724. * Gets the number of samples used to render the buffer (anti aliasing).
  34725. */
  34726. /**
  34727. * Sets the number of samples used to render the buffer (anti aliasing).
  34728. */
  34729. samples: number;
  34730. /**
  34731. * Disposes the renderer and frees up associated resources.
  34732. */
  34733. dispose(): void;
  34734. protected _createRenderTargets(): void;
  34735. }
  34736. }
  34737. declare module BABYLON {
  34738. interface Scene {
  34739. /** @hidden (Backing field) */
  34740. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34741. /**
  34742. * Gets or Sets the current geometry buffer associated to the scene.
  34743. */
  34744. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  34745. /**
  34746. * Enables a GeometryBufferRender and associates it with the scene
  34747. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  34748. * @returns the GeometryBufferRenderer
  34749. */
  34750. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  34751. /**
  34752. * Disables the GeometryBufferRender associated with the scene
  34753. */
  34754. disableGeometryBufferRenderer(): void;
  34755. }
  34756. /**
  34757. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  34758. * in several rendering techniques.
  34759. */
  34760. class GeometryBufferRendererSceneComponent implements ISceneComponent {
  34761. /**
  34762. * The component name helpful to identify the component in the list of scene components.
  34763. */
  34764. readonly name: string;
  34765. /**
  34766. * The scene the component belongs to.
  34767. */
  34768. scene: Scene;
  34769. /**
  34770. * Creates a new instance of the component for the given scene
  34771. * @param scene Defines the scene to register the component in
  34772. */
  34773. constructor(scene: Scene);
  34774. /**
  34775. * Registers the component in a given scene
  34776. */
  34777. register(): void;
  34778. /**
  34779. * Rebuilds the elements related to this component in case of
  34780. * context lost for instance.
  34781. */
  34782. rebuild(): void;
  34783. /**
  34784. * Disposes the component and the associated ressources
  34785. */
  34786. dispose(): void;
  34787. private _gatherRenderTargets;
  34788. }
  34789. }
  34790. declare module BABYLON {
  34791. /**
  34792. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  34793. */
  34794. class LineEdgesRenderer extends EdgesRenderer {
  34795. /**
  34796. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  34797. * @param source LineMesh used to generate edges
  34798. * @param epsilon not important (specified angle for edge detection)
  34799. * @param checkVerticesInsteadOfIndices not important for LineMesh
  34800. */
  34801. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  34802. /**
  34803. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  34804. */
  34805. _generateEdgesLines(): void;
  34806. }
  34807. }
  34808. declare module BABYLON {
  34809. interface Scene {
  34810. /** @hidden */
  34811. _outlineRenderer: OutlineRenderer;
  34812. /**
  34813. * Gets the outline renderer associated with the scene
  34814. * @returns a OutlineRenderer
  34815. */
  34816. getOutlineRenderer(): OutlineRenderer;
  34817. }
  34818. interface AbstractMesh {
  34819. /** @hidden (Backing field) */
  34820. _renderOutline: boolean;
  34821. /**
  34822. * Gets or sets a boolean indicating if the outline must be rendered as well
  34823. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  34824. */
  34825. renderOutline: boolean;
  34826. /** @hidden (Backing field) */
  34827. _renderOverlay: boolean;
  34828. /**
  34829. * Gets or sets a boolean indicating if the overlay must be rendered as well
  34830. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  34831. */
  34832. renderOverlay: boolean;
  34833. }
  34834. /**
  34835. * This class is responsible to draw bothe outline/overlay of meshes.
  34836. * It should not be used directly but through the available method on mesh.
  34837. */
  34838. class OutlineRenderer implements ISceneComponent {
  34839. /**
  34840. * The name of the component. Each component must have a unique name.
  34841. */
  34842. name: string;
  34843. /**
  34844. * The scene the component belongs to.
  34845. */
  34846. scene: Scene;
  34847. /**
  34848. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  34849. */
  34850. zOffset: number;
  34851. private _engine;
  34852. private _effect;
  34853. private _cachedDefines;
  34854. private _savedDepthWrite;
  34855. /**
  34856. * Instantiates a new outline renderer. (There could be only one per scene).
  34857. * @param scene Defines the scene it belongs to
  34858. */
  34859. constructor(scene: Scene);
  34860. /**
  34861. * Register the component to one instance of a scene.
  34862. */
  34863. register(): void;
  34864. /**
  34865. * Rebuilds the elements related to this component in case of
  34866. * context lost for instance.
  34867. */
  34868. rebuild(): void;
  34869. /**
  34870. * Disposes the component and the associated ressources.
  34871. */
  34872. dispose(): void;
  34873. /**
  34874. * Renders the outline in the canvas.
  34875. * @param subMesh Defines the sumesh to render
  34876. * @param batch Defines the batch of meshes in case of instances
  34877. * @param useOverlay Defines if the rendering is for the overlay or the outline
  34878. */
  34879. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  34880. /**
  34881. * Returns whether or not the outline renderer is ready for a given submesh.
  34882. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  34883. * @param subMesh Defines the submesh to check readyness for
  34884. * @param useInstances Defines wheter wee are trying to render instances or not
  34885. * @returns true if ready otherwise false
  34886. */
  34887. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  34888. private _beforeRenderingMesh;
  34889. private _afterRenderingMesh;
  34890. }
  34891. }
  34892. declare module BABYLON {
  34893. /**
  34894. * This represents the object necessary to create a rendering group.
  34895. * This is exclusively used and created by the rendering manager.
  34896. * To modify the behavior, you use the available helpers in your scene or meshes.
  34897. * @hidden
  34898. */
  34899. class RenderingGroup {
  34900. index: number;
  34901. private _scene;
  34902. private _opaqueSubMeshes;
  34903. private _transparentSubMeshes;
  34904. private _alphaTestSubMeshes;
  34905. private _depthOnlySubMeshes;
  34906. private _particleSystems;
  34907. private _spriteManagers;
  34908. private _opaqueSortCompareFn;
  34909. private _alphaTestSortCompareFn;
  34910. private _transparentSortCompareFn;
  34911. private _renderOpaque;
  34912. private _renderAlphaTest;
  34913. private _renderTransparent;
  34914. private _edgesRenderers;
  34915. onBeforeTransparentRendering: () => void;
  34916. /**
  34917. * Set the opaque sort comparison function.
  34918. * If null the sub meshes will be render in the order they were created
  34919. */
  34920. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34921. /**
  34922. * Set the alpha test sort comparison function.
  34923. * If null the sub meshes will be render in the order they were created
  34924. */
  34925. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34926. /**
  34927. * Set the transparent sort comparison function.
  34928. * If null the sub meshes will be render in the order they were created
  34929. */
  34930. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  34931. /**
  34932. * Creates a new rendering group.
  34933. * @param index The rendering group index
  34934. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  34935. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  34936. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  34937. */
  34938. 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>);
  34939. /**
  34940. * Render all the sub meshes contained in the group.
  34941. * @param customRenderFunction Used to override the default render behaviour of the group.
  34942. * @returns true if rendered some submeshes.
  34943. */
  34944. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  34945. /**
  34946. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  34947. * @param subMeshes The submeshes to render
  34948. */
  34949. private renderOpaqueSorted;
  34950. /**
  34951. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  34952. * @param subMeshes The submeshes to render
  34953. */
  34954. private renderAlphaTestSorted;
  34955. /**
  34956. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  34957. * @param subMeshes The submeshes to render
  34958. */
  34959. private renderTransparentSorted;
  34960. /**
  34961. * Renders the submeshes in a specified order.
  34962. * @param subMeshes The submeshes to sort before render
  34963. * @param sortCompareFn The comparison function use to sort
  34964. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  34965. * @param transparent Specifies to activate blending if true
  34966. */
  34967. private static renderSorted;
  34968. /**
  34969. * Renders the submeshes in the order they were dispatched (no sort applied).
  34970. * @param subMeshes The submeshes to render
  34971. */
  34972. private static renderUnsorted;
  34973. /**
  34974. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34975. * are rendered back to front if in the same alpha index.
  34976. *
  34977. * @param a The first submesh
  34978. * @param b The second submesh
  34979. * @returns The result of the comparison
  34980. */
  34981. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  34982. /**
  34983. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34984. * are rendered back to front.
  34985. *
  34986. * @param a The first submesh
  34987. * @param b The second submesh
  34988. * @returns The result of the comparison
  34989. */
  34990. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  34991. /**
  34992. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  34993. * are rendered front to back (prevent overdraw).
  34994. *
  34995. * @param a The first submesh
  34996. * @param b The second submesh
  34997. * @returns The result of the comparison
  34998. */
  34999. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  35000. /**
  35001. * Resets the different lists of submeshes to prepare a new frame.
  35002. */
  35003. prepare(): void;
  35004. dispose(): void;
  35005. /**
  35006. * Inserts the submesh in its correct queue depending on its material.
  35007. * @param subMesh The submesh to dispatch
  35008. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35009. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35010. */
  35011. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35012. dispatchSprites(spriteManager: ISpriteManager): void;
  35013. dispatchParticles(particleSystem: IParticleSystem): void;
  35014. private _renderParticles;
  35015. private _renderSprites;
  35016. }
  35017. }
  35018. declare module BABYLON {
  35019. /**
  35020. * Interface describing the different options available in the rendering manager
  35021. * regarding Auto Clear between groups.
  35022. */
  35023. interface IRenderingManagerAutoClearSetup {
  35024. /**
  35025. * Defines whether or not autoclear is enable.
  35026. */
  35027. autoClear: boolean;
  35028. /**
  35029. * Defines whether or not to autoclear the depth buffer.
  35030. */
  35031. depth: boolean;
  35032. /**
  35033. * Defines whether or not to autoclear the stencil buffer.
  35034. */
  35035. stencil: boolean;
  35036. }
  35037. /**
  35038. * This is the manager responsible of all the rendering for meshes sprites and particles.
  35039. * It is enable to manage the different groups as well as the different necessary sort functions.
  35040. * This should not be used directly aside of the few static configurations
  35041. */
  35042. class RenderingManager {
  35043. /**
  35044. * The max id used for rendering groups (not included)
  35045. */
  35046. static MAX_RENDERINGGROUPS: number;
  35047. /**
  35048. * The min id used for rendering groups (included)
  35049. */
  35050. static MIN_RENDERINGGROUPS: number;
  35051. /**
  35052. * Used to globally prevent autoclearing scenes.
  35053. */
  35054. static AUTOCLEAR: boolean;
  35055. /**
  35056. * @hidden
  35057. */
  35058. _useSceneAutoClearSetup: boolean;
  35059. private _scene;
  35060. private _renderingGroups;
  35061. private _depthStencilBufferAlreadyCleaned;
  35062. private _autoClearDepthStencil;
  35063. private _customOpaqueSortCompareFn;
  35064. private _customAlphaTestSortCompareFn;
  35065. private _customTransparentSortCompareFn;
  35066. private _renderingGroupInfo;
  35067. /**
  35068. * Instantiates a new rendering group for a particular scene
  35069. * @param scene Defines the scene the groups belongs to
  35070. */
  35071. constructor(scene: Scene);
  35072. private _clearDepthStencilBuffer;
  35073. /**
  35074. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  35075. * @hidden
  35076. */
  35077. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  35078. /**
  35079. * Resets the different information of the group to prepare a new frame
  35080. * @hidden
  35081. */
  35082. reset(): void;
  35083. /**
  35084. * Dispose and release the group and its associated resources.
  35085. * @hidden
  35086. */
  35087. dispose(): void;
  35088. /**
  35089. * Clear the info related to rendering groups preventing retention points during dispose.
  35090. */
  35091. freeRenderingGroups(): void;
  35092. private _prepareRenderingGroup;
  35093. /**
  35094. * Add a sprite manager to the rendering manager in order to render it this frame.
  35095. * @param spriteManager Define the sprite manager to render
  35096. */
  35097. dispatchSprites(spriteManager: ISpriteManager): void;
  35098. /**
  35099. * Add a particle system to the rendering manager in order to render it this frame.
  35100. * @param particleSystem Define the particle system to render
  35101. */
  35102. dispatchParticles(particleSystem: IParticleSystem): void;
  35103. /**
  35104. * Add a submesh to the manager in order to render it this frame
  35105. * @param subMesh The submesh to dispatch
  35106. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  35107. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  35108. */
  35109. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  35110. /**
  35111. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35112. * This allowed control for front to back rendering or reversly depending of the special needs.
  35113. *
  35114. * @param renderingGroupId The rendering group id corresponding to its index
  35115. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35116. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35117. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35118. */
  35119. 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;
  35120. /**
  35121. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35122. *
  35123. * @param renderingGroupId The rendering group id corresponding to its index
  35124. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35125. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35126. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35127. */
  35128. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35129. /**
  35130. * Gets the current auto clear configuration for one rendering group of the rendering
  35131. * manager.
  35132. * @param index the rendering group index to get the information for
  35133. * @returns The auto clear setup for the requested rendering group
  35134. */
  35135. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35136. }
  35137. }
  35138. declare module BABYLON {
  35139. /**
  35140. * Renders a layer on top of an existing scene
  35141. */
  35142. class UtilityLayerRenderer implements IDisposable {
  35143. /** the original scene that will be rendered on top of */
  35144. originalScene: Scene;
  35145. private _pointerCaptures;
  35146. private _lastPointerEvents;
  35147. private static _DefaultUtilityLayer;
  35148. private static _DefaultKeepDepthUtilityLayer;
  35149. /**
  35150. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  35151. */
  35152. pickUtilitySceneFirst: boolean;
  35153. /**
  35154. * 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)
  35155. */
  35156. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  35157. /**
  35158. * 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)
  35159. */
  35160. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  35161. /**
  35162. * The scene that is rendered on top of the original scene
  35163. */
  35164. utilityLayerScene: Scene;
  35165. /**
  35166. * If the utility layer should automatically be rendered on top of existing scene
  35167. */
  35168. shouldRender: boolean;
  35169. /**
  35170. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  35171. */
  35172. onlyCheckPointerDownEvents: boolean;
  35173. /**
  35174. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  35175. */
  35176. processAllEvents: boolean;
  35177. /**
  35178. * Observable raised when the pointer move from the utility layer scene to the main scene
  35179. */
  35180. onPointerOutObservable: Observable<number>;
  35181. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  35182. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  35183. private _afterRenderObserver;
  35184. private _sceneDisposeObserver;
  35185. private _originalPointerObserver;
  35186. /**
  35187. * Instantiates a UtilityLayerRenderer
  35188. * @param originalScene the original scene that will be rendered on top of
  35189. */
  35190. constructor(
  35191. /** the original scene that will be rendered on top of */
  35192. originalScene: Scene);
  35193. private _notifyObservers;
  35194. /**
  35195. * Renders the utility layers scene on top of the original scene
  35196. */
  35197. render(): void;
  35198. /**
  35199. * Disposes of the renderer
  35200. */
  35201. dispose(): void;
  35202. private _updateCamera;
  35203. }
  35204. }
  35205. declare module BABYLON {
  35206. /**
  35207. * Postprocess used to generate anaglyphic rendering
  35208. */
  35209. class AnaglyphPostProcess extends PostProcess {
  35210. private _passedProcess;
  35211. /**
  35212. * Creates a new AnaglyphPostProcess
  35213. * @param name defines postprocess name
  35214. * @param options defines creation options or target ratio scale
  35215. * @param rigCameras defines cameras using this postprocess
  35216. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  35217. * @param engine defines hosting engine
  35218. * @param reusable defines if the postprocess will be reused multiple times per frame
  35219. */
  35220. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  35221. }
  35222. }
  35223. declare module BABYLON {
  35224. /**
  35225. * Post process used to render in black and white
  35226. */
  35227. class BlackAndWhitePostProcess extends PostProcess {
  35228. /**
  35229. * Linear about to convert he result to black and white (default: 1)
  35230. */
  35231. degree: number;
  35232. /**
  35233. * Creates a black and white post process
  35234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  35235. * @param name The name of the effect.
  35236. * @param options The required width/height ratio to downsize to before computing the render pass.
  35237. * @param camera The camera to apply the render pass to.
  35238. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35239. * @param engine The engine which the post process will be applied. (default: current engine)
  35240. * @param reusable If the post process can be reused on the same frame. (default: false)
  35241. */
  35242. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35243. }
  35244. }
  35245. declare module BABYLON {
  35246. /**
  35247. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  35248. */
  35249. class BloomEffect extends PostProcessRenderEffect {
  35250. private bloomScale;
  35251. /**
  35252. * @hidden Internal
  35253. */
  35254. _effects: Array<PostProcess>;
  35255. /**
  35256. * @hidden Internal
  35257. */
  35258. _downscale: ExtractHighlightsPostProcess;
  35259. private _blurX;
  35260. private _blurY;
  35261. private _merge;
  35262. /**
  35263. * The luminance threshold to find bright areas of the image to bloom.
  35264. */
  35265. threshold: number;
  35266. /**
  35267. * The strength of the bloom.
  35268. */
  35269. weight: number;
  35270. /**
  35271. * Specifies the size of the bloom blur kernel, relative to the final output size
  35272. */
  35273. kernel: number;
  35274. /**
  35275. * Creates a new instance of @see BloomEffect
  35276. * @param scene The scene the effect belongs to.
  35277. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  35278. * @param bloomKernel The size of the kernel to be used when applying the blur.
  35279. * @param bloomWeight The the strength of bloom.
  35280. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35281. * @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)
  35282. */
  35283. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  35284. /**
  35285. * Disposes each of the internal effects for a given camera.
  35286. * @param camera The camera to dispose the effect on.
  35287. */
  35288. disposeEffects(camera: Camera): void;
  35289. /**
  35290. * @hidden Internal
  35291. */
  35292. _updateEffects(): void;
  35293. /**
  35294. * Internal
  35295. * @returns if all the contained post processes are ready.
  35296. * @hidden
  35297. */
  35298. _isReady(): boolean;
  35299. }
  35300. }
  35301. declare module BABYLON {
  35302. /**
  35303. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35304. */
  35305. class BloomMergePostProcess extends PostProcess {
  35306. /** Weight of the bloom to be added to the original input. */
  35307. weight: number;
  35308. /**
  35309. * Creates a new instance of @see BloomMergePostProcess
  35310. * @param name The name of the effect.
  35311. * @param originalFromInput Post process which's input will be used for the merge.
  35312. * @param blurred Blurred highlights post process which's output will be used.
  35313. * @param weight Weight of the bloom to be added to the original input.
  35314. * @param options The required width/height ratio to downsize to before computing the render pass.
  35315. * @param camera The camera to apply the render pass to.
  35316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35317. * @param engine The engine which the post process will be applied. (default: current engine)
  35318. * @param reusable If the post process can be reused on the same frame. (default: false)
  35319. * @param textureType Type of textures used when performing the post process. (default: 0)
  35320. * @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)
  35321. */
  35322. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  35323. /** Weight of the bloom to be added to the original input. */
  35324. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35325. }
  35326. }
  35327. declare module BABYLON {
  35328. /**
  35329. * The Blur Post Process which blurs an image based on a kernel and direction.
  35330. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  35331. */
  35332. class BlurPostProcess extends PostProcess {
  35333. /** The direction in which to blur the image. */
  35334. direction: Vector2;
  35335. private blockCompilation;
  35336. protected _kernel: number;
  35337. protected _idealKernel: number;
  35338. protected _packedFloat: boolean;
  35339. private _staticDefines;
  35340. /**
  35341. * Sets the length in pixels of the blur sample region
  35342. */
  35343. /**
  35344. * Gets the length in pixels of the blur sample region
  35345. */
  35346. kernel: number;
  35347. /**
  35348. * Sets wether or not the blur needs to unpack/repack floats
  35349. */
  35350. /**
  35351. * Gets wether or not the blur is unpacking/repacking floats
  35352. */
  35353. packedFloat: boolean;
  35354. /**
  35355. * Creates a new instance BlurPostProcess
  35356. * @param name The name of the effect.
  35357. * @param direction The direction in which to blur the image.
  35358. * @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.
  35359. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  35360. * @param camera The camera to apply the render pass to.
  35361. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35362. * @param engine The engine which the post process will be applied. (default: current engine)
  35363. * @param reusable If the post process can be reused on the same frame. (default: false)
  35364. * @param textureType Type of textures used when performing the post process. (default: 0)
  35365. * @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)
  35366. */
  35367. constructor(name: string,
  35368. /** The direction in which to blur the image. */
  35369. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  35370. /**
  35371. * Updates the effect with the current post process compile time values and recompiles the shader.
  35372. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35373. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35374. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35375. * @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
  35376. * @param onCompiled Called when the shader has been compiled.
  35377. * @param onError Called if there is an error when compiling a shader.
  35378. */
  35379. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35380. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35381. /**
  35382. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  35383. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  35384. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  35385. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  35386. * The gaps between physical kernels are compensated for in the weighting of the samples
  35387. * @param idealKernel Ideal blur kernel.
  35388. * @return Nearest best kernel.
  35389. */
  35390. protected _nearestBestKernel(idealKernel: number): number;
  35391. /**
  35392. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  35393. * @param x The point on the Gaussian distribution to sample.
  35394. * @return the value of the Gaussian function at x.
  35395. */
  35396. protected _gaussianWeight(x: number): number;
  35397. /**
  35398. * Generates a string that can be used as a floating point number in GLSL.
  35399. * @param x Value to print.
  35400. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  35401. * @return GLSL float string.
  35402. */
  35403. protected _glslFloat(x: number, decimalFigures?: number): string;
  35404. }
  35405. }
  35406. declare module BABYLON {
  35407. /**
  35408. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  35409. */
  35410. class ChromaticAberrationPostProcess extends PostProcess {
  35411. /**
  35412. * The amount of seperation of rgb channels (default: 30)
  35413. */
  35414. aberrationAmount: number;
  35415. /**
  35416. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  35417. */
  35418. radialIntensity: number;
  35419. /**
  35420. * 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))
  35421. */
  35422. direction: Vector2;
  35423. /**
  35424. * 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))
  35425. */
  35426. centerPosition: Vector2;
  35427. /**
  35428. * Creates a new instance ChromaticAberrationPostProcess
  35429. * @param name The name of the effect.
  35430. * @param screenWidth The width of the screen to apply the effect on.
  35431. * @param screenHeight The height of the screen to apply the effect on.
  35432. * @param options The required width/height ratio to downsize to before computing the render pass.
  35433. * @param camera The camera to apply the render pass to.
  35434. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35435. * @param engine The engine which the post process will be applied. (default: current engine)
  35436. * @param reusable If the post process can be reused on the same frame. (default: false)
  35437. * @param textureType Type of textures used when performing the post process. (default: 0)
  35438. * @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)
  35439. */
  35440. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35441. }
  35442. }
  35443. declare module BABYLON {
  35444. /**
  35445. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  35446. */
  35447. class CircleOfConfusionPostProcess extends PostProcess {
  35448. /**
  35449. * 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.
  35450. */
  35451. lensSize: number;
  35452. /**
  35453. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35454. */
  35455. fStop: number;
  35456. /**
  35457. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35458. */
  35459. focusDistance: number;
  35460. /**
  35461. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  35462. */
  35463. focalLength: number;
  35464. private _depthTexture;
  35465. /**
  35466. * Creates a new instance CircleOfConfusionPostProcess
  35467. * @param name The name of the effect.
  35468. * @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.
  35469. * @param options The required width/height ratio to downsize to before computing the render pass.
  35470. * @param camera The camera to apply the render pass to.
  35471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35472. * @param engine The engine which the post process will be applied. (default: current engine)
  35473. * @param reusable If the post process can be reused on the same frame. (default: false)
  35474. * @param textureType Type of textures used when performing the post process. (default: 0)
  35475. * @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)
  35476. */
  35477. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35478. /**
  35479. * 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.
  35480. */
  35481. depthTexture: RenderTargetTexture;
  35482. }
  35483. }
  35484. declare module BABYLON {
  35485. /**
  35486. *
  35487. * This post-process allows the modification of rendered colors by using
  35488. * a 'look-up table' (LUT). This effect is also called Color Grading.
  35489. *
  35490. * The object needs to be provided an url to a texture containing the color
  35491. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  35492. * Use an image editing software to tweak the LUT to match your needs.
  35493. *
  35494. * For an example of a color LUT, see here:
  35495. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  35496. * For explanations on color grading, see here:
  35497. * @see http://udn.epicgames.com/Three/ColorGrading.html
  35498. *
  35499. */
  35500. class ColorCorrectionPostProcess extends PostProcess {
  35501. private _colorTableTexture;
  35502. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35503. }
  35504. }
  35505. declare module BABYLON {
  35506. /**
  35507. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  35508. * input texture to perform effects such as edge detection or sharpening
  35509. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  35510. */
  35511. class ConvolutionPostProcess extends PostProcess {
  35512. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35513. kernel: number[];
  35514. /**
  35515. * Creates a new instance ConvolutionPostProcess
  35516. * @param name The name of the effect.
  35517. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  35518. * @param options The required width/height ratio to downsize to before computing the render pass.
  35519. * @param camera The camera to apply the render pass to.
  35520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35521. * @param engine The engine which the post process will be applied. (default: current engine)
  35522. * @param reusable If the post process can be reused on the same frame. (default: false)
  35523. * @param textureType Type of textures used when performing the post process. (default: 0)
  35524. */
  35525. constructor(name: string,
  35526. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  35527. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35528. /**
  35529. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35530. */
  35531. static EdgeDetect0Kernel: number[];
  35532. /**
  35533. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35534. */
  35535. static EdgeDetect1Kernel: number[];
  35536. /**
  35537. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35538. */
  35539. static EdgeDetect2Kernel: number[];
  35540. /**
  35541. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35542. */
  35543. static SharpenKernel: number[];
  35544. /**
  35545. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35546. */
  35547. static EmbossKernel: number[];
  35548. /**
  35549. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  35550. */
  35551. static GaussianKernel: number[];
  35552. }
  35553. }
  35554. declare module BABYLON {
  35555. /**
  35556. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  35557. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  35558. * based on samples that have a large difference in distance than the center pixel.
  35559. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  35560. */
  35561. class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  35562. direction: Vector2;
  35563. /**
  35564. * Creates a new instance CircleOfConfusionPostProcess
  35565. * @param name The name of the effect.
  35566. * @param scene The scene the effect belongs to.
  35567. * @param direction The direction the blur should be applied.
  35568. * @param kernel The size of the kernel used to blur.
  35569. * @param options The required width/height ratio to downsize to before computing the render pass.
  35570. * @param camera The camera to apply the render pass to.
  35571. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  35572. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  35573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35574. * @param engine The engine which the post process will be applied. (default: current engine)
  35575. * @param reusable If the post process can be reused on the same frame. (default: false)
  35576. * @param textureType Type of textures used when performing the post process. (default: 0)
  35577. * @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)
  35578. */
  35579. 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);
  35580. }
  35581. }
  35582. declare module BABYLON {
  35583. /**
  35584. * Specifies the level of max blur that should be applied when using the depth of field effect
  35585. */
  35586. enum DepthOfFieldEffectBlurLevel {
  35587. /**
  35588. * Subtle blur
  35589. */
  35590. Low = 0,
  35591. /**
  35592. * Medium blur
  35593. */
  35594. Medium = 1,
  35595. /**
  35596. * Large blur
  35597. */
  35598. High = 2
  35599. }
  35600. /**
  35601. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  35602. */
  35603. class DepthOfFieldEffect extends PostProcessRenderEffect {
  35604. private _circleOfConfusion;
  35605. /**
  35606. * @hidden Internal, blurs from high to low
  35607. */
  35608. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  35609. private _depthOfFieldBlurY;
  35610. private _dofMerge;
  35611. /**
  35612. * @hidden Internal post processes in depth of field effect
  35613. */
  35614. _effects: Array<PostProcess>;
  35615. /**
  35616. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  35617. */
  35618. focalLength: number;
  35619. /**
  35620. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  35621. */
  35622. fStop: number;
  35623. /**
  35624. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  35625. */
  35626. focusDistance: number;
  35627. /**
  35628. * 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.
  35629. */
  35630. lensSize: number;
  35631. /**
  35632. * Creates a new instance DepthOfFieldEffect
  35633. * @param scene The scene the effect belongs to.
  35634. * @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.
  35635. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  35636. * @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)
  35637. */
  35638. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  35639. /**
  35640. * 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.
  35641. */
  35642. depthTexture: RenderTargetTexture;
  35643. /**
  35644. * Disposes each of the internal effects for a given camera.
  35645. * @param camera The camera to dispose the effect on.
  35646. */
  35647. disposeEffects(camera: Camera): void;
  35648. /**
  35649. * @hidden Internal
  35650. */
  35651. _updateEffects(): void;
  35652. /**
  35653. * Internal
  35654. * @returns if all the contained post processes are ready.
  35655. * @hidden
  35656. */
  35657. _isReady(): boolean;
  35658. }
  35659. }
  35660. declare module BABYLON {
  35661. /**
  35662. * Options to be set when merging outputs from the default pipeline.
  35663. */
  35664. class DepthOfFieldMergePostProcessOptions {
  35665. /**
  35666. * The original image to merge on top of
  35667. */
  35668. originalFromInput: PostProcess;
  35669. /**
  35670. * Parameters to perform the merge of the depth of field effect
  35671. */
  35672. depthOfField?: {
  35673. circleOfConfusion: PostProcess;
  35674. blurSteps: Array<PostProcess>;
  35675. };
  35676. /**
  35677. * Parameters to perform the merge of bloom effect
  35678. */
  35679. bloom?: {
  35680. blurred: PostProcess;
  35681. weight: number;
  35682. };
  35683. }
  35684. /**
  35685. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  35686. */
  35687. class DepthOfFieldMergePostProcess extends PostProcess {
  35688. private blurSteps;
  35689. /**
  35690. * Creates a new instance of DepthOfFieldMergePostProcess
  35691. * @param name The name of the effect.
  35692. * @param originalFromInput Post process which's input will be used for the merge.
  35693. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  35694. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  35695. * @param options The required width/height ratio to downsize to before computing the render pass.
  35696. * @param camera The camera to apply the render pass to.
  35697. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35698. * @param engine The engine which the post process will be applied. (default: current engine)
  35699. * @param reusable If the post process can be reused on the same frame. (default: false)
  35700. * @param textureType Type of textures used when performing the post process. (default: 0)
  35701. * @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)
  35702. */
  35703. 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);
  35704. /**
  35705. * Updates the effect with the current post process compile time values and recompiles the shader.
  35706. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  35707. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  35708. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  35709. * @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
  35710. * @param onCompiled Called when the shader has been compiled.
  35711. * @param onError Called if there is an error when compiling a shader.
  35712. */
  35713. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  35714. }
  35715. }
  35716. declare module BABYLON {
  35717. /**
  35718. * DisplayPassPostProcess which produces an output the same as it's input
  35719. */
  35720. class DisplayPassPostProcess extends PostProcess {
  35721. /**
  35722. * Creates the DisplayPassPostProcess
  35723. * @param name The name of the effect.
  35724. * @param options The required width/height ratio to downsize to before computing the render pass.
  35725. * @param camera The camera to apply the render pass to.
  35726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35727. * @param engine The engine which the post process will be applied. (default: current engine)
  35728. * @param reusable If the post process can be reused on the same frame. (default: false)
  35729. */
  35730. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35731. }
  35732. }
  35733. declare module BABYLON {
  35734. /**
  35735. * 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.
  35736. */
  35737. class ExtractHighlightsPostProcess extends PostProcess {
  35738. /**
  35739. * The luminance threshold, pixels below this value will be set to black.
  35740. */
  35741. threshold: number;
  35742. /** @hidden */
  35743. _exposure: number;
  35744. /**
  35745. * Post process which has the input texture to be used when performing highlight extraction
  35746. * @hidden
  35747. */
  35748. _inputPostProcess: Nullable<PostProcess>;
  35749. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35750. }
  35751. }
  35752. declare module BABYLON {
  35753. /**
  35754. * Applies a kernel filter to the image
  35755. */
  35756. class FilterPostProcess extends PostProcess {
  35757. /** The matrix to be applied to the image */
  35758. kernelMatrix: Matrix;
  35759. /**
  35760. *
  35761. * @param name The name of the effect.
  35762. * @param kernelMatrix The matrix to be applied to the image
  35763. * @param options The required width/height ratio to downsize to before computing the render pass.
  35764. * @param camera The camera to apply the render pass to.
  35765. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35766. * @param engine The engine which the post process will be applied. (default: current engine)
  35767. * @param reusable If the post process can be reused on the same frame. (default: false)
  35768. */
  35769. constructor(name: string,
  35770. /** The matrix to be applied to the image */
  35771. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  35772. }
  35773. }
  35774. declare module BABYLON {
  35775. /**
  35776. * Fxaa post process
  35777. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  35778. */
  35779. class FxaaPostProcess extends PostProcess {
  35780. /** @hidden */
  35781. texelWidth: number;
  35782. /** @hidden */
  35783. texelHeight: number;
  35784. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35785. private _getDefines;
  35786. }
  35787. }
  35788. declare module BABYLON {
  35789. /**
  35790. * The GrainPostProcess adds noise to the image at mid luminance levels
  35791. */
  35792. class GrainPostProcess extends PostProcess {
  35793. /**
  35794. * The intensity of the grain added (default: 30)
  35795. */
  35796. intensity: number;
  35797. /**
  35798. * If the grain should be randomized on every frame
  35799. */
  35800. animated: boolean;
  35801. /**
  35802. * Creates a new instance of @see GrainPostProcess
  35803. * @param name The name of the effect.
  35804. * @param options The required width/height ratio to downsize to before computing the render pass.
  35805. * @param camera The camera to apply the render pass to.
  35806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35807. * @param engine The engine which the post process will be applied. (default: current engine)
  35808. * @param reusable If the post process can be reused on the same frame. (default: false)
  35809. * @param textureType Type of textures used when performing the post process. (default: 0)
  35810. * @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)
  35811. */
  35812. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  35813. }
  35814. }
  35815. declare module BABYLON {
  35816. /**
  35817. * Extracts highlights from the image
  35818. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35819. */
  35820. class HighlightsPostProcess extends PostProcess {
  35821. /**
  35822. * Extracts highlights from the image
  35823. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  35824. * @param name The name of the effect.
  35825. * @param options The required width/height ratio to downsize to before computing the render pass.
  35826. * @param camera The camera to apply the render pass to.
  35827. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  35828. * @param engine The engine which the post process will be applied. (default: current engine)
  35829. * @param reusable If the post process can be reused on the same frame. (default: false)
  35830. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  35831. */
  35832. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  35833. }
  35834. }
  35835. declare module BABYLON {
  35836. /**
  35837. * ImageProcessingPostProcess
  35838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  35839. */
  35840. class ImageProcessingPostProcess extends PostProcess {
  35841. /**
  35842. * Default configuration related to image processing available in the PBR Material.
  35843. */
  35844. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35845. /**
  35846. * Gets the image processing configuration used either in this material.
  35847. */
  35848. /**
  35849. * Sets the Default image processing configuration used either in the this material.
  35850. *
  35851. * If sets to null, the scene one is in use.
  35852. */
  35853. imageProcessingConfiguration: ImageProcessingConfiguration;
  35854. /**
  35855. * Keep track of the image processing observer to allow dispose and replace.
  35856. */
  35857. private _imageProcessingObserver;
  35858. /**
  35859. * Attaches a new image processing configuration to the PBR Material.
  35860. * @param configuration
  35861. */
  35862. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  35863. /**
  35864. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35865. */
  35866. /**
  35867. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  35868. */
  35869. colorCurves: Nullable<ColorCurves>;
  35870. /**
  35871. * Gets wether the color curves effect is enabled.
  35872. */
  35873. /**
  35874. * Sets wether the color curves effect is enabled.
  35875. */
  35876. colorCurvesEnabled: boolean;
  35877. /**
  35878. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35879. */
  35880. /**
  35881. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  35882. */
  35883. colorGradingTexture: Nullable<BaseTexture>;
  35884. /**
  35885. * Gets wether the color grading effect is enabled.
  35886. */
  35887. /**
  35888. * Gets wether the color grading effect is enabled.
  35889. */
  35890. colorGradingEnabled: boolean;
  35891. /**
  35892. * Gets exposure used in the effect.
  35893. */
  35894. /**
  35895. * Sets exposure used in the effect.
  35896. */
  35897. exposure: number;
  35898. /**
  35899. * Gets wether tonemapping is enabled or not.
  35900. */
  35901. /**
  35902. * Sets wether tonemapping is enabled or not
  35903. */
  35904. toneMappingEnabled: boolean;
  35905. /**
  35906. * Gets contrast used in the effect.
  35907. */
  35908. /**
  35909. * Sets contrast used in the effect.
  35910. */
  35911. contrast: number;
  35912. /**
  35913. * Gets Vignette stretch size.
  35914. */
  35915. /**
  35916. * Sets Vignette stretch size.
  35917. */
  35918. vignetteStretch: number;
  35919. /**
  35920. * Gets Vignette centre X Offset.
  35921. */
  35922. /**
  35923. * Sets Vignette centre X Offset.
  35924. */
  35925. vignetteCentreX: number;
  35926. /**
  35927. * Gets Vignette centre Y Offset.
  35928. */
  35929. /**
  35930. * Sets Vignette centre Y Offset.
  35931. */
  35932. vignetteCentreY: number;
  35933. /**
  35934. * Gets Vignette weight or intensity of the vignette effect.
  35935. */
  35936. /**
  35937. * Sets Vignette weight or intensity of the vignette effect.
  35938. */
  35939. vignetteWeight: number;
  35940. /**
  35941. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35942. * if vignetteEnabled is set to true.
  35943. */
  35944. /**
  35945. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  35946. * if vignetteEnabled is set to true.
  35947. */
  35948. vignetteColor: Color4;
  35949. /**
  35950. * Gets Camera field of view used by the Vignette effect.
  35951. */
  35952. /**
  35953. * Sets Camera field of view used by the Vignette effect.
  35954. */
  35955. vignetteCameraFov: number;
  35956. /**
  35957. * Gets the vignette blend mode allowing different kind of effect.
  35958. */
  35959. /**
  35960. * Sets the vignette blend mode allowing different kind of effect.
  35961. */
  35962. vignetteBlendMode: number;
  35963. /**
  35964. * Gets wether the vignette effect is enabled.
  35965. */
  35966. /**
  35967. * Sets wether the vignette effect is enabled.
  35968. */
  35969. vignetteEnabled: boolean;
  35970. private _fromLinearSpace;
  35971. /**
  35972. * Gets wether the input of the processing is in Gamma or Linear Space.
  35973. */
  35974. /**
  35975. * Sets wether the input of the processing is in Gamma or Linear Space.
  35976. */
  35977. fromLinearSpace: boolean;
  35978. /**
  35979. * Defines cache preventing GC.
  35980. */
  35981. private _defines;
  35982. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  35983. /**
  35984. * "ImageProcessingPostProcess"
  35985. * @returns "ImageProcessingPostProcess"
  35986. */
  35987. getClassName(): string;
  35988. protected _updateParameters(): void;
  35989. dispose(camera?: Camera): void;
  35990. }
  35991. }
  35992. declare module BABYLON {
  35993. /**
  35994. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  35995. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  35996. * As an example, all you have to do is to create the post-process:
  35997. * var mb = new BABYLON.MotionBlurPostProcess(
  35998. * 'mb', // The name of the effect.
  35999. * scene, // The scene containing the objects to blur according to their velocity.
  36000. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  36001. * camera // The camera to apply the render pass to.
  36002. * );
  36003. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  36004. */
  36005. class MotionBlurPostProcess extends PostProcess {
  36006. /**
  36007. * Defines how much the image is blurred by the movement. Default value is equal to 1
  36008. */
  36009. motionStrength: number;
  36010. /**
  36011. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  36012. */
  36013. /**
  36014. * Sets the number of iterations to be used for motion blur quality
  36015. */
  36016. motionBlurSamples: number;
  36017. private _motionBlurSamples;
  36018. private _geometryBufferRenderer;
  36019. /**
  36020. * Creates a new instance MotionBlurPostProcess
  36021. * @param name The name of the effect.
  36022. * @param scene The scene containing the objects to blur according to their velocity.
  36023. * @param options The required width/height ratio to downsize to before computing the render pass.
  36024. * @param camera The camera to apply the render pass to.
  36025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36026. * @param engine The engine which the post process will be applied. (default: current engine)
  36027. * @param reusable If the post process can be reused on the same frame. (default: false)
  36028. * @param textureType Type of textures used when performing the post process. (default: 0)
  36029. * @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)
  36030. */
  36031. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36032. /**
  36033. * Disposes the post process.
  36034. * @param camera The camera to dispose the post process on.
  36035. */
  36036. dispose(camera?: Camera): void;
  36037. }
  36038. }
  36039. declare module BABYLON {
  36040. /**
  36041. * PassPostProcess which produces an output the same as it's input
  36042. */
  36043. class PassPostProcess extends PostProcess {
  36044. /**
  36045. * Creates the PassPostProcess
  36046. * @param name The name of the effect.
  36047. * @param options The required width/height ratio to downsize to before computing the render pass.
  36048. * @param camera The camera to apply the render pass to.
  36049. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36050. * @param engine The engine which the post process will be applied. (default: current engine)
  36051. * @param reusable If the post process can be reused on the same frame. (default: false)
  36052. * @param textureType The type of texture to be used when performing the post processing.
  36053. * @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)
  36054. */
  36055. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36056. }
  36057. /**
  36058. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36059. */
  36060. class PassCubePostProcess extends PostProcess {
  36061. private _face;
  36062. /**
  36063. * Gets or sets the cube face to display.
  36064. * * 0 is +X
  36065. * * 1 is -X
  36066. * * 2 is +Y
  36067. * * 3 is -Y
  36068. * * 4 is +Z
  36069. * * 5 is -Z
  36070. */
  36071. face: number;
  36072. /**
  36073. * Creates the PassCubePostProcess
  36074. * @param name The name of the effect.
  36075. * @param options The required width/height ratio to downsize to before computing the render pass.
  36076. * @param camera The camera to apply the render pass to.
  36077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36078. * @param engine The engine which the post process will be applied. (default: current engine)
  36079. * @param reusable If the post process can be reused on the same frame. (default: false)
  36080. * @param textureType The type of texture to be used when performing the post processing.
  36081. * @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)
  36082. */
  36083. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36084. }
  36085. }
  36086. declare module BABYLON {
  36087. /**
  36088. * Size options for a post process
  36089. */
  36090. type PostProcessOptions = {
  36091. width: number;
  36092. height: number;
  36093. };
  36094. /**
  36095. * PostProcess can be used to apply a shader to a texture after it has been rendered
  36096. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36097. */
  36098. class PostProcess {
  36099. /** Name of the PostProcess. */
  36100. name: string;
  36101. /**
  36102. * Width of the texture to apply the post process on
  36103. */
  36104. width: number;
  36105. /**
  36106. * Height of the texture to apply the post process on
  36107. */
  36108. height: number;
  36109. /**
  36110. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  36111. * @hidden
  36112. */
  36113. _outputTexture: Nullable<InternalTexture>;
  36114. /**
  36115. * Sampling mode used by the shader
  36116. * See https://doc.babylonjs.com/classes/3.1/texture
  36117. */
  36118. renderTargetSamplingMode: number;
  36119. /**
  36120. * Clear color to use when screen clearing
  36121. */
  36122. clearColor: Color4;
  36123. /**
  36124. * If the buffer needs to be cleared before applying the post process. (default: true)
  36125. * Should be set to false if shader will overwrite all previous pixels.
  36126. */
  36127. autoClear: boolean;
  36128. /**
  36129. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  36130. */
  36131. alphaMode: number;
  36132. /**
  36133. * Sets the setAlphaBlendConstants of the babylon engine
  36134. */
  36135. alphaConstants: Color4;
  36136. /**
  36137. * Animations to be used for the post processing
  36138. */
  36139. animations: Animation[];
  36140. /**
  36141. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  36142. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  36143. */
  36144. enablePixelPerfectMode: boolean;
  36145. /**
  36146. * Force the postprocess to be applied without taking in account viewport
  36147. */
  36148. forceFullscreenViewport: boolean;
  36149. /**
  36150. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  36151. *
  36152. * | Value | Type | Description |
  36153. * | ----- | ----------------------------------- | ----------- |
  36154. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  36155. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  36156. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  36157. *
  36158. */
  36159. scaleMode: number;
  36160. /**
  36161. * Force textures to be a power of two (default: false)
  36162. */
  36163. alwaysForcePOT: boolean;
  36164. private _samples;
  36165. /**
  36166. * Number of sample textures (default: 1)
  36167. */
  36168. samples: number;
  36169. /**
  36170. * Modify the scale of the post process to be the same as the viewport (default: false)
  36171. */
  36172. adaptScaleToCurrentViewport: boolean;
  36173. private _camera;
  36174. private _scene;
  36175. private _engine;
  36176. private _options;
  36177. private _reusable;
  36178. private _textureType;
  36179. /**
  36180. * Smart array of input and output textures for the post process.
  36181. * @hidden
  36182. */
  36183. _textures: SmartArray<InternalTexture>;
  36184. /**
  36185. * The index in _textures that corresponds to the output texture.
  36186. * @hidden
  36187. */
  36188. _currentRenderTextureInd: number;
  36189. private _effect;
  36190. private _samplers;
  36191. private _fragmentUrl;
  36192. private _vertexUrl;
  36193. private _parameters;
  36194. private _scaleRatio;
  36195. protected _indexParameters: any;
  36196. private _shareOutputWithPostProcess;
  36197. private _texelSize;
  36198. private _forcedOutputTexture;
  36199. /**
  36200. * An event triggered when the postprocess is activated.
  36201. */
  36202. onActivateObservable: Observable<Camera>;
  36203. private _onActivateObserver;
  36204. /**
  36205. * A function that is added to the onActivateObservable
  36206. */
  36207. onActivate: Nullable<(camera: Camera) => void>;
  36208. /**
  36209. * An event triggered when the postprocess changes its size.
  36210. */
  36211. onSizeChangedObservable: Observable<PostProcess>;
  36212. private _onSizeChangedObserver;
  36213. /**
  36214. * A function that is added to the onSizeChangedObservable
  36215. */
  36216. onSizeChanged: (postProcess: PostProcess) => void;
  36217. /**
  36218. * An event triggered when the postprocess applies its effect.
  36219. */
  36220. onApplyObservable: Observable<Effect>;
  36221. private _onApplyObserver;
  36222. /**
  36223. * A function that is added to the onApplyObservable
  36224. */
  36225. onApply: (effect: Effect) => void;
  36226. /**
  36227. * An event triggered before rendering the postprocess
  36228. */
  36229. onBeforeRenderObservable: Observable<Effect>;
  36230. private _onBeforeRenderObserver;
  36231. /**
  36232. * A function that is added to the onBeforeRenderObservable
  36233. */
  36234. onBeforeRender: (effect: Effect) => void;
  36235. /**
  36236. * An event triggered after rendering the postprocess
  36237. */
  36238. onAfterRenderObservable: Observable<Effect>;
  36239. private _onAfterRenderObserver;
  36240. /**
  36241. * A function that is added to the onAfterRenderObservable
  36242. */
  36243. onAfterRender: (efect: Effect) => void;
  36244. /**
  36245. * 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
  36246. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  36247. */
  36248. inputTexture: InternalTexture;
  36249. /**
  36250. * Gets the camera which post process is applied to.
  36251. * @returns The camera the post process is applied to.
  36252. */
  36253. getCamera(): Camera;
  36254. /**
  36255. * Gets the texel size of the postprocess.
  36256. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  36257. */
  36258. readonly texelSize: Vector2;
  36259. /**
  36260. * Creates a new instance PostProcess
  36261. * @param name The name of the PostProcess.
  36262. * @param fragmentUrl The url of the fragment shader to be used.
  36263. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  36264. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  36265. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  36266. * @param camera The camera to apply the render pass to.
  36267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36268. * @param engine The engine which the post process will be applied. (default: current engine)
  36269. * @param reusable If the post process can be reused on the same frame. (default: false)
  36270. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  36271. * @param textureType Type of textures used when performing the post process. (default: 0)
  36272. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  36273. * @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
  36274. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  36275. */
  36276. constructor(
  36277. /** Name of the PostProcess. */
  36278. 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);
  36279. /**
  36280. * Gets the engine which this post process belongs to.
  36281. * @returns The engine the post process was enabled with.
  36282. */
  36283. getEngine(): Engine;
  36284. /**
  36285. * The effect that is created when initializing the post process.
  36286. * @returns The created effect corrisponding the the postprocess.
  36287. */
  36288. getEffect(): Effect;
  36289. /**
  36290. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  36291. * @param postProcess The post process to share the output with.
  36292. * @returns This post process.
  36293. */
  36294. shareOutputWith(postProcess: PostProcess): PostProcess;
  36295. /**
  36296. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  36297. * This should be called if the post process that shares output with this post process is disabled/disposed.
  36298. */
  36299. useOwnOutput(): void;
  36300. /**
  36301. * Updates the effect with the current post process compile time values and recompiles the shader.
  36302. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  36303. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  36304. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  36305. * @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
  36306. * @param onCompiled Called when the shader has been compiled.
  36307. * @param onError Called if there is an error when compiling a shader.
  36308. */
  36309. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  36310. /**
  36311. * The post process is reusable if it can be used multiple times within one frame.
  36312. * @returns If the post process is reusable
  36313. */
  36314. isReusable(): boolean;
  36315. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  36316. markTextureDirty(): void;
  36317. /**
  36318. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  36319. * 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.
  36320. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  36321. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  36322. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  36323. * @returns The target texture that was bound to be written to.
  36324. */
  36325. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  36326. /**
  36327. * If the post process is supported.
  36328. */
  36329. readonly isSupported: boolean;
  36330. /**
  36331. * The aspect ratio of the output texture.
  36332. */
  36333. readonly aspectRatio: number;
  36334. /**
  36335. * Get a value indicating if the post-process is ready to be used
  36336. * @returns true if the post-process is ready (shader is compiled)
  36337. */
  36338. isReady(): boolean;
  36339. /**
  36340. * Binds all textures and uniforms to the shader, this will be run on every pass.
  36341. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  36342. */
  36343. apply(): Nullable<Effect>;
  36344. private _disposeTextures;
  36345. /**
  36346. * Disposes the post process.
  36347. * @param camera The camera to dispose the post process on.
  36348. */
  36349. dispose(camera?: Camera): void;
  36350. }
  36351. }
  36352. declare module BABYLON {
  36353. /**
  36354. * PostProcessManager is used to manage one or more post processes or post process pipelines
  36355. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  36356. */
  36357. class PostProcessManager {
  36358. private _scene;
  36359. private _indexBuffer;
  36360. private _vertexBuffers;
  36361. /**
  36362. * Creates a new instance PostProcess
  36363. * @param scene The scene that the post process is associated with.
  36364. */
  36365. constructor(scene: Scene);
  36366. private _prepareBuffers;
  36367. private _buildIndexBuffer;
  36368. /**
  36369. * Rebuilds the vertex buffers of the manager.
  36370. * @hidden
  36371. */
  36372. _rebuild(): void;
  36373. /**
  36374. * Prepares a frame to be run through a post process.
  36375. * @param sourceTexture The input texture to the post procesess. (default: null)
  36376. * @param postProcesses An array of post processes to be run. (default: null)
  36377. * @returns True if the post processes were able to be run.
  36378. * @hidden
  36379. */
  36380. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  36381. /**
  36382. * Manually render a set of post processes to a texture.
  36383. * @param postProcesses An array of post processes to be run.
  36384. * @param targetTexture The target texture to render to.
  36385. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  36386. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  36387. * @param lodLevel defines which lod of the texture to render to
  36388. */
  36389. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  36390. /**
  36391. * Finalize the result of the output of the postprocesses.
  36392. * @param doNotPresent If true the result will not be displayed to the screen.
  36393. * @param targetTexture The target texture to render to.
  36394. * @param faceIndex The index of the face to bind the target texture to.
  36395. * @param postProcesses The array of post processes to render.
  36396. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  36397. * @hidden
  36398. */
  36399. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  36400. /**
  36401. * Disposes of the post process manager.
  36402. */
  36403. dispose(): void;
  36404. }
  36405. }
  36406. declare module BABYLON {
  36407. /**
  36408. * Post process which applies a refractin texture
  36409. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36410. */
  36411. class RefractionPostProcess extends PostProcess {
  36412. /** the base color of the refraction (used to taint the rendering) */
  36413. color: Color3;
  36414. /** simulated refraction depth */
  36415. depth: number;
  36416. /** the coefficient of the base color (0 to remove base color tainting) */
  36417. colorLevel: number;
  36418. private _refTexture;
  36419. private _ownRefractionTexture;
  36420. /**
  36421. * Gets or sets the refraction texture
  36422. * Please note that you are responsible for disposing the texture if you set it manually
  36423. */
  36424. refractionTexture: Texture;
  36425. /**
  36426. * Initializes the RefractionPostProcess
  36427. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  36428. * @param name The name of the effect.
  36429. * @param refractionTextureUrl Url of the refraction texture to use
  36430. * @param color the base color of the refraction (used to taint the rendering)
  36431. * @param depth simulated refraction depth
  36432. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  36433. * @param camera The camera to apply the render pass to.
  36434. * @param options The required width/height ratio to downsize to before computing the render pass.
  36435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36436. * @param engine The engine which the post process will be applied. (default: current engine)
  36437. * @param reusable If the post process can be reused on the same frame. (default: false)
  36438. */
  36439. constructor(name: string, refractionTextureUrl: string,
  36440. /** the base color of the refraction (used to taint the rendering) */
  36441. color: Color3,
  36442. /** simulated refraction depth */
  36443. depth: number,
  36444. /** the coefficient of the base color (0 to remove base color tainting) */
  36445. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36446. /**
  36447. * Disposes of the post process
  36448. * @param camera Camera to dispose post process on
  36449. */
  36450. dispose(camera: Camera): void;
  36451. }
  36452. }
  36453. declare module BABYLON {
  36454. /**
  36455. * The SharpenPostProcess applies a sharpen kernel to every pixel
  36456. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  36457. */
  36458. class SharpenPostProcess extends PostProcess {
  36459. /**
  36460. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  36461. */
  36462. colorAmount: number;
  36463. /**
  36464. * How much sharpness should be applied (default: 0.3)
  36465. */
  36466. edgeAmount: number;
  36467. /**
  36468. * Creates a new instance ConvolutionPostProcess
  36469. * @param name The name of the effect.
  36470. * @param options The required width/height ratio to downsize to before computing the render pass.
  36471. * @param camera The camera to apply the render pass to.
  36472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36473. * @param engine The engine which the post process will be applied. (default: current engine)
  36474. * @param reusable If the post process can be reused on the same frame. (default: false)
  36475. * @param textureType Type of textures used when performing the post process. (default: 0)
  36476. * @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)
  36477. */
  36478. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36479. }
  36480. }
  36481. declare module BABYLON {
  36482. /**
  36483. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36484. */
  36485. class StereoscopicInterlacePostProcess extends PostProcess {
  36486. private _stepSize;
  36487. private _passedProcess;
  36488. /**
  36489. * Initializes a StereoscopicInterlacePostProcess
  36490. * @param name The name of the effect.
  36491. * @param rigCameras The rig cameras to be appled to the post process
  36492. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36493. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36494. * @param engine The engine which the post process will be applied. (default: current engine)
  36495. * @param reusable If the post process can be reused on the same frame. (default: false)
  36496. */
  36497. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36498. }
  36499. }
  36500. declare module BABYLON {
  36501. /** Defines operator used for tonemapping */
  36502. enum TonemappingOperator {
  36503. /** Hable */
  36504. Hable = 0,
  36505. /** Reinhard */
  36506. Reinhard = 1,
  36507. /** HejiDawson */
  36508. HejiDawson = 2,
  36509. /** Photographic */
  36510. Photographic = 3
  36511. }
  36512. /**
  36513. * Defines a post process to apply tone mapping
  36514. */
  36515. class TonemapPostProcess extends PostProcess {
  36516. private _operator;
  36517. /** Defines the required exposure adjustement */
  36518. exposureAdjustment: number;
  36519. /**
  36520. * Creates a new TonemapPostProcess
  36521. * @param name defines the name of the postprocess
  36522. * @param _operator defines the operator to use
  36523. * @param exposureAdjustment defines the required exposure adjustement
  36524. * @param camera defines the camera to use (can be null)
  36525. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  36526. * @param engine defines the hosting engine (can be ignore if camera is set)
  36527. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  36528. */
  36529. constructor(name: string, _operator: TonemappingOperator,
  36530. /** Defines the required exposure adjustement */
  36531. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  36532. }
  36533. }
  36534. declare module BABYLON {
  36535. /**
  36536. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  36537. */
  36538. class VolumetricLightScatteringPostProcess extends PostProcess {
  36539. private _volumetricLightScatteringPass;
  36540. private _volumetricLightScatteringRTT;
  36541. private _viewPort;
  36542. private _screenCoordinates;
  36543. private _cachedDefines;
  36544. /**
  36545. * If not undefined, the mesh position is computed from the attached node position
  36546. */
  36547. attachedNode: {
  36548. position: Vector3;
  36549. };
  36550. /**
  36551. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  36552. */
  36553. customMeshPosition: Vector3;
  36554. /**
  36555. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  36556. */
  36557. useCustomMeshPosition: boolean;
  36558. /**
  36559. * If the post-process should inverse the light scattering direction
  36560. */
  36561. invert: boolean;
  36562. /**
  36563. * The internal mesh used by the post-process
  36564. */
  36565. mesh: Mesh;
  36566. /**
  36567. * @hidden
  36568. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  36569. */
  36570. useDiffuseColor: boolean;
  36571. /**
  36572. * Array containing the excluded meshes not rendered in the internal pass
  36573. */
  36574. excludedMeshes: AbstractMesh[];
  36575. /**
  36576. * Controls the overall intensity of the post-process
  36577. */
  36578. exposure: number;
  36579. /**
  36580. * Dissipates each sample's contribution in range [0, 1]
  36581. */
  36582. decay: number;
  36583. /**
  36584. * Controls the overall intensity of each sample
  36585. */
  36586. weight: number;
  36587. /**
  36588. * Controls the density of each sample
  36589. */
  36590. density: number;
  36591. /**
  36592. * @constructor
  36593. * @param name The post-process name
  36594. * @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)
  36595. * @param camera The camera that the post-process will be attached to
  36596. * @param mesh The mesh used to create the light scattering
  36597. * @param samples The post-process quality, default 100
  36598. * @param samplingModeThe post-process filtering mode
  36599. * @param engine The babylon engine
  36600. * @param reusable If the post-process is reusable
  36601. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  36602. */
  36603. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  36604. /**
  36605. * Returns the string "VolumetricLightScatteringPostProcess"
  36606. * @returns "VolumetricLightScatteringPostProcess"
  36607. */
  36608. getClassName(): string;
  36609. private _isReady;
  36610. /**
  36611. * Sets the new light position for light scattering effect
  36612. * @param position The new custom light position
  36613. */
  36614. setCustomMeshPosition(position: Vector3): void;
  36615. /**
  36616. * Returns the light position for light scattering effect
  36617. * @return Vector3 The custom light position
  36618. */
  36619. getCustomMeshPosition(): Vector3;
  36620. /**
  36621. * Disposes the internal assets and detaches the post-process from the camera
  36622. */
  36623. dispose(camera: Camera): void;
  36624. /**
  36625. * Returns the render target texture used by the post-process
  36626. * @return the render target texture used by the post-process
  36627. */
  36628. getPass(): RenderTargetTexture;
  36629. private _meshExcluded;
  36630. private _createPass;
  36631. private _updateMeshScreenCoordinates;
  36632. /**
  36633. * Creates a default mesh for the Volumeric Light Scattering post-process
  36634. * @param name The mesh name
  36635. * @param scene The scene where to create the mesh
  36636. * @return the default mesh
  36637. */
  36638. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  36639. }
  36640. }
  36641. declare module BABYLON {
  36642. /**
  36643. * VRDistortionCorrectionPostProcess used for mobile VR
  36644. */
  36645. class VRDistortionCorrectionPostProcess extends PostProcess {
  36646. private _isRightEye;
  36647. private _distortionFactors;
  36648. private _postProcessScaleFactor;
  36649. private _lensCenterOffset;
  36650. private _scaleIn;
  36651. private _scaleFactor;
  36652. private _lensCenter;
  36653. /**
  36654. * Initializes the VRDistortionCorrectionPostProcess
  36655. * @param name The name of the effect.
  36656. * @param camera The camera to apply the render pass to.
  36657. * @param isRightEye If this is for the right eye distortion
  36658. * @param vrMetrics All the required metrics for the VR camera
  36659. */
  36660. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  36661. }
  36662. }
  36663. declare module BABYLON {
  36664. /**
  36665. * Class used to represent a sprite
  36666. * @see http://doc.babylonjs.com/babylon101/sprites
  36667. */
  36668. class Sprite {
  36669. /** defines the name */
  36670. name: string;
  36671. /** Gets or sets the current world position */
  36672. position: Vector3;
  36673. /** Gets or sets the main color */
  36674. color: Color4;
  36675. /** Gets or sets the width */
  36676. width: number;
  36677. /** Gets or sets the height */
  36678. height: number;
  36679. /** Gets or sets rotation angle */
  36680. angle: number;
  36681. /** Gets or sets the cell index in the sprite sheet */
  36682. cellIndex: number;
  36683. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  36684. invertU: number;
  36685. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  36686. invertV: number;
  36687. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  36688. disposeWhenFinishedAnimating: boolean;
  36689. /** Gets the list of attached animations */
  36690. animations: Animation[];
  36691. /** Gets or sets a boolean indicating if the sprite can be picked */
  36692. isPickable: boolean;
  36693. /**
  36694. * Gets or sets the associated action manager
  36695. */
  36696. actionManager: Nullable<ActionManager>;
  36697. private _animationStarted;
  36698. private _loopAnimation;
  36699. private _fromIndex;
  36700. private _toIndex;
  36701. private _delay;
  36702. private _direction;
  36703. private _manager;
  36704. private _time;
  36705. private _onAnimationEnd;
  36706. /**
  36707. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  36708. */
  36709. isVisible: boolean;
  36710. /**
  36711. * Gets or sets the sprite size
  36712. */
  36713. size: number;
  36714. /**
  36715. * Creates a new Sprite
  36716. * @param name defines the name
  36717. * @param manager defines the manager
  36718. */
  36719. constructor(
  36720. /** defines the name */
  36721. name: string, manager: ISpriteManager);
  36722. /**
  36723. * Starts an animation
  36724. * @param from defines the initial key
  36725. * @param to defines the end key
  36726. * @param loop defines if the animation must loop
  36727. * @param delay defines the start delay (in ms)
  36728. * @param onAnimationEnd defines a callback to call when animation ends
  36729. */
  36730. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  36731. /** Stops current animation (if any) */
  36732. stopAnimation(): void;
  36733. /** @hidden */
  36734. _animate(deltaTime: number): void;
  36735. /** Release associated resources */
  36736. dispose(): void;
  36737. }
  36738. }
  36739. declare module BABYLON {
  36740. /**
  36741. * Defines the minimum interface to fullfil in order to be a sprite manager.
  36742. */
  36743. interface ISpriteManager extends IDisposable {
  36744. /**
  36745. * Restricts the camera to viewing objects with the same layerMask.
  36746. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  36747. */
  36748. layerMask: number;
  36749. /**
  36750. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36751. */
  36752. isPickable: boolean;
  36753. /**
  36754. * Specifies the rendering group id for this mesh (0 by default)
  36755. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36756. */
  36757. renderingGroupId: number;
  36758. /**
  36759. * Defines the list of sprites managed by the manager.
  36760. */
  36761. sprites: Array<Sprite>;
  36762. /**
  36763. * Tests the intersection of a sprite with a specific ray.
  36764. * @param ray The ray we are sending to test the collision
  36765. * @param camera The camera space we are sending rays in
  36766. * @param predicate A predicate allowing excluding sprites from the list of object to test
  36767. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  36768. * @returns picking info or null.
  36769. */
  36770. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36771. /**
  36772. * Renders the list of sprites on screen.
  36773. */
  36774. render(): void;
  36775. }
  36776. /**
  36777. * Class used to manage multiple sprites on the same spritesheet
  36778. * @see http://doc.babylonjs.com/babylon101/sprites
  36779. */
  36780. class SpriteManager implements ISpriteManager {
  36781. /** defines the manager's name */
  36782. name: string;
  36783. /** Gets the list of sprites */
  36784. sprites: Sprite[];
  36785. /** Gets or sets the rendering group id (0 by default) */
  36786. renderingGroupId: number;
  36787. /** Gets or sets camera layer mask */
  36788. layerMask: number;
  36789. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  36790. fogEnabled: boolean;
  36791. /** Gets or sets a boolean indicating if the sprites are pickable */
  36792. isPickable: boolean;
  36793. /** Defines the default width of a cell in the spritesheet */
  36794. cellWidth: number;
  36795. /** Defines the default height of a cell in the spritesheet */
  36796. cellHeight: number;
  36797. /**
  36798. * An event triggered when the manager is disposed.
  36799. */
  36800. onDisposeObservable: Observable<SpriteManager>;
  36801. private _onDisposeObserver;
  36802. /**
  36803. * Callback called when the manager is disposed
  36804. */
  36805. onDispose: () => void;
  36806. private _capacity;
  36807. private _spriteTexture;
  36808. private _epsilon;
  36809. private _scene;
  36810. private _vertexData;
  36811. private _buffer;
  36812. private _vertexBuffers;
  36813. private _indexBuffer;
  36814. private _effectBase;
  36815. private _effectFog;
  36816. /**
  36817. * Gets or sets the spritesheet texture
  36818. */
  36819. texture: Texture;
  36820. /**
  36821. * Creates a new sprite manager
  36822. * @param name defines the manager's name
  36823. * @param imgUrl defines the sprite sheet url
  36824. * @param capacity defines the maximum allowed number of sprites
  36825. * @param cellSize defines the size of a sprite cell
  36826. * @param scene defines the hosting scene
  36827. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  36828. * @param samplingMode defines the smapling mode to use with spritesheet
  36829. */
  36830. constructor(
  36831. /** defines the manager's name */
  36832. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  36833. private _appendSpriteVertex;
  36834. /**
  36835. * Intersects the sprites with a ray
  36836. * @param ray defines the ray to intersect with
  36837. * @param camera defines the current active camera
  36838. * @param predicate defines a predicate used to select candidate sprites
  36839. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  36840. * @returns null if no hit or a PickingInfo
  36841. */
  36842. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  36843. /**
  36844. * Render all child sprites
  36845. */
  36846. render(): void;
  36847. /**
  36848. * Release associated resources
  36849. */
  36850. dispose(): void;
  36851. }
  36852. }
  36853. declare module BABYLON {
  36854. interface Scene {
  36855. /** @hidden */
  36856. _pointerOverSprite: Nullable<Sprite>;
  36857. /** @hidden */
  36858. _pickedDownSprite: Nullable<Sprite>;
  36859. /** @hidden */
  36860. _tempSpritePickingRay: Nullable<Ray>;
  36861. /**
  36862. * All of the sprite managers added to this scene
  36863. * @see http://doc.babylonjs.com/babylon101/sprites
  36864. */
  36865. spriteManagers: Array<ISpriteManager>;
  36866. /**
  36867. * An event triggered when sprites rendering is about to start
  36868. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36869. */
  36870. onBeforeSpritesRenderingObservable: Observable<Scene>;
  36871. /**
  36872. * An event triggered when sprites rendering is done
  36873. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  36874. */
  36875. onAfterSpritesRenderingObservable: Observable<Scene>;
  36876. /** @hidden */
  36877. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36878. /** Launch a ray to try to pick a sprite in the scene
  36879. * @param x position on screen
  36880. * @param y position on screen
  36881. * @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
  36882. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36883. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36884. * @returns a PickingInfo
  36885. */
  36886. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36887. /** Use the given ray to pick a sprite in the scene
  36888. * @param ray The ray (in world space) to use to pick meshes
  36889. * @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
  36890. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36891. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  36892. * @returns a PickingInfo
  36893. */
  36894. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  36895. /**
  36896. * Force the sprite under the pointer
  36897. * @param sprite defines the sprite to use
  36898. */
  36899. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  36900. /**
  36901. * Gets the sprite under the pointer
  36902. * @returns a Sprite or null if no sprite is under the pointer
  36903. */
  36904. getPointerOverSprite(): Nullable<Sprite>;
  36905. }
  36906. /**
  36907. * Defines the sprite scene component responsible to manage sprites
  36908. * in a given scene.
  36909. */
  36910. class SpriteSceneComponent implements ISceneComponent {
  36911. /**
  36912. * The component name helpfull to identify the component in the list of scene components.
  36913. */
  36914. readonly name: string;
  36915. /**
  36916. * The scene the component belongs to.
  36917. */
  36918. scene: Scene;
  36919. /** @hidden */
  36920. private _spritePredicate;
  36921. /**
  36922. * Creates a new instance of the component for the given scene
  36923. * @param scene Defines the scene to register the component in
  36924. */
  36925. constructor(scene: Scene);
  36926. /**
  36927. * Registers the component in a given scene
  36928. */
  36929. register(): void;
  36930. /**
  36931. * Rebuilds the elements related to this component in case of
  36932. * context lost for instance.
  36933. */
  36934. rebuild(): void;
  36935. /**
  36936. * Disposes the component and the associated ressources.
  36937. */
  36938. dispose(): void;
  36939. private _pickSpriteButKeepRay;
  36940. private _pointerMove;
  36941. private _pointerDown;
  36942. private _pointerUp;
  36943. }
  36944. }
  36945. declare module BABYLON {
  36946. /**
  36947. * @hidden
  36948. **/
  36949. class _AlphaState {
  36950. private _isAlphaBlendDirty;
  36951. private _isBlendFunctionParametersDirty;
  36952. private _isBlendEquationParametersDirty;
  36953. private _isBlendConstantsDirty;
  36954. private _alphaBlend;
  36955. private _blendFunctionParameters;
  36956. private _blendEquationParameters;
  36957. private _blendConstants;
  36958. /**
  36959. * Initializes the state.
  36960. */
  36961. constructor();
  36962. readonly isDirty: boolean;
  36963. alphaBlend: boolean;
  36964. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36965. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36966. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36967. reset(): void;
  36968. apply(gl: WebGLRenderingContext): void;
  36969. }
  36970. }
  36971. declare module BABYLON {
  36972. /**
  36973. * @hidden
  36974. **/
  36975. class _DepthCullingState {
  36976. private _isDepthTestDirty;
  36977. private _isDepthMaskDirty;
  36978. private _isDepthFuncDirty;
  36979. private _isCullFaceDirty;
  36980. private _isCullDirty;
  36981. private _isZOffsetDirty;
  36982. private _isFrontFaceDirty;
  36983. private _depthTest;
  36984. private _depthMask;
  36985. private _depthFunc;
  36986. private _cull;
  36987. private _cullFace;
  36988. private _zOffset;
  36989. private _frontFace;
  36990. /**
  36991. * Initializes the state.
  36992. */
  36993. constructor();
  36994. readonly isDirty: boolean;
  36995. zOffset: number;
  36996. cullFace: Nullable<number>;
  36997. cull: Nullable<boolean>;
  36998. depthFunc: Nullable<number>;
  36999. depthMask: boolean;
  37000. depthTest: boolean;
  37001. frontFace: Nullable<number>;
  37002. reset(): void;
  37003. apply(gl: WebGLRenderingContext): void;
  37004. }
  37005. }
  37006. declare module BABYLON {
  37007. /**
  37008. * @hidden
  37009. **/
  37010. class _StencilState {
  37011. private _isStencilTestDirty;
  37012. private _isStencilMaskDirty;
  37013. private _isStencilFuncDirty;
  37014. private _isStencilOpDirty;
  37015. private _stencilTest;
  37016. private _stencilMask;
  37017. private _stencilFunc;
  37018. private _stencilFuncRef;
  37019. private _stencilFuncMask;
  37020. private _stencilOpStencilFail;
  37021. private _stencilOpDepthFail;
  37022. private _stencilOpStencilDepthPass;
  37023. readonly isDirty: boolean;
  37024. stencilFunc: number;
  37025. stencilFuncRef: number;
  37026. stencilFuncMask: number;
  37027. stencilOpStencilFail: number;
  37028. stencilOpDepthFail: number;
  37029. stencilOpStencilDepthPass: number;
  37030. stencilMask: number;
  37031. stencilTest: boolean;
  37032. constructor();
  37033. reset(): void;
  37034. apply(gl: WebGLRenderingContext): void;
  37035. }
  37036. }
  37037. declare module BABYLON {
  37038. /**
  37039. * Class used to evalaute queries containing `and` and `or` operators
  37040. */
  37041. class AndOrNotEvaluator {
  37042. /**
  37043. * Evaluate a query
  37044. * @param query defines the query to evaluate
  37045. * @param evaluateCallback defines the callback used to filter result
  37046. * @returns true if the query matches
  37047. */
  37048. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  37049. private static _HandleParenthesisContent;
  37050. private static _SimplifyNegation;
  37051. }
  37052. }
  37053. declare module BABYLON {
  37054. /**
  37055. * Defines the list of states available for a task inside a AssetsManager
  37056. */
  37057. enum AssetTaskState {
  37058. /**
  37059. * Initialization
  37060. */
  37061. INIT = 0,
  37062. /**
  37063. * Running
  37064. */
  37065. RUNNING = 1,
  37066. /**
  37067. * Done
  37068. */
  37069. DONE = 2,
  37070. /**
  37071. * Error
  37072. */
  37073. ERROR = 3
  37074. }
  37075. /**
  37076. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  37077. */
  37078. abstract class AbstractAssetTask {
  37079. /**
  37080. * Task name
  37081. */ name: string;
  37082. /**
  37083. * Callback called when the task is successful
  37084. */
  37085. onSuccess: (task: any) => void;
  37086. /**
  37087. * Callback called when the task is not successful
  37088. */
  37089. onError: (task: any, message?: string, exception?: any) => void;
  37090. /**
  37091. * Creates a new AssetsManager
  37092. * @param name defines the name of the task
  37093. */
  37094. constructor(
  37095. /**
  37096. * Task name
  37097. */ name: string);
  37098. private _isCompleted;
  37099. private _taskState;
  37100. private _errorObject;
  37101. /**
  37102. * Get if the task is completed
  37103. */
  37104. readonly isCompleted: boolean;
  37105. /**
  37106. * Gets the current state of the task
  37107. */
  37108. readonly taskState: AssetTaskState;
  37109. /**
  37110. * Gets the current error object (if task is in error)
  37111. */
  37112. readonly errorObject: {
  37113. message?: string;
  37114. exception?: any;
  37115. };
  37116. /**
  37117. * Internal only
  37118. * @hidden
  37119. */
  37120. _setErrorObject(message?: string, exception?: any): void;
  37121. /**
  37122. * Execute the current task
  37123. * @param scene defines the scene where you want your assets to be loaded
  37124. * @param onSuccess is a callback called when the task is successfully executed
  37125. * @param onError is a callback called if an error occurs
  37126. */
  37127. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37128. /**
  37129. * Execute the current task
  37130. * @param scene defines the scene where you want your assets to be loaded
  37131. * @param onSuccess is a callback called when the task is successfully executed
  37132. * @param onError is a callback called if an error occurs
  37133. */
  37134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37135. /**
  37136. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  37137. * This can be used with failed tasks that have the reason for failure fixed.
  37138. */
  37139. reset(): void;
  37140. private onErrorCallback;
  37141. private onDoneCallback;
  37142. }
  37143. /**
  37144. * Define the interface used by progress events raised during assets loading
  37145. */
  37146. interface IAssetsProgressEvent {
  37147. /**
  37148. * Defines the number of remaining tasks to process
  37149. */
  37150. remainingCount: number;
  37151. /**
  37152. * Defines the total number of tasks
  37153. */
  37154. totalCount: number;
  37155. /**
  37156. * Defines the task that was just processed
  37157. */
  37158. task: AbstractAssetTask;
  37159. }
  37160. /**
  37161. * Class used to share progress information about assets loading
  37162. */
  37163. class AssetsProgressEvent implements IAssetsProgressEvent {
  37164. /**
  37165. * Defines the number of remaining tasks to process
  37166. */
  37167. remainingCount: number;
  37168. /**
  37169. * Defines the total number of tasks
  37170. */
  37171. totalCount: number;
  37172. /**
  37173. * Defines the task that was just processed
  37174. */
  37175. task: AbstractAssetTask;
  37176. /**
  37177. * Creates a AssetsProgressEvent
  37178. * @param remainingCount defines the number of remaining tasks to process
  37179. * @param totalCount defines the total number of tasks
  37180. * @param task defines the task that was just processed
  37181. */
  37182. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  37183. }
  37184. /**
  37185. * Define a task used by AssetsManager to load meshes
  37186. */
  37187. class MeshAssetTask extends AbstractAssetTask {
  37188. /**
  37189. * Defines the name of the task
  37190. */
  37191. name: string;
  37192. /**
  37193. * Defines the list of mesh's names you want to load
  37194. */
  37195. meshesNames: any;
  37196. /**
  37197. * Defines the root url to use as a base to load your meshes and associated resources
  37198. */
  37199. rootUrl: string;
  37200. /**
  37201. * Defines the filename of the scene to load from
  37202. */
  37203. sceneFilename: string;
  37204. /**
  37205. * Gets the list of loaded meshes
  37206. */
  37207. loadedMeshes: Array<AbstractMesh>;
  37208. /**
  37209. * Gets the list of loaded particle systems
  37210. */
  37211. loadedParticleSystems: Array<IParticleSystem>;
  37212. /**
  37213. * Gets the list of loaded skeletons
  37214. */
  37215. loadedSkeletons: Array<Skeleton>;
  37216. /**
  37217. * Callback called when the task is successful
  37218. */
  37219. onSuccess: (task: MeshAssetTask) => void;
  37220. /**
  37221. * Callback called when the task is successful
  37222. */
  37223. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  37224. /**
  37225. * Creates a new MeshAssetTask
  37226. * @param name defines the name of the task
  37227. * @param meshesNames defines the list of mesh's names you want to load
  37228. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  37229. * @param sceneFilename defines the filename of the scene to load from
  37230. */
  37231. constructor(
  37232. /**
  37233. * Defines the name of the task
  37234. */
  37235. name: string,
  37236. /**
  37237. * Defines the list of mesh's names you want to load
  37238. */
  37239. meshesNames: any,
  37240. /**
  37241. * Defines the root url to use as a base to load your meshes and associated resources
  37242. */
  37243. rootUrl: string,
  37244. /**
  37245. * Defines the filename of the scene to load from
  37246. */
  37247. sceneFilename: string);
  37248. /**
  37249. * Execute the current task
  37250. * @param scene defines the scene where you want your assets to be loaded
  37251. * @param onSuccess is a callback called when the task is successfully executed
  37252. * @param onError is a callback called if an error occurs
  37253. */
  37254. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37255. }
  37256. /**
  37257. * Define a task used by AssetsManager to load text content
  37258. */
  37259. class TextFileAssetTask extends AbstractAssetTask {
  37260. /**
  37261. * Defines the name of the task
  37262. */
  37263. name: string;
  37264. /**
  37265. * Defines the location of the file to load
  37266. */
  37267. url: string;
  37268. /**
  37269. * Gets the loaded text string
  37270. */
  37271. text: string;
  37272. /**
  37273. * Callback called when the task is successful
  37274. */
  37275. onSuccess: (task: TextFileAssetTask) => void;
  37276. /**
  37277. * Callback called when the task is successful
  37278. */
  37279. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  37280. /**
  37281. * Creates a new TextFileAssetTask object
  37282. * @param name defines the name of the task
  37283. * @param url defines the location of the file to load
  37284. */
  37285. constructor(
  37286. /**
  37287. * Defines the name of the task
  37288. */
  37289. name: string,
  37290. /**
  37291. * Defines the location of the file to load
  37292. */
  37293. url: string);
  37294. /**
  37295. * Execute the current task
  37296. * @param scene defines the scene where you want your assets to be loaded
  37297. * @param onSuccess is a callback called when the task is successfully executed
  37298. * @param onError is a callback called if an error occurs
  37299. */
  37300. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37301. }
  37302. /**
  37303. * Define a task used by AssetsManager to load binary data
  37304. */
  37305. class BinaryFileAssetTask extends AbstractAssetTask {
  37306. /**
  37307. * Defines the name of the task
  37308. */
  37309. name: string;
  37310. /**
  37311. * Defines the location of the file to load
  37312. */
  37313. url: string;
  37314. /**
  37315. * Gets the lodaded data (as an array buffer)
  37316. */
  37317. data: ArrayBuffer;
  37318. /**
  37319. * Callback called when the task is successful
  37320. */
  37321. onSuccess: (task: BinaryFileAssetTask) => void;
  37322. /**
  37323. * Callback called when the task is successful
  37324. */
  37325. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  37326. /**
  37327. * Creates a new BinaryFileAssetTask object
  37328. * @param name defines the name of the new task
  37329. * @param url defines the location of the file to load
  37330. */
  37331. constructor(
  37332. /**
  37333. * Defines the name of the task
  37334. */
  37335. name: string,
  37336. /**
  37337. * Defines the location of the file to load
  37338. */
  37339. url: string);
  37340. /**
  37341. * Execute the current task
  37342. * @param scene defines the scene where you want your assets to be loaded
  37343. * @param onSuccess is a callback called when the task is successfully executed
  37344. * @param onError is a callback called if an error occurs
  37345. */
  37346. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37347. }
  37348. /**
  37349. * Define a task used by AssetsManager to load images
  37350. */
  37351. class ImageAssetTask extends AbstractAssetTask {
  37352. /**
  37353. * Defines the name of the task
  37354. */
  37355. name: string;
  37356. /**
  37357. * Defines the location of the image to load
  37358. */
  37359. url: string;
  37360. /**
  37361. * Gets the loaded images
  37362. */
  37363. image: HTMLImageElement;
  37364. /**
  37365. * Callback called when the task is successful
  37366. */
  37367. onSuccess: (task: ImageAssetTask) => void;
  37368. /**
  37369. * Callback called when the task is successful
  37370. */
  37371. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  37372. /**
  37373. * Creates a new ImageAssetTask
  37374. * @param name defines the name of the task
  37375. * @param url defines the location of the image to load
  37376. */
  37377. constructor(
  37378. /**
  37379. * Defines the name of the task
  37380. */
  37381. name: string,
  37382. /**
  37383. * Defines the location of the image to load
  37384. */
  37385. url: string);
  37386. /**
  37387. * Execute the current task
  37388. * @param scene defines the scene where you want your assets to be loaded
  37389. * @param onSuccess is a callback called when the task is successfully executed
  37390. * @param onError is a callback called if an error occurs
  37391. */
  37392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37393. }
  37394. /**
  37395. * Defines the interface used by texture loading tasks
  37396. */
  37397. interface ITextureAssetTask<TEX extends BaseTexture> {
  37398. /**
  37399. * Gets the loaded texture
  37400. */
  37401. texture: TEX;
  37402. }
  37403. /**
  37404. * Define a task used by AssetsManager to load 2D textures
  37405. */
  37406. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  37407. /**
  37408. * Defines the name of the task
  37409. */
  37410. name: string;
  37411. /**
  37412. * Defines the location of the file to load
  37413. */
  37414. url: string;
  37415. /**
  37416. * Defines if mipmap should not be generated (default is false)
  37417. */
  37418. noMipmap?: boolean | undefined;
  37419. /**
  37420. * Defines if texture must be inverted on Y axis (default is false)
  37421. */
  37422. invertY?: boolean | undefined;
  37423. /**
  37424. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37425. */
  37426. samplingMode: number;
  37427. /**
  37428. * Gets the loaded texture
  37429. */
  37430. texture: Texture;
  37431. /**
  37432. * Callback called when the task is successful
  37433. */
  37434. onSuccess: (task: TextureAssetTask) => void;
  37435. /**
  37436. * Callback called when the task is successful
  37437. */
  37438. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  37439. /**
  37440. * Creates a new TextureAssetTask object
  37441. * @param name defines the name of the task
  37442. * @param url defines the location of the file to load
  37443. * @param noMipmap defines if mipmap should not be generated (default is false)
  37444. * @param invertY defines if texture must be inverted on Y axis (default is false)
  37445. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37446. */
  37447. constructor(
  37448. /**
  37449. * Defines the name of the task
  37450. */
  37451. name: string,
  37452. /**
  37453. * Defines the location of the file to load
  37454. */
  37455. url: string,
  37456. /**
  37457. * Defines if mipmap should not be generated (default is false)
  37458. */
  37459. noMipmap?: boolean | undefined,
  37460. /**
  37461. * Defines if texture must be inverted on Y axis (default is false)
  37462. */
  37463. invertY?: boolean | undefined,
  37464. /**
  37465. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  37466. */
  37467. samplingMode?: number);
  37468. /**
  37469. * Execute the current task
  37470. * @param scene defines the scene where you want your assets to be loaded
  37471. * @param onSuccess is a callback called when the task is successfully executed
  37472. * @param onError is a callback called if an error occurs
  37473. */
  37474. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37475. }
  37476. /**
  37477. * Define a task used by AssetsManager to load cube textures
  37478. */
  37479. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  37480. /**
  37481. * Defines the name of the task
  37482. */
  37483. name: string;
  37484. /**
  37485. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37486. */
  37487. url: string;
  37488. /**
  37489. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37490. */
  37491. extensions?: string[] | undefined;
  37492. /**
  37493. * Defines if mipmaps should not be generated (default is false)
  37494. */
  37495. noMipmap?: boolean | undefined;
  37496. /**
  37497. * Defines the explicit list of files (undefined by default)
  37498. */
  37499. files?: string[] | undefined;
  37500. /**
  37501. * Gets the loaded texture
  37502. */
  37503. texture: CubeTexture;
  37504. /**
  37505. * Callback called when the task is successful
  37506. */
  37507. onSuccess: (task: CubeTextureAssetTask) => void;
  37508. /**
  37509. * Callback called when the task is successful
  37510. */
  37511. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  37512. /**
  37513. * Creates a new CubeTextureAssetTask
  37514. * @param name defines the name of the task
  37515. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37516. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37517. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37518. * @param files defines the explicit list of files (undefined by default)
  37519. */
  37520. constructor(
  37521. /**
  37522. * Defines the name of the task
  37523. */
  37524. name: string,
  37525. /**
  37526. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  37527. */
  37528. url: string,
  37529. /**
  37530. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  37531. */
  37532. extensions?: string[] | undefined,
  37533. /**
  37534. * Defines if mipmaps should not be generated (default is false)
  37535. */
  37536. noMipmap?: boolean | undefined,
  37537. /**
  37538. * Defines the explicit list of files (undefined by default)
  37539. */
  37540. files?: string[] | undefined);
  37541. /**
  37542. * Execute the current task
  37543. * @param scene defines the scene where you want your assets to be loaded
  37544. * @param onSuccess is a callback called when the task is successfully executed
  37545. * @param onError is a callback called if an error occurs
  37546. */
  37547. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37548. }
  37549. /**
  37550. * Define a task used by AssetsManager to load HDR cube textures
  37551. */
  37552. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  37553. /**
  37554. * Defines the name of the task
  37555. */
  37556. name: string;
  37557. /**
  37558. * Defines the location of the file to load
  37559. */
  37560. url: string;
  37561. /**
  37562. * Defines the desired size (the more it increases the longer the generation will be)
  37563. */
  37564. size: number;
  37565. /**
  37566. * Defines if mipmaps should not be generated (default is false)
  37567. */
  37568. noMipmap: boolean;
  37569. /**
  37570. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37571. */
  37572. generateHarmonics: boolean;
  37573. /**
  37574. * 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)
  37575. */
  37576. gammaSpace: boolean;
  37577. /**
  37578. * Internal Use Only
  37579. */
  37580. reserved: boolean;
  37581. /**
  37582. * Gets the loaded texture
  37583. */
  37584. texture: HDRCubeTexture;
  37585. /**
  37586. * Callback called when the task is successful
  37587. */
  37588. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  37589. /**
  37590. * Callback called when the task is successful
  37591. */
  37592. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  37593. /**
  37594. * Creates a new HDRCubeTextureAssetTask object
  37595. * @param name defines the name of the task
  37596. * @param url defines the location of the file to load
  37597. * @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.
  37598. * @param noMipmap defines if mipmaps should not be generated (default is false)
  37599. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37600. * @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)
  37601. * @param reserved Internal use only
  37602. */
  37603. constructor(
  37604. /**
  37605. * Defines the name of the task
  37606. */
  37607. name: string,
  37608. /**
  37609. * Defines the location of the file to load
  37610. */
  37611. url: string,
  37612. /**
  37613. * Defines the desired size (the more it increases the longer the generation will be)
  37614. */
  37615. size: number,
  37616. /**
  37617. * Defines if mipmaps should not be generated (default is false)
  37618. */
  37619. noMipmap?: boolean,
  37620. /**
  37621. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  37622. */
  37623. generateHarmonics?: boolean,
  37624. /**
  37625. * 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)
  37626. */
  37627. gammaSpace?: boolean,
  37628. /**
  37629. * Internal Use Only
  37630. */
  37631. reserved?: boolean);
  37632. /**
  37633. * Execute the current task
  37634. * @param scene defines the scene where you want your assets to be loaded
  37635. * @param onSuccess is a callback called when the task is successfully executed
  37636. * @param onError is a callback called if an error occurs
  37637. */
  37638. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  37639. }
  37640. /**
  37641. * This class can be used to easily import assets into a scene
  37642. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  37643. */
  37644. class AssetsManager {
  37645. private _scene;
  37646. private _isLoading;
  37647. protected _tasks: AbstractAssetTask[];
  37648. protected _waitingTasksCount: number;
  37649. protected _totalTasksCount: number;
  37650. /**
  37651. * Callback called when all tasks are processed
  37652. */
  37653. onFinish: (tasks: AbstractAssetTask[]) => void;
  37654. /**
  37655. * Callback called when a task is successful
  37656. */
  37657. onTaskSuccess: (task: AbstractAssetTask) => void;
  37658. /**
  37659. * Callback called when a task had an error
  37660. */
  37661. onTaskError: (task: AbstractAssetTask) => void;
  37662. /**
  37663. * Callback called when a task is done (whatever the result is)
  37664. */
  37665. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  37666. /**
  37667. * Observable called when all tasks are processed
  37668. */
  37669. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  37670. /**
  37671. * Observable called when a task had an error
  37672. */
  37673. onTaskErrorObservable: Observable<AbstractAssetTask>;
  37674. /**
  37675. * Observable called when a task is successful
  37676. */
  37677. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  37678. /**
  37679. * Observable called when a task is done (whatever the result is)
  37680. */
  37681. onProgressObservable: Observable<IAssetsProgressEvent>;
  37682. /**
  37683. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  37684. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37685. */
  37686. useDefaultLoadingScreen: boolean;
  37687. /**
  37688. * Creates a new AssetsManager
  37689. * @param scene defines the scene to work on
  37690. */
  37691. constructor(scene: Scene);
  37692. /**
  37693. * Add a MeshAssetTask to the list of active tasks
  37694. * @param taskName defines the name of the new task
  37695. * @param meshesNames defines the name of meshes to load
  37696. * @param rootUrl defines the root url to use to locate files
  37697. * @param sceneFilename defines the filename of the scene file
  37698. * @returns a new MeshAssetTask object
  37699. */
  37700. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  37701. /**
  37702. * Add a TextFileAssetTask to the list of active tasks
  37703. * @param taskName defines the name of the new task
  37704. * @param url defines the url of the file to load
  37705. * @returns a new TextFileAssetTask object
  37706. */
  37707. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  37708. /**
  37709. * Add a BinaryFileAssetTask to the list of active tasks
  37710. * @param taskName defines the name of the new task
  37711. * @param url defines the url of the file to load
  37712. * @returns a new BinaryFileAssetTask object
  37713. */
  37714. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  37715. /**
  37716. * Add a ImageAssetTask to the list of active tasks
  37717. * @param taskName defines the name of the new task
  37718. * @param url defines the url of the file to load
  37719. * @returns a new ImageAssetTask object
  37720. */
  37721. addImageTask(taskName: string, url: string): ImageAssetTask;
  37722. /**
  37723. * Add a TextureAssetTask to the list of active tasks
  37724. * @param taskName defines the name of the new task
  37725. * @param url defines the url of the file to load
  37726. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37727. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  37728. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  37729. * @returns a new TextureAssetTask object
  37730. */
  37731. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  37732. /**
  37733. * Add a CubeTextureAssetTask to the list of active tasks
  37734. * @param taskName defines the name of the new task
  37735. * @param url defines the url of the file to load
  37736. * @param extensions defines the extension to use to load the cube map (can be null)
  37737. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37738. * @param files defines the list of files to load (can be null)
  37739. * @returns a new CubeTextureAssetTask object
  37740. */
  37741. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  37742. /**
  37743. *
  37744. * Add a HDRCubeTextureAssetTask to the list of active tasks
  37745. * @param taskName defines the name of the new task
  37746. * @param url defines the url of the file to load
  37747. * @param size defines the size you want for the cubemap (can be null)
  37748. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  37749. * @param generateHarmonics defines if you want to automatically generate (true by default)
  37750. * @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)
  37751. * @param reserved Internal use only
  37752. * @returns a new HDRCubeTextureAssetTask object
  37753. */
  37754. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  37755. /**
  37756. * Remove a task from the assets manager.
  37757. * @param task the task to remove
  37758. */
  37759. removeTask(task: AbstractAssetTask): void;
  37760. private _decreaseWaitingTasksCount;
  37761. private _runTask;
  37762. /**
  37763. * Reset the AssetsManager and remove all tasks
  37764. * @return the current instance of the AssetsManager
  37765. */
  37766. reset(): AssetsManager;
  37767. /**
  37768. * Start the loading process
  37769. * @return the current instance of the AssetsManager
  37770. */
  37771. load(): AssetsManager;
  37772. }
  37773. }
  37774. declare module BABYLON {
  37775. /**
  37776. * Direct draw surface info
  37777. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  37778. */
  37779. interface DDSInfo {
  37780. /**
  37781. * Width of the texture
  37782. */
  37783. width: number;
  37784. /**
  37785. * Width of the texture
  37786. */
  37787. height: number;
  37788. /**
  37789. * Number of Mipmaps for the texture
  37790. * @see https://en.wikipedia.org/wiki/Mipmap
  37791. */
  37792. mipmapCount: number;
  37793. /**
  37794. * If the textures format is a known fourCC format
  37795. * @see https://www.fourcc.org/
  37796. */
  37797. isFourCC: boolean;
  37798. /**
  37799. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  37800. */
  37801. isRGB: boolean;
  37802. /**
  37803. * If the texture is a lumincance format
  37804. */
  37805. isLuminance: boolean;
  37806. /**
  37807. * If this is a cube texture
  37808. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  37809. */
  37810. isCube: boolean;
  37811. /**
  37812. * If the texture is a compressed format eg. FOURCC_DXT1
  37813. */
  37814. isCompressed: boolean;
  37815. /**
  37816. * The dxgiFormat of the texture
  37817. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  37818. */
  37819. dxgiFormat: number;
  37820. /**
  37821. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  37822. */
  37823. textureType: number;
  37824. /**
  37825. * Sphericle polynomial created for the dds texture
  37826. */
  37827. sphericalPolynomial?: SphericalPolynomial;
  37828. }
  37829. /**
  37830. * Class used to provide DDS decompression tools
  37831. */
  37832. class DDSTools {
  37833. /**
  37834. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  37835. */
  37836. static StoreLODInAlphaChannel: boolean;
  37837. /**
  37838. * Gets DDS information from an array buffer
  37839. * @param arrayBuffer defines the array buffer to read data from
  37840. * @returns the DDS information
  37841. */
  37842. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  37843. private static _FloatView;
  37844. private static _Int32View;
  37845. private static _ToHalfFloat;
  37846. private static _FromHalfFloat;
  37847. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  37848. private static _GetHalfFloatRGBAArrayBuffer;
  37849. private static _GetFloatRGBAArrayBuffer;
  37850. private static _GetFloatAsUIntRGBAArrayBuffer;
  37851. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  37852. private static _GetRGBAArrayBuffer;
  37853. private static _ExtractLongWordOrder;
  37854. private static _GetRGBArrayBuffer;
  37855. private static _GetLuminanceArrayBuffer;
  37856. /**
  37857. * Uploads DDS Levels to a Babylon Texture
  37858. * @hidden
  37859. */
  37860. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  37861. }
  37862. }
  37863. declare module BABYLON {
  37864. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37865. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37866. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37867. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37868. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37869. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37870. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37871. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37872. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37873. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37874. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37875. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37876. /**
  37877. * Decorator used to define property that can be serialized as reference to a camera
  37878. * @param sourceName defines the name of the property to decorate
  37879. */
  37880. function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37881. /**
  37882. * Class used to help serialization objects
  37883. */
  37884. class SerializationHelper {
  37885. /**
  37886. * Static function used to serialized a specific entity
  37887. * @param entity defines the entity to serialize
  37888. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37889. * @returns a JSON compatible object representing the serialization of the entity
  37890. */
  37891. static Serialize<T>(entity: T, serializationObject?: any): any;
  37892. /**
  37893. * Creates a new entity from a serialization data object
  37894. * @param creationFunction defines a function used to instanciated the new entity
  37895. * @param source defines the source serialization data
  37896. * @param scene defines the hosting scene
  37897. * @param rootUrl defines the root url for resources
  37898. * @returns a new entity
  37899. */
  37900. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37901. /**
  37902. * Clones an object
  37903. * @param creationFunction defines the function used to instanciate the new object
  37904. * @param source defines the source object
  37905. * @returns the cloned object
  37906. */
  37907. static Clone<T>(creationFunction: () => T, source: T): T;
  37908. /**
  37909. * Instanciates a new object based on a source one (some data will be shared between both object)
  37910. * @param creationFunction defines the function used to instanciate the new object
  37911. * @param source defines the source object
  37912. * @returns the new object
  37913. */
  37914. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37915. }
  37916. }
  37917. declare module BABYLON {
  37918. /**
  37919. * Wrapper class for promise with external resolve and reject.
  37920. */
  37921. class Deferred<T> {
  37922. /**
  37923. * The promise associated with this deferred object.
  37924. */
  37925. readonly promise: Promise<T>;
  37926. private _resolve;
  37927. private _reject;
  37928. /**
  37929. * The resolve method of the promise associated with this deferred object.
  37930. */
  37931. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  37932. /**
  37933. * The reject method of the promise associated with this deferred object.
  37934. */
  37935. readonly reject: (reason?: any) => void;
  37936. /**
  37937. * Constructor for this deferred object.
  37938. */
  37939. constructor();
  37940. }
  37941. }
  37942. declare module BABYLON {
  37943. /**
  37944. * Raw texture data and descriptor sufficient for WebGL texture upload
  37945. */
  37946. interface EnvironmentTextureInfo {
  37947. /**
  37948. * Version of the environment map
  37949. */
  37950. version: number;
  37951. /**
  37952. * Width of image
  37953. */
  37954. width: number;
  37955. /**
  37956. * Irradiance information stored in the file.
  37957. */
  37958. irradiance: any;
  37959. /**
  37960. * Specular information stored in the file.
  37961. */
  37962. specular: any;
  37963. }
  37964. /**
  37965. * Sets of helpers addressing the serialization and deserialization of environment texture
  37966. * stored in a BabylonJS env file.
  37967. * Those files are usually stored as .env files.
  37968. */
  37969. class EnvironmentTextureTools {
  37970. /**
  37971. * Magic number identifying the env file.
  37972. */
  37973. private static _MagicBytes;
  37974. /**
  37975. * Gets the environment info from an env file.
  37976. * @param data The array buffer containing the .env bytes.
  37977. * @returns the environment file info (the json header) if successfully parsed.
  37978. */
  37979. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  37980. /**
  37981. * Creates an environment texture from a loaded cube texture.
  37982. * @param texture defines the cube texture to convert in env file
  37983. * @return a promise containing the environment data if succesfull.
  37984. */
  37985. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  37986. /**
  37987. * Creates a JSON representation of the spherical data.
  37988. * @param texture defines the texture containing the polynomials
  37989. * @return the JSON representation of the spherical info
  37990. */
  37991. private static _CreateEnvTextureIrradiance;
  37992. /**
  37993. * Uploads the texture info contained in the env file to the GPU.
  37994. * @param texture defines the internal texture to upload to
  37995. * @param arrayBuffer defines the buffer cotaining the data to load
  37996. * @param info defines the texture info retrieved through the GetEnvInfo method
  37997. * @returns a promise
  37998. */
  37999. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  38000. /**
  38001. * Uploads the levels of image data to the GPU.
  38002. * @param texture defines the internal texture to upload to
  38003. * @param imageData defines the array buffer views of image data [mipmap][face]
  38004. * @returns a promise
  38005. */
  38006. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  38007. /**
  38008. * Uploads spherical polynomials information to the texture.
  38009. * @param texture defines the texture we are trying to upload the information to
  38010. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  38011. */
  38012. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  38013. }
  38014. }
  38015. declare module BABYLON {
  38016. /**
  38017. * Class used to help managing file picking and drag'n'drop
  38018. */
  38019. class FilesInput {
  38020. /**
  38021. * List of files ready to be loaded
  38022. */
  38023. static FilesToLoad: {
  38024. [key: string]: File;
  38025. };
  38026. /**
  38027. * Callback called when a file is processed
  38028. */
  38029. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  38030. private _engine;
  38031. private _currentScene;
  38032. private _sceneLoadedCallback;
  38033. private _progressCallback;
  38034. private _additionalRenderLoopLogicCallback;
  38035. private _textureLoadingCallback;
  38036. private _startingProcessingFilesCallback;
  38037. private _onReloadCallback;
  38038. private _errorCallback;
  38039. private _elementToMonitor;
  38040. private _sceneFileToLoad;
  38041. private _filesToLoad;
  38042. /**
  38043. * Creates a new FilesInput
  38044. * @param engine defines the rendering engine
  38045. * @param scene defines the hosting scene
  38046. * @param sceneLoadedCallback callback called when scene is loaded
  38047. * @param progressCallback callback called to track progress
  38048. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  38049. * @param textureLoadingCallback callback called when a texture is loading
  38050. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  38051. * @param onReloadCallback callback called when a reload is requested
  38052. * @param errorCallback callback call if an error occurs
  38053. */
  38054. 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);
  38055. private _dragEnterHandler;
  38056. private _dragOverHandler;
  38057. private _dropHandler;
  38058. /**
  38059. * Calls this function to listen to drag'n'drop events on a specific DOM element
  38060. * @param elementToMonitor defines the DOM element to track
  38061. */
  38062. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  38063. /**
  38064. * Release all associated resources
  38065. */
  38066. dispose(): void;
  38067. private renderFunction;
  38068. private drag;
  38069. private drop;
  38070. private _traverseFolder;
  38071. private _processFiles;
  38072. /**
  38073. * Load files from a drop event
  38074. * @param event defines the drop event to use as source
  38075. */
  38076. loadFiles(event: any): void;
  38077. private _processReload;
  38078. /**
  38079. * Reload the current scene from the loaded files
  38080. */
  38081. reload(): void;
  38082. }
  38083. }
  38084. declare module BABYLON {
  38085. /**
  38086. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  38087. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  38088. */
  38089. class KhronosTextureContainer {
  38090. /** contents of the KTX container file */
  38091. arrayBuffer: any;
  38092. private static HEADER_LEN;
  38093. private static COMPRESSED_2D;
  38094. private static COMPRESSED_3D;
  38095. private static TEX_2D;
  38096. private static TEX_3D;
  38097. /**
  38098. * Gets the openGL type
  38099. */
  38100. glType: number;
  38101. /**
  38102. * Gets the openGL type size
  38103. */
  38104. glTypeSize: number;
  38105. /**
  38106. * Gets the openGL format
  38107. */
  38108. glFormat: number;
  38109. /**
  38110. * Gets the openGL internal format
  38111. */
  38112. glInternalFormat: number;
  38113. /**
  38114. * Gets the base internal format
  38115. */
  38116. glBaseInternalFormat: number;
  38117. /**
  38118. * Gets image width in pixel
  38119. */
  38120. pixelWidth: number;
  38121. /**
  38122. * Gets image height in pixel
  38123. */
  38124. pixelHeight: number;
  38125. /**
  38126. * Gets image depth in pixels
  38127. */
  38128. pixelDepth: number;
  38129. /**
  38130. * Gets the number of array elements
  38131. */
  38132. numberOfArrayElements: number;
  38133. /**
  38134. * Gets the number of faces
  38135. */
  38136. numberOfFaces: number;
  38137. /**
  38138. * Gets the number of mipmap levels
  38139. */
  38140. numberOfMipmapLevels: number;
  38141. /**
  38142. * Gets the bytes of key value data
  38143. */
  38144. bytesOfKeyValueData: number;
  38145. /**
  38146. * Gets the load type
  38147. */
  38148. loadType: number;
  38149. /**
  38150. * Creates a new KhronosTextureContainer
  38151. * @param arrayBuffer contents of the KTX container file
  38152. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  38153. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  38154. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  38155. */
  38156. constructor(
  38157. /** contents of the KTX container file */
  38158. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  38159. /**
  38160. * Revert the endianness of a value.
  38161. * Not as fast hardware based, but will probably never need to use
  38162. * @param val defines the value to convert
  38163. * @returns the new value
  38164. */
  38165. switchEndianness(val: number): number;
  38166. /**
  38167. * Uploads KTX content to a Babylon Texture.
  38168. * It is assumed that the texture has already been created & is currently bound
  38169. * @hidden
  38170. */
  38171. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  38172. private _upload2DCompressedLevels;
  38173. }
  38174. }
  38175. declare module BABYLON {
  38176. /**
  38177. * A class serves as a medium between the observable and its observers
  38178. */
  38179. class EventState {
  38180. /**
  38181. * Create a new EventState
  38182. * @param mask defines the mask associated with this state
  38183. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38184. * @param target defines the original target of the state
  38185. * @param currentTarget defines the current target of the state
  38186. */
  38187. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  38188. /**
  38189. * Initialize the current event state
  38190. * @param mask defines the mask associated with this state
  38191. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  38192. * @param target defines the original target of the state
  38193. * @param currentTarget defines the current target of the state
  38194. * @returns the current event state
  38195. */
  38196. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  38197. /**
  38198. * An Observer can set this property to true to prevent subsequent observers of being notified
  38199. */
  38200. skipNextObservers: boolean;
  38201. /**
  38202. * Get the mask value that were used to trigger the event corresponding to this EventState object
  38203. */
  38204. mask: number;
  38205. /**
  38206. * The object that originally notified the event
  38207. */
  38208. target?: any;
  38209. /**
  38210. * The current object in the bubbling phase
  38211. */
  38212. currentTarget?: any;
  38213. /**
  38214. * This will be populated with the return value of the last function that was executed.
  38215. * If it is the first function in the callback chain it will be the event data.
  38216. */
  38217. lastReturnValue?: any;
  38218. }
  38219. /**
  38220. * Represent an Observer registered to a given Observable object.
  38221. */
  38222. class Observer<T> {
  38223. /**
  38224. * Defines the callback to call when the observer is notified
  38225. */
  38226. callback: (eventData: T, eventState: EventState) => void;
  38227. /**
  38228. * Defines the mask of the observer (used to filter notifications)
  38229. */
  38230. mask: number;
  38231. /**
  38232. * Defines the current scope used to restore the JS context
  38233. */
  38234. scope: any;
  38235. /** @hidden */
  38236. _willBeUnregistered: boolean;
  38237. /**
  38238. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  38239. */
  38240. unregisterOnNextCall: boolean;
  38241. /**
  38242. * Creates a new observer
  38243. * @param callback defines the callback to call when the observer is notified
  38244. * @param mask defines the mask of the observer (used to filter notifications)
  38245. * @param scope defines the current scope used to restore the JS context
  38246. */
  38247. constructor(
  38248. /**
  38249. * Defines the callback to call when the observer is notified
  38250. */
  38251. callback: (eventData: T, eventState: EventState) => void,
  38252. /**
  38253. * Defines the mask of the observer (used to filter notifications)
  38254. */
  38255. mask: number,
  38256. /**
  38257. * Defines the current scope used to restore the JS context
  38258. */
  38259. scope?: any);
  38260. }
  38261. /**
  38262. * Represent a list of observers registered to multiple Observables object.
  38263. */
  38264. class MultiObserver<T> {
  38265. private _observers;
  38266. private _observables;
  38267. /**
  38268. * Release associated resources
  38269. */
  38270. dispose(): void;
  38271. /**
  38272. * Raise a callback when one of the observable will notify
  38273. * @param observables defines a list of observables to watch
  38274. * @param callback defines the callback to call on notification
  38275. * @param mask defines the mask used to filter notifications
  38276. * @param scope defines the current scope used to restore the JS context
  38277. * @returns the new MultiObserver
  38278. */
  38279. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  38280. }
  38281. /**
  38282. * The Observable class is a simple implementation of the Observable pattern.
  38283. *
  38284. * 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.
  38285. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  38286. * 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).
  38287. * 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.
  38288. */
  38289. class Observable<T> {
  38290. private _observers;
  38291. private _eventState;
  38292. private _onObserverAdded;
  38293. /**
  38294. * Creates a new observable
  38295. * @param onObserverAdded defines a callback to call when a new observer is added
  38296. */
  38297. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  38298. /**
  38299. * Create a new Observer with the specified callback
  38300. * @param callback the callback that will be executed for that Observer
  38301. * @param mask the mask used to filter observers
  38302. * @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.
  38303. * @param scope optional scope for the callback to be called from
  38304. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  38305. * @returns the new observer created for the callback
  38306. */
  38307. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  38308. /**
  38309. * Create a new Observer with the specified callback and unregisters after the next notification
  38310. * @param callback the callback that will be executed for that Observer
  38311. * @returns the new observer created for the callback
  38312. */
  38313. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  38314. /**
  38315. * Remove an Observer from the Observable object
  38316. * @param observer the instance of the Observer to remove
  38317. * @returns false if it doesn't belong to this Observable
  38318. */
  38319. remove(observer: Nullable<Observer<T>>): boolean;
  38320. /**
  38321. * Remove a callback from the Observable object
  38322. * @param callback the callback to remove
  38323. * @param scope optional scope. If used only the callbacks with this scope will be removed
  38324. * @returns false if it doesn't belong to this Observable
  38325. */
  38326. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  38327. private _deferUnregister;
  38328. private _remove;
  38329. /**
  38330. * Notify all Observers by calling their respective callback with the given data
  38331. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  38332. * @param eventData defines the data to send to all observers
  38333. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  38334. * @param target defines the original target of the state
  38335. * @param currentTarget defines the current target of the state
  38336. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  38337. */
  38338. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  38339. /**
  38340. * Calling this will execute each callback, expecting it to be a promise or return a value.
  38341. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  38342. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  38343. * and it is crucial that all callbacks will be executed.
  38344. * The order of the callbacks is kept, callbacks are not executed parallel.
  38345. *
  38346. * @param eventData The data to be sent to each callback
  38347. * @param mask is used to filter observers defaults to -1
  38348. * @param target defines the callback target (see EventState)
  38349. * @param currentTarget defines he current object in the bubbling phase
  38350. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  38351. */
  38352. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  38353. /**
  38354. * Notify a specific observer
  38355. * @param observer defines the observer to notify
  38356. * @param eventData defines the data to be sent to each callback
  38357. * @param mask is used to filter observers defaults to -1
  38358. */
  38359. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  38360. /**
  38361. * Gets a boolean indicating if the observable has at least one observer
  38362. * @returns true is the Observable has at least one Observer registered
  38363. */
  38364. hasObservers(): boolean;
  38365. /**
  38366. * Clear the list of observers
  38367. */
  38368. clear(): void;
  38369. /**
  38370. * Clone the current observable
  38371. * @returns a new observable
  38372. */
  38373. clone(): Observable<T>;
  38374. /**
  38375. * Does this observable handles observer registered with a given mask
  38376. * @param mask defines the mask to be tested
  38377. * @return whether or not one observer registered with the given mask is handeled
  38378. **/
  38379. hasSpecificMask(mask?: number): boolean;
  38380. }
  38381. }
  38382. declare module BABYLON {
  38383. /**
  38384. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38385. */
  38386. class PerformanceMonitor {
  38387. private _enabled;
  38388. private _rollingFrameTime;
  38389. private _lastFrameTimeMs;
  38390. /**
  38391. * constructor
  38392. * @param frameSampleSize The number of samples required to saturate the sliding window
  38393. */
  38394. constructor(frameSampleSize?: number);
  38395. /**
  38396. * Samples current frame
  38397. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38398. */
  38399. sampleFrame(timeMs?: number): void;
  38400. /**
  38401. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38402. */
  38403. readonly averageFrameTime: number;
  38404. /**
  38405. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38406. */
  38407. readonly averageFrameTimeVariance: number;
  38408. /**
  38409. * Returns the frame time of the most recent frame
  38410. */
  38411. readonly instantaneousFrameTime: number;
  38412. /**
  38413. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38414. */
  38415. readonly averageFPS: number;
  38416. /**
  38417. * Returns the average framerate in frames per second using the most recent frame time
  38418. */
  38419. readonly instantaneousFPS: number;
  38420. /**
  38421. * Returns true if enough samples have been taken to completely fill the sliding window
  38422. */
  38423. readonly isSaturated: boolean;
  38424. /**
  38425. * Enables contributions to the sliding window sample set
  38426. */
  38427. enable(): void;
  38428. /**
  38429. * Disables contributions to the sliding window sample set
  38430. * Samples will not be interpolated over the disabled period
  38431. */
  38432. disable(): void;
  38433. /**
  38434. * Returns true if sampling is enabled
  38435. */
  38436. readonly isEnabled: boolean;
  38437. /**
  38438. * Resets performance monitor
  38439. */
  38440. reset(): void;
  38441. }
  38442. /**
  38443. * RollingAverage
  38444. *
  38445. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38446. */
  38447. class RollingAverage {
  38448. /**
  38449. * Current average
  38450. */
  38451. average: number;
  38452. /**
  38453. * Current variance
  38454. */
  38455. variance: number;
  38456. protected _samples: Array<number>;
  38457. protected _sampleCount: number;
  38458. protected _pos: number;
  38459. protected _m2: number;
  38460. /**
  38461. * constructor
  38462. * @param length The number of samples required to saturate the sliding window
  38463. */
  38464. constructor(length: number);
  38465. /**
  38466. * Adds a sample to the sample set
  38467. * @param v The sample value
  38468. */
  38469. add(v: number): void;
  38470. /**
  38471. * Returns previously added values or null if outside of history or outside the sliding window domain
  38472. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38473. * @return Value previously recorded with add() or null if outside of range
  38474. */
  38475. history(i: number): number;
  38476. /**
  38477. * Returns true if enough samples have been taken to completely fill the sliding window
  38478. * @return true if sample-set saturated
  38479. */
  38480. isSaturated(): boolean;
  38481. /**
  38482. * Resets the rolling average (equivalent to 0 samples taken so far)
  38483. */
  38484. reset(): void;
  38485. /**
  38486. * Wraps a value around the sample range boundaries
  38487. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38488. * @return Wrapped position in sample range
  38489. */
  38490. protected _wrapPosition(i: number): number;
  38491. }
  38492. }
  38493. declare module BABYLON {
  38494. /**
  38495. * Helper class that provides a small promise polyfill
  38496. */
  38497. class PromisePolyfill {
  38498. /**
  38499. * Static function used to check if the polyfill is required
  38500. * If this is the case then the function will inject the polyfill to window.Promise
  38501. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38502. */
  38503. static Apply(force?: boolean): void;
  38504. }
  38505. }
  38506. declare module BABYLON {
  38507. /**
  38508. * Defines the root class used to create scene optimization to use with SceneOptimizer
  38509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38510. */
  38511. class SceneOptimization {
  38512. /**
  38513. * Defines the priority of this optimization (0 by default which means first in the list)
  38514. */
  38515. priority: number;
  38516. /**
  38517. * Gets a string describing the action executed by the current optimization
  38518. * @returns description string
  38519. */
  38520. getDescription(): string;
  38521. /**
  38522. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38523. * @param scene defines the current scene where to apply this optimization
  38524. * @param optimizer defines the current optimizer
  38525. * @returns true if everything that can be done was applied
  38526. */
  38527. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38528. /**
  38529. * Creates the SceneOptimization object
  38530. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38531. * @param desc defines the description associated with the optimization
  38532. */
  38533. constructor(
  38534. /**
  38535. * Defines the priority of this optimization (0 by default which means first in the list)
  38536. */
  38537. priority?: number);
  38538. }
  38539. /**
  38540. * Defines an optimization used to reduce the size of render target textures
  38541. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38542. */
  38543. class TextureOptimization extends SceneOptimization {
  38544. /**
  38545. * Defines the priority of this optimization (0 by default which means first in the list)
  38546. */
  38547. priority: number;
  38548. /**
  38549. * 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
  38550. */
  38551. maximumSize: number;
  38552. /**
  38553. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38554. */
  38555. step: number;
  38556. /**
  38557. * Gets a string describing the action executed by the current optimization
  38558. * @returns description string
  38559. */
  38560. getDescription(): string;
  38561. /**
  38562. * Creates the TextureOptimization object
  38563. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38564. * @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
  38565. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38566. */
  38567. constructor(
  38568. /**
  38569. * Defines the priority of this optimization (0 by default which means first in the list)
  38570. */
  38571. priority?: number,
  38572. /**
  38573. * 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
  38574. */
  38575. maximumSize?: number,
  38576. /**
  38577. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  38578. */
  38579. step?: number);
  38580. /**
  38581. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38582. * @param scene defines the current scene where to apply this optimization
  38583. * @param optimizer defines the current optimizer
  38584. * @returns true if everything that can be done was applied
  38585. */
  38586. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38587. }
  38588. /**
  38589. * Defines an optimization used to increase or decrease the rendering resolution
  38590. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38591. */
  38592. class HardwareScalingOptimization extends SceneOptimization {
  38593. /**
  38594. * Defines the priority of this optimization (0 by default which means first in the list)
  38595. */
  38596. priority: number;
  38597. /**
  38598. * Defines the maximum scale to use (2 by default)
  38599. */
  38600. maximumScale: number;
  38601. /**
  38602. * Defines the step to use between two passes (0.5 by default)
  38603. */
  38604. step: number;
  38605. private _currentScale;
  38606. private _directionOffset;
  38607. /**
  38608. * Gets a string describing the action executed by the current optimization
  38609. * @return description string
  38610. */
  38611. getDescription(): string;
  38612. /**
  38613. * Creates the HardwareScalingOptimization object
  38614. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38615. * @param maximumScale defines the maximum scale to use (2 by default)
  38616. * @param step defines the step to use between two passes (0.5 by default)
  38617. */
  38618. constructor(
  38619. /**
  38620. * Defines the priority of this optimization (0 by default which means first in the list)
  38621. */
  38622. priority?: number,
  38623. /**
  38624. * Defines the maximum scale to use (2 by default)
  38625. */
  38626. maximumScale?: number,
  38627. /**
  38628. * Defines the step to use between two passes (0.5 by default)
  38629. */
  38630. step?: number);
  38631. /**
  38632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38633. * @param scene defines the current scene where to apply this optimization
  38634. * @param optimizer defines the current optimizer
  38635. * @returns true if everything that can be done was applied
  38636. */
  38637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38638. }
  38639. /**
  38640. * Defines an optimization used to remove shadows
  38641. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38642. */
  38643. class ShadowsOptimization extends SceneOptimization {
  38644. /**
  38645. * Gets a string describing the action executed by the current optimization
  38646. * @return description string
  38647. */
  38648. getDescription(): string;
  38649. /**
  38650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38651. * @param scene defines the current scene where to apply this optimization
  38652. * @param optimizer defines the current optimizer
  38653. * @returns true if everything that can be done was applied
  38654. */
  38655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38656. }
  38657. /**
  38658. * Defines an optimization used to turn post-processes off
  38659. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38660. */
  38661. class PostProcessesOptimization extends SceneOptimization {
  38662. /**
  38663. * Gets a string describing the action executed by the current optimization
  38664. * @return description string
  38665. */
  38666. getDescription(): string;
  38667. /**
  38668. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38669. * @param scene defines the current scene where to apply this optimization
  38670. * @param optimizer defines the current optimizer
  38671. * @returns true if everything that can be done was applied
  38672. */
  38673. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38674. }
  38675. /**
  38676. * Defines an optimization used to turn lens flares off
  38677. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38678. */
  38679. class LensFlaresOptimization extends SceneOptimization {
  38680. /**
  38681. * Gets a string describing the action executed by the current optimization
  38682. * @return description string
  38683. */
  38684. getDescription(): string;
  38685. /**
  38686. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38687. * @param scene defines the current scene where to apply this optimization
  38688. * @param optimizer defines the current optimizer
  38689. * @returns true if everything that can be done was applied
  38690. */
  38691. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38692. }
  38693. /**
  38694. * Defines an optimization based on user defined callback.
  38695. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38696. */
  38697. class CustomOptimization extends SceneOptimization {
  38698. /**
  38699. * Callback called to apply the custom optimization.
  38700. */
  38701. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  38702. /**
  38703. * Callback called to get custom description
  38704. */
  38705. onGetDescription: () => string;
  38706. /**
  38707. * Gets a string describing the action executed by the current optimization
  38708. * @returns description string
  38709. */
  38710. getDescription(): string;
  38711. /**
  38712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38713. * @param scene defines the current scene where to apply this optimization
  38714. * @param optimizer defines the current optimizer
  38715. * @returns true if everything that can be done was applied
  38716. */
  38717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38718. }
  38719. /**
  38720. * Defines an optimization used to turn particles off
  38721. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38722. */
  38723. class ParticlesOptimization extends SceneOptimization {
  38724. /**
  38725. * Gets a string describing the action executed by the current optimization
  38726. * @return description string
  38727. */
  38728. getDescription(): string;
  38729. /**
  38730. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38731. * @param scene defines the current scene where to apply this optimization
  38732. * @param optimizer defines the current optimizer
  38733. * @returns true if everything that can be done was applied
  38734. */
  38735. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38736. }
  38737. /**
  38738. * Defines an optimization used to turn render targets off
  38739. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38740. */
  38741. class RenderTargetsOptimization extends SceneOptimization {
  38742. /**
  38743. * Gets a string describing the action executed by the current optimization
  38744. * @return description string
  38745. */
  38746. getDescription(): string;
  38747. /**
  38748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38749. * @param scene defines the current scene where to apply this optimization
  38750. * @param optimizer defines the current optimizer
  38751. * @returns true if everything that can be done was applied
  38752. */
  38753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  38754. }
  38755. /**
  38756. * Defines an optimization used to merge meshes with compatible materials
  38757. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38758. */
  38759. class MergeMeshesOptimization extends SceneOptimization {
  38760. private static _UpdateSelectionTree;
  38761. /**
  38762. * Gets or sets a boolean which defines if optimization octree has to be updated
  38763. */
  38764. /**
  38765. * Gets or sets a boolean which defines if optimization octree has to be updated
  38766. */
  38767. static UpdateSelectionTree: boolean;
  38768. /**
  38769. * Gets a string describing the action executed by the current optimization
  38770. * @return description string
  38771. */
  38772. getDescription(): string;
  38773. private _canBeMerged;
  38774. /**
  38775. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  38776. * @param scene defines the current scene where to apply this optimization
  38777. * @param optimizer defines the current optimizer
  38778. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  38779. * @returns true if everything that can be done was applied
  38780. */
  38781. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  38782. }
  38783. /**
  38784. * Defines a list of options used by SceneOptimizer
  38785. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38786. */
  38787. class SceneOptimizerOptions {
  38788. /**
  38789. * Defines the target frame rate to reach (60 by default)
  38790. */
  38791. targetFrameRate: number;
  38792. /**
  38793. * Defines the interval between two checkes (2000ms by default)
  38794. */
  38795. trackerDuration: number;
  38796. /**
  38797. * Gets the list of optimizations to apply
  38798. */
  38799. optimizations: SceneOptimization[];
  38800. /**
  38801. * Creates a new list of options used by SceneOptimizer
  38802. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  38803. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  38804. */
  38805. constructor(
  38806. /**
  38807. * Defines the target frame rate to reach (60 by default)
  38808. */
  38809. targetFrameRate?: number,
  38810. /**
  38811. * Defines the interval between two checkes (2000ms by default)
  38812. */
  38813. trackerDuration?: number);
  38814. /**
  38815. * Add a new optimization
  38816. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  38817. * @returns the current SceneOptimizerOptions
  38818. */
  38819. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  38820. /**
  38821. * Add a new custom optimization
  38822. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  38823. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  38824. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  38825. * @returns the current SceneOptimizerOptions
  38826. */
  38827. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  38828. /**
  38829. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  38830. * @param targetFrameRate defines the target frame rate (60 by default)
  38831. * @returns a SceneOptimizerOptions object
  38832. */
  38833. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38834. /**
  38835. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  38836. * @param targetFrameRate defines the target frame rate (60 by default)
  38837. * @returns a SceneOptimizerOptions object
  38838. */
  38839. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38840. /**
  38841. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  38842. * @param targetFrameRate defines the target frame rate (60 by default)
  38843. * @returns a SceneOptimizerOptions object
  38844. */
  38845. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  38846. }
  38847. /**
  38848. * Class used to run optimizations in order to reach a target frame rate
  38849. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  38850. */
  38851. class SceneOptimizer implements IDisposable {
  38852. private _isRunning;
  38853. private _options;
  38854. private _scene;
  38855. private _currentPriorityLevel;
  38856. private _targetFrameRate;
  38857. private _trackerDuration;
  38858. private _currentFrameRate;
  38859. private _sceneDisposeObserver;
  38860. private _improvementMode;
  38861. /**
  38862. * Defines an observable called when the optimizer reaches the target frame rate
  38863. */
  38864. onSuccessObservable: Observable<SceneOptimizer>;
  38865. /**
  38866. * Defines an observable called when the optimizer enables an optimization
  38867. */
  38868. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  38869. /**
  38870. * Defines an observable called when the optimizer is not able to reach the target frame rate
  38871. */
  38872. onFailureObservable: Observable<SceneOptimizer>;
  38873. /**
  38874. * Gets a boolean indicating if the optimizer is in improvement mode
  38875. */
  38876. readonly isInImprovementMode: boolean;
  38877. /**
  38878. * Gets the current priority level (0 at start)
  38879. */
  38880. readonly currentPriorityLevel: number;
  38881. /**
  38882. * Gets the current frame rate checked by the SceneOptimizer
  38883. */
  38884. readonly currentFrameRate: number;
  38885. /**
  38886. * Gets or sets the current target frame rate (60 by default)
  38887. */
  38888. /**
  38889. * Gets or sets the current target frame rate (60 by default)
  38890. */
  38891. targetFrameRate: number;
  38892. /**
  38893. * Gets or sets the current interval between two checks (every 2000ms by default)
  38894. */
  38895. /**
  38896. * Gets or sets the current interval between two checks (every 2000ms by default)
  38897. */
  38898. trackerDuration: number;
  38899. /**
  38900. * Gets the list of active optimizations
  38901. */
  38902. readonly optimizations: SceneOptimization[];
  38903. /**
  38904. * Creates a new SceneOptimizer
  38905. * @param scene defines the scene to work on
  38906. * @param options defines the options to use with the SceneOptimizer
  38907. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  38908. * @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)
  38909. */
  38910. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  38911. /**
  38912. * Stops the current optimizer
  38913. */
  38914. stop(): void;
  38915. /**
  38916. * Reset the optimizer to initial step (current priority level = 0)
  38917. */
  38918. reset(): void;
  38919. /**
  38920. * Start the optimizer. By default it will try to reach a specific framerate
  38921. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  38922. */
  38923. start(): void;
  38924. private _checkCurrentState;
  38925. /**
  38926. * Release all resources
  38927. */
  38928. dispose(): void;
  38929. /**
  38930. * Helper function to create a SceneOptimizer with one single line of code
  38931. * @param scene defines the scene to work on
  38932. * @param options defines the options to use with the SceneOptimizer
  38933. * @param onSuccess defines a callback to call on success
  38934. * @param onFailure defines a callback to call on failure
  38935. * @returns the new SceneOptimizer object
  38936. */
  38937. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  38938. }
  38939. }
  38940. declare module BABYLON {
  38941. /**
  38942. * Class used to serialize a scene into a string
  38943. */
  38944. class SceneSerializer {
  38945. /**
  38946. * Clear cache used by a previous serialization
  38947. */
  38948. static ClearCache(): void;
  38949. /**
  38950. * Serialize a scene into a JSON compatible object
  38951. * @param scene defines the scene to serialize
  38952. * @returns a JSON compatible object
  38953. */
  38954. static Serialize(scene: Scene): any;
  38955. /**
  38956. * Serialize a mesh into a JSON compatible object
  38957. * @param toSerialize defines the mesh to serialize
  38958. * @param withParents defines if parents must be serialized as well
  38959. * @param withChildren defines if children must be serialized as well
  38960. * @returns a JSON compatible object
  38961. */
  38962. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  38963. }
  38964. }
  38965. declare module BABYLON {
  38966. /**
  38967. * Defines an array and its length.
  38968. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  38969. */
  38970. interface ISmartArrayLike<T> {
  38971. /**
  38972. * The data of the array.
  38973. */
  38974. data: Array<T>;
  38975. /**
  38976. * The active length of the array.
  38977. */
  38978. length: number;
  38979. }
  38980. /**
  38981. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  38982. */
  38983. class SmartArray<T> implements ISmartArrayLike<T> {
  38984. /**
  38985. * The full set of data from the array.
  38986. */
  38987. data: Array<T>;
  38988. /**
  38989. * The active length of the array.
  38990. */
  38991. length: number;
  38992. protected _id: number;
  38993. /**
  38994. * Instantiates a Smart Array.
  38995. * @param capacity defines the default capacity of the array.
  38996. */
  38997. constructor(capacity: number);
  38998. /**
  38999. * Pushes a value at the end of the active data.
  39000. * @param value defines the object to push in the array.
  39001. */
  39002. push(value: T): void;
  39003. /**
  39004. * Iterates over the active data and apply the lambda to them.
  39005. * @param func defines the action to apply on each value.
  39006. */
  39007. forEach(func: (content: T) => void): void;
  39008. /**
  39009. * Sorts the full sets of data.
  39010. * @param compareFn defines the comparison function to apply.
  39011. */
  39012. sort(compareFn: (a: T, b: T) => number): void;
  39013. /**
  39014. * Resets the active data to an empty array.
  39015. */
  39016. reset(): void;
  39017. /**
  39018. * Releases all the data from the array as well as the array.
  39019. */
  39020. dispose(): void;
  39021. /**
  39022. * Concats the active data with a given array.
  39023. * @param array defines the data to concatenate with.
  39024. */
  39025. concat(array: any): void;
  39026. /**
  39027. * Returns the position of a value in the active data.
  39028. * @param value defines the value to find the index for
  39029. * @returns the index if found in the active data otherwise -1
  39030. */
  39031. indexOf(value: T): number;
  39032. /**
  39033. * Returns whether an element is part of the active data.
  39034. * @param value defines the value to look for
  39035. * @returns true if found in the active data otherwise false
  39036. */
  39037. contains(value: T): boolean;
  39038. private static _GlobalId;
  39039. }
  39040. /**
  39041. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  39042. * The data in this array can only be present once
  39043. */
  39044. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  39045. private _duplicateId;
  39046. /**
  39047. * Pushes a value at the end of the active data.
  39048. * THIS DOES NOT PREVENT DUPPLICATE DATA
  39049. * @param value defines the object to push in the array.
  39050. */
  39051. push(value: T): void;
  39052. /**
  39053. * Pushes a value at the end of the active data.
  39054. * If the data is already present, it won t be added again
  39055. * @param value defines the object to push in the array.
  39056. * @returns true if added false if it was already present
  39057. */
  39058. pushNoDuplicate(value: T): boolean;
  39059. /**
  39060. * Resets the active data to an empty array.
  39061. */
  39062. reset(): void;
  39063. /**
  39064. * Concats the active data with a given array.
  39065. * This ensures no dupplicate will be present in the result.
  39066. * @param array defines the data to concatenate with.
  39067. */
  39068. concatWithNoDuplicate(array: any): void;
  39069. }
  39070. }
  39071. declare module BABYLON {
  39072. /**
  39073. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39074. * The underlying implementation relies on an associative array to ensure the best performances.
  39075. * The value can be anything including 'null' but except 'undefined'
  39076. */
  39077. class StringDictionary<T> {
  39078. /**
  39079. * This will clear this dictionary and copy the content from the 'source' one.
  39080. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39081. * @param source the dictionary to take the content from and copy to this dictionary
  39082. */
  39083. copyFrom(source: StringDictionary<T>): void;
  39084. /**
  39085. * Get a value based from its key
  39086. * @param key the given key to get the matching value from
  39087. * @return the value if found, otherwise undefined is returned
  39088. */
  39089. get(key: string): T | undefined;
  39090. /**
  39091. * Get a value from its key or add it if it doesn't exist.
  39092. * This method will ensure you that a given key/data will be present in the dictionary.
  39093. * @param key the given key to get the matching value from
  39094. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39095. * The factory will only be invoked if there's no data for the given key.
  39096. * @return the value corresponding to the key.
  39097. */
  39098. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39099. /**
  39100. * Get a value from its key if present in the dictionary otherwise add it
  39101. * @param key the key to get the value from
  39102. * @param val if there's no such key/value pair in the dictionary add it with this value
  39103. * @return the value corresponding to the key
  39104. */
  39105. getOrAdd(key: string, val: T): T;
  39106. /**
  39107. * Check if there's a given key in the dictionary
  39108. * @param key the key to check for
  39109. * @return true if the key is present, false otherwise
  39110. */
  39111. contains(key: string): boolean;
  39112. /**
  39113. * Add a new key and its corresponding value
  39114. * @param key the key to add
  39115. * @param value the value corresponding to the key
  39116. * @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
  39117. */
  39118. add(key: string, value: T): boolean;
  39119. /**
  39120. * Update a specific value associated to a key
  39121. * @param key defines the key to use
  39122. * @param value defines the value to store
  39123. * @returns true if the value was updated (or false if the key was not found)
  39124. */
  39125. set(key: string, value: T): boolean;
  39126. /**
  39127. * Get the element of the given key and remove it from the dictionary
  39128. * @param key defines the key to search
  39129. * @returns the value associated with the key or null if not found
  39130. */
  39131. getAndRemove(key: string): Nullable<T>;
  39132. /**
  39133. * Remove a key/value from the dictionary.
  39134. * @param key the key to remove
  39135. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39136. */
  39137. remove(key: string): boolean;
  39138. /**
  39139. * Clear the whole content of the dictionary
  39140. */
  39141. clear(): void;
  39142. /**
  39143. * Gets the current count
  39144. */
  39145. readonly count: number;
  39146. /**
  39147. * Execute a callback on each key/val of the dictionary.
  39148. * Note that you can remove any element in this dictionary in the callback implementation
  39149. * @param callback the callback to execute on a given key/value pair
  39150. */
  39151. forEach(callback: (key: string, val: T) => void): void;
  39152. /**
  39153. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39154. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39155. * Note that you can remove any element in this dictionary in the callback implementation
  39156. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39157. * @returns the first item
  39158. */
  39159. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39160. private _count;
  39161. private _data;
  39162. }
  39163. }
  39164. declare module BABYLON {
  39165. /**
  39166. * Class used to store custom tags
  39167. */
  39168. class Tags {
  39169. /**
  39170. * Adds support for tags on the given object
  39171. * @param obj defines the object to use
  39172. */
  39173. static EnableFor(obj: any): void;
  39174. /**
  39175. * Removes tags support
  39176. * @param obj defines the object to use
  39177. */
  39178. static DisableFor(obj: any): void;
  39179. /**
  39180. * Gets a boolean indicating if the given object has tags
  39181. * @param obj defines the object to use
  39182. * @returns a boolean
  39183. */
  39184. static HasTags(obj: any): boolean;
  39185. /**
  39186. * Gets the tags available on a given object
  39187. * @param obj defines the object to use
  39188. * @param asString defines if the tags must be returned as a string instead of an array of strings
  39189. * @returns the tags
  39190. */
  39191. static GetTags(obj: any, asString?: boolean): any;
  39192. /**
  39193. * Adds tags to an object
  39194. * @param obj defines the object to use
  39195. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  39196. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  39197. */
  39198. static AddTagsTo(obj: any, tagsString: string): void;
  39199. /**
  39200. * @hidden
  39201. */
  39202. static _AddTagTo(obj: any, tag: string): void;
  39203. /**
  39204. * Removes specific tags from a specific object
  39205. * @param obj defines the object to use
  39206. * @param tagsString defines the tags to remove
  39207. */
  39208. static RemoveTagsFrom(obj: any, tagsString: string): void;
  39209. /**
  39210. * @hidden
  39211. */
  39212. static _RemoveTagFrom(obj: any, tag: string): void;
  39213. /**
  39214. * Defines if tags hosted on an object match a given query
  39215. * @param obj defines the object to use
  39216. * @param tagsQuery defines the tag query
  39217. * @returns a boolean
  39218. */
  39219. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  39220. }
  39221. }
  39222. declare module BABYLON {
  39223. /**
  39224. * Class used to host texture specific utilities
  39225. */
  39226. class TextureTools {
  39227. /**
  39228. * Uses the GPU to create a copy texture rescaled at a given size
  39229. * @param texture Texture to copy from
  39230. * @param width defines the desired width
  39231. * @param height defines the desired height
  39232. * @param useBilinearMode defines if bilinear mode has to be used
  39233. * @return the generated texture
  39234. */
  39235. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  39236. /**
  39237. * Gets an environment BRDF texture for a given scene
  39238. * @param scene defines the hosting scene
  39239. * @returns the environment BRDF texture
  39240. */
  39241. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  39242. private static _environmentBRDFBase64Texture;
  39243. }
  39244. }
  39245. declare module BABYLON {
  39246. /**
  39247. * Based on jsTGALoader - Javascript loader for TGA file
  39248. * By Vincent Thibault
  39249. * @see http://blog.robrowser.com/javascript-tga-loader.html
  39250. */
  39251. class TGATools {
  39252. private static _TYPE_INDEXED;
  39253. private static _TYPE_RGB;
  39254. private static _TYPE_GREY;
  39255. private static _TYPE_RLE_INDEXED;
  39256. private static _TYPE_RLE_RGB;
  39257. private static _TYPE_RLE_GREY;
  39258. private static _ORIGIN_MASK;
  39259. private static _ORIGIN_SHIFT;
  39260. private static _ORIGIN_BL;
  39261. private static _ORIGIN_BR;
  39262. private static _ORIGIN_UL;
  39263. private static _ORIGIN_UR;
  39264. /**
  39265. * Gets the header of a TGA file
  39266. * @param data defines the TGA data
  39267. * @returns the header
  39268. */
  39269. static GetTGAHeader(data: Uint8Array): any;
  39270. /**
  39271. * Uploads TGA content to a Babylon Texture
  39272. * @hidden
  39273. */
  39274. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  39275. /** @hidden */
  39276. 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;
  39277. /** @hidden */
  39278. 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;
  39279. /** @hidden */
  39280. 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;
  39281. /** @hidden */
  39282. 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;
  39283. /** @hidden */
  39284. 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;
  39285. /** @hidden */
  39286. 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;
  39287. }
  39288. }
  39289. declare module BABYLON {
  39290. /**
  39291. * Interface for any object that can request an animation frame
  39292. */
  39293. interface ICustomAnimationFrameRequester {
  39294. /**
  39295. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  39296. */
  39297. renderFunction?: Function;
  39298. /**
  39299. * Called to request the next frame to render to
  39300. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  39301. */
  39302. requestAnimationFrame: Function;
  39303. /**
  39304. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  39305. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  39306. */
  39307. requestID?: number;
  39308. }
  39309. /**
  39310. * Interface containing an array of animations
  39311. */
  39312. interface IAnimatable {
  39313. /**
  39314. * Array of animations
  39315. */
  39316. animations: Array<Animation>;
  39317. }
  39318. /** Interface used by value gradients (color, factor, ...) */
  39319. interface IValueGradient {
  39320. /**
  39321. * Gets or sets the gradient value (between 0 and 1)
  39322. */
  39323. gradient: number;
  39324. }
  39325. /** Class used to store color4 gradient */
  39326. class ColorGradient implements IValueGradient {
  39327. /**
  39328. * Gets or sets the gradient value (between 0 and 1)
  39329. */
  39330. gradient: number;
  39331. /**
  39332. * Gets or sets first associated color
  39333. */
  39334. color1: Color4;
  39335. /**
  39336. * Gets or sets second associated color
  39337. */
  39338. color2?: Color4;
  39339. /**
  39340. * Will get a color picked randomly between color1 and color2.
  39341. * If color2 is undefined then color1 will be used
  39342. * @param result defines the target Color4 to store the result in
  39343. */
  39344. getColorToRef(result: Color4): void;
  39345. }
  39346. /** Class used to store color 3 gradient */
  39347. class Color3Gradient implements IValueGradient {
  39348. /**
  39349. * Gets or sets the gradient value (between 0 and 1)
  39350. */
  39351. gradient: number;
  39352. /**
  39353. * Gets or sets the associated color
  39354. */
  39355. color: Color3;
  39356. }
  39357. /** Class used to store factor gradient */
  39358. class FactorGradient implements IValueGradient {
  39359. /**
  39360. * Gets or sets the gradient value (between 0 and 1)
  39361. */
  39362. gradient: number;
  39363. /**
  39364. * Gets or sets first associated factor
  39365. */
  39366. factor1: number;
  39367. /**
  39368. * Gets or sets second associated factor
  39369. */
  39370. factor2?: number;
  39371. /**
  39372. * Will get a number picked randomly between factor1 and factor2.
  39373. * If factor2 is undefined then factor1 will be used
  39374. * @returns the picked number
  39375. */
  39376. getFactor(): number;
  39377. }
  39378. /**
  39379. * @ignore
  39380. * Application error to support additional information when loading a file
  39381. */
  39382. class LoadFileError extends Error {
  39383. /** defines the optional XHR request */
  39384. request?: XMLHttpRequest | undefined;
  39385. private static _setPrototypeOf;
  39386. /**
  39387. * Creates a new LoadFileError
  39388. * @param message defines the message of the error
  39389. * @param request defines the optional XHR request
  39390. */
  39391. constructor(message: string,
  39392. /** defines the optional XHR request */
  39393. request?: XMLHttpRequest | undefined);
  39394. }
  39395. /**
  39396. * Class used to define a retry strategy when error happens while loading assets
  39397. */
  39398. class RetryStrategy {
  39399. /**
  39400. * Function used to defines an exponential back off strategy
  39401. * @param maxRetries defines the maximum number of retries (3 by default)
  39402. * @param baseInterval defines the interval between retries
  39403. * @returns the strategy function to use
  39404. */
  39405. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39406. }
  39407. /**
  39408. * File request interface
  39409. */
  39410. interface IFileRequest {
  39411. /**
  39412. * Raised when the request is complete (success or error).
  39413. */
  39414. onCompleteObservable: Observable<IFileRequest>;
  39415. /**
  39416. * Aborts the request for a file.
  39417. */
  39418. abort: () => void;
  39419. }
  39420. /**
  39421. * Class containing a set of static utilities functions
  39422. */
  39423. class Tools {
  39424. /**
  39425. * Gets or sets the base URL to use to load assets
  39426. */
  39427. static BaseUrl: string;
  39428. /**
  39429. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39430. */
  39431. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  39432. /**
  39433. * Default behaviour for cors in the application.
  39434. * It can be a string if the expected behavior is identical in the entire app.
  39435. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39436. */
  39437. static CorsBehavior: string | ((url: string | string[]) => string);
  39438. /**
  39439. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39440. * @ignorenaming
  39441. */
  39442. static UseFallbackTexture: boolean;
  39443. /**
  39444. * Use this object to register external classes like custom textures or material
  39445. * to allow the laoders to instantiate them
  39446. */
  39447. static RegisteredExternalClasses: {
  39448. [key: string]: Object;
  39449. };
  39450. /**
  39451. * Texture content used if a texture cannot loaded
  39452. * @ignorenaming
  39453. */
  39454. static fallbackTexture: string;
  39455. /**
  39456. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39457. * @param u defines the coordinate on X axis
  39458. * @param v defines the coordinate on Y axis
  39459. * @param width defines the width of the source data
  39460. * @param height defines the height of the source data
  39461. * @param pixels defines the source byte array
  39462. * @param color defines the output color
  39463. */
  39464. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  39465. /**
  39466. * Interpolates between a and b via alpha
  39467. * @param a The lower value (returned when alpha = 0)
  39468. * @param b The upper value (returned when alpha = 1)
  39469. * @param alpha The interpolation-factor
  39470. * @return The mixed value
  39471. */
  39472. static Mix(a: number, b: number, alpha: number): number;
  39473. /**
  39474. * Tries to instantiate a new object from a given class name
  39475. * @param className defines the class name to instantiate
  39476. * @returns the new object or null if the system was not able to do the instantiation
  39477. */
  39478. static Instantiate(className: string): any;
  39479. /**
  39480. * Provides a slice function that will work even on IE
  39481. * @param data defines the array to slice
  39482. * @param start defines the start of the data (optional)
  39483. * @param end defines the end of the data (optional)
  39484. * @returns the new sliced array
  39485. */
  39486. static Slice<T>(data: T, start?: number, end?: number): T;
  39487. /**
  39488. * Polyfill for setImmediate
  39489. * @param action defines the action to execute after the current execution block
  39490. */
  39491. static SetImmediate(action: () => void): void;
  39492. /**
  39493. * Function indicating if a number is an exponent of 2
  39494. * @param value defines the value to test
  39495. * @returns true if the value is an exponent of 2
  39496. */
  39497. static IsExponentOfTwo(value: number): boolean;
  39498. private static _tmpFloatArray;
  39499. /**
  39500. * Returns the nearest 32-bit single precision float representation of a Number
  39501. * @param value A Number. If the parameter is of a different type, it will get converted
  39502. * to a number or to NaN if it cannot be converted
  39503. * @returns number
  39504. */
  39505. static FloatRound(value: number): number;
  39506. /**
  39507. * Find the next highest power of two.
  39508. * @param x Number to start search from.
  39509. * @return Next highest power of two.
  39510. */
  39511. static CeilingPOT(x: number): number;
  39512. /**
  39513. * Find the next lowest power of two.
  39514. * @param x Number to start search from.
  39515. * @return Next lowest power of two.
  39516. */
  39517. static FloorPOT(x: number): number;
  39518. /**
  39519. * Find the nearest power of two.
  39520. * @param x Number to start search from.
  39521. * @return Next nearest power of two.
  39522. */
  39523. static NearestPOT(x: number): number;
  39524. /**
  39525. * Get the closest exponent of two
  39526. * @param value defines the value to approximate
  39527. * @param max defines the maximum value to return
  39528. * @param mode defines how to define the closest value
  39529. * @returns closest exponent of two of the given value
  39530. */
  39531. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39532. /**
  39533. * Extracts the filename from a path
  39534. * @param path defines the path to use
  39535. * @returns the filename
  39536. */
  39537. static GetFilename(path: string): string;
  39538. /**
  39539. * Extracts the "folder" part of a path (everything before the filename).
  39540. * @param uri The URI to extract the info from
  39541. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39542. * @returns The "folder" part of the path
  39543. */
  39544. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39545. /**
  39546. * Extracts text content from a DOM element hierarchy
  39547. * @param element defines the root element
  39548. * @returns a string
  39549. */
  39550. static GetDOMTextContent(element: HTMLElement): string;
  39551. /**
  39552. * Convert an angle in radians to degrees
  39553. * @param angle defines the angle to convert
  39554. * @returns the angle in degrees
  39555. */
  39556. static ToDegrees(angle: number): number;
  39557. /**
  39558. * Convert an angle in degrees to radians
  39559. * @param angle defines the angle to convert
  39560. * @returns the angle in radians
  39561. */
  39562. static ToRadians(angle: number): number;
  39563. /**
  39564. * Encode a buffer to a base64 string
  39565. * @param buffer defines the buffer to encode
  39566. * @returns the encoded string
  39567. */
  39568. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  39569. /**
  39570. * Extracts minimum and maximum values from a list of indexed positions
  39571. * @param positions defines the positions to use
  39572. * @param indices defines the indices to the positions
  39573. * @param indexStart defines the start index
  39574. * @param indexCount defines the end index
  39575. * @param bias defines bias value to add to the result
  39576. * @return minimum and maximum values
  39577. */
  39578. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  39579. minimum: Vector3;
  39580. maximum: Vector3;
  39581. };
  39582. /**
  39583. * Extracts minimum and maximum values from a list of positions
  39584. * @param positions defines the positions to use
  39585. * @param start defines the start index in the positions array
  39586. * @param count defines the number of positions to handle
  39587. * @param bias defines bias value to add to the result
  39588. * @param stride defines the stride size to use (distance between two positions in the positions array)
  39589. * @return minimum and maximum values
  39590. */
  39591. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  39592. minimum: Vector3;
  39593. maximum: Vector3;
  39594. };
  39595. /**
  39596. * Returns an array if obj is not an array
  39597. * @param obj defines the object to evaluate as an array
  39598. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39599. * @returns either obj directly if obj is an array or a new array containing obj
  39600. */
  39601. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39602. /**
  39603. * Returns an array of the given size filled with element built from the given constructor and the paramters
  39604. * @param size the number of element to construct and put in the array
  39605. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  39606. * @returns a new array filled with new objects
  39607. */
  39608. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  39609. /**
  39610. * Gets the pointer prefix to use
  39611. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39612. */
  39613. static GetPointerPrefix(): string;
  39614. /**
  39615. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39616. * @param func - the function to be called
  39617. * @param requester - the object that will request the next frame. Falls back to window.
  39618. * @returns frame number
  39619. */
  39620. static QueueNewFrame(func: () => void, requester?: any): number;
  39621. /**
  39622. * Ask the browser to promote the current element to fullscreen rendering mode
  39623. * @param element defines the DOM element to promote
  39624. */
  39625. static RequestFullscreen(element: HTMLElement): void;
  39626. /**
  39627. * Asks the browser to exit fullscreen mode
  39628. */
  39629. static ExitFullscreen(): void;
  39630. /**
  39631. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39632. * @param url define the url we are trying
  39633. * @param element define the dom element where to configure the cors policy
  39634. */
  39635. static SetCorsBehavior(url: string | string[], element: {
  39636. crossOrigin: string | null;
  39637. }): void;
  39638. /**
  39639. * Removes unwanted characters from an url
  39640. * @param url defines the url to clean
  39641. * @returns the cleaned url
  39642. */
  39643. static CleanUrl(url: string): string;
  39644. /**
  39645. * Gets or sets a function used to pre-process url before using them to load assets
  39646. */
  39647. static PreprocessUrl: (url: string) => string;
  39648. /**
  39649. * Loads an image as an HTMLImageElement.
  39650. * @param input url string, ArrayBuffer, or Blob to load
  39651. * @param onLoad callback called when the image successfully loads
  39652. * @param onError callback called when the image fails to load
  39653. * @param offlineProvider offline provider for caching
  39654. * @returns the HTMLImageElement of the loaded image
  39655. */
  39656. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  39657. /**
  39658. * Loads a file
  39659. * @param url url string, ArrayBuffer, or Blob to load
  39660. * @param onSuccess callback called when the file successfully loads
  39661. * @param onProgress callback called while file is loading (if the server supports this mode)
  39662. * @param offlineProvider defines the offline provider for caching
  39663. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39664. * @param onError callback called when the file fails to load
  39665. * @returns a file request object
  39666. */
  39667. 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;
  39668. /**
  39669. * Load a script (identified by an url). When the url returns, the
  39670. * content of this file is added into a new script element, attached to the DOM (body element)
  39671. * @param scriptUrl defines the url of the script to laod
  39672. * @param onSuccess defines the callback called when the script is loaded
  39673. * @param onError defines the callback to call if an error occurs
  39674. */
  39675. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  39676. /**
  39677. * Loads a file from a blob
  39678. * @param fileToLoad defines the blob to use
  39679. * @param callback defines the callback to call when data is loaded
  39680. * @param progressCallback defines the callback to call during loading process
  39681. * @returns a file request object
  39682. */
  39683. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39684. /**
  39685. * Loads a file
  39686. * @param fileToLoad defines the file to load
  39687. * @param callback defines the callback to call when data is loaded
  39688. * @param progressCallBack defines the callback to call during loading process
  39689. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39690. * @returns a file request object
  39691. */
  39692. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  39693. /**
  39694. * Creates a data url from a given string content
  39695. * @param content defines the content to convert
  39696. * @returns the new data url link
  39697. */
  39698. static FileAsURL(content: string): string;
  39699. /**
  39700. * Format the given number to a specific decimal format
  39701. * @param value defines the number to format
  39702. * @param decimals defines the number of decimals to use
  39703. * @returns the formatted string
  39704. */
  39705. static Format(value: number, decimals?: number): string;
  39706. /**
  39707. * Checks if a given vector is inside a specific range
  39708. * @param v defines the vector to test
  39709. * @param min defines the minimum range
  39710. * @param max defines the maximum range
  39711. */
  39712. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  39713. /**
  39714. * Tries to copy an object by duplicating every property
  39715. * @param source defines the source object
  39716. * @param destination defines the target object
  39717. * @param doNotCopyList defines a list of properties to avoid
  39718. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39719. */
  39720. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39721. /**
  39722. * Gets a boolean indicating if the given object has no own property
  39723. * @param obj defines the object to test
  39724. * @returns true if object has no own property
  39725. */
  39726. static IsEmpty(obj: any): boolean;
  39727. /**
  39728. * Function used to register events at window level
  39729. * @param events defines the events to register
  39730. */
  39731. static RegisterTopRootEvents(events: {
  39732. name: string;
  39733. handler: Nullable<(e: FocusEvent) => any>;
  39734. }[]): void;
  39735. /**
  39736. * Function used to unregister events from window level
  39737. * @param events defines the events to unregister
  39738. */
  39739. static UnregisterTopRootEvents(events: {
  39740. name: string;
  39741. handler: Nullable<(e: FocusEvent) => any>;
  39742. }[]): void;
  39743. /**
  39744. * Dumps the current bound framebuffer
  39745. * @param width defines the rendering width
  39746. * @param height defines the rendering height
  39747. * @param engine defines the hosting engine
  39748. * @param successCallback defines the callback triggered once the data are available
  39749. * @param mimeType defines the mime type of the result
  39750. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39751. */
  39752. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39753. /**
  39754. * Converts the canvas data to blob.
  39755. * This acts as a polyfill for browsers not supporting the to blob function.
  39756. * @param canvas Defines the canvas to extract the data from
  39757. * @param successCallback Defines the callback triggered once the data are available
  39758. * @param mimeType Defines the mime type of the result
  39759. */
  39760. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39761. /**
  39762. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39763. * @param successCallback defines the callback triggered once the data are available
  39764. * @param mimeType defines the mime type of the result
  39765. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39766. */
  39767. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39768. /**
  39769. * Downloads a blob in the browser
  39770. * @param blob defines the blob to download
  39771. * @param fileName defines the name of the downloaded file
  39772. */
  39773. static Download(blob: Blob, fileName: string): void;
  39774. /**
  39775. * Captures a screenshot of the current rendering
  39776. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39777. * @param engine defines the rendering engine
  39778. * @param camera defines the source camera
  39779. * @param size This parameter can be set to a single number or to an object with the
  39780. * following (optional) properties: precision, width, height. If a single number is passed,
  39781. * it will be used for both width and height. If an object is passed, the screenshot size
  39782. * will be derived from the parameters. The precision property is a multiplier allowing
  39783. * rendering at a higher or lower resolution
  39784. * @param successCallback defines the callback receives a single parameter which contains the
  39785. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39786. * src parameter of an <img> to display it
  39787. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39788. * Check your browser for supported MIME types
  39789. */
  39790. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  39791. /**
  39792. * Generates an image screenshot from the specified camera.
  39793. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  39794. * @param engine The engine to use for rendering
  39795. * @param camera The camera to use for rendering
  39796. * @param size This parameter can be set to a single number or to an object with the
  39797. * following (optional) properties: precision, width, height. If a single number is passed,
  39798. * it will be used for both width and height. If an object is passed, the screenshot size
  39799. * will be derived from the parameters. The precision property is a multiplier allowing
  39800. * rendering at a higher or lower resolution
  39801. * @param successCallback The callback receives a single parameter which contains the
  39802. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39803. * src parameter of an <img> to display it
  39804. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39805. * Check your browser for supported MIME types
  39806. * @param samples Texture samples (default: 1)
  39807. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39808. * @param fileName A name for for the downloaded file.
  39809. */
  39810. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39811. /**
  39812. * Validates if xhr data is correct
  39813. * @param xhr defines the request to validate
  39814. * @param dataType defines the expected data type
  39815. * @returns true if data is correct
  39816. */
  39817. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  39818. /**
  39819. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39820. * Be aware Math.random() could cause collisions, but:
  39821. * "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"
  39822. * @returns a pseudo random id
  39823. */
  39824. static RandomId(): string;
  39825. /**
  39826. * Test if the given uri is a base64 string
  39827. * @param uri The uri to test
  39828. * @return True if the uri is a base64 string or false otherwise
  39829. */
  39830. static IsBase64(uri: string): boolean;
  39831. /**
  39832. * Decode the given base64 uri.
  39833. * @param uri The uri to decode
  39834. * @return The decoded base64 data.
  39835. */
  39836. static DecodeBase64(uri: string): ArrayBuffer;
  39837. /**
  39838. * No log
  39839. */
  39840. static readonly NoneLogLevel: number;
  39841. /**
  39842. * Only message logs
  39843. */
  39844. static readonly MessageLogLevel: number;
  39845. /**
  39846. * Only warning logs
  39847. */
  39848. static readonly WarningLogLevel: number;
  39849. /**
  39850. * Only error logs
  39851. */
  39852. static readonly ErrorLogLevel: number;
  39853. /**
  39854. * All logs
  39855. */
  39856. static readonly AllLogLevel: number;
  39857. private static _LogCache;
  39858. /**
  39859. * Gets a value indicating the number of loading errors
  39860. * @ignorenaming
  39861. */
  39862. static errorsCount: number;
  39863. /**
  39864. * Callback called when a new log is added
  39865. */
  39866. static OnNewCacheEntry: (entry: string) => void;
  39867. private static _AddLogEntry;
  39868. private static _FormatMessage;
  39869. private static _LogDisabled;
  39870. private static _LogEnabled;
  39871. private static _WarnDisabled;
  39872. private static _WarnEnabled;
  39873. private static _ErrorDisabled;
  39874. private static _ErrorEnabled;
  39875. /**
  39876. * Log a message to the console
  39877. */
  39878. static Log: (message: string) => void;
  39879. /**
  39880. * Write a warning message to the console
  39881. */
  39882. static Warn: (message: string) => void;
  39883. /**
  39884. * Write an error message to the console
  39885. */
  39886. static Error: (message: string) => void;
  39887. /**
  39888. * Gets current log cache (list of logs)
  39889. */
  39890. static readonly LogCache: string;
  39891. /**
  39892. * Clears the log cache
  39893. */
  39894. static ClearLogCache(): void;
  39895. /**
  39896. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39897. */
  39898. static LogLevels: number;
  39899. /**
  39900. * Checks if the loaded document was accessed via `file:`-Protocol.
  39901. * @returns boolean
  39902. */
  39903. static IsFileURL(): boolean;
  39904. /**
  39905. * Checks if the window object exists
  39906. * @returns true if the window object exists
  39907. */
  39908. static IsWindowObjectExist(): boolean;
  39909. /**
  39910. * No performance log
  39911. */
  39912. static readonly PerformanceNoneLogLevel: number;
  39913. /**
  39914. * Use user marks to log performance
  39915. */
  39916. static readonly PerformanceUserMarkLogLevel: number;
  39917. /**
  39918. * Log performance to the console
  39919. */
  39920. static readonly PerformanceConsoleLogLevel: number;
  39921. private static _performance;
  39922. /**
  39923. * Sets the current performance log level
  39924. */
  39925. static PerformanceLogLevel: number;
  39926. private static _StartPerformanceCounterDisabled;
  39927. private static _EndPerformanceCounterDisabled;
  39928. private static _StartUserMark;
  39929. private static _EndUserMark;
  39930. private static _StartPerformanceConsole;
  39931. private static _EndPerformanceConsole;
  39932. /**
  39933. * Starts a performance counter
  39934. */
  39935. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39936. /**
  39937. * Ends a specific performance coutner
  39938. */
  39939. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39940. /**
  39941. * Gets either window.performance.now() if supported or Date.now() else
  39942. */
  39943. static readonly Now: number;
  39944. /**
  39945. * This method will return the name of the class used to create the instance of the given object.
  39946. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39947. * @param object the object to get the class name from
  39948. * @param isType defines if the object is actually a type
  39949. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39950. */
  39951. static GetClassName(object: any, isType?: boolean): string;
  39952. /**
  39953. * Gets the first element of an array satisfying a given predicate
  39954. * @param array defines the array to browse
  39955. * @param predicate defines the predicate to use
  39956. * @returns null if not found or the element
  39957. */
  39958. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39959. /**
  39960. * This method will return the name of the full name of the class, including its owning module (if any).
  39961. * 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).
  39962. * @param object the object to get the class name from
  39963. * @param isType defines if the object is actually a type
  39964. * @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.
  39965. * @ignorenaming
  39966. */
  39967. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39968. /**
  39969. * Returns a promise that resolves after the given amount of time.
  39970. * @param delay Number of milliseconds to delay
  39971. * @returns Promise that resolves after the given amount of time
  39972. */
  39973. static DelayAsync(delay: number): Promise<void>;
  39974. /**
  39975. * Gets the current gradient from an array of IValueGradient
  39976. * @param ratio defines the current ratio to get
  39977. * @param gradients defines the array of IValueGradient
  39978. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  39979. */
  39980. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  39981. }
  39982. /**
  39983. * This class is used to track a performance counter which is number based.
  39984. * The user has access to many properties which give statistics of different nature.
  39985. *
  39986. * The implementer can track two kinds of Performance Counter: time and count.
  39987. * 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.
  39988. * 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.
  39989. */
  39990. class PerfCounter {
  39991. /**
  39992. * Gets or sets a global boolean to turn on and off all the counters
  39993. */
  39994. static Enabled: boolean;
  39995. /**
  39996. * Returns the smallest value ever
  39997. */
  39998. readonly min: number;
  39999. /**
  40000. * Returns the biggest value ever
  40001. */
  40002. readonly max: number;
  40003. /**
  40004. * Returns the average value since the performance counter is running
  40005. */
  40006. readonly average: number;
  40007. /**
  40008. * Returns the average value of the last second the counter was monitored
  40009. */
  40010. readonly lastSecAverage: number;
  40011. /**
  40012. * Returns the current value
  40013. */
  40014. readonly current: number;
  40015. /**
  40016. * Gets the accumulated total
  40017. */
  40018. readonly total: number;
  40019. /**
  40020. * Gets the total value count
  40021. */
  40022. readonly count: number;
  40023. /**
  40024. * Creates a new counter
  40025. */
  40026. constructor();
  40027. /**
  40028. * Call this method to start monitoring a new frame.
  40029. * 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.
  40030. */
  40031. fetchNewFrame(): void;
  40032. /**
  40033. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40034. * @param newCount the count value to add to the monitored count
  40035. * @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.
  40036. */
  40037. addCount(newCount: number, fetchResult: boolean): void;
  40038. /**
  40039. * Start monitoring this performance counter
  40040. */
  40041. beginMonitoring(): void;
  40042. /**
  40043. * Compute the time lapsed since the previous beginMonitoring() call.
  40044. * @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
  40045. */
  40046. endMonitoring(newFrame?: boolean): void;
  40047. private _fetchResult;
  40048. private _startMonitoringTime;
  40049. private _min;
  40050. private _max;
  40051. private _average;
  40052. private _current;
  40053. private _totalValueCount;
  40054. private _totalAccumulated;
  40055. private _lastSecAverage;
  40056. private _lastSecAccumulated;
  40057. private _lastSecTime;
  40058. private _lastSecValueCount;
  40059. }
  40060. /**
  40061. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40062. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40063. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40064. * @param name The name of the class, case should be preserved
  40065. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40066. */
  40067. function className(name: string, module?: string): (target: Object) => void;
  40068. /**
  40069. * An implementation of a loop for asynchronous functions.
  40070. */
  40071. class AsyncLoop {
  40072. /**
  40073. * Defines the number of iterations for the loop
  40074. */
  40075. iterations: number;
  40076. /**
  40077. * Defines the current index of the loop.
  40078. */
  40079. index: number;
  40080. private _done;
  40081. private _fn;
  40082. private _successCallback;
  40083. /**
  40084. * Constructor.
  40085. * @param iterations the number of iterations.
  40086. * @param func the function to run each iteration
  40087. * @param successCallback the callback that will be called upon succesful execution
  40088. * @param offset starting offset.
  40089. */
  40090. constructor(
  40091. /**
  40092. * Defines the number of iterations for the loop
  40093. */
  40094. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40095. /**
  40096. * Execute the next iteration. Must be called after the last iteration was finished.
  40097. */
  40098. executeNext(): void;
  40099. /**
  40100. * Break the loop and run the success callback.
  40101. */
  40102. breakLoop(): void;
  40103. /**
  40104. * Create and run an async loop.
  40105. * @param iterations the number of iterations.
  40106. * @param fn the function to run each iteration
  40107. * @param successCallback the callback that will be called upon succesful execution
  40108. * @param offset starting offset.
  40109. * @returns the created async loop object
  40110. */
  40111. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40112. /**
  40113. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40114. * @param iterations total number of iterations
  40115. * @param syncedIterations number of synchronous iterations in each async iteration.
  40116. * @param fn the function to call each iteration.
  40117. * @param callback a success call back that will be called when iterating stops.
  40118. * @param breakFunction a break condition (optional)
  40119. * @param timeout timeout settings for the setTimeout function. default - 0.
  40120. * @returns the created async loop object
  40121. */
  40122. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40123. }
  40124. }
  40125. interface HTMLCanvasElement {
  40126. /** Track wether a record is in progress */
  40127. isRecording: boolean;
  40128. /** Capture Stream method defined by some browsers */
  40129. captureStream(fps?: number): MediaStream;
  40130. }
  40131. interface MediaRecorder {
  40132. /** Starts recording */
  40133. start(timeSlice: number): void;
  40134. /** Stops recording */
  40135. stop(): void;
  40136. /** Event raised when an error arised. */
  40137. onerror: (event: ErrorEvent) => void;
  40138. /** Event raised when the recording stops. */
  40139. onstop: (event: Event) => void;
  40140. /** Event raised when a new chunk of data is available and should be tracked. */
  40141. ondataavailable: (event: Event) => void;
  40142. }
  40143. interface MediaRecorderOptions {
  40144. /** The mime type you want to use as the recording container for the new MediaRecorder */
  40145. mimeType?: string;
  40146. /** The chosen bitrate for the audio component of the media. */
  40147. audioBitsPerSecond?: number;
  40148. /** The chosen bitrate for the video component of the media. */
  40149. videoBitsPerSecond?: number;
  40150. /** The chosen bitrate for the audio and video components of the media. This can be specified instead of the above two properties. If this is specified along with one or the other of the above properties, this will be used for the one that isn't specified. */
  40151. bitsPerSecond?: number;
  40152. }
  40153. interface MediaRecorderConstructor {
  40154. /**
  40155. * A reference to the prototype.
  40156. */
  40157. readonly prototype: MediaRecorder;
  40158. /**
  40159. * Creates a new MediaRecorder.
  40160. * @param stream Defines the stream to record.
  40161. * @param options Defines the options for the recorder available in the type MediaRecorderOptions.
  40162. */
  40163. new (stream: MediaStream, options?: MediaRecorderOptions): MediaRecorder;
  40164. }
  40165. /**
  40166. * MediaRecoreder object available in some browsers.
  40167. */
  40168. declare var MediaRecorder: MediaRecorderConstructor;
  40169. declare module BABYLON {
  40170. /**
  40171. * This represents the different options avilable for the video capture.
  40172. */
  40173. interface VideoRecorderOptions {
  40174. /** Defines the mime type of the video */
  40175. mimeType: string;
  40176. /** Defines the video the video should be recorded at */
  40177. fps: number;
  40178. /** Defines the chunk size for the recording data */
  40179. recordChunckSize: number;
  40180. }
  40181. /**
  40182. * This can helps recording videos from BabylonJS.
  40183. * This is based on the available WebRTC functionalities of the browser.
  40184. *
  40185. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  40186. */
  40187. class VideoRecorder {
  40188. private static readonly _defaultOptions;
  40189. /**
  40190. * Returns wehther or not the VideoRecorder is available in your browser.
  40191. * @param engine Defines the Babylon Engine to check the support for
  40192. * @returns true if supported otherwise false
  40193. */
  40194. static IsSupported(engine: Engine): boolean;
  40195. private readonly _options;
  40196. private _canvas;
  40197. private _mediaRecorder;
  40198. private _recordedChunks;
  40199. private _fileName;
  40200. private _resolve;
  40201. private _reject;
  40202. /**
  40203. * True wether a recording is already in progress.
  40204. */
  40205. readonly isRecording: boolean;
  40206. /**
  40207. * Create a new VideoCapture object which can help converting what you see in Babylon to
  40208. * a video file.
  40209. * @param engine Defines the BabylonJS Engine you wish to record
  40210. * @param options Defines options that can be used to customized the capture
  40211. */
  40212. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  40213. /**
  40214. * Stops the current recording before the default capture timeout passed in the startRecording
  40215. * functions.
  40216. */
  40217. stopRecording(): void;
  40218. /**
  40219. * Starts recording the canvas for a max duration specified in parameters.
  40220. * @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.
  40221. * @param maxDuration Defines the maximum recording time in seconds.
  40222. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  40223. * @return a promise callback at the end of the recording with the video data in Blob.
  40224. */
  40225. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  40226. /**
  40227. * Releases internal resources used during the recording.
  40228. */
  40229. dispose(): void;
  40230. private _handleDataAvailable;
  40231. private _handleError;
  40232. private _handleStop;
  40233. }
  40234. }
  40235. declare module BABYLON {
  40236. /**
  40237. * Defines the potential axis of a Joystick
  40238. */
  40239. enum JoystickAxis {
  40240. /** X axis */
  40241. X = 0,
  40242. /** Y axis */
  40243. Y = 1,
  40244. /** Z axis */
  40245. Z = 2
  40246. }
  40247. /**
  40248. * Class used to define virtual joystick (used in touch mode)
  40249. */
  40250. class VirtualJoystick {
  40251. /**
  40252. * Gets or sets a boolean indicating that left and right values must be inverted
  40253. */
  40254. reverseLeftRight: boolean;
  40255. /**
  40256. * Gets or sets a boolean indicating that up and down values must be inverted
  40257. */
  40258. reverseUpDown: boolean;
  40259. /**
  40260. * Gets the offset value for the position (ie. the change of the position value)
  40261. */
  40262. deltaPosition: Vector3;
  40263. /**
  40264. * Gets a boolean indicating if the virtual joystick was pressed
  40265. */
  40266. pressed: boolean;
  40267. private static _globalJoystickIndex;
  40268. private static vjCanvas;
  40269. private static vjCanvasContext;
  40270. private static vjCanvasWidth;
  40271. private static vjCanvasHeight;
  40272. private static halfWidth;
  40273. private _action;
  40274. private _axisTargetedByLeftAndRight;
  40275. private _axisTargetedByUpAndDown;
  40276. private _joystickSensibility;
  40277. private _inversedSensibility;
  40278. private _joystickPointerID;
  40279. private _joystickColor;
  40280. private _joystickPointerPos;
  40281. private _joystickPreviousPointerPos;
  40282. private _joystickPointerStartPos;
  40283. private _deltaJoystickVector;
  40284. private _leftJoystick;
  40285. private _touches;
  40286. private _onPointerDownHandlerRef;
  40287. private _onPointerMoveHandlerRef;
  40288. private _onPointerUpHandlerRef;
  40289. private _onResize;
  40290. /**
  40291. * Creates a new virtual joystick
  40292. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40293. */
  40294. constructor(leftJoystick?: boolean);
  40295. /**
  40296. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40297. * @param newJoystickSensibility defines the new sensibility
  40298. */
  40299. setJoystickSensibility(newJoystickSensibility: number): void;
  40300. private _onPointerDown;
  40301. private _onPointerMove;
  40302. private _onPointerUp;
  40303. /**
  40304. * Change the color of the virtual joystick
  40305. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40306. */
  40307. setJoystickColor(newColor: string): void;
  40308. /**
  40309. * Defines a callback to call when the joystick is touched
  40310. * @param action defines the callback
  40311. */
  40312. setActionOnTouch(action: () => any): void;
  40313. /**
  40314. * Defines which axis you'd like to control for left & right
  40315. * @param axis defines the axis to use
  40316. */
  40317. setAxisForLeftRight(axis: JoystickAxis): void;
  40318. /**
  40319. * Defines which axis you'd like to control for up & down
  40320. * @param axis defines the axis to use
  40321. */
  40322. setAxisForUpDown(axis: JoystickAxis): void;
  40323. private _drawVirtualJoystick;
  40324. /**
  40325. * Release internal HTML canvas
  40326. */
  40327. releaseCanvas(): void;
  40328. }
  40329. }
  40330. declare module BABYLON {
  40331. /**
  40332. * Helper class to push actions to a pool of workers.
  40333. */
  40334. class WorkerPool implements IDisposable {
  40335. private _workerInfos;
  40336. private _pendingActions;
  40337. /**
  40338. * Constructor
  40339. * @param workers Array of workers to use for actions
  40340. */
  40341. constructor(workers: Array<Worker>);
  40342. /**
  40343. * Terminates all workers and clears any pending actions.
  40344. */
  40345. dispose(): void;
  40346. /**
  40347. * Pushes an action to the worker pool. If all the workers are active, the action will be
  40348. * pended until a worker has completed its action.
  40349. * @param action The action to perform. Call onComplete when the action is complete.
  40350. */
  40351. push(action: (worker: Worker, onComplete: () => void) => void): void;
  40352. private _execute;
  40353. }
  40354. }
  40355. declare module BABYLON {
  40356. /**
  40357. * The autoRotation behavior (BABYLON.AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40358. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40359. */
  40360. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40361. /**
  40362. * Gets the name of the behavior.
  40363. */
  40364. readonly name: string;
  40365. private _zoomStopsAnimation;
  40366. private _idleRotationSpeed;
  40367. private _idleRotationWaitTime;
  40368. private _idleRotationSpinupTime;
  40369. /**
  40370. * Sets the flag that indicates if user zooming should stop animation.
  40371. */
  40372. /**
  40373. * Gets the flag that indicates if user zooming should stop animation.
  40374. */
  40375. zoomStopsAnimation: boolean;
  40376. /**
  40377. * Sets the default speed at which the camera rotates around the model.
  40378. */
  40379. /**
  40380. * Gets the default speed at which the camera rotates around the model.
  40381. */
  40382. idleRotationSpeed: number;
  40383. /**
  40384. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40385. */
  40386. /**
  40387. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40388. */
  40389. idleRotationWaitTime: number;
  40390. /**
  40391. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40392. */
  40393. /**
  40394. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40395. */
  40396. idleRotationSpinupTime: number;
  40397. /**
  40398. * Gets a value indicating if the camera is currently rotating because of this behavior
  40399. */
  40400. readonly rotationInProgress: boolean;
  40401. private _onPrePointerObservableObserver;
  40402. private _onAfterCheckInputsObserver;
  40403. private _attachedCamera;
  40404. private _isPointerDown;
  40405. private _lastFrameTime;
  40406. private _lastInteractionTime;
  40407. private _cameraRotationSpeed;
  40408. /**
  40409. * Initializes the behavior.
  40410. */
  40411. init(): void;
  40412. /**
  40413. * Attaches the behavior to its arc rotate camera.
  40414. * @param camera Defines the camera to attach the behavior to
  40415. */
  40416. attach(camera: ArcRotateCamera): void;
  40417. /**
  40418. * Detaches the behavior from its current arc rotate camera.
  40419. */
  40420. detach(): void;
  40421. /**
  40422. * Returns true if user is scrolling.
  40423. * @return true if user is scrolling.
  40424. */
  40425. private _userIsZooming;
  40426. private _lastFrameRadius;
  40427. private _shouldAnimationStopForInteraction;
  40428. /**
  40429. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40430. */
  40431. private _applyUserInteraction;
  40432. private _userIsMoving;
  40433. }
  40434. }
  40435. declare module BABYLON {
  40436. /**
  40437. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  40438. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40439. */
  40440. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  40441. /**
  40442. * Gets the name of the behavior.
  40443. */
  40444. readonly name: string;
  40445. /**
  40446. * The easing function used by animations
  40447. */
  40448. static EasingFunction: BackEase;
  40449. /**
  40450. * The easing mode used by animations
  40451. */
  40452. static EasingMode: number;
  40453. /**
  40454. * The duration of the animation, in milliseconds
  40455. */
  40456. transitionDuration: number;
  40457. /**
  40458. * Length of the distance animated by the transition when lower radius is reached
  40459. */
  40460. lowerRadiusTransitionRange: number;
  40461. /**
  40462. * Length of the distance animated by the transition when upper radius is reached
  40463. */
  40464. upperRadiusTransitionRange: number;
  40465. private _autoTransitionRange;
  40466. /**
  40467. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40468. */
  40469. /**
  40470. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  40471. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  40472. */
  40473. autoTransitionRange: boolean;
  40474. private _attachedCamera;
  40475. private _onAfterCheckInputsObserver;
  40476. private _onMeshTargetChangedObserver;
  40477. /**
  40478. * Initializes the behavior.
  40479. */
  40480. init(): void;
  40481. /**
  40482. * Attaches the behavior to its arc rotate camera.
  40483. * @param camera Defines the camera to attach the behavior to
  40484. */
  40485. attach(camera: ArcRotateCamera): void;
  40486. /**
  40487. * Detaches the behavior from its current arc rotate camera.
  40488. */
  40489. detach(): void;
  40490. private _radiusIsAnimating;
  40491. private _radiusBounceTransition;
  40492. private _animatables;
  40493. private _cachedWheelPrecision;
  40494. /**
  40495. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  40496. * @param radiusLimit The limit to check against.
  40497. * @return Bool to indicate if at limit.
  40498. */
  40499. private _isRadiusAtLimit;
  40500. /**
  40501. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  40502. * @param radiusDelta The delta by which to animate to. Can be negative.
  40503. */
  40504. private _applyBoundRadiusAnimation;
  40505. /**
  40506. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  40507. */
  40508. protected _clearAnimationLocks(): void;
  40509. /**
  40510. * Stops and removes all animations that have been applied to the camera
  40511. */
  40512. stopAllAnimations(): void;
  40513. }
  40514. }
  40515. declare module BABYLON {
  40516. /**
  40517. * The framing behavior (BABYLON.FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  40518. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40519. */
  40520. class FramingBehavior implements Behavior<ArcRotateCamera> {
  40521. /**
  40522. * Gets the name of the behavior.
  40523. */
  40524. readonly name: string;
  40525. private _mode;
  40526. private _radiusScale;
  40527. private _positionScale;
  40528. private _defaultElevation;
  40529. private _elevationReturnTime;
  40530. private _elevationReturnWaitTime;
  40531. private _zoomStopsAnimation;
  40532. private _framingTime;
  40533. /**
  40534. * The easing function used by animations
  40535. */
  40536. static EasingFunction: ExponentialEase;
  40537. /**
  40538. * The easing mode used by animations
  40539. */
  40540. static EasingMode: number;
  40541. /**
  40542. * Sets the current mode used by the behavior
  40543. */
  40544. /**
  40545. * Gets current mode used by the behavior.
  40546. */
  40547. mode: number;
  40548. /**
  40549. * Sets the scale applied to the radius (1 by default)
  40550. */
  40551. /**
  40552. * Gets the scale applied to the radius
  40553. */
  40554. radiusScale: number;
  40555. /**
  40556. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40557. */
  40558. /**
  40559. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  40560. */
  40561. positionScale: number;
  40562. /**
  40563. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40564. * behaviour is triggered, in radians.
  40565. */
  40566. /**
  40567. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  40568. * behaviour is triggered, in radians.
  40569. */
  40570. defaultElevation: number;
  40571. /**
  40572. * Sets the time (in milliseconds) taken to return to the default beta position.
  40573. * Negative value indicates camera should not return to default.
  40574. */
  40575. /**
  40576. * Gets the time (in milliseconds) taken to return to the default beta position.
  40577. * Negative value indicates camera should not return to default.
  40578. */
  40579. elevationReturnTime: number;
  40580. /**
  40581. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40582. */
  40583. /**
  40584. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  40585. */
  40586. elevationReturnWaitTime: number;
  40587. /**
  40588. * Sets the flag that indicates if user zooming should stop animation.
  40589. */
  40590. /**
  40591. * Gets the flag that indicates if user zooming should stop animation.
  40592. */
  40593. zoomStopsAnimation: boolean;
  40594. /**
  40595. * Sets the transition time when framing the mesh, in milliseconds
  40596. */
  40597. /**
  40598. * Gets the transition time when framing the mesh, in milliseconds
  40599. */
  40600. framingTime: number;
  40601. /**
  40602. * Define if the behavior should automatically change the configured
  40603. * camera limits and sensibilities.
  40604. */
  40605. autoCorrectCameraLimitsAndSensibility: boolean;
  40606. private _onPrePointerObservableObserver;
  40607. private _onAfterCheckInputsObserver;
  40608. private _onMeshTargetChangedObserver;
  40609. private _attachedCamera;
  40610. private _isPointerDown;
  40611. private _lastInteractionTime;
  40612. /**
  40613. * Initializes the behavior.
  40614. */
  40615. init(): void;
  40616. /**
  40617. * Attaches the behavior to its arc rotate camera.
  40618. * @param camera Defines the camera to attach the behavior to
  40619. */
  40620. attach(camera: ArcRotateCamera): void;
  40621. /**
  40622. * Detaches the behavior from its current arc rotate camera.
  40623. */
  40624. detach(): void;
  40625. private _animatables;
  40626. private _betaIsAnimating;
  40627. private _betaTransition;
  40628. private _radiusTransition;
  40629. private _vectorTransition;
  40630. /**
  40631. * Targets the given mesh and updates zoom level accordingly.
  40632. * @param mesh The mesh to target.
  40633. * @param radius Optional. If a cached radius position already exists, overrides default.
  40634. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40635. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40636. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40637. */
  40638. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40639. /**
  40640. * Targets the given mesh with its children and updates zoom level accordingly.
  40641. * @param mesh The mesh to target.
  40642. * @param radius Optional. If a cached radius position already exists, overrides default.
  40643. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40644. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40645. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40646. */
  40647. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40648. /**
  40649. * Targets the given meshes with their children and updates zoom level accordingly.
  40650. * @param meshes The mesh to target.
  40651. * @param radius Optional. If a cached radius position already exists, overrides default.
  40652. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  40653. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40654. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40655. */
  40656. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40657. /**
  40658. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  40659. * @param minimumWorld Determines the smaller position of the bounding box extend
  40660. * @param maximumWorld Determines the bigger position of the bounding box extend
  40661. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  40662. * @param onAnimationEnd Callback triggered at the end of the framing animation
  40663. */
  40664. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  40665. /**
  40666. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  40667. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  40668. * frustum width.
  40669. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  40670. * to fully enclose the mesh in the viewing frustum.
  40671. */
  40672. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  40673. /**
  40674. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  40675. * is automatically returned to its default position (expected to be above ground plane).
  40676. */
  40677. private _maintainCameraAboveGround;
  40678. /**
  40679. * Returns the frustum slope based on the canvas ratio and camera FOV
  40680. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  40681. */
  40682. private _getFrustumSlope;
  40683. /**
  40684. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  40685. */
  40686. private _clearAnimationLocks;
  40687. /**
  40688. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40689. */
  40690. private _applyUserInteraction;
  40691. /**
  40692. * Stops and removes all animations that have been applied to the camera
  40693. */
  40694. stopAllAnimations(): void;
  40695. /**
  40696. * Gets a value indicating if the user is moving the camera
  40697. */
  40698. readonly isUserIsMoving: boolean;
  40699. /**
  40700. * The camera can move all the way towards the mesh.
  40701. */
  40702. static IgnoreBoundsSizeMode: number;
  40703. /**
  40704. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  40705. */
  40706. static FitFrustumSidesMode: number;
  40707. }
  40708. }
  40709. declare module BABYLON {
  40710. /**
  40711. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40712. */
  40713. class AttachToBoxBehavior implements BABYLON.Behavior<BABYLON.Mesh> {
  40714. private ui;
  40715. /**
  40716. * The name of the behavior
  40717. */
  40718. name: string;
  40719. /**
  40720. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40721. */
  40722. distanceAwayFromFace: number;
  40723. /**
  40724. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40725. */
  40726. distanceAwayFromBottomOfFace: number;
  40727. private _faceVectors;
  40728. private _target;
  40729. private _scene;
  40730. private _onRenderObserver;
  40731. private _tmpMatrix;
  40732. private _tmpVector;
  40733. /**
  40734. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40735. * @param ui The transform node that should be attched to the mesh
  40736. */
  40737. constructor(ui: BABYLON.TransformNode);
  40738. /**
  40739. * Initializes the behavior
  40740. */
  40741. init(): void;
  40742. private _closestFace;
  40743. private _zeroVector;
  40744. private _lookAtTmpMatrix;
  40745. private _lookAtToRef;
  40746. /**
  40747. * Attaches the AttachToBoxBehavior to the passed in mesh
  40748. * @param target The mesh that the specified node will be attached to
  40749. */
  40750. attach(target: BABYLON.Mesh): void;
  40751. /**
  40752. * Detaches the behavior from the mesh
  40753. */
  40754. detach(): void;
  40755. }
  40756. }
  40757. declare module BABYLON {
  40758. /**
  40759. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40760. */
  40761. class FadeInOutBehavior implements Behavior<Mesh> {
  40762. /**
  40763. * Time in milliseconds to delay before fading in (Default: 0)
  40764. */
  40765. delay: number;
  40766. /**
  40767. * Time in milliseconds for the mesh to fade in (Default: 300)
  40768. */
  40769. fadeInTime: number;
  40770. private _millisecondsPerFrame;
  40771. private _hovered;
  40772. private _hoverValue;
  40773. private _ownerNode;
  40774. /**
  40775. * Instatiates the FadeInOutBehavior
  40776. */
  40777. constructor();
  40778. /**
  40779. * The name of the behavior
  40780. */
  40781. readonly name: string;
  40782. /**
  40783. * Initializes the behavior
  40784. */
  40785. init(): void;
  40786. /**
  40787. * Attaches the fade behavior on the passed in mesh
  40788. * @param ownerNode The mesh that will be faded in/out once attached
  40789. */
  40790. attach(ownerNode: Mesh): void;
  40791. /**
  40792. * Detaches the behavior from the mesh
  40793. */
  40794. detach(): void;
  40795. /**
  40796. * Triggers the mesh to begin fading in or out
  40797. * @param value if the object should fade in or out (true to fade in)
  40798. */
  40799. fadeIn(value: boolean): void;
  40800. private _update;
  40801. private _setAllVisibility;
  40802. }
  40803. }
  40804. declare module BABYLON {
  40805. /**
  40806. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40807. */
  40808. class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40809. private _dragBehaviorA;
  40810. private _dragBehaviorB;
  40811. private _startDistance;
  40812. private _initialScale;
  40813. private _targetScale;
  40814. private _ownerNode;
  40815. private _sceneRenderObserver;
  40816. /**
  40817. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40818. */
  40819. constructor();
  40820. /**
  40821. * The name of the behavior
  40822. */
  40823. readonly name: string;
  40824. /**
  40825. * Initializes the behavior
  40826. */
  40827. init(): void;
  40828. private _getCurrentDistance;
  40829. /**
  40830. * Attaches the scale behavior the passed in mesh
  40831. * @param ownerNode The mesh that will be scaled around once attached
  40832. */
  40833. attach(ownerNode: Mesh): void;
  40834. /**
  40835. * Detaches the behavior from the mesh
  40836. */
  40837. detach(): void;
  40838. }
  40839. }
  40840. declare module BABYLON {
  40841. /**
  40842. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40843. */
  40844. class PointerDragBehavior implements Behavior<Mesh> {
  40845. private static _AnyMouseID;
  40846. private _attachedNode;
  40847. private _dragPlane;
  40848. private _scene;
  40849. private _pointerObserver;
  40850. private _beforeRenderObserver;
  40851. private static _planeScene;
  40852. /**
  40853. * 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)
  40854. */
  40855. maxDragAngle: number;
  40856. /**
  40857. * @hidden
  40858. */
  40859. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40860. /**
  40861. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40862. */
  40863. currentDraggingPointerID: number;
  40864. /**
  40865. * The last position where the pointer hit the drag plane in world space
  40866. */
  40867. lastDragPosition: Vector3;
  40868. /**
  40869. * If the behavior is currently in a dragging state
  40870. */
  40871. dragging: boolean;
  40872. /**
  40873. * 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)
  40874. */
  40875. dragDeltaRatio: number;
  40876. /**
  40877. * If the drag plane orientation should be updated during the dragging (Default: true)
  40878. */
  40879. updateDragPlane: boolean;
  40880. private _debugMode;
  40881. private _moving;
  40882. /**
  40883. * Fires each time the attached mesh is dragged with the pointer
  40884. * * delta between last drag position and current drag position in world space
  40885. * * dragDistance along the drag axis
  40886. * * dragPlaneNormal normal of the current drag plane used during the drag
  40887. * * dragPlanePoint in world space where the drag intersects the drag plane
  40888. */
  40889. onDragObservable: Observable<{
  40890. delta: Vector3;
  40891. dragPlanePoint: Vector3;
  40892. dragPlaneNormal: Vector3;
  40893. dragDistance: number;
  40894. pointerId: number;
  40895. }>;
  40896. /**
  40897. * Fires each time a drag begins (eg. mouse down on mesh)
  40898. */
  40899. onDragStartObservable: Observable<{
  40900. dragPlanePoint: Vector3;
  40901. pointerId: number;
  40902. }>;
  40903. /**
  40904. * Fires each time a drag ends (eg. mouse release after drag)
  40905. */
  40906. onDragEndObservable: Observable<{
  40907. dragPlanePoint: Vector3;
  40908. pointerId: number;
  40909. }>;
  40910. /**
  40911. * If the attached mesh should be moved when dragged
  40912. */
  40913. moveAttached: boolean;
  40914. /**
  40915. * If the drag behavior will react to drag events (Default: true)
  40916. */
  40917. enabled: boolean;
  40918. /**
  40919. * If camera controls should be detached during the drag
  40920. */
  40921. detachCameraControls: boolean;
  40922. /**
  40923. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40924. */
  40925. useObjectOrienationForDragging: boolean;
  40926. private _options;
  40927. /**
  40928. * Creates a pointer drag behavior that can be attached to a mesh
  40929. * @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)
  40930. */
  40931. constructor(options?: {
  40932. dragAxis?: Vector3;
  40933. dragPlaneNormal?: Vector3;
  40934. });
  40935. /**
  40936. * The name of the behavior
  40937. */
  40938. readonly name: string;
  40939. /**
  40940. * Initializes the behavior
  40941. */
  40942. init(): void;
  40943. private _tmpVector;
  40944. private _alternatePickedPoint;
  40945. private _worldDragAxis;
  40946. private _targetPosition;
  40947. private _attachedElement;
  40948. /**
  40949. * Attaches the drag behavior the passed in mesh
  40950. * @param ownerNode The mesh that will be dragged around once attached
  40951. */
  40952. attach(ownerNode: Mesh): void;
  40953. /**
  40954. * Force relase the drag action by code.
  40955. */
  40956. releaseDrag(): void;
  40957. private _startDragRay;
  40958. private _lastPointerRay;
  40959. /**
  40960. * Simulates the start of a pointer drag event on the behavior
  40961. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40962. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40963. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40964. */
  40965. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40966. private _startDrag;
  40967. private _dragDelta;
  40968. private _moveDrag;
  40969. private _pickWithRayOnDragPlane;
  40970. private _pointA;
  40971. private _pointB;
  40972. private _pointC;
  40973. private _lineA;
  40974. private _lineB;
  40975. private _localAxis;
  40976. private _lookAt;
  40977. private _updateDragPlanePosition;
  40978. /**
  40979. * Detaches the behavior from the mesh
  40980. */
  40981. detach(): void;
  40982. }
  40983. }
  40984. declare module BABYLON {
  40985. /**
  40986. * 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
  40987. */
  40988. class SixDofDragBehavior implements Behavior<Mesh> {
  40989. private static _virtualScene;
  40990. private _ownerNode;
  40991. private _sceneRenderObserver;
  40992. private _scene;
  40993. private _targetPosition;
  40994. private _virtualOriginMesh;
  40995. private _virtualDragMesh;
  40996. private _pointerObserver;
  40997. private _moving;
  40998. private _startingOrientation;
  40999. /**
  41000. * 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)
  41001. */
  41002. private zDragFactor;
  41003. /**
  41004. * If the behavior is currently in a dragging state
  41005. */
  41006. dragging: boolean;
  41007. /**
  41008. * 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)
  41009. */
  41010. dragDeltaRatio: number;
  41011. /**
  41012. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41013. */
  41014. currentDraggingPointerID: number;
  41015. /**
  41016. * If camera controls should be detached during the drag
  41017. */
  41018. detachCameraControls: boolean;
  41019. /**
  41020. * Fires each time a drag starts
  41021. */
  41022. onDragStartObservable: Observable<{}>;
  41023. /**
  41024. * Fires each time a drag ends (eg. mouse release after drag)
  41025. */
  41026. onDragEndObservable: Observable<{}>;
  41027. /**
  41028. * 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
  41029. */
  41030. constructor();
  41031. /**
  41032. * The name of the behavior
  41033. */
  41034. readonly name: string;
  41035. /**
  41036. * Initializes the behavior
  41037. */
  41038. init(): void;
  41039. /**
  41040. * Attaches the scale behavior the passed in mesh
  41041. * @param ownerNode The mesh that will be scaled around once attached
  41042. */
  41043. attach(ownerNode: Mesh): void;
  41044. /**
  41045. * Detaches the behavior from the mesh
  41046. */
  41047. detach(): void;
  41048. }
  41049. }
  41050. declare module BABYLON {
  41051. /**
  41052. * Contains an array of blocks representing the octree
  41053. */
  41054. interface IOctreeContainer<T> {
  41055. /**
  41056. * Blocks within the octree
  41057. */
  41058. blocks: Array<OctreeBlock<T>>;
  41059. }
  41060. /**
  41061. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41062. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41063. */
  41064. class Octree<T> {
  41065. /** 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.) */
  41066. maxDepth: number;
  41067. /**
  41068. * Blocks within the octree containing objects
  41069. */
  41070. blocks: Array<OctreeBlock<T>>;
  41071. /**
  41072. * Content stored in the octree
  41073. */
  41074. dynamicContent: T[];
  41075. private _maxBlockCapacity;
  41076. private _selectionContent;
  41077. private _creationFunc;
  41078. /**
  41079. * Creates a octree
  41080. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41081. * @param creationFunc function to be used to instatiate the octree
  41082. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41083. * @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.)
  41084. */
  41085. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41086. /** 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.) */
  41087. maxDepth?: number);
  41088. /**
  41089. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41090. * @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);
  41091. * @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);
  41092. * @param entries meshes to be added to the octree blocks
  41093. */
  41094. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41095. /**
  41096. * Adds a mesh to the octree
  41097. * @param entry Mesh to add to the octree
  41098. */
  41099. addMesh(entry: T): void;
  41100. /**
  41101. * Selects an array of meshes within the frustum
  41102. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41103. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41104. * @returns array of meshes within the frustum
  41105. */
  41106. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41107. /**
  41108. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41109. * @param sphereCenter defines the bounding sphere center
  41110. * @param sphereRadius defines the bounding sphere radius
  41111. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41112. * @returns an array of objects that intersect the sphere
  41113. */
  41114. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41115. /**
  41116. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41117. * @param ray defines the ray to test with
  41118. * @returns array of intersected objects
  41119. */
  41120. intersectsRay(ray: Ray): SmartArray<T>;
  41121. /**
  41122. * @hidden
  41123. */
  41124. 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;
  41125. /**
  41126. * Adds a mesh into the octree block if it intersects the block
  41127. */
  41128. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41129. /**
  41130. * Adds a submesh into the octree block if it intersects the block
  41131. */
  41132. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41133. }
  41134. }
  41135. declare module BABYLON {
  41136. /**
  41137. * Class used to store a cell in an octree
  41138. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41139. */
  41140. class OctreeBlock<T> {
  41141. /**
  41142. * Gets the content of the current block
  41143. */
  41144. entries: T[];
  41145. /**
  41146. * Gets the list of block children
  41147. */
  41148. blocks: Array<OctreeBlock<T>>;
  41149. private _depth;
  41150. private _maxDepth;
  41151. private _capacity;
  41152. private _minPoint;
  41153. private _maxPoint;
  41154. private _boundingVectors;
  41155. private _creationFunc;
  41156. /**
  41157. * Creates a new block
  41158. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41159. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41160. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41161. * @param depth defines the current depth of this block in the octree
  41162. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41163. * @param creationFunc defines a callback to call when an element is added to the block
  41164. */
  41165. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41166. /**
  41167. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41168. */
  41169. readonly capacity: number;
  41170. /**
  41171. * Gets the minimum vector (in world space) of the block's bounding box
  41172. */
  41173. readonly minPoint: Vector3;
  41174. /**
  41175. * Gets the maximum vector (in world space) of the block's bounding box
  41176. */
  41177. readonly maxPoint: Vector3;
  41178. /**
  41179. * Add a new element to this block
  41180. * @param entry defines the element to add
  41181. */
  41182. addEntry(entry: T): void;
  41183. /**
  41184. * Add an array of elements to this block
  41185. * @param entries defines the array of elements to add
  41186. */
  41187. addEntries(entries: T[]): void;
  41188. /**
  41189. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41190. * @param frustumPlanes defines the frustum planes to test
  41191. * @param selection defines the array to store current content if selection is positive
  41192. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41193. */
  41194. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41195. /**
  41196. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41197. * @param sphereCenter defines the bounding sphere center
  41198. * @param sphereRadius defines the bounding sphere radius
  41199. * @param selection defines the array to store current content if selection is positive
  41200. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41201. */
  41202. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41203. /**
  41204. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41205. * @param ray defines the ray to test with
  41206. * @param selection defines the array to store current content if selection is positive
  41207. */
  41208. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41209. /**
  41210. * Subdivide the content into child blocks (this block will then be empty)
  41211. */
  41212. createInnerBlocks(): void;
  41213. }
  41214. }
  41215. declare module BABYLON {
  41216. interface Scene {
  41217. /**
  41218. * @hidden
  41219. * Backing Filed
  41220. */
  41221. _selectionOctree: Octree<AbstractMesh>;
  41222. /**
  41223. * Gets the octree used to boost mesh selection (picking)
  41224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41225. */
  41226. selectionOctree: Octree<AbstractMesh>;
  41227. /**
  41228. * Creates or updates the octree used to boost selection (picking)
  41229. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41230. * @param maxCapacity defines the maximum capacity per leaf
  41231. * @param maxDepth defines the maximum depth of the octree
  41232. * @returns an octree of AbstractMesh
  41233. */
  41234. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41235. }
  41236. interface AbstractMesh {
  41237. /**
  41238. * @hidden
  41239. * Backing Field
  41240. */
  41241. _submeshesOctree: Octree<SubMesh>;
  41242. /**
  41243. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41244. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41245. * @param maxCapacity defines the maximum size of each block (64 by default)
  41246. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41247. * @returns the new octree
  41248. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41249. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41250. */
  41251. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41252. }
  41253. /**
  41254. * Defines the octree scene component responsible to manage any octrees
  41255. * in a given scene.
  41256. */
  41257. class OctreeSceneComponent {
  41258. /**
  41259. * The component name helpfull to identify the component in the list of scene components.
  41260. */
  41261. readonly name: string;
  41262. /**
  41263. * The scene the component belongs to.
  41264. */
  41265. scene: Scene;
  41266. /**
  41267. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41268. */
  41269. readonly checksIsEnabled: boolean;
  41270. /**
  41271. * Creates a new instance of the component for the given scene
  41272. * @param scene Defines the scene to register the component in
  41273. */
  41274. constructor(scene: Scene);
  41275. /**
  41276. * Registers the component in a given scene
  41277. */
  41278. register(): void;
  41279. /**
  41280. * Return the list of active meshes
  41281. * @returns the list of active meshes
  41282. */
  41283. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41284. /**
  41285. * Return the list of active sub meshes
  41286. * @param mesh The mesh to get the candidates sub meshes from
  41287. * @returns the list of active sub meshes
  41288. */
  41289. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41290. private _tempRay;
  41291. /**
  41292. * Return the list of sub meshes intersecting with a given local ray
  41293. * @param mesh defines the mesh to find the submesh for
  41294. * @param localRay defines the ray in local space
  41295. * @returns the list of intersecting sub meshes
  41296. */
  41297. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41298. /**
  41299. * Return the list of sub meshes colliding with a collider
  41300. * @param mesh defines the mesh to find the submesh for
  41301. * @param collider defines the collider to evaluate the collision against
  41302. * @returns the list of colliding sub meshes
  41303. */
  41304. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41305. /**
  41306. * Rebuilds the elements related to this component in case of
  41307. * context lost for instance.
  41308. */
  41309. rebuild(): void;
  41310. /**
  41311. * Disposes the component and the associated ressources.
  41312. */
  41313. dispose(): void;
  41314. }
  41315. }
  41316. declare module BABYLON {
  41317. /**
  41318. * Manage the gamepad inputs to control an arc rotate camera.
  41319. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41320. */
  41321. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41322. /**
  41323. * Defines the camera the input is attached to.
  41324. */
  41325. camera: ArcRotateCamera;
  41326. /**
  41327. * Defines the gamepad the input is gathering event from.
  41328. */
  41329. gamepad: Nullable<Gamepad>;
  41330. /**
  41331. * Defines the gamepad rotation sensiblity.
  41332. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41333. */
  41334. gamepadRotationSensibility: number;
  41335. /**
  41336. * Defines the gamepad move sensiblity.
  41337. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41338. */
  41339. gamepadMoveSensibility: number;
  41340. private _onGamepadConnectedObserver;
  41341. private _onGamepadDisconnectedObserver;
  41342. /**
  41343. * Attach the input controls to a specific dom element to get the input from.
  41344. * @param element Defines the element the controls should be listened from
  41345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41346. */
  41347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41348. /**
  41349. * Detach the current controls from the specified dom element.
  41350. * @param element Defines the element to stop listening the inputs from
  41351. */
  41352. detachControl(element: Nullable<HTMLElement>): void;
  41353. /**
  41354. * Update the current camera state depending on the inputs that have been used this frame.
  41355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41356. */
  41357. checkInputs(): void;
  41358. /**
  41359. * Gets the class name of the current intput.
  41360. * @returns the class name
  41361. */
  41362. getClassName(): string;
  41363. /**
  41364. * Get the friendly name associated with the input class.
  41365. * @returns the input friendly name
  41366. */
  41367. getSimpleName(): string;
  41368. }
  41369. }
  41370. declare module BABYLON {
  41371. /**
  41372. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41373. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41374. */
  41375. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41376. /**
  41377. * Defines the camera the input is attached to.
  41378. */
  41379. camera: ArcRotateCamera;
  41380. /**
  41381. * Defines the list of key codes associated with the up action (increase alpha)
  41382. */
  41383. keysUp: number[];
  41384. /**
  41385. * Defines the list of key codes associated with the down action (decrease alpha)
  41386. */
  41387. keysDown: number[];
  41388. /**
  41389. * Defines the list of key codes associated with the left action (increase beta)
  41390. */
  41391. keysLeft: number[];
  41392. /**
  41393. * Defines the list of key codes associated with the right action (decrease beta)
  41394. */
  41395. keysRight: number[];
  41396. /**
  41397. * Defines the list of key codes associated with the reset action.
  41398. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41399. */
  41400. keysReset: number[];
  41401. /**
  41402. * Defines the panning sensibility of the inputs.
  41403. * (How fast is the camera paning)
  41404. */
  41405. panningSensibility: number;
  41406. /**
  41407. * Defines the zooming sensibility of the inputs.
  41408. * (How fast is the camera zooming)
  41409. */
  41410. zoomingSensibility: number;
  41411. /**
  41412. * Defines wether maintaining the alt key down switch the movement mode from
  41413. * orientation to zoom.
  41414. */
  41415. useAltToZoom: boolean;
  41416. /**
  41417. * Rotation speed of the camera
  41418. */
  41419. angularSpeed: number;
  41420. private _keys;
  41421. private _ctrlPressed;
  41422. private _altPressed;
  41423. private _onCanvasBlurObserver;
  41424. private _onKeyboardObserver;
  41425. private _engine;
  41426. private _scene;
  41427. /**
  41428. * Attach the input controls to a specific dom element to get the input from.
  41429. * @param element Defines the element the controls should be listened from
  41430. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41431. */
  41432. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41433. /**
  41434. * Detach the current controls from the specified dom element.
  41435. * @param element Defines the element to stop listening the inputs from
  41436. */
  41437. detachControl(element: Nullable<HTMLElement>): void;
  41438. /**
  41439. * Update the current camera state depending on the inputs that have been used this frame.
  41440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41441. */
  41442. checkInputs(): void;
  41443. /**
  41444. * Gets the class name of the current intput.
  41445. * @returns the class name
  41446. */
  41447. getClassName(): string;
  41448. /**
  41449. * Get the friendly name associated with the input class.
  41450. * @returns the input friendly name
  41451. */
  41452. getSimpleName(): string;
  41453. }
  41454. }
  41455. declare module BABYLON {
  41456. /**
  41457. * Manage the mouse wheel inputs to control an arc rotate camera.
  41458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41459. */
  41460. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41461. /**
  41462. * Defines the camera the input is attached to.
  41463. */
  41464. camera: ArcRotateCamera;
  41465. /**
  41466. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41467. */
  41468. wheelPrecision: number;
  41469. /**
  41470. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41471. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41472. */
  41473. wheelDeltaPercentage: number;
  41474. private _wheel;
  41475. private _observer;
  41476. /**
  41477. * Attach the input controls to a specific dom element to get the input from.
  41478. * @param element Defines the element the controls should be listened from
  41479. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41480. */
  41481. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41482. /**
  41483. * Detach the current controls from the specified dom element.
  41484. * @param element Defines the element to stop listening the inputs from
  41485. */
  41486. detachControl(element: Nullable<HTMLElement>): void;
  41487. /**
  41488. * Gets the class name of the current intput.
  41489. * @returns the class name
  41490. */
  41491. getClassName(): string;
  41492. /**
  41493. * Get the friendly name associated with the input class.
  41494. * @returns the input friendly name
  41495. */
  41496. getSimpleName(): string;
  41497. }
  41498. }
  41499. declare module BABYLON {
  41500. /**
  41501. * Manage the pointers inputs to control an arc rotate camera.
  41502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41503. */
  41504. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  41505. /**
  41506. * Defines the camera the input is attached to.
  41507. */
  41508. camera: ArcRotateCamera;
  41509. /**
  41510. * Defines the buttons associated with the input to handle camera move.
  41511. */
  41512. buttons: number[];
  41513. /**
  41514. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  41515. */
  41516. angularSensibilityX: number;
  41517. /**
  41518. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  41519. */
  41520. angularSensibilityY: number;
  41521. /**
  41522. * Defines the pointer pinch precision or how fast is the camera zooming.
  41523. */
  41524. pinchPrecision: number;
  41525. /**
  41526. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  41527. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  41528. */
  41529. pinchDeltaPercentage: number;
  41530. /**
  41531. * Defines the pointer panning sensibility or how fast is the camera moving.
  41532. */
  41533. panningSensibility: number;
  41534. /**
  41535. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41536. */
  41537. multiTouchPanning: boolean;
  41538. /**
  41539. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  41540. */
  41541. multiTouchPanAndZoom: boolean;
  41542. /**
  41543. * Revers pinch action direction.
  41544. */
  41545. pinchInwards: boolean;
  41546. private _isPanClick;
  41547. private _pointerInput;
  41548. private _observer;
  41549. private _onMouseMove;
  41550. private _onGestureStart;
  41551. private _onGesture;
  41552. private _MSGestureHandler;
  41553. private _onLostFocus;
  41554. private _onContextMenu;
  41555. /**
  41556. * Attach the input controls to a specific dom element to get the input from.
  41557. * @param element Defines the element the controls should be listened from
  41558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41559. */
  41560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41561. /**
  41562. * Detach the current controls from the specified dom element.
  41563. * @param element Defines the element to stop listening the inputs from
  41564. */
  41565. detachControl(element: Nullable<HTMLElement>): void;
  41566. /**
  41567. * Gets the class name of the current intput.
  41568. * @returns the class name
  41569. */
  41570. getClassName(): string;
  41571. /**
  41572. * Get the friendly name associated with the input class.
  41573. * @returns the input friendly name
  41574. */
  41575. getSimpleName(): string;
  41576. }
  41577. }
  41578. declare module BABYLON {
  41579. /**
  41580. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41581. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41582. */
  41583. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41584. /**
  41585. * Defines the camera the input is attached to.
  41586. */
  41587. camera: ArcRotateCamera;
  41588. /**
  41589. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41590. */
  41591. alphaCorrection: number;
  41592. /**
  41593. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41594. */
  41595. gammaCorrection: number;
  41596. private _alpha;
  41597. private _gamma;
  41598. private _dirty;
  41599. private _deviceOrientationHandler;
  41600. /**
  41601. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41602. */
  41603. constructor();
  41604. /**
  41605. * Attach the input controls to a specific dom element to get the input from.
  41606. * @param element Defines the element the controls should be listened from
  41607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41608. */
  41609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41610. /** @hidden */
  41611. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41612. /**
  41613. * Update the current camera state depending on the inputs that have been used this frame.
  41614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41615. */
  41616. checkInputs(): void;
  41617. /**
  41618. * Detach the current controls from the specified dom element.
  41619. * @param element Defines the element to stop listening the inputs from
  41620. */
  41621. detachControl(element: Nullable<HTMLElement>): void;
  41622. /**
  41623. * Gets the class name of the current intput.
  41624. * @returns the class name
  41625. */
  41626. getClassName(): string;
  41627. /**
  41628. * Get the friendly name associated with the input class.
  41629. * @returns the input friendly name
  41630. */
  41631. getSimpleName(): string;
  41632. }
  41633. }
  41634. declare module BABYLON {
  41635. /**
  41636. * Listen to keyboard events to control the camera.
  41637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41638. */
  41639. class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41640. /**
  41641. * Defines the camera the input is attached to.
  41642. */
  41643. camera: FlyCamera;
  41644. /**
  41645. * The list of keyboard keys used to control the forward move of the camera.
  41646. */
  41647. keysForward: number[];
  41648. /**
  41649. * The list of keyboard keys used to control the backward move of the camera.
  41650. */
  41651. keysBackward: number[];
  41652. /**
  41653. * The list of keyboard keys used to control the forward move of the camera.
  41654. */
  41655. keysUp: number[];
  41656. /**
  41657. * The list of keyboard keys used to control the backward move of the camera.
  41658. */
  41659. keysDown: number[];
  41660. /**
  41661. * The list of keyboard keys used to control the right strafe move of the camera.
  41662. */
  41663. keysRight: number[];
  41664. /**
  41665. * The list of keyboard keys used to control the left strafe move of the camera.
  41666. */
  41667. keysLeft: number[];
  41668. private _keys;
  41669. private _onCanvasBlurObserver;
  41670. private _onKeyboardObserver;
  41671. private _engine;
  41672. private _scene;
  41673. /**
  41674. * Attach the input controls to a specific dom element to get the input from.
  41675. * @param element Defines the element the controls should be listened from
  41676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41677. */
  41678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41679. /**
  41680. * Detach the current controls from the specified dom element.
  41681. * @param element Defines the element to stop listening the inputs from
  41682. */
  41683. detachControl(element: Nullable<HTMLElement>): void;
  41684. /**
  41685. * Gets the class name of the current intput.
  41686. * @returns the class name
  41687. */
  41688. getClassName(): string;
  41689. /** @hidden */
  41690. _onLostFocus(e: FocusEvent): void;
  41691. /**
  41692. * Get the friendly name associated with the input class.
  41693. * @returns the input friendly name
  41694. */
  41695. getSimpleName(): string;
  41696. /**
  41697. * Update the current camera state depending on the inputs that have been used this frame.
  41698. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41699. */
  41700. checkInputs(): void;
  41701. }
  41702. }
  41703. declare module BABYLON {
  41704. /**
  41705. * Listen to mouse events to control the camera.
  41706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41707. */
  41708. class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41709. /**
  41710. * Defines the camera the input is attached to.
  41711. */
  41712. camera: FlyCamera;
  41713. /**
  41714. * Defines if touch is enabled. (Default is true.)
  41715. */
  41716. touchEnabled: boolean;
  41717. /**
  41718. * Defines the buttons associated with the input to handle camera rotation.
  41719. */
  41720. buttons: number[];
  41721. /**
  41722. * Assign buttons for Yaw control.
  41723. */
  41724. buttonsYaw: number[];
  41725. /**
  41726. * Assign buttons for Pitch control.
  41727. */
  41728. buttonsPitch: number[];
  41729. /**
  41730. * Assign buttons for Roll control.
  41731. */
  41732. buttonsRoll: number[];
  41733. /**
  41734. * Detect if any button is being pressed while mouse is moved.
  41735. * -1 = Mouse locked.
  41736. * 0 = Left button.
  41737. * 1 = Middle Button.
  41738. * 2 = Right Button.
  41739. */
  41740. activeButton: number;
  41741. /**
  41742. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41743. * Higher values reduce its sensitivity.
  41744. */
  41745. angularSensibility: number;
  41746. private _mousemoveCallback;
  41747. private _observer;
  41748. private _rollObserver;
  41749. private previousPosition;
  41750. private noPreventDefault;
  41751. private element;
  41752. /**
  41753. * Listen to mouse events to control the camera.
  41754. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41756. */
  41757. constructor(touchEnabled?: boolean);
  41758. /**
  41759. * Attach the mouse control to the HTML DOM element.
  41760. * @param element Defines the element that listens to the input events.
  41761. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41762. */
  41763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41764. /**
  41765. * Detach the current controls from the specified dom element.
  41766. * @param element Defines the element to stop listening the inputs from
  41767. */
  41768. detachControl(element: Nullable<HTMLElement>): void;
  41769. /**
  41770. * Gets the class name of the current input.
  41771. * @returns the class name.
  41772. */
  41773. getClassName(): string;
  41774. /**
  41775. * Get the friendly name associated with the input class.
  41776. * @returns the input's friendly name.
  41777. */
  41778. getSimpleName(): string;
  41779. private _pointerInput;
  41780. private _onMouseMove;
  41781. /**
  41782. * Rotate camera by mouse offset.
  41783. */
  41784. private rotateCamera;
  41785. }
  41786. }
  41787. declare module BABYLON {
  41788. /**
  41789. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41790. * Screen rotation is taken into account.
  41791. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41792. */
  41793. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41794. private _camera;
  41795. private _screenOrientationAngle;
  41796. private _constantTranform;
  41797. private _screenQuaternion;
  41798. private _alpha;
  41799. private _beta;
  41800. private _gamma;
  41801. /**
  41802. * Instantiates a new input
  41803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41804. */
  41805. constructor();
  41806. /**
  41807. * Define the camera controlled by the input.
  41808. */
  41809. camera: FreeCamera;
  41810. /**
  41811. * Attach the input controls to a specific dom element to get the input from.
  41812. * @param element Defines the element the controls should be listened from
  41813. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41814. */
  41815. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41816. private _orientationChanged;
  41817. private _deviceOrientation;
  41818. /**
  41819. * Detach the current controls from the specified dom element.
  41820. * @param element Defines the element to stop listening the inputs from
  41821. */
  41822. detachControl(element: Nullable<HTMLElement>): void;
  41823. /**
  41824. * Update the current camera state depending on the inputs that have been used this frame.
  41825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41826. */
  41827. checkInputs(): void;
  41828. /**
  41829. * Gets the class name of the current intput.
  41830. * @returns the class name
  41831. */
  41832. getClassName(): string;
  41833. /**
  41834. * Get the friendly name associated with the input class.
  41835. * @returns the input friendly name
  41836. */
  41837. getSimpleName(): string;
  41838. }
  41839. }
  41840. declare module BABYLON {
  41841. /**
  41842. * Manage the gamepad inputs to control a free camera.
  41843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41844. */
  41845. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41846. /**
  41847. * Define the camera the input is attached to.
  41848. */
  41849. camera: FreeCamera;
  41850. /**
  41851. * Define the Gamepad controlling the input
  41852. */
  41853. gamepad: Nullable<Gamepad>;
  41854. /**
  41855. * Defines the gamepad rotation sensiblity.
  41856. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41857. */
  41858. gamepadAngularSensibility: number;
  41859. /**
  41860. * Defines the gamepad move sensiblity.
  41861. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41862. */
  41863. gamepadMoveSensibility: number;
  41864. private _onGamepadConnectedObserver;
  41865. private _onGamepadDisconnectedObserver;
  41866. private _cameraTransform;
  41867. private _deltaTransform;
  41868. private _vector3;
  41869. private _vector2;
  41870. /**
  41871. * Attach the input controls to a specific dom element to get the input from.
  41872. * @param element Defines the element the controls should be listened from
  41873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41874. */
  41875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41876. /**
  41877. * Detach the current controls from the specified dom element.
  41878. * @param element Defines the element to stop listening the inputs from
  41879. */
  41880. detachControl(element: Nullable<HTMLElement>): void;
  41881. /**
  41882. * Update the current camera state depending on the inputs that have been used this frame.
  41883. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41884. */
  41885. checkInputs(): void;
  41886. /**
  41887. * Gets the class name of the current intput.
  41888. * @returns the class name
  41889. */
  41890. getClassName(): string;
  41891. /**
  41892. * Get the friendly name associated with the input class.
  41893. * @returns the input friendly name
  41894. */
  41895. getSimpleName(): string;
  41896. }
  41897. }
  41898. declare module BABYLON {
  41899. /**
  41900. * Manage the keyboard inputs to control the movement of a free camera.
  41901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41902. */
  41903. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  41904. /**
  41905. * Defines the camera the input is attached to.
  41906. */
  41907. camera: FreeCamera;
  41908. /**
  41909. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  41910. */
  41911. keysUp: number[];
  41912. /**
  41913. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  41914. */
  41915. keysDown: number[];
  41916. /**
  41917. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  41918. */
  41919. keysLeft: number[];
  41920. /**
  41921. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  41922. */
  41923. keysRight: number[];
  41924. private _keys;
  41925. private _onCanvasBlurObserver;
  41926. private _onKeyboardObserver;
  41927. private _engine;
  41928. private _scene;
  41929. /**
  41930. * Attach the input controls to a specific dom element to get the input from.
  41931. * @param element Defines the element the controls should be listened from
  41932. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41933. */
  41934. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41935. /**
  41936. * Detach the current controls from the specified dom element.
  41937. * @param element Defines the element to stop listening the inputs from
  41938. */
  41939. detachControl(element: Nullable<HTMLElement>): void;
  41940. /**
  41941. * Update the current camera state depending on the inputs that have been used this frame.
  41942. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41943. */
  41944. checkInputs(): void;
  41945. /**
  41946. * Gets the class name of the current intput.
  41947. * @returns the class name
  41948. */
  41949. getClassName(): string;
  41950. /** @hidden */
  41951. _onLostFocus(e: FocusEvent): void;
  41952. /**
  41953. * Get the friendly name associated with the input class.
  41954. * @returns the input friendly name
  41955. */
  41956. getSimpleName(): string;
  41957. }
  41958. }
  41959. declare module BABYLON {
  41960. /**
  41961. * Manage the mouse inputs to control the movement of a free camera.
  41962. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41963. */
  41964. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  41965. /**
  41966. * Define if touch is enabled in the mouse input
  41967. */
  41968. touchEnabled: boolean;
  41969. /**
  41970. * Defines the camera the input is attached to.
  41971. */
  41972. camera: FreeCamera;
  41973. /**
  41974. * Defines the buttons associated with the input to handle camera move.
  41975. */
  41976. buttons: number[];
  41977. /**
  41978. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  41979. */
  41980. angularSensibility: number;
  41981. private _pointerInput;
  41982. private _onMouseMove;
  41983. private _observer;
  41984. private previousPosition;
  41985. /**
  41986. * Manage the mouse inputs to control the movement of a free camera.
  41987. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41988. * @param touchEnabled Defines if touch is enabled or not
  41989. */
  41990. constructor(
  41991. /**
  41992. * Define if touch is enabled in the mouse input
  41993. */
  41994. touchEnabled?: boolean);
  41995. /**
  41996. * Attach the input controls to a specific dom element to get the input from.
  41997. * @param element Defines the element the controls should be listened from
  41998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41999. */
  42000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42001. /**
  42002. * Detach the current controls from the specified dom element.
  42003. * @param element Defines the element to stop listening the inputs from
  42004. */
  42005. detachControl(element: Nullable<HTMLElement>): void;
  42006. /**
  42007. * Gets the class name of the current intput.
  42008. * @returns the class name
  42009. */
  42010. getClassName(): string;
  42011. /**
  42012. * Get the friendly name associated with the input class.
  42013. * @returns the input friendly name
  42014. */
  42015. getSimpleName(): string;
  42016. }
  42017. }
  42018. declare module BABYLON {
  42019. /**
  42020. * Manage the touch inputs to control the movement of a free camera.
  42021. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42022. */
  42023. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  42024. /**
  42025. * Defines the camera the input is attached to.
  42026. */
  42027. camera: FreeCamera;
  42028. /**
  42029. * Defines the touch sensibility for rotation.
  42030. * The higher the faster.
  42031. */
  42032. touchAngularSensibility: number;
  42033. /**
  42034. * Defines the touch sensibility for move.
  42035. * The higher the faster.
  42036. */
  42037. touchMoveSensibility: number;
  42038. private _offsetX;
  42039. private _offsetY;
  42040. private _pointerPressed;
  42041. private _pointerInput;
  42042. private _observer;
  42043. private _onLostFocus;
  42044. /**
  42045. * Attach the input controls to a specific dom element to get the input from.
  42046. * @param element Defines the element the controls should be listened from
  42047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42048. */
  42049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42050. /**
  42051. * Detach the current controls from the specified dom element.
  42052. * @param element Defines the element to stop listening the inputs from
  42053. */
  42054. detachControl(element: Nullable<HTMLElement>): void;
  42055. /**
  42056. * Update the current camera state depending on the inputs that have been used this frame.
  42057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42058. */
  42059. checkInputs(): void;
  42060. /**
  42061. * Gets the class name of the current intput.
  42062. * @returns the class name
  42063. */
  42064. getClassName(): string;
  42065. /**
  42066. * Get the friendly name associated with the input class.
  42067. * @returns the input friendly name
  42068. */
  42069. getSimpleName(): string;
  42070. }
  42071. }
  42072. declare module BABYLON {
  42073. /**
  42074. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42076. */
  42077. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42078. /**
  42079. * Defines the camera the input is attached to.
  42080. */
  42081. camera: FreeCamera;
  42082. private _leftjoystick;
  42083. private _rightjoystick;
  42084. /**
  42085. * Gets the left stick of the virtual joystick.
  42086. * @returns The virtual Joystick
  42087. */
  42088. getLeftJoystick(): VirtualJoystick;
  42089. /**
  42090. * Gets the right stick of the virtual joystick.
  42091. * @returns The virtual Joystick
  42092. */
  42093. getRightJoystick(): VirtualJoystick;
  42094. /**
  42095. * Update the current camera state depending on the inputs that have been used this frame.
  42096. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42097. */
  42098. checkInputs(): void;
  42099. /**
  42100. * Attach the input controls to a specific dom element to get the input from.
  42101. * @param element Defines the element the controls should be listened from
  42102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42103. */
  42104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42105. /**
  42106. * Detach the current controls from the specified dom element.
  42107. * @param element Defines the element to stop listening the inputs from
  42108. */
  42109. detachControl(element: Nullable<HTMLElement>): void;
  42110. /**
  42111. * Gets the class name of the current intput.
  42112. * @returns the class name
  42113. */
  42114. getClassName(): string;
  42115. /**
  42116. * Get the friendly name associated with the input class.
  42117. * @returns the input friendly name
  42118. */
  42119. getSimpleName(): string;
  42120. }
  42121. }
  42122. declare module BABYLON {
  42123. /**
  42124. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42125. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42126. */
  42127. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42128. /**
  42129. * Creates a new AnaglyphArcRotateCamera
  42130. * @param name defines camera name
  42131. * @param alpha defines alpha angle (in radians)
  42132. * @param beta defines beta angle (in radians)
  42133. * @param radius defines radius
  42134. * @param target defines camera target
  42135. * @param interaxialDistance defines distance between each color axis
  42136. * @param scene defines the hosting scene
  42137. */
  42138. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42139. /**
  42140. * Gets camera class name
  42141. * @returns AnaglyphArcRotateCamera
  42142. */
  42143. getClassName(): string;
  42144. }
  42145. }
  42146. declare module BABYLON {
  42147. /**
  42148. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42149. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42150. */
  42151. class AnaglyphFreeCamera extends FreeCamera {
  42152. /**
  42153. * Creates a new AnaglyphFreeCamera
  42154. * @param name defines camera name
  42155. * @param position defines initial position
  42156. * @param interaxialDistance defines distance between each color axis
  42157. * @param scene defines the hosting scene
  42158. */
  42159. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42160. /**
  42161. * Gets camera class name
  42162. * @returns AnaglyphFreeCamera
  42163. */
  42164. getClassName(): string;
  42165. }
  42166. }
  42167. declare module BABYLON {
  42168. /**
  42169. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42170. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42171. */
  42172. class AnaglyphGamepadCamera extends GamepadCamera {
  42173. /**
  42174. * Creates a new AnaglyphGamepadCamera
  42175. * @param name defines camera name
  42176. * @param position defines initial position
  42177. * @param interaxialDistance defines distance between each color axis
  42178. * @param scene defines the hosting scene
  42179. */
  42180. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42181. /**
  42182. * Gets camera class name
  42183. * @returns AnaglyphGamepadCamera
  42184. */
  42185. getClassName(): string;
  42186. }
  42187. }
  42188. declare module BABYLON {
  42189. /**
  42190. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42191. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42192. */
  42193. class AnaglyphUniversalCamera extends UniversalCamera {
  42194. /**
  42195. * Creates a new AnaglyphUniversalCamera
  42196. * @param name defines camera name
  42197. * @param position defines initial position
  42198. * @param interaxialDistance defines distance between each color axis
  42199. * @param scene defines the hosting scene
  42200. */
  42201. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42202. /**
  42203. * Gets camera class name
  42204. * @returns AnaglyphUniversalCamera
  42205. */
  42206. getClassName(): string;
  42207. }
  42208. }
  42209. declare module BABYLON {
  42210. /**
  42211. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42212. * @see http://doc.babylonjs.com/features/cameras
  42213. */
  42214. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42215. /**
  42216. * Creates a new StereoscopicArcRotateCamera
  42217. * @param name defines camera name
  42218. * @param alpha defines alpha angle (in radians)
  42219. * @param beta defines beta angle (in radians)
  42220. * @param radius defines radius
  42221. * @param target defines camera target
  42222. * @param interaxialDistance defines distance between each color axis
  42223. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42224. * @param scene defines the hosting scene
  42225. */
  42226. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42227. /**
  42228. * Gets camera class name
  42229. * @returns StereoscopicArcRotateCamera
  42230. */
  42231. getClassName(): string;
  42232. }
  42233. }
  42234. declare module BABYLON {
  42235. /**
  42236. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42237. * @see http://doc.babylonjs.com/features/cameras
  42238. */
  42239. class StereoscopicFreeCamera extends FreeCamera {
  42240. /**
  42241. * Creates a new StereoscopicFreeCamera
  42242. * @param name defines camera name
  42243. * @param position defines initial position
  42244. * @param interaxialDistance defines distance between each color axis
  42245. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42246. * @param scene defines the hosting scene
  42247. */
  42248. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42249. /**
  42250. * Gets camera class name
  42251. * @returns StereoscopicFreeCamera
  42252. */
  42253. getClassName(): string;
  42254. }
  42255. }
  42256. declare module BABYLON {
  42257. /**
  42258. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42259. * @see http://doc.babylonjs.com/features/cameras
  42260. */
  42261. class StereoscopicGamepadCamera extends GamepadCamera {
  42262. /**
  42263. * Creates a new StereoscopicGamepadCamera
  42264. * @param name defines camera name
  42265. * @param position defines initial position
  42266. * @param interaxialDistance defines distance between each color axis
  42267. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42268. * @param scene defines the hosting scene
  42269. */
  42270. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42271. /**
  42272. * Gets camera class name
  42273. * @returns StereoscopicGamepadCamera
  42274. */
  42275. getClassName(): string;
  42276. }
  42277. }
  42278. declare module BABYLON {
  42279. /**
  42280. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42281. * @see http://doc.babylonjs.com/features/cameras
  42282. */
  42283. class StereoscopicUniversalCamera extends UniversalCamera {
  42284. /**
  42285. * Creates a new StereoscopicUniversalCamera
  42286. * @param name defines camera name
  42287. * @param position defines initial position
  42288. * @param interaxialDistance defines distance between each color axis
  42289. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42290. * @param scene defines the hosting scene
  42291. */
  42292. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42293. /**
  42294. * Gets camera class name
  42295. * @returns StereoscopicUniversalCamera
  42296. */
  42297. getClassName(): string;
  42298. }
  42299. }
  42300. declare module BABYLON {
  42301. /**
  42302. * This represents all the required metrics to create a VR camera.
  42303. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42304. */
  42305. class VRCameraMetrics {
  42306. /**
  42307. * Define the horizontal resolution off the screen.
  42308. */
  42309. hResolution: number;
  42310. /**
  42311. * Define the vertical resolution off the screen.
  42312. */
  42313. vResolution: number;
  42314. /**
  42315. * Define the horizontal screen size.
  42316. */
  42317. hScreenSize: number;
  42318. /**
  42319. * Define the vertical screen size.
  42320. */
  42321. vScreenSize: number;
  42322. /**
  42323. * Define the vertical screen center position.
  42324. */
  42325. vScreenCenter: number;
  42326. /**
  42327. * Define the distance of the eyes to the screen.
  42328. */
  42329. eyeToScreenDistance: number;
  42330. /**
  42331. * Define the distance between both lenses
  42332. */
  42333. lensSeparationDistance: number;
  42334. /**
  42335. * Define the distance between both viewer's eyes.
  42336. */
  42337. interpupillaryDistance: number;
  42338. /**
  42339. * Define the distortion factor of the VR postprocess.
  42340. * Please, touch with care.
  42341. */
  42342. distortionK: number[];
  42343. /**
  42344. * Define the chromatic aberration correction factors for the VR post process.
  42345. */
  42346. chromaAbCorrection: number[];
  42347. /**
  42348. * Define the scale factor of the post process.
  42349. * The smaller the better but the slower.
  42350. */
  42351. postProcessScaleFactor: number;
  42352. /**
  42353. * Define an offset for the lens center.
  42354. */
  42355. lensCenterOffset: number;
  42356. /**
  42357. * Define if the current vr camera should compensate the distortion of the lense or not.
  42358. */
  42359. compensateDistortion: boolean;
  42360. /**
  42361. * Gets the rendering aspect ratio based on the provided resolutions.
  42362. */
  42363. readonly aspectRatio: number;
  42364. /**
  42365. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42366. */
  42367. readonly aspectRatioFov: number;
  42368. /**
  42369. * @hidden
  42370. */
  42371. readonly leftHMatrix: Matrix;
  42372. /**
  42373. * @hidden
  42374. */
  42375. readonly rightHMatrix: Matrix;
  42376. /**
  42377. * @hidden
  42378. */
  42379. readonly leftPreViewMatrix: Matrix;
  42380. /**
  42381. * @hidden
  42382. */
  42383. readonly rightPreViewMatrix: Matrix;
  42384. /**
  42385. * Get the default VRMetrics based on the most generic setup.
  42386. * @returns the default vr metrics
  42387. */
  42388. static GetDefault(): VRCameraMetrics;
  42389. }
  42390. }
  42391. declare module BABYLON {
  42392. /**
  42393. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42394. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42395. */
  42396. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42397. /**
  42398. * Creates a new VRDeviceOrientationArcRotateCamera
  42399. * @param name defines camera name
  42400. * @param alpha defines the camera rotation along the logitudinal axis
  42401. * @param beta defines the camera rotation along the latitudinal axis
  42402. * @param radius defines the camera distance from its target
  42403. * @param target defines the camera target
  42404. * @param scene defines the scene the camera belongs to
  42405. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42406. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42407. */
  42408. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42409. /**
  42410. * Gets camera class name
  42411. * @returns VRDeviceOrientationArcRotateCamera
  42412. */
  42413. getClassName(): string;
  42414. }
  42415. }
  42416. declare module BABYLON {
  42417. /**
  42418. * Camera used to simulate VR rendering (based on FreeCamera)
  42419. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42420. */
  42421. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42422. /**
  42423. * Creates a new VRDeviceOrientationFreeCamera
  42424. * @param name defines camera name
  42425. * @param position defines the start position of the camera
  42426. * @param scene defines the scene the camera belongs to
  42427. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42428. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42429. */
  42430. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42431. /**
  42432. * Gets camera class name
  42433. * @returns VRDeviceOrientationFreeCamera
  42434. */
  42435. getClassName(): string;
  42436. }
  42437. }
  42438. declare module BABYLON {
  42439. /**
  42440. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42441. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42442. */
  42443. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42444. /**
  42445. * Creates a new VRDeviceOrientationGamepadCamera
  42446. * @param name defines camera name
  42447. * @param position defines the start position of the camera
  42448. * @param scene defines the scene the camera belongs to
  42449. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42450. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42451. */
  42452. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42453. /**
  42454. * Gets camera class name
  42455. * @returns VRDeviceOrientationGamepadCamera
  42456. */
  42457. getClassName(): string;
  42458. }
  42459. }
  42460. declare module BABYLON {
  42461. /**
  42462. * Options to modify the vr teleportation behavior.
  42463. */
  42464. interface VRTeleportationOptions {
  42465. /**
  42466. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42467. */
  42468. floorMeshName?: string;
  42469. /**
  42470. * A list of meshes to be used as the teleportation floor. (default: empty)
  42471. */
  42472. floorMeshes?: Mesh[];
  42473. }
  42474. /**
  42475. * Options to modify the vr experience helper's behavior.
  42476. */
  42477. interface VRExperienceHelperOptions extends WebVROptions {
  42478. /**
  42479. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42480. */
  42481. createDeviceOrientationCamera?: boolean;
  42482. /**
  42483. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42484. */
  42485. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42486. /**
  42487. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42488. */
  42489. laserToggle?: boolean;
  42490. /**
  42491. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42492. */
  42493. floorMeshes?: Mesh[];
  42494. }
  42495. /**
  42496. * Helps to quickly add VR support to an existing scene.
  42497. * See http://doc.babylonjs.com/how_to/webvr_helper
  42498. */
  42499. class VRExperienceHelper {
  42500. /** Options to modify the vr experience helper's behavior. */
  42501. webVROptions: VRExperienceHelperOptions;
  42502. private _scene;
  42503. private _position;
  42504. private _btnVR;
  42505. private _btnVRDisplayed;
  42506. private _webVRsupported;
  42507. private _webVRready;
  42508. private _webVRrequesting;
  42509. private _webVRpresenting;
  42510. private _hasEnteredVR;
  42511. private _fullscreenVRpresenting;
  42512. private _canvas;
  42513. private _webVRCamera;
  42514. private _vrDeviceOrientationCamera;
  42515. private _deviceOrientationCamera;
  42516. private _existingCamera;
  42517. private _onKeyDown;
  42518. private _onVrDisplayPresentChange;
  42519. private _onVRDisplayChanged;
  42520. private _onVRRequestPresentStart;
  42521. private _onVRRequestPresentComplete;
  42522. /**
  42523. * Observable raised when entering VR.
  42524. */
  42525. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42526. /**
  42527. * Observable raised when exiting VR.
  42528. */
  42529. onExitingVRObservable: Observable<VRExperienceHelper>;
  42530. /**
  42531. * Observable raised when controller mesh is loaded.
  42532. */
  42533. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42534. /** Return this.onEnteringVRObservable
  42535. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42536. */
  42537. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42538. /** Return this.onExitingVRObservable
  42539. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42540. */
  42541. readonly onExitingVR: Observable<VRExperienceHelper>;
  42542. /** Return this.onControllerMeshLoadedObservable
  42543. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42544. */
  42545. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42546. private _rayLength;
  42547. private _useCustomVRButton;
  42548. private _teleportationRequested;
  42549. private _teleportActive;
  42550. private _floorMeshName;
  42551. private _floorMeshesCollection;
  42552. private _rotationAllowed;
  42553. private _teleportBackwardsVector;
  42554. private _teleportationTarget;
  42555. private _isDefaultTeleportationTarget;
  42556. private _postProcessMove;
  42557. private _teleportationFillColor;
  42558. private _teleportationBorderColor;
  42559. private _rotationAngle;
  42560. private _haloCenter;
  42561. private _cameraGazer;
  42562. private _padSensibilityUp;
  42563. private _padSensibilityDown;
  42564. private _leftController;
  42565. private _rightController;
  42566. /**
  42567. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42568. */
  42569. onNewMeshSelected: Observable<AbstractMesh>;
  42570. /**
  42571. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42572. */
  42573. onNewMeshPicked: Observable<PickingInfo>;
  42574. private _circleEase;
  42575. /**
  42576. * Observable raised before camera teleportation
  42577. */
  42578. onBeforeCameraTeleport: Observable<Vector3>;
  42579. /**
  42580. * Observable raised after camera teleportation
  42581. */
  42582. onAfterCameraTeleport: Observable<Vector3>;
  42583. /**
  42584. * Observable raised when current selected mesh gets unselected
  42585. */
  42586. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42587. private _raySelectionPredicate;
  42588. /**
  42589. * To be optionaly changed by user to define custom ray selection
  42590. */
  42591. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42592. /**
  42593. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42594. */
  42595. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42596. /**
  42597. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42598. */
  42599. teleportationEnabled: boolean;
  42600. private _defaultHeight;
  42601. private _teleportationInitialized;
  42602. private _interactionsEnabled;
  42603. private _interactionsRequested;
  42604. private _displayGaze;
  42605. private _displayLaserPointer;
  42606. /**
  42607. * The mesh used to display where the user is going to teleport.
  42608. */
  42609. /**
  42610. * Sets the mesh to be used to display where the user is going to teleport.
  42611. */
  42612. teleportationTarget: Mesh;
  42613. /**
  42614. * 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
  42615. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42616. * See http://doc.babylonjs.com/resources/baking_transformations
  42617. */
  42618. gazeTrackerMesh: Mesh;
  42619. /**
  42620. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42621. */
  42622. updateGazeTrackerScale: boolean;
  42623. /**
  42624. * The gaze tracking mesh corresponding to the left controller
  42625. */
  42626. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42627. /**
  42628. * The gaze tracking mesh corresponding to the right controller
  42629. */
  42630. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42631. /**
  42632. * If the ray of the gaze should be displayed.
  42633. */
  42634. /**
  42635. * Sets if the ray of the gaze should be displayed.
  42636. */
  42637. displayGaze: boolean;
  42638. /**
  42639. * If the ray of the LaserPointer should be displayed.
  42640. */
  42641. /**
  42642. * Sets if the ray of the LaserPointer should be displayed.
  42643. */
  42644. displayLaserPointer: boolean;
  42645. /**
  42646. * The deviceOrientationCamera used as the camera when not in VR.
  42647. */
  42648. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42649. /**
  42650. * Based on the current WebVR support, returns the current VR camera used.
  42651. */
  42652. readonly currentVRCamera: Nullable<Camera>;
  42653. /**
  42654. * The webVRCamera which is used when in VR.
  42655. */
  42656. readonly webVRCamera: WebVRFreeCamera;
  42657. /**
  42658. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42659. */
  42660. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42661. private readonly _teleportationRequestInitiated;
  42662. /**
  42663. * Instantiates a VRExperienceHelper.
  42664. * Helps to quickly add VR support to an existing scene.
  42665. * @param scene The scene the VRExperienceHelper belongs to.
  42666. * @param webVROptions Options to modify the vr experience helper's behavior.
  42667. */
  42668. constructor(scene: Scene,
  42669. /** Options to modify the vr experience helper's behavior. */
  42670. webVROptions?: VRExperienceHelperOptions);
  42671. private _onDefaultMeshLoaded;
  42672. private _onResize;
  42673. private _onFullscreenChange;
  42674. /**
  42675. * Gets a value indicating if we are currently in VR mode.
  42676. */
  42677. readonly isInVRMode: boolean;
  42678. private onVrDisplayPresentChange;
  42679. private onVRDisplayChanged;
  42680. private moveButtonToBottomRight;
  42681. private displayVRButton;
  42682. private updateButtonVisibility;
  42683. private _cachedAngularSensibility;
  42684. /**
  42685. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42686. * Otherwise, will use the fullscreen API.
  42687. */
  42688. enterVR(): void;
  42689. /**
  42690. * Attempt to exit VR, or fullscreen.
  42691. */
  42692. exitVR(): void;
  42693. /**
  42694. * The position of the vr experience helper.
  42695. */
  42696. /**
  42697. * Sets the position of the vr experience helper.
  42698. */
  42699. position: Vector3;
  42700. /**
  42701. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42702. */
  42703. enableInteractions(): void;
  42704. private readonly _noControllerIsActive;
  42705. private beforeRender;
  42706. private _isTeleportationFloor;
  42707. /**
  42708. * Adds a floor mesh to be used for teleportation.
  42709. * @param floorMesh the mesh to be used for teleportation.
  42710. */
  42711. addFloorMesh(floorMesh: Mesh): void;
  42712. /**
  42713. * Removes a floor mesh from being used for teleportation.
  42714. * @param floorMesh the mesh to be removed.
  42715. */
  42716. removeFloorMesh(floorMesh: Mesh): void;
  42717. /**
  42718. * Enables interactions and teleportation using the VR controllers and gaze.
  42719. * @param vrTeleportationOptions options to modify teleportation behavior.
  42720. */
  42721. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42722. private _onNewGamepadConnected;
  42723. private _tryEnableInteractionOnController;
  42724. private _onNewGamepadDisconnected;
  42725. private _enableInteractionOnController;
  42726. private _checkTeleportWithRay;
  42727. private _checkRotate;
  42728. private _checkTeleportBackwards;
  42729. private _enableTeleportationOnController;
  42730. private _createTeleportationCircles;
  42731. private _displayTeleportationTarget;
  42732. private _hideTeleportationTarget;
  42733. private _rotateCamera;
  42734. private _moveTeleportationSelectorTo;
  42735. private _workingVector;
  42736. private _workingQuaternion;
  42737. private _workingMatrix;
  42738. /**
  42739. * Teleports the users feet to the desired location
  42740. * @param location The location where the user's feet should be placed
  42741. */
  42742. teleportCamera(location: Vector3): void;
  42743. private _convertNormalToDirectionOfRay;
  42744. private _castRayAndSelectObject;
  42745. private _notifySelectedMeshUnselected;
  42746. /**
  42747. * Sets the color of the laser ray from the vr controllers.
  42748. * @param color new color for the ray.
  42749. */
  42750. changeLaserColor(color: Color3): void;
  42751. /**
  42752. * Sets the color of the ray from the vr headsets gaze.
  42753. * @param color new color for the ray.
  42754. */
  42755. changeGazeColor(color: Color3): void;
  42756. /**
  42757. * Exits VR and disposes of the vr experience helper
  42758. */
  42759. dispose(): void;
  42760. /**
  42761. * Gets the name of the VRExperienceHelper class
  42762. * @returns "VRExperienceHelper"
  42763. */
  42764. getClassName(): string;
  42765. }
  42766. }
  42767. declare module BABYLON {
  42768. /**
  42769. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  42770. * IMPORTANT!! The data is right-hand data.
  42771. * @export
  42772. * @interface DevicePose
  42773. */
  42774. interface DevicePose {
  42775. /**
  42776. * The position of the device, values in array are [x,y,z].
  42777. */
  42778. readonly position: Nullable<Float32Array>;
  42779. /**
  42780. * The linearVelocity of the device, values in array are [x,y,z].
  42781. */
  42782. readonly linearVelocity: Nullable<Float32Array>;
  42783. /**
  42784. * The linearAcceleration of the device, values in array are [x,y,z].
  42785. */
  42786. readonly linearAcceleration: Nullable<Float32Array>;
  42787. /**
  42788. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  42789. */
  42790. readonly orientation: Nullable<Float32Array>;
  42791. /**
  42792. * The angularVelocity of the device, values in array are [x,y,z].
  42793. */
  42794. readonly angularVelocity: Nullable<Float32Array>;
  42795. /**
  42796. * The angularAcceleration of the device, values in array are [x,y,z].
  42797. */
  42798. readonly angularAcceleration: Nullable<Float32Array>;
  42799. }
  42800. /**
  42801. * Interface representing a pose controlled object in Babylon.
  42802. * A pose controlled object has both regular pose values as well as pose values
  42803. * from an external device such as a VR head mounted display
  42804. */
  42805. interface PoseControlled {
  42806. /**
  42807. * The position of the object in babylon space.
  42808. */
  42809. position: Vector3;
  42810. /**
  42811. * The rotation quaternion of the object in babylon space.
  42812. */
  42813. rotationQuaternion: Quaternion;
  42814. /**
  42815. * The position of the device in babylon space.
  42816. */
  42817. devicePosition?: Vector3;
  42818. /**
  42819. * The rotation quaternion of the device in babylon space.
  42820. */
  42821. deviceRotationQuaternion: Quaternion;
  42822. /**
  42823. * The raw pose coming from the device.
  42824. */
  42825. rawPose: Nullable<DevicePose>;
  42826. /**
  42827. * The scale of the device to be used when translating from device space to babylon space.
  42828. */
  42829. deviceScaleFactor: number;
  42830. /**
  42831. * Updates the poseControlled values based on the input device pose.
  42832. * @param poseData the pose data to update the object with
  42833. */
  42834. updateFromDevice(poseData: DevicePose): void;
  42835. }
  42836. /**
  42837. * Set of options to customize the webVRCamera
  42838. */
  42839. interface WebVROptions {
  42840. /**
  42841. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  42842. */
  42843. trackPosition?: boolean;
  42844. /**
  42845. * Sets the scale of the vrDevice in babylon space. (default: 1)
  42846. */
  42847. positionScale?: number;
  42848. /**
  42849. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  42850. */
  42851. displayName?: string;
  42852. /**
  42853. * Should the native controller meshes be initialized. (default: true)
  42854. */
  42855. controllerMeshes?: boolean;
  42856. /**
  42857. * Creating a default HemiLight only on controllers. (default: true)
  42858. */
  42859. defaultLightingOnControllers?: boolean;
  42860. /**
  42861. * If you don't want to use the default VR button of the helper. (default: false)
  42862. */
  42863. useCustomVRButton?: boolean;
  42864. /**
  42865. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  42866. */
  42867. customVRButton?: HTMLButtonElement;
  42868. /**
  42869. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  42870. */
  42871. rayLength?: number;
  42872. /**
  42873. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  42874. */
  42875. defaultHeight?: number;
  42876. }
  42877. /**
  42878. * This represents a WebVR camera.
  42879. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  42880. * @example http://doc.babylonjs.com/how_to/webvr_camera
  42881. */
  42882. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  42883. private webVROptions;
  42884. /**
  42885. * @hidden
  42886. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  42887. */
  42888. _vrDevice: any;
  42889. /**
  42890. * The rawPose of the vrDevice.
  42891. */
  42892. rawPose: Nullable<DevicePose>;
  42893. private _onVREnabled;
  42894. private _specsVersion;
  42895. private _attached;
  42896. private _frameData;
  42897. protected _descendants: Array<Node>;
  42898. private _deviceRoomPosition;
  42899. /** @hidden */
  42900. _deviceRoomRotationQuaternion: Quaternion;
  42901. private _standingMatrix;
  42902. /**
  42903. * Represents device position in babylon space.
  42904. */
  42905. devicePosition: Vector3;
  42906. /**
  42907. * Represents device rotation in babylon space.
  42908. */
  42909. deviceRotationQuaternion: Quaternion;
  42910. /**
  42911. * The scale of the device to be used when translating from device space to babylon space.
  42912. */
  42913. deviceScaleFactor: number;
  42914. private _deviceToWorld;
  42915. private _worldToDevice;
  42916. /**
  42917. * References to the webVR controllers for the vrDevice.
  42918. */
  42919. controllers: Array<WebVRController>;
  42920. /**
  42921. * Emits an event when a controller is attached.
  42922. */
  42923. onControllersAttachedObservable: Observable<WebVRController[]>;
  42924. /**
  42925. * Emits an event when a controller's mesh has been loaded;
  42926. */
  42927. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42928. /**
  42929. * Emits an event when the HMD's pose has been updated.
  42930. */
  42931. onPoseUpdatedFromDeviceObservable: Observable<any>;
  42932. private _poseSet;
  42933. /**
  42934. * If the rig cameras be used as parent instead of this camera.
  42935. */
  42936. rigParenting: boolean;
  42937. private _lightOnControllers;
  42938. private _defaultHeight?;
  42939. /**
  42940. * Instantiates a WebVRFreeCamera.
  42941. * @param name The name of the WebVRFreeCamera
  42942. * @param position The starting anchor position for the camera
  42943. * @param scene The scene the camera belongs to
  42944. * @param webVROptions a set of customizable options for the webVRCamera
  42945. */
  42946. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  42947. /**
  42948. * Gets the device distance from the ground in meters.
  42949. * @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.
  42950. */
  42951. deviceDistanceToRoomGround(): number;
  42952. /**
  42953. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42954. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  42955. */
  42956. useStandingMatrix(callback?: (bool: boolean) => void): void;
  42957. /**
  42958. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  42959. * @returns A promise with a boolean set to if the standing matrix is supported.
  42960. */
  42961. useStandingMatrixAsync(): Promise<boolean>;
  42962. /**
  42963. * Disposes the camera
  42964. */
  42965. dispose(): void;
  42966. /**
  42967. * Gets a vrController by name.
  42968. * @param name The name of the controller to retreive
  42969. * @returns the controller matching the name specified or null if not found
  42970. */
  42971. getControllerByName(name: string): Nullable<WebVRController>;
  42972. private _leftController;
  42973. /**
  42974. * The controller corrisponding to the users left hand.
  42975. */
  42976. readonly leftController: Nullable<WebVRController>;
  42977. private _rightController;
  42978. /**
  42979. * The controller corrisponding to the users right hand.
  42980. */
  42981. readonly rightController: Nullable<WebVRController>;
  42982. /**
  42983. * Casts a ray forward from the vrCamera's gaze.
  42984. * @param length Length of the ray (default: 100)
  42985. * @returns the ray corrisponding to the gaze
  42986. */
  42987. getForwardRay(length?: number): Ray;
  42988. /**
  42989. * @hidden
  42990. * Updates the camera based on device's frame data
  42991. */
  42992. _checkInputs(): void;
  42993. /**
  42994. * Updates the poseControlled values based on the input device pose.
  42995. * @param poseData Pose coming from the device
  42996. */
  42997. updateFromDevice(poseData: DevicePose): void;
  42998. private _htmlElementAttached;
  42999. private _detachIfAttached;
  43000. /**
  43001. * WebVR's attach control will start broadcasting frames to the device.
  43002. * Note that in certain browsers (chrome for example) this function must be called
  43003. * within a user-interaction callback. Example:
  43004. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  43005. *
  43006. * @param element html element to attach the vrDevice to
  43007. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  43008. */
  43009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43010. /**
  43011. * Detaches the camera from the html element and disables VR
  43012. *
  43013. * @param element html element to detach from
  43014. */
  43015. detachControl(element: HTMLElement): void;
  43016. /**
  43017. * @returns the name of this class
  43018. */
  43019. getClassName(): string;
  43020. /**
  43021. * Calls resetPose on the vrDisplay
  43022. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  43023. */
  43024. resetToCurrentRotation(): void;
  43025. /**
  43026. * @hidden
  43027. * Updates the rig cameras (left and right eye)
  43028. */
  43029. _updateRigCameras(): void;
  43030. private _workingVector;
  43031. private _oneVector;
  43032. private _workingMatrix;
  43033. private updateCacheCalled;
  43034. private _correctPositionIfNotTrackPosition;
  43035. /**
  43036. * @hidden
  43037. * Updates the cached values of the camera
  43038. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  43039. */
  43040. _updateCache(ignoreParentClass?: boolean): void;
  43041. /**
  43042. * @hidden
  43043. * Get current device position in babylon world
  43044. */
  43045. _computeDevicePosition(): void;
  43046. /**
  43047. * Updates the current device position and rotation in the babylon world
  43048. */
  43049. update(): void;
  43050. /**
  43051. * @hidden
  43052. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  43053. * @returns an identity matrix
  43054. */
  43055. _getViewMatrix(): Matrix;
  43056. private _tmpMatrix;
  43057. /**
  43058. * This function is called by the two RIG cameras.
  43059. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  43060. */
  43061. protected _getWebVRViewMatrix(): Matrix;
  43062. protected _getWebVRProjectionMatrix(): Matrix;
  43063. private _onGamepadConnectedObserver;
  43064. private _onGamepadDisconnectedObserver;
  43065. private _updateCacheWhenTrackingDisabledObserver;
  43066. /**
  43067. * Initializes the controllers and their meshes
  43068. */
  43069. initControllers(): void;
  43070. }
  43071. }
  43072. declare module BABYLON {
  43073. /**
  43074. * WebXR Camera which holds the views for the xrSession
  43075. * @see https://doc.babylonjs.com/how_to/webxr
  43076. */
  43077. class WebXRCamera extends FreeCamera {
  43078. private static _TmpMatrix;
  43079. /**
  43080. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43081. * @param name the name of the camera
  43082. * @param scene the scene to add the camera to
  43083. */
  43084. constructor(name: string, scene: BABYLON.Scene);
  43085. private _updateNumberOfRigCameras;
  43086. /** @hidden */
  43087. _updateForDualEyeDebugging(pupilDistance?: number): void;
  43088. /**
  43089. * Updates the cameras position from the current pose information of the XR session
  43090. * @param xrSessionManager the session containing pose information
  43091. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  43092. */
  43093. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43094. }
  43095. }
  43096. declare module BABYLON {
  43097. /**
  43098. * Button which can be used to enter a different mode of XR
  43099. */
  43100. class WebXREnterExitUIButton {
  43101. /** button element */
  43102. element: HTMLElement;
  43103. /** XR initialization options for the button */
  43104. initializationOptions: XRSessionCreationOptions;
  43105. /**
  43106. * Creates a WebXREnterExitUIButton
  43107. * @param element button element
  43108. * @param initializationOptions XR initialization options for the button
  43109. */
  43110. constructor(
  43111. /** button element */
  43112. element: HTMLElement,
  43113. /** XR initialization options for the button */
  43114. initializationOptions: XRSessionCreationOptions);
  43115. /**
  43116. * Overwritable function which can be used to update the button's visuals when the state changes
  43117. * @param activeButton the current active button in the UI
  43118. */
  43119. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43120. }
  43121. /**
  43122. * Options to create the webXR UI
  43123. */
  43124. class WebXREnterExitUIOptions {
  43125. /**
  43126. * Context to enter xr with
  43127. */
  43128. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  43129. /**
  43130. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43131. */
  43132. customButtons?: Array<WebXREnterExitUIButton>;
  43133. }
  43134. /**
  43135. * UI to allow the user to enter/exit XR mode
  43136. */
  43137. class WebXREnterExitUI implements IDisposable {
  43138. private scene;
  43139. private _overlay;
  43140. private _buttons;
  43141. private _activeButton;
  43142. /**
  43143. * Fired every time the active button is changed.
  43144. *
  43145. * When xr is entered via a button that launches xr that button will be the callback parameter
  43146. *
  43147. * When exiting xr the callback parameter will be null)
  43148. */
  43149. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43150. /**
  43151. * Creates UI to allow the user to enter/exit XR mode
  43152. * @param scene the scene to add the ui to
  43153. * @param helper the xr experience helper to enter/exit xr with
  43154. * @param options options to configure the UI
  43155. * @returns the created ui
  43156. */
  43157. static CreateAsync(scene: BABYLON.Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43158. private constructor();
  43159. private _updateButtons;
  43160. /**
  43161. * Disposes of the object
  43162. */
  43163. dispose(): void;
  43164. }
  43165. }
  43166. declare module BABYLON {
  43167. /**
  43168. * States of the webXR experience
  43169. */
  43170. enum WebXRState {
  43171. /**
  43172. * Transitioning to being in XR mode
  43173. */
  43174. ENTERING_XR = 0,
  43175. /**
  43176. * Transitioning to non XR mode
  43177. */
  43178. EXITING_XR = 1,
  43179. /**
  43180. * In XR mode and presenting
  43181. */
  43182. IN_XR = 2,
  43183. /**
  43184. * Not entered XR mode
  43185. */
  43186. NOT_IN_XR = 3
  43187. }
  43188. /**
  43189. * Helper class used to enable XR
  43190. * @see https://doc.babylonjs.com/how_to/webxr
  43191. */
  43192. class WebXRExperienceHelper implements IDisposable {
  43193. private scene;
  43194. /**
  43195. * 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
  43196. */
  43197. container: AbstractMesh;
  43198. /**
  43199. * Camera used to render xr content
  43200. */
  43201. camera: WebXRCamera;
  43202. /**
  43203. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43204. */
  43205. state: WebXRState;
  43206. private _setState;
  43207. private static _TmpVector;
  43208. /**
  43209. * Fires when the state of the experience helper has changed
  43210. */
  43211. onStateChangedObservable: Observable<WebXRState>;
  43212. /** @hidden */
  43213. _sessionManager: WebXRSessionManager;
  43214. private _nonVRCamera;
  43215. private _originalSceneAutoClear;
  43216. private _supported;
  43217. /**
  43218. * Creates the experience helper
  43219. * @param scene the scene to attach the experience helper to
  43220. * @returns a promise for the experience helper
  43221. */
  43222. static CreateAsync(scene: BABYLON.Scene): Promise<WebXRExperienceHelper>;
  43223. /**
  43224. * Creates a WebXRExperienceHelper
  43225. * @param scene The scene the helper should be created in
  43226. */
  43227. private constructor();
  43228. /**
  43229. * Exits XR mode and returns the scene to its original state
  43230. * @returns promise that resolves after xr mode has exited
  43231. */
  43232. exitXRAsync(): Promise<void>;
  43233. /**
  43234. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43235. * @param sessionCreationOptions options for the XR session
  43236. * @param frameOfReference frame of reference of the XR session
  43237. * @returns promise that resolves after xr mode has entered
  43238. */
  43239. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  43240. /**
  43241. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43242. * @param ray ray to cast into the environment
  43243. * @returns Promise which resolves with a collision point in the environment if it exists
  43244. */
  43245. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43246. /**
  43247. * Updates the global position of the camera by moving the camera's container
  43248. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43249. * @param position The desired global position of the camera
  43250. */
  43251. setPositionOfCameraUsingContainer(position: Vector3): void;
  43252. /**
  43253. * Rotates the xr camera by rotating the camera's container around the camera's position
  43254. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43255. * @param rotation the desired quaternion rotation to apply to the camera
  43256. */
  43257. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43258. /**
  43259. * Checks if the creation options are supported by the xr session
  43260. * @param options creation options
  43261. * @returns true if supported
  43262. */
  43263. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43264. /**
  43265. * Disposes of the experience helper
  43266. */
  43267. dispose(): void;
  43268. }
  43269. }
  43270. declare module BABYLON {
  43271. /**
  43272. * Represents an XR input
  43273. */
  43274. class WebXRController {
  43275. /**
  43276. * 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
  43277. */
  43278. grip?: BABYLON.AbstractMesh;
  43279. /**
  43280. * Pointer which can be used to select objects or attach a visible laser to
  43281. */
  43282. pointer: BABYLON.AbstractMesh;
  43283. /**
  43284. * Creates the controller
  43285. * @see https://doc.babylonjs.com/how_to/webxr
  43286. * @param scene the scene which the controller should be associated to
  43287. */
  43288. constructor(scene: BABYLON.Scene);
  43289. /**
  43290. * Disposes of the object
  43291. */
  43292. dispose(): void;
  43293. }
  43294. /**
  43295. * XR input used to track XR inputs such as controllers/rays
  43296. */
  43297. class WebXRInput implements IDisposable {
  43298. private helper;
  43299. /**
  43300. * XR controllers being tracked
  43301. */
  43302. controllers: Array<WebXRController>;
  43303. private _tmpMatrix;
  43304. private _frameObserver;
  43305. /**
  43306. * Initializes the WebXRInput
  43307. * @param helper experience helper which the input should be created for
  43308. */
  43309. constructor(helper: WebXRExperienceHelper);
  43310. /**
  43311. * Disposes of the object
  43312. */
  43313. dispose(): void;
  43314. }
  43315. }
  43316. declare module BABYLON {
  43317. /**
  43318. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43319. */
  43320. class WebXRManagedOutputCanvas implements IDisposable {
  43321. private _canvas;
  43322. /**
  43323. * xrpresent context of the canvas which can be used to display/mirror xr content
  43324. */
  43325. canvasContext: Nullable<WebGLRenderingContext>;
  43326. /**
  43327. * Initializes the canvas to be added/removed upon entering/exiting xr
  43328. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43329. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43330. */
  43331. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43332. /**
  43333. * Disposes of the object
  43334. */
  43335. dispose(): void;
  43336. private _setManagedOutputCanvas;
  43337. private _addCanvas;
  43338. private _removeCanvas;
  43339. }
  43340. }
  43341. declare module BABYLON {
  43342. /**
  43343. * Manages an XRSession
  43344. * @see https://doc.babylonjs.com/how_to/webxr
  43345. */
  43346. class WebXRSessionManager implements IDisposable {
  43347. private scene;
  43348. /**
  43349. * Fires every time a new xrFrame arrives which can be used to update the camera
  43350. */
  43351. onXRFrameObservable: Observable<any>;
  43352. /**
  43353. * Fires when the xr session is ended either by the device or manually done
  43354. */
  43355. onXRSessionEnded: Observable<any>;
  43356. /** @hidden */
  43357. _xrSession: XRSession;
  43358. /** @hidden */
  43359. _frameOfReference: XRFrameOfReference;
  43360. /** @hidden */
  43361. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  43362. /** @hidden */
  43363. _currentXRFrame: Nullable<XRFrame>;
  43364. private _xrNavigator;
  43365. private _xrDevice;
  43366. private _tmpMatrix;
  43367. /**
  43368. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43369. * @param scene The scene which the session should be created for
  43370. */
  43371. constructor(scene: BABYLON.Scene);
  43372. /**
  43373. * Initializes the manager
  43374. * After initialization enterXR can be called to start an XR session
  43375. * @returns Promise which resolves after it is initialized
  43376. */
  43377. initializeAsync(): Promise<void>;
  43378. /**
  43379. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  43380. * @param sessionCreationOptions xr options to create the session with
  43381. * @param frameOfReferenceType option to configure how the xr pose is expressed
  43382. * @returns Promise which resolves after it enters XR
  43383. */
  43384. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  43385. /**
  43386. * Stops the xrSession and restores the renderloop
  43387. * @returns Promise which resolves after it exits XR
  43388. */
  43389. exitXRAsync(): Promise<void>;
  43390. /**
  43391. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  43392. * @param ray ray to cast into the environment
  43393. * @returns Promise which resolves with a collision point in the environment if it exists
  43394. */
  43395. environmentPointHitTestAsync(ray: BABYLON.Ray): Promise<Nullable<Vector3>>;
  43396. /**
  43397. * Checks if a session would be supported for the creation options specified
  43398. * @param options creation options to check if they are supported
  43399. * @returns true if supported
  43400. */
  43401. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  43402. /**
  43403. * @hidden
  43404. * Converts the render layer of xrSession to a render target
  43405. * @param session session to create render target for
  43406. * @param scene scene the new render target should be created for
  43407. */
  43408. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: BABYLON.Scene): RenderTargetTexture;
  43409. /**
  43410. * Disposes of the session manager
  43411. */
  43412. dispose(): void;
  43413. }
  43414. }
  43415. declare module BABYLON {
  43416. /** @hidden */
  43417. class _OcclusionDataStorage {
  43418. /** @hidden */
  43419. occlusionInternalRetryCounter: number;
  43420. /** @hidden */
  43421. isOcclusionQueryInProgress: boolean;
  43422. /** @hidden */
  43423. isOccluded: boolean;
  43424. /** @hidden */
  43425. occlusionRetryCount: number;
  43426. /** @hidden */
  43427. occlusionType: number;
  43428. /** @hidden */
  43429. occlusionQueryAlgorithmType: number;
  43430. }
  43431. interface Engine {
  43432. /**
  43433. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43434. * @return the new query
  43435. */
  43436. createQuery(): WebGLQuery;
  43437. /**
  43438. * Delete and release a webGL query
  43439. * @param query defines the query to delete
  43440. * @return the current engine
  43441. */
  43442. deleteQuery(query: WebGLQuery): Engine;
  43443. /**
  43444. * Check if a given query has resolved and got its value
  43445. * @param query defines the query to check
  43446. * @returns true if the query got its value
  43447. */
  43448. isQueryResultAvailable(query: WebGLQuery): boolean;
  43449. /**
  43450. * Gets the value of a given query
  43451. * @param query defines the query to check
  43452. * @returns the value of the query
  43453. */
  43454. getQueryResult(query: WebGLQuery): number;
  43455. /**
  43456. * Initiates an occlusion query
  43457. * @param algorithmType defines the algorithm to use
  43458. * @param query defines the query to use
  43459. * @returns the current engine
  43460. * @see http://doc.babylonjs.com/features/occlusionquery
  43461. */
  43462. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43463. /**
  43464. * Ends an occlusion query
  43465. * @see http://doc.babylonjs.com/features/occlusionquery
  43466. * @param algorithmType defines the algorithm to use
  43467. * @returns the current engine
  43468. */
  43469. endOcclusionQuery(algorithmType: number): Engine;
  43470. /**
  43471. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43472. * Please note that only one query can be issued at a time
  43473. * @returns a time token used to track the time span
  43474. */
  43475. startTimeQuery(): Nullable<_TimeToken>;
  43476. /**
  43477. * Ends a time query
  43478. * @param token defines the token used to measure the time span
  43479. * @returns the time spent (in ns)
  43480. */
  43481. endTimeQuery(token: _TimeToken): int;
  43482. /** @hidden */
  43483. _currentNonTimestampToken: Nullable<_TimeToken>;
  43484. /** @hidden */
  43485. _createTimeQuery(): WebGLQuery;
  43486. /** @hidden */
  43487. _deleteTimeQuery(query: WebGLQuery): void;
  43488. /** @hidden */
  43489. _getGlAlgorithmType(algorithmType: number): number;
  43490. /** @hidden */
  43491. _getTimeQueryResult(query: WebGLQuery): any;
  43492. /** @hidden */
  43493. _getTimeQueryAvailability(query: WebGLQuery): any;
  43494. }
  43495. interface AbstractMesh {
  43496. /**
  43497. * Backing filed
  43498. * @hidden
  43499. */
  43500. __occlusionDataStorage: _OcclusionDataStorage;
  43501. /**
  43502. * Access property
  43503. * @hidden
  43504. */
  43505. _occlusionDataStorage: _OcclusionDataStorage;
  43506. /**
  43507. * 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.
  43508. * The default value is -1 which means don't break the query and wait till the result
  43509. * @see http://doc.babylonjs.com/features/occlusionquery
  43510. */
  43511. occlusionRetryCount: number;
  43512. /**
  43513. * 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:
  43514. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43515. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43516. * * 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.
  43517. * @see http://doc.babylonjs.com/features/occlusionquery
  43518. */
  43519. occlusionType: number;
  43520. /**
  43521. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43522. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43523. * * 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.
  43524. * @see http://doc.babylonjs.com/features/occlusionquery
  43525. */
  43526. occlusionQueryAlgorithmType: number;
  43527. /**
  43528. * 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
  43529. * @see http://doc.babylonjs.com/features/occlusionquery
  43530. */
  43531. isOccluded: boolean;
  43532. /**
  43533. * Flag to check the progress status of the query
  43534. * @see http://doc.babylonjs.com/features/occlusionquery
  43535. */
  43536. isOcclusionQueryInProgress: boolean;
  43537. }
  43538. }
  43539. declare module BABYLON {
  43540. interface Engine {
  43541. /**
  43542. * Creates a webGL transform feedback object
  43543. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43544. * @returns the webGL transform feedback object
  43545. */
  43546. createTransformFeedback(): WebGLTransformFeedback;
  43547. /**
  43548. * Delete a webGL transform feedback object
  43549. * @param value defines the webGL transform feedback object to delete
  43550. */
  43551. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43552. /**
  43553. * Bind a webGL transform feedback object to the webgl context
  43554. * @param value defines the webGL transform feedback object to bind
  43555. */
  43556. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43557. /**
  43558. * Begins a transform feedback operation
  43559. * @param usePoints defines if points or triangles must be used
  43560. */
  43561. beginTransformFeedback(usePoints: boolean): void;
  43562. /**
  43563. * Ends a transform feedback operation
  43564. */
  43565. endTransformFeedback(): void;
  43566. /**
  43567. * Specify the varyings to use with transform feedback
  43568. * @param program defines the associated webGL program
  43569. * @param value defines the list of strings representing the varying names
  43570. */
  43571. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43572. /**
  43573. * Bind a webGL buffer for a transform feedback operation
  43574. * @param value defines the webGL buffer to bind
  43575. */
  43576. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  43577. }
  43578. }
  43579. declare module BABYLON {
  43580. /**
  43581. * Google Daydream controller
  43582. */
  43583. class DaydreamController extends WebVRController {
  43584. /**
  43585. * Base Url for the controller model.
  43586. */
  43587. static MODEL_BASE_URL: string;
  43588. /**
  43589. * File name for the controller model.
  43590. */
  43591. static MODEL_FILENAME: string;
  43592. /**
  43593. * Gamepad Id prefix used to identify Daydream Controller.
  43594. */
  43595. static readonly GAMEPAD_ID_PREFIX: string;
  43596. /**
  43597. * Creates a new DaydreamController from a gamepad
  43598. * @param vrGamepad the gamepad that the controller should be created from
  43599. */
  43600. constructor(vrGamepad: any);
  43601. /**
  43602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43603. * @param scene scene in which to add meshes
  43604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43605. */
  43606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43607. /**
  43608. * Called once for each button that changed state since the last frame
  43609. * @param buttonIdx Which button index changed
  43610. * @param state New state of the button
  43611. * @param changes Which properties on the state changed since last frame
  43612. */
  43613. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43614. }
  43615. }
  43616. declare module BABYLON {
  43617. /**
  43618. * Gear VR Controller
  43619. */
  43620. class GearVRController extends WebVRController {
  43621. /**
  43622. * Base Url for the controller model.
  43623. */
  43624. static MODEL_BASE_URL: string;
  43625. /**
  43626. * File name for the controller model.
  43627. */
  43628. static MODEL_FILENAME: string;
  43629. /**
  43630. * Gamepad Id prefix used to identify this controller.
  43631. */
  43632. static readonly GAMEPAD_ID_PREFIX: string;
  43633. private readonly _buttonIndexToObservableNameMap;
  43634. /**
  43635. * Creates a new GearVRController from a gamepad
  43636. * @param vrGamepad the gamepad that the controller should be created from
  43637. */
  43638. constructor(vrGamepad: any);
  43639. /**
  43640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43641. * @param scene scene in which to add meshes
  43642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43643. */
  43644. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43645. /**
  43646. * Called once for each button that changed state since the last frame
  43647. * @param buttonIdx Which button index changed
  43648. * @param state New state of the button
  43649. * @param changes Which properties on the state changed since last frame
  43650. */
  43651. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43652. }
  43653. }
  43654. declare module BABYLON {
  43655. /**
  43656. * Generic Controller
  43657. */
  43658. class GenericController extends WebVRController {
  43659. /**
  43660. * Base Url for the controller model.
  43661. */
  43662. static readonly MODEL_BASE_URL: string;
  43663. /**
  43664. * File name for the controller model.
  43665. */
  43666. static readonly MODEL_FILENAME: string;
  43667. /**
  43668. * Creates a new GenericController from a gamepad
  43669. * @param vrGamepad the gamepad that the controller should be created from
  43670. */
  43671. constructor(vrGamepad: any);
  43672. /**
  43673. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43674. * @param scene scene in which to add meshes
  43675. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43676. */
  43677. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43678. /**
  43679. * Called once for each button that changed state since the last frame
  43680. * @param buttonIdx Which button index changed
  43681. * @param state New state of the button
  43682. * @param changes Which properties on the state changed since last frame
  43683. */
  43684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43685. }
  43686. }
  43687. declare module BABYLON {
  43688. /**
  43689. * Oculus Touch Controller
  43690. */
  43691. class OculusTouchController extends WebVRController {
  43692. /**
  43693. * Base Url for the controller model.
  43694. */
  43695. static MODEL_BASE_URL: string;
  43696. /**
  43697. * File name for the left controller model.
  43698. */
  43699. static MODEL_LEFT_FILENAME: string;
  43700. /**
  43701. * File name for the right controller model.
  43702. */
  43703. static MODEL_RIGHT_FILENAME: string;
  43704. /**
  43705. * Fired when the secondary trigger on this controller is modified
  43706. */
  43707. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43708. /**
  43709. * Fired when the thumb rest on this controller is modified
  43710. */
  43711. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43712. /**
  43713. * Creates a new OculusTouchController from a gamepad
  43714. * @param vrGamepad the gamepad that the controller should be created from
  43715. */
  43716. constructor(vrGamepad: any);
  43717. /**
  43718. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43719. * @param scene scene in which to add meshes
  43720. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43721. */
  43722. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43723. /**
  43724. * Fired when the A button on this controller is modified
  43725. */
  43726. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43727. /**
  43728. * Fired when the B button on this controller is modified
  43729. */
  43730. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43731. /**
  43732. * Fired when the X button on this controller is modified
  43733. */
  43734. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43735. /**
  43736. * Fired when the Y button on this controller is modified
  43737. */
  43738. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43739. /**
  43740. * Called once for each button that changed state since the last frame
  43741. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43742. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43743. * 2) secondary trigger (same)
  43744. * 3) A (right) X (left), touch, pressed = value
  43745. * 4) B / Y
  43746. * 5) thumb rest
  43747. * @param buttonIdx Which button index changed
  43748. * @param state New state of the button
  43749. * @param changes Which properties on the state changed since last frame
  43750. */
  43751. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43752. }
  43753. }
  43754. declare module BABYLON {
  43755. /**
  43756. * Defines the types of pose enabled controllers that are supported
  43757. */
  43758. enum PoseEnabledControllerType {
  43759. /**
  43760. * HTC Vive
  43761. */
  43762. VIVE = 0,
  43763. /**
  43764. * Oculus Rift
  43765. */
  43766. OCULUS = 1,
  43767. /**
  43768. * Windows mixed reality
  43769. */
  43770. WINDOWS = 2,
  43771. /**
  43772. * Samsung gear VR
  43773. */
  43774. GEAR_VR = 3,
  43775. /**
  43776. * Google Daydream
  43777. */
  43778. DAYDREAM = 4,
  43779. /**
  43780. * Generic
  43781. */
  43782. GENERIC = 5
  43783. }
  43784. /**
  43785. * Defines the MutableGamepadButton interface for the state of a gamepad button
  43786. */
  43787. interface MutableGamepadButton {
  43788. /**
  43789. * Value of the button/trigger
  43790. */
  43791. value: number;
  43792. /**
  43793. * If the button/trigger is currently touched
  43794. */
  43795. touched: boolean;
  43796. /**
  43797. * If the button/trigger is currently pressed
  43798. */
  43799. pressed: boolean;
  43800. }
  43801. /**
  43802. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  43803. * @hidden
  43804. */
  43805. interface ExtendedGamepadButton extends GamepadButton {
  43806. /**
  43807. * If the button/trigger is currently pressed
  43808. */
  43809. readonly pressed: boolean;
  43810. /**
  43811. * If the button/trigger is currently touched
  43812. */
  43813. readonly touched: boolean;
  43814. /**
  43815. * Value of the button/trigger
  43816. */
  43817. readonly value: number;
  43818. }
  43819. /**
  43820. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43821. */
  43822. class PoseEnabledControllerHelper {
  43823. /**
  43824. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  43825. * @param vrGamepad the gamepad to initialized
  43826. * @returns a vr controller of the type the gamepad identified as
  43827. */
  43828. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | DaydreamController | GenericController;
  43829. }
  43830. /**
  43831. * Defines the PoseEnabledController object that contains state of a vr capable controller
  43832. */
  43833. class PoseEnabledController extends Gamepad implements PoseControlled {
  43834. private _deviceRoomPosition;
  43835. private _deviceRoomRotationQuaternion;
  43836. /**
  43837. * The device position in babylon space
  43838. */
  43839. devicePosition: Vector3;
  43840. /**
  43841. * The device rotation in babylon space
  43842. */
  43843. deviceRotationQuaternion: Quaternion;
  43844. /**
  43845. * The scale factor of the device in babylon space
  43846. */
  43847. deviceScaleFactor: number;
  43848. /**
  43849. * (Likely devicePosition should be used instead) The device position in its room space
  43850. */
  43851. position: Vector3;
  43852. /**
  43853. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  43854. */
  43855. rotationQuaternion: Quaternion;
  43856. /**
  43857. * The type of controller (Eg. Windows mixed reality)
  43858. */
  43859. controllerType: PoseEnabledControllerType;
  43860. protected _calculatedPosition: Vector3;
  43861. private _calculatedRotation;
  43862. /**
  43863. * The raw pose from the device
  43864. */
  43865. rawPose: DevicePose;
  43866. private _trackPosition;
  43867. private _maxRotationDistFromHeadset;
  43868. private _draggedRoomRotation;
  43869. /**
  43870. * @hidden
  43871. */
  43872. _disableTrackPosition(fixedPosition: Vector3): void;
  43873. /**
  43874. * Internal, the mesh attached to the controller
  43875. * @hidden
  43876. */
  43877. _mesh: Nullable<AbstractMesh>;
  43878. private _poseControlledCamera;
  43879. private _leftHandSystemQuaternion;
  43880. /**
  43881. * Internal, matrix used to convert room space to babylon space
  43882. * @hidden
  43883. */
  43884. _deviceToWorld: Matrix;
  43885. /**
  43886. * Node to be used when casting a ray from the controller
  43887. * @hidden
  43888. */
  43889. _pointingPoseNode: Nullable<TransformNode>;
  43890. /**
  43891. * Name of the child mesh that can be used to cast a ray from the controller
  43892. */
  43893. static readonly POINTING_POSE: string;
  43894. /**
  43895. * Creates a new PoseEnabledController from a gamepad
  43896. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  43897. */
  43898. constructor(browserGamepad: any);
  43899. private _workingMatrix;
  43900. /**
  43901. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  43902. */
  43903. update(): void;
  43904. /**
  43905. * Updates only the pose device and mesh without doing any button event checking
  43906. */
  43907. protected _updatePoseAndMesh(): void;
  43908. /**
  43909. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  43910. * @param poseData raw pose fromthe device
  43911. */
  43912. updateFromDevice(poseData: DevicePose): void;
  43913. /**
  43914. * @hidden
  43915. */
  43916. _meshAttachedObservable: Observable<AbstractMesh>;
  43917. /**
  43918. * Attaches a mesh to the controller
  43919. * @param mesh the mesh to be attached
  43920. */
  43921. attachToMesh(mesh: AbstractMesh): void;
  43922. /**
  43923. * Attaches the controllers mesh to a camera
  43924. * @param camera the camera the mesh should be attached to
  43925. */
  43926. attachToPoseControlledCamera(camera: TargetCamera): void;
  43927. /**
  43928. * Disposes of the controller
  43929. */
  43930. dispose(): void;
  43931. /**
  43932. * The mesh that is attached to the controller
  43933. */
  43934. readonly mesh: Nullable<AbstractMesh>;
  43935. /**
  43936. * Gets the ray of the controller in the direction the controller is pointing
  43937. * @param length the length the resulting ray should be
  43938. * @returns a ray in the direction the controller is pointing
  43939. */
  43940. getForwardRay(length?: number): Ray;
  43941. }
  43942. }
  43943. declare module BABYLON {
  43944. /**
  43945. * Vive Controller
  43946. */
  43947. class ViveController extends WebVRController {
  43948. /**
  43949. * Base Url for the controller model.
  43950. */
  43951. static MODEL_BASE_URL: string;
  43952. /**
  43953. * File name for the controller model.
  43954. */
  43955. static MODEL_FILENAME: string;
  43956. /**
  43957. * Creates a new ViveController from a gamepad
  43958. * @param vrGamepad the gamepad that the controller should be created from
  43959. */
  43960. constructor(vrGamepad: any);
  43961. /**
  43962. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43963. * @param scene scene in which to add meshes
  43964. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43965. */
  43966. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43967. /**
  43968. * Fired when the left button on this controller is modified
  43969. */
  43970. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43971. /**
  43972. * Fired when the right button on this controller is modified
  43973. */
  43974. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43975. /**
  43976. * Fired when the menu button on this controller is modified
  43977. */
  43978. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43979. /**
  43980. * Called once for each button that changed state since the last frame
  43981. * Vive mapping:
  43982. * 0: touchpad
  43983. * 1: trigger
  43984. * 2: left AND right buttons
  43985. * 3: menu button
  43986. * @param buttonIdx Which button index changed
  43987. * @param state New state of the button
  43988. * @param changes Which properties on the state changed since last frame
  43989. */
  43990. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43991. }
  43992. }
  43993. declare module BABYLON {
  43994. /**
  43995. * Defines the WebVRController object that represents controllers tracked in 3D space
  43996. */
  43997. abstract class WebVRController extends PoseEnabledController {
  43998. /**
  43999. * Internal, the default controller model for the controller
  44000. */
  44001. protected _defaultModel: AbstractMesh;
  44002. /**
  44003. * Fired when the trigger state has changed
  44004. */
  44005. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44006. /**
  44007. * Fired when the main button state has changed
  44008. */
  44009. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44010. /**
  44011. * Fired when the secondary button state has changed
  44012. */
  44013. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44014. /**
  44015. * Fired when the pad state has changed
  44016. */
  44017. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  44018. /**
  44019. * Fired when controllers stick values have changed
  44020. */
  44021. onPadValuesChangedObservable: Observable<StickValues>;
  44022. /**
  44023. * Array of button availible on the controller
  44024. */
  44025. protected _buttons: Array<MutableGamepadButton>;
  44026. private _onButtonStateChange;
  44027. /**
  44028. * Fired when a controller button's state has changed
  44029. * @param callback the callback containing the button that was modified
  44030. */
  44031. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  44032. /**
  44033. * X and Y axis corrisponding to the controllers joystick
  44034. */
  44035. pad: StickValues;
  44036. /**
  44037. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  44038. */
  44039. hand: string;
  44040. /**
  44041. * The default controller model for the controller
  44042. */
  44043. readonly defaultModel: AbstractMesh;
  44044. /**
  44045. * Creates a new WebVRController from a gamepad
  44046. * @param vrGamepad the gamepad that the WebVRController should be created from
  44047. */
  44048. constructor(vrGamepad: any);
  44049. /**
  44050. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  44051. */
  44052. update(): void;
  44053. /**
  44054. * Function to be called when a button is modified
  44055. */
  44056. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44057. /**
  44058. * Loads a mesh and attaches it to the controller
  44059. * @param scene the scene the mesh should be added to
  44060. * @param meshLoaded callback for when the mesh has been loaded
  44061. */
  44062. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44063. private _setButtonValue;
  44064. private _changes;
  44065. private _checkChanges;
  44066. /**
  44067. * Disposes of th webVRCOntroller
  44068. */
  44069. dispose(): void;
  44070. }
  44071. }
  44072. declare module BABYLON {
  44073. /**
  44074. * Defines the WindowsMotionController object that the state of the windows motion controller
  44075. */
  44076. class WindowsMotionController extends WebVRController {
  44077. /**
  44078. * The base url used to load the left and right controller models
  44079. */
  44080. static MODEL_BASE_URL: string;
  44081. /**
  44082. * The name of the left controller model file
  44083. */
  44084. static MODEL_LEFT_FILENAME: string;
  44085. /**
  44086. * The name of the right controller model file
  44087. */
  44088. static MODEL_RIGHT_FILENAME: string;
  44089. /**
  44090. * The controller name prefix for this controller type
  44091. */
  44092. static readonly GAMEPAD_ID_PREFIX: string;
  44093. /**
  44094. * The controller id pattern for this controller type
  44095. */
  44096. private static readonly GAMEPAD_ID_PATTERN;
  44097. private _loadedMeshInfo;
  44098. private readonly _mapping;
  44099. /**
  44100. * Fired when the trackpad on this controller is clicked
  44101. */
  44102. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44103. /**
  44104. * Fired when the trackpad on this controller is modified
  44105. */
  44106. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44107. /**
  44108. * The current x and y values of this controller's trackpad
  44109. */
  44110. trackpad: StickValues;
  44111. /**
  44112. * Creates a new WindowsMotionController from a gamepad
  44113. * @param vrGamepad the gamepad that the controller should be created from
  44114. */
  44115. constructor(vrGamepad: any);
  44116. /**
  44117. * Fired when the trigger on this controller is modified
  44118. */
  44119. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44120. /**
  44121. * Fired when the menu button on this controller is modified
  44122. */
  44123. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44124. /**
  44125. * Fired when the grip button on this controller is modified
  44126. */
  44127. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44128. /**
  44129. * Fired when the thumbstick button on this controller is modified
  44130. */
  44131. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44132. /**
  44133. * Fired when the touchpad button on this controller is modified
  44134. */
  44135. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44136. /**
  44137. * Fired when the touchpad values on this controller are modified
  44138. */
  44139. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44140. private _updateTrackpad;
  44141. /**
  44142. * Called once per frame by the engine.
  44143. */
  44144. update(): void;
  44145. /**
  44146. * Called once for each button that changed state since the last frame
  44147. * @param buttonIdx Which button index changed
  44148. * @param state New state of the button
  44149. * @param changes Which properties on the state changed since last frame
  44150. */
  44151. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44152. /**
  44153. * Moves the buttons on the controller mesh based on their current state
  44154. * @param buttonName the name of the button to move
  44155. * @param buttonValue the value of the button which determines the buttons new position
  44156. */
  44157. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44158. /**
  44159. * Moves the axis on the controller mesh based on its current state
  44160. * @param axis the index of the axis
  44161. * @param axisValue the value of the axis which determines the meshes new position
  44162. * @hidden
  44163. */
  44164. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44165. /**
  44166. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44167. * @param scene scene in which to add meshes
  44168. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44169. */
  44170. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44171. /**
  44172. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44173. * can be transformed by button presses and axes values, based on this._mapping.
  44174. *
  44175. * @param scene scene in which the meshes exist
  44176. * @param meshes list of meshes that make up the controller model to process
  44177. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44178. */
  44179. private processModel;
  44180. private createMeshInfo;
  44181. /**
  44182. * Gets the ray of the controller in the direction the controller is pointing
  44183. * @param length the length the resulting ray should be
  44184. * @returns a ray in the direction the controller is pointing
  44185. */
  44186. getForwardRay(length?: number): Ray;
  44187. /**
  44188. * Disposes of the controller
  44189. */
  44190. dispose(): void;
  44191. }
  44192. }
  44193. declare module BABYLON {
  44194. /**
  44195. * Interface to implement to create a shadow generator compatible with BJS.
  44196. */
  44197. interface IShadowGenerator {
  44198. /**
  44199. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44200. * @returns The render target texture if present otherwise, null
  44201. */
  44202. getShadowMap(): Nullable<RenderTargetTexture>;
  44203. /**
  44204. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44205. * @returns The render target texture if the shadow map is present otherwise, null
  44206. */
  44207. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44208. /**
  44209. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44210. * @param subMesh The submesh we want to render in the shadow map
  44211. * @param useInstances Defines wether will draw in the map using instances
  44212. * @returns true if ready otherwise, false
  44213. */
  44214. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44215. /**
  44216. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44217. * @param defines Defines of the material we want to update
  44218. * @param lightIndex Index of the light in the enabled light list of the material
  44219. */
  44220. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  44221. /**
  44222. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44223. * defined in the generator but impacting the effect).
  44224. * It implies the unifroms available on the materials are the standard BJS ones.
  44225. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44226. * @param effect The effect we are binfing the information for
  44227. */
  44228. bindShadowLight(lightIndex: string, effect: Effect): void;
  44229. /**
  44230. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44231. * (eq to shadow prjection matrix * light transform matrix)
  44232. * @returns The transform matrix used to create the shadow map
  44233. */
  44234. getTransformMatrix(): Matrix;
  44235. /**
  44236. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44237. * Cube and 2D textures for instance.
  44238. */
  44239. recreateShadowMap(): void;
  44240. /**
  44241. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44242. * @param onCompiled Callback triggered at the and of the effects compilation
  44243. * @param options Sets of optional options forcing the compilation with different modes
  44244. */
  44245. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44246. useInstances: boolean;
  44247. }>): void;
  44248. /**
  44249. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44250. * @param options Sets of optional options forcing the compilation with different modes
  44251. * @returns A promise that resolves when the compilation completes
  44252. */
  44253. forceCompilationAsync(options?: Partial<{
  44254. useInstances: boolean;
  44255. }>): Promise<void>;
  44256. /**
  44257. * Serializes the shadow generator setup to a json object.
  44258. * @returns The serialized JSON object
  44259. */
  44260. serialize(): any;
  44261. /**
  44262. * Disposes the Shadow map and related Textures and effects.
  44263. */
  44264. dispose(): void;
  44265. }
  44266. /**
  44267. * Default implementation IShadowGenerator.
  44268. * This is the main object responsible of generating shadows in the framework.
  44269. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44270. */
  44271. class ShadowGenerator implements IShadowGenerator {
  44272. /**
  44273. * Shadow generator mode None: no filtering applied.
  44274. */
  44275. static readonly FILTER_NONE: number;
  44276. /**
  44277. * Shadow generator mode ESM: Exponential Shadow Mapping.
  44278. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44279. */
  44280. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  44281. /**
  44282. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  44283. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  44284. */
  44285. static readonly FILTER_POISSONSAMPLING: number;
  44286. /**
  44287. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  44288. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44289. */
  44290. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  44291. /**
  44292. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  44293. * edge artifacts on steep falloff.
  44294. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44295. */
  44296. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  44297. /**
  44298. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  44299. * edge artifacts on steep falloff.
  44300. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  44301. */
  44302. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  44303. /**
  44304. * Shadow generator mode PCF: Percentage Closer Filtering
  44305. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44306. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  44307. */
  44308. static readonly FILTER_PCF: number;
  44309. /**
  44310. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  44311. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  44312. * Contact Hardening
  44313. */
  44314. static readonly FILTER_PCSS: number;
  44315. /**
  44316. * Reserved for PCF and PCSS
  44317. * Highest Quality.
  44318. *
  44319. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  44320. *
  44321. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  44322. */
  44323. static readonly QUALITY_HIGH: number;
  44324. /**
  44325. * Reserved for PCF and PCSS
  44326. * Good tradeoff for quality/perf cross devices
  44327. *
  44328. * Execute PCF on a 3*3 kernel.
  44329. *
  44330. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  44331. */
  44332. static readonly QUALITY_MEDIUM: number;
  44333. /**
  44334. * Reserved for PCF and PCSS
  44335. * The lowest quality but the fastest.
  44336. *
  44337. * Execute PCF on a 1*1 kernel.
  44338. *
  44339. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  44340. */
  44341. static readonly QUALITY_LOW: number;
  44342. private _bias;
  44343. /**
  44344. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44345. */
  44346. /**
  44347. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44348. */
  44349. bias: number;
  44350. private _normalBias;
  44351. /**
  44352. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44353. */
  44354. /**
  44355. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44356. */
  44357. normalBias: number;
  44358. private _blurBoxOffset;
  44359. /**
  44360. * Gets the blur box offset: offset applied during the blur pass.
  44361. * Only usefull if useKernelBlur = false
  44362. */
  44363. /**
  44364. * Sets the blur box offset: offset applied during the blur pass.
  44365. * Only usefull if useKernelBlur = false
  44366. */
  44367. blurBoxOffset: number;
  44368. private _blurScale;
  44369. /**
  44370. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44371. * 2 means half of the size.
  44372. */
  44373. /**
  44374. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44375. * 2 means half of the size.
  44376. */
  44377. blurScale: number;
  44378. private _blurKernel;
  44379. /**
  44380. * Gets the blur kernel: kernel size of the blur pass.
  44381. * Only usefull if useKernelBlur = true
  44382. */
  44383. /**
  44384. * Sets the blur kernel: kernel size of the blur pass.
  44385. * Only usefull if useKernelBlur = true
  44386. */
  44387. blurKernel: number;
  44388. private _useKernelBlur;
  44389. /**
  44390. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44391. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44392. */
  44393. /**
  44394. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44395. * Only usefull in filtered mode (useBlurExponentialShadowMap...)
  44396. */
  44397. useKernelBlur: boolean;
  44398. private _depthScale;
  44399. /**
  44400. * Gets the depth scale used in ESM mode.
  44401. */
  44402. /**
  44403. * Sets the depth scale used in ESM mode.
  44404. * This can override the scale stored on the light.
  44405. */
  44406. depthScale: number;
  44407. private _filter;
  44408. /**
  44409. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44410. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44411. */
  44412. /**
  44413. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44414. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44415. */
  44416. filter: number;
  44417. /**
  44418. * Gets if the current filter is set to Poisson Sampling.
  44419. */
  44420. /**
  44421. * Sets the current filter to Poisson Sampling.
  44422. */
  44423. usePoissonSampling: boolean;
  44424. /**
  44425. * Gets if the current filter is set to ESM.
  44426. */
  44427. /**
  44428. * Sets the current filter is to ESM.
  44429. */
  44430. useExponentialShadowMap: boolean;
  44431. /**
  44432. * Gets if the current filter is set to filtered ESM.
  44433. */
  44434. /**
  44435. * Gets if the current filter is set to filtered ESM.
  44436. */
  44437. useBlurExponentialShadowMap: boolean;
  44438. /**
  44439. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44440. * exponential to prevent steep falloff artifacts).
  44441. */
  44442. /**
  44443. * Sets the current filter to "close ESM" (using the inverse of the
  44444. * exponential to prevent steep falloff artifacts).
  44445. */
  44446. useCloseExponentialShadowMap: boolean;
  44447. /**
  44448. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44449. * exponential to prevent steep falloff artifacts).
  44450. */
  44451. /**
  44452. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44453. * exponential to prevent steep falloff artifacts).
  44454. */
  44455. useBlurCloseExponentialShadowMap: boolean;
  44456. /**
  44457. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44458. */
  44459. /**
  44460. * Sets the current filter to "PCF" (percentage closer filtering).
  44461. */
  44462. usePercentageCloserFiltering: boolean;
  44463. private _filteringQuality;
  44464. /**
  44465. * Gets the PCF or PCSS Quality.
  44466. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44467. */
  44468. /**
  44469. * Sets the PCF or PCSS Quality.
  44470. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44471. */
  44472. filteringQuality: number;
  44473. /**
  44474. * Gets if the current filter is set to "PCSS" (contact hardening).
  44475. */
  44476. /**
  44477. * Sets the current filter to "PCSS" (contact hardening).
  44478. */
  44479. useContactHardeningShadow: boolean;
  44480. private _contactHardeningLightSizeUVRatio;
  44481. /**
  44482. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44483. * Using a ratio helps keeping shape stability independently of the map size.
  44484. *
  44485. * It does not account for the light projection as it was having too much
  44486. * instability during the light setup or during light position changes.
  44487. *
  44488. * Only valid if useContactHardeningShadow is true.
  44489. */
  44490. /**
  44491. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44492. * Using a ratio helps keeping shape stability independently of the map size.
  44493. *
  44494. * It does not account for the light projection as it was having too much
  44495. * instability during the light setup or during light position changes.
  44496. *
  44497. * Only valid if useContactHardeningShadow is true.
  44498. */
  44499. contactHardeningLightSizeUVRatio: number;
  44500. private _darkness;
  44501. /**
  44502. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44503. * 0 means strongest and 1 would means no shadow.
  44504. * @returns the darkness.
  44505. */
  44506. getDarkness(): number;
  44507. /**
  44508. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44509. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44510. * @returns the shadow generator allowing fluent coding.
  44511. */
  44512. setDarkness(darkness: number): ShadowGenerator;
  44513. private _transparencyShadow;
  44514. /**
  44515. * Sets the ability to have transparent shadow (boolean).
  44516. * @param transparent True if transparent else False
  44517. * @returns the shadow generator allowing fluent coding
  44518. */
  44519. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  44520. private _shadowMap;
  44521. private _shadowMap2;
  44522. /**
  44523. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44524. * @returns The render target texture if present otherwise, null
  44525. */
  44526. getShadowMap(): Nullable<RenderTargetTexture>;
  44527. /**
  44528. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44529. * @returns The render target texture if the shadow map is present otherwise, null
  44530. */
  44531. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  44532. /**
  44533. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44534. * @param mesh Mesh to add
  44535. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44536. * @returns the Shadow Generator itself
  44537. */
  44538. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44539. /**
  44540. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44541. * @param mesh Mesh to remove
  44542. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44543. * @returns the Shadow Generator itself
  44544. */
  44545. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  44546. /**
  44547. * Controls the extent to which the shadows fade out at the edge of the frustum
  44548. * Used only by directionals and spots
  44549. */
  44550. frustumEdgeFalloff: number;
  44551. private _light;
  44552. /**
  44553. * Returns the associated light object.
  44554. * @returns the light generating the shadow
  44555. */
  44556. getLight(): IShadowLight;
  44557. /**
  44558. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44559. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44560. * It might on the other hand introduce peter panning.
  44561. */
  44562. forceBackFacesOnly: boolean;
  44563. private _scene;
  44564. private _lightDirection;
  44565. private _effect;
  44566. private _viewMatrix;
  44567. private _projectionMatrix;
  44568. private _transformMatrix;
  44569. private _cachedPosition;
  44570. private _cachedDirection;
  44571. private _cachedDefines;
  44572. private _currentRenderID;
  44573. private _boxBlurPostprocess;
  44574. private _kernelBlurXPostprocess;
  44575. private _kernelBlurYPostprocess;
  44576. private _blurPostProcesses;
  44577. private _mapSize;
  44578. private _currentFaceIndex;
  44579. private _currentFaceIndexCache;
  44580. private _textureType;
  44581. private _defaultTextureMatrix;
  44582. /**
  44583. * Creates a ShadowGenerator object.
  44584. * A ShadowGenerator is the required tool to use the shadows.
  44585. * Each light casting shadows needs to use its own ShadowGenerator.
  44586. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  44587. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44588. * @param light The light object generating the shadows.
  44589. * @param useFullFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  44590. */
  44591. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  44592. private _initializeGenerator;
  44593. private _initializeShadowMap;
  44594. private _initializeBlurRTTAndPostProcesses;
  44595. private _renderForShadowMap;
  44596. private _renderSubMeshForShadowMap;
  44597. private _applyFilterValues;
  44598. /**
  44599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44600. * @param onCompiled Callback triggered at the and of the effects compilation
  44601. * @param options Sets of optional options forcing the compilation with different modes
  44602. */
  44603. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  44604. useInstances: boolean;
  44605. }>): void;
  44606. /**
  44607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  44608. * @param options Sets of optional options forcing the compilation with different modes
  44609. * @returns A promise that resolves when the compilation completes
  44610. */
  44611. forceCompilationAsync(options?: Partial<{
  44612. useInstances: boolean;
  44613. }>): Promise<void>;
  44614. /**
  44615. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  44616. * @param subMesh The submesh we want to render in the shadow map
  44617. * @param useInstances Defines wether will draw in the map using instances
  44618. * @returns true if ready otherwise, false
  44619. */
  44620. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  44621. /**
  44622. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  44623. * @param defines Defines of the material we want to update
  44624. * @param lightIndex Index of the light in the enabled light list of the material
  44625. */
  44626. prepareDefines(defines: any, lightIndex: number): void;
  44627. /**
  44628. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  44629. * defined in the generator but impacting the effect).
  44630. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  44631. * @param effect The effect we are binfing the information for
  44632. */
  44633. bindShadowLight(lightIndex: string, effect: Effect): void;
  44634. /**
  44635. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  44636. * (eq to shadow prjection matrix * light transform matrix)
  44637. * @returns The transform matrix used to create the shadow map
  44638. */
  44639. getTransformMatrix(): Matrix;
  44640. /**
  44641. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  44642. * Cube and 2D textures for instance.
  44643. */
  44644. recreateShadowMap(): void;
  44645. private _disposeBlurPostProcesses;
  44646. private _disposeRTTandPostProcesses;
  44647. /**
  44648. * Disposes the ShadowGenerator.
  44649. * Returns nothing.
  44650. */
  44651. dispose(): void;
  44652. /**
  44653. * Serializes the shadow generator setup to a json object.
  44654. * @returns The serialized JSON object
  44655. */
  44656. serialize(): any;
  44657. /**
  44658. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  44659. * @param parsedShadowGenerator The JSON object to parse
  44660. * @param scene The scene to create the shadow map for
  44661. * @returns The parsed shadow generator
  44662. */
  44663. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  44664. }
  44665. }
  44666. declare module BABYLON {
  44667. /**
  44668. * Defines the shadow generator component responsible to manage any shadow generators
  44669. * in a given scene.
  44670. */
  44671. class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  44672. /**
  44673. * The component name helpfull to identify the component in the list of scene components.
  44674. */
  44675. readonly name: string;
  44676. /**
  44677. * The scene the component belongs to.
  44678. */
  44679. scene: Scene;
  44680. /**
  44681. * Creates a new instance of the component for the given scene
  44682. * @param scene Defines the scene to register the component in
  44683. */
  44684. constructor(scene: Scene);
  44685. /**
  44686. * Registers the component in a given scene
  44687. */
  44688. register(): void;
  44689. /**
  44690. * Rebuilds the elements related to this component in case of
  44691. * context lost for instance.
  44692. */
  44693. rebuild(): void;
  44694. /**
  44695. * Serializes the component data to the specified json object
  44696. * @param serializationObject The object to serialize to
  44697. */
  44698. serialize(serializationObject: any): void;
  44699. /**
  44700. * Adds all the element from the container to the scene
  44701. * @param container the container holding the elements
  44702. */
  44703. addFromContainer(container: AbstractScene): void;
  44704. /**
  44705. * Removes all the elements in the container from the scene
  44706. * @param container contains the elements to remove
  44707. */
  44708. removeFromContainer(container: AbstractScene): void;
  44709. /**
  44710. * Rebuilds the elements related to this component in case of
  44711. * context lost for instance.
  44712. */
  44713. dispose(): void;
  44714. private _gatherRenderTargets;
  44715. }
  44716. }
  44717. declare module BABYLON {
  44718. }
  44719. declare module BABYLON {
  44720. /**
  44721. * Background material used to create an efficient environement around your scene.
  44722. */
  44723. class BackgroundMaterial extends PushMaterial {
  44724. /**
  44725. * Standard reflectance value at parallel view angle.
  44726. */
  44727. static StandardReflectance0: number;
  44728. /**
  44729. * Standard reflectance value at grazing angle.
  44730. */
  44731. static StandardReflectance90: number;
  44732. protected _primaryColor: Color3;
  44733. /**
  44734. * Key light Color (multiply against the environement texture)
  44735. */
  44736. primaryColor: Color3;
  44737. protected __perceptualColor: Nullable<Color3>;
  44738. /**
  44739. * Experimental Internal Use Only.
  44740. *
  44741. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44742. * This acts as a helper to set the primary color to a more "human friendly" value.
  44743. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44744. * output color as close as possible from the chosen value.
  44745. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44746. * part of lighting setup.)
  44747. */
  44748. _perceptualColor: Nullable<Color3>;
  44749. protected _primaryColorShadowLevel: float;
  44750. /**
  44751. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44752. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44753. */
  44754. primaryColorShadowLevel: float;
  44755. protected _primaryColorHighlightLevel: float;
  44756. /**
  44757. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44758. * The primary color is used at the level chosen to define what the white area would look.
  44759. */
  44760. primaryColorHighlightLevel: float;
  44761. protected _reflectionTexture: Nullable<BaseTexture>;
  44762. /**
  44763. * Reflection Texture used in the material.
  44764. * Should be author in a specific way for the best result (refer to the documentation).
  44765. */
  44766. reflectionTexture: Nullable<BaseTexture>;
  44767. protected _reflectionBlur: float;
  44768. /**
  44769. * Reflection Texture level of blur.
  44770. *
  44771. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44772. * texture twice.
  44773. */
  44774. reflectionBlur: float;
  44775. protected _diffuseTexture: Nullable<BaseTexture>;
  44776. /**
  44777. * Diffuse Texture used in the material.
  44778. * Should be author in a specific way for the best result (refer to the documentation).
  44779. */
  44780. diffuseTexture: Nullable<BaseTexture>;
  44781. protected _shadowLights: Nullable<IShadowLight[]>;
  44782. /**
  44783. * Specify the list of lights casting shadow on the material.
  44784. * All scene shadow lights will be included if null.
  44785. */
  44786. shadowLights: Nullable<IShadowLight[]>;
  44787. protected _shadowLevel: float;
  44788. /**
  44789. * Helps adjusting the shadow to a softer level if required.
  44790. * 0 means black shadows and 1 means no shadows.
  44791. */
  44792. shadowLevel: float;
  44793. protected _sceneCenter: Vector3;
  44794. /**
  44795. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44796. * It is usually zero but might be interesting to modify according to your setup.
  44797. */
  44798. sceneCenter: Vector3;
  44799. protected _opacityFresnel: boolean;
  44800. /**
  44801. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44802. * This helps ensuring a nice transition when the camera goes under the ground.
  44803. */
  44804. opacityFresnel: boolean;
  44805. protected _reflectionFresnel: boolean;
  44806. /**
  44807. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44808. * This helps adding a mirror texture on the ground.
  44809. */
  44810. reflectionFresnel: boolean;
  44811. protected _reflectionFalloffDistance: number;
  44812. /**
  44813. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44814. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44815. */
  44816. reflectionFalloffDistance: number;
  44817. protected _reflectionAmount: number;
  44818. /**
  44819. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44820. */
  44821. reflectionAmount: number;
  44822. protected _reflectionReflectance0: number;
  44823. /**
  44824. * This specifies the weight of the reflection at grazing angle.
  44825. */
  44826. reflectionReflectance0: number;
  44827. protected _reflectionReflectance90: number;
  44828. /**
  44829. * This specifies the weight of the reflection at a perpendicular point of view.
  44830. */
  44831. reflectionReflectance90: number;
  44832. /**
  44833. * Sets the reflection reflectance fresnel values according to the default standard
  44834. * empirically know to work well :-)
  44835. */
  44836. reflectionStandardFresnelWeight: number;
  44837. protected _useRGBColor: boolean;
  44838. /**
  44839. * Helps to directly use the maps channels instead of their level.
  44840. */
  44841. useRGBColor: boolean;
  44842. protected _enableNoise: boolean;
  44843. /**
  44844. * This helps reducing the banding effect that could occur on the background.
  44845. */
  44846. enableNoise: boolean;
  44847. /**
  44848. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44849. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44850. * Recommended to be keep at 1.0 except for special cases.
  44851. */
  44852. fovMultiplier: number;
  44853. private _fovMultiplier;
  44854. /**
  44855. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44856. */
  44857. useEquirectangularFOV: boolean;
  44858. private _maxSimultaneousLights;
  44859. /**
  44860. * Number of Simultaneous lights allowed on the material.
  44861. */
  44862. maxSimultaneousLights: int;
  44863. /**
  44864. * Default configuration related to image processing available in the Background Material.
  44865. */
  44866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44867. /**
  44868. * Keep track of the image processing observer to allow dispose and replace.
  44869. */
  44870. private _imageProcessingObserver;
  44871. /**
  44872. * Attaches a new image processing configuration to the PBR Material.
  44873. * @param configuration (if null the scene configuration will be use)
  44874. */
  44875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44876. /**
  44877. * Gets the image processing configuration used either in this material.
  44878. */
  44879. /**
  44880. * Sets the Default image processing configuration used either in the this material.
  44881. *
  44882. * If sets to null, the scene one is in use.
  44883. */
  44884. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44885. /**
  44886. * Gets wether the color curves effect is enabled.
  44887. */
  44888. /**
  44889. * Sets wether the color curves effect is enabled.
  44890. */
  44891. cameraColorCurvesEnabled: boolean;
  44892. /**
  44893. * Gets wether the color grading effect is enabled.
  44894. */
  44895. /**
  44896. * Gets wether the color grading effect is enabled.
  44897. */
  44898. cameraColorGradingEnabled: boolean;
  44899. /**
  44900. * Gets wether tonemapping is enabled or not.
  44901. */
  44902. /**
  44903. * Sets wether tonemapping is enabled or not
  44904. */
  44905. cameraToneMappingEnabled: boolean;
  44906. /**
  44907. * The camera exposure used on this material.
  44908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44909. * This corresponds to a photographic exposure.
  44910. */
  44911. /**
  44912. * The camera exposure used on this material.
  44913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44914. * This corresponds to a photographic exposure.
  44915. */
  44916. cameraExposure: float;
  44917. /**
  44918. * Gets The camera contrast used on this material.
  44919. */
  44920. /**
  44921. * Sets The camera contrast used on this material.
  44922. */
  44923. cameraContrast: float;
  44924. /**
  44925. * Gets the Color Grading 2D Lookup Texture.
  44926. */
  44927. /**
  44928. * Sets the Color Grading 2D Lookup Texture.
  44929. */
  44930. cameraColorGradingTexture: Nullable<BaseTexture>;
  44931. /**
  44932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44934. * 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;
  44935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44936. */
  44937. /**
  44938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44940. * 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;
  44941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44942. */
  44943. cameraColorCurves: Nullable<ColorCurves>;
  44944. /**
  44945. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44946. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44947. */
  44948. switchToBGR: boolean;
  44949. private _renderTargets;
  44950. private _reflectionControls;
  44951. private _white;
  44952. private _primaryShadowColor;
  44953. private _primaryHighlightColor;
  44954. /**
  44955. * Instantiates a Background Material in the given scene
  44956. * @param name The friendly name of the material
  44957. * @param scene The scene to add the material to
  44958. */
  44959. constructor(name: string, scene: Scene);
  44960. /**
  44961. * Gets a boolean indicating that current material needs to register RTT
  44962. */
  44963. readonly hasRenderTargetTextures: boolean;
  44964. /**
  44965. * The entire material has been created in order to prevent overdraw.
  44966. * @returns false
  44967. */
  44968. needAlphaTesting(): boolean;
  44969. /**
  44970. * The entire material has been created in order to prevent overdraw.
  44971. * @returns true if blending is enable
  44972. */
  44973. needAlphaBlending(): boolean;
  44974. /**
  44975. * Checks wether the material is ready to be rendered for a given mesh.
  44976. * @param mesh The mesh to render
  44977. * @param subMesh The submesh to check against
  44978. * @param useInstances Specify wether or not the material is used with instances
  44979. * @returns true if all the dependencies are ready (Textures, Effects...)
  44980. */
  44981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44982. /**
  44983. * Compute the primary color according to the chosen perceptual color.
  44984. */
  44985. private _computePrimaryColorFromPerceptualColor;
  44986. /**
  44987. * Compute the highlights and shadow colors according to their chosen levels.
  44988. */
  44989. private _computePrimaryColors;
  44990. /**
  44991. * Build the uniform buffer used in the material.
  44992. */
  44993. buildUniformLayout(): void;
  44994. /**
  44995. * Unbind the material.
  44996. */
  44997. unbind(): void;
  44998. /**
  44999. * Bind only the world matrix to the material.
  45000. * @param world The world matrix to bind.
  45001. */
  45002. bindOnlyWorldMatrix(world: Matrix): void;
  45003. /**
  45004. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45005. * @param world The world matrix to bind.
  45006. * @param subMesh The submesh to bind for.
  45007. */
  45008. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45009. /**
  45010. * Dispose the material.
  45011. * @param forceDisposeEffect Force disposal of the associated effect.
  45012. * @param forceDisposeTextures Force disposal of the associated textures.
  45013. */
  45014. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45015. /**
  45016. * Clones the material.
  45017. * @param name The cloned name.
  45018. * @returns The cloned material.
  45019. */
  45020. clone(name: string): BackgroundMaterial;
  45021. /**
  45022. * Serializes the current material to its JSON representation.
  45023. * @returns The JSON representation.
  45024. */
  45025. serialize(): any;
  45026. /**
  45027. * Gets the class name of the material
  45028. * @returns "BackgroundMaterial"
  45029. */
  45030. getClassName(): string;
  45031. /**
  45032. * Parse a JSON input to create back a background material.
  45033. * @param source The JSON data to parse
  45034. * @param scene The scene to create the parsed material in
  45035. * @param rootUrl The root url of the assets the material depends upon
  45036. * @returns the instantiated BackgroundMaterial.
  45037. */
  45038. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45039. }
  45040. }
  45041. declare module BABYLON {
  45042. /**
  45043. * The Physically based material base class of BJS.
  45044. *
  45045. * This offers the main features of a standard PBR material.
  45046. * For more information, please refer to the documentation :
  45047. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45048. */
  45049. abstract class PBRBaseMaterial extends PushMaterial {
  45050. /**
  45051. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45052. */
  45053. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45054. /**
  45055. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45056. * to enhance interoperability with other engines.
  45057. */
  45058. static readonly LIGHTFALLOFF_GLTF: number;
  45059. /**
  45060. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45061. * to enhance interoperability with other materials.
  45062. */
  45063. static readonly LIGHTFALLOFF_STANDARD: number;
  45064. /**
  45065. * Intensity of the direct lights e.g. the four lights available in your scene.
  45066. * This impacts both the direct diffuse and specular highlights.
  45067. */
  45068. protected _directIntensity: number;
  45069. /**
  45070. * Intensity of the emissive part of the material.
  45071. * This helps controlling the emissive effect without modifying the emissive color.
  45072. */
  45073. protected _emissiveIntensity: number;
  45074. /**
  45075. * Intensity of the environment e.g. how much the environment will light the object
  45076. * either through harmonics for rough material or through the refelction for shiny ones.
  45077. */
  45078. protected _environmentIntensity: number;
  45079. /**
  45080. * This is a special control allowing the reduction of the specular highlights coming from the
  45081. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45082. */
  45083. protected _specularIntensity: number;
  45084. /**
  45085. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45086. */
  45087. private _lightingInfos;
  45088. /**
  45089. * Debug Control allowing disabling the bump map on this material.
  45090. */
  45091. protected _disableBumpMap: boolean;
  45092. /**
  45093. * AKA Diffuse Texture in standard nomenclature.
  45094. */
  45095. protected _albedoTexture: BaseTexture;
  45096. /**
  45097. * AKA Occlusion Texture in other nomenclature.
  45098. */
  45099. protected _ambientTexture: BaseTexture;
  45100. /**
  45101. * AKA Occlusion Texture Intensity in other nomenclature.
  45102. */
  45103. protected _ambientTextureStrength: number;
  45104. /**
  45105. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45106. * 1 means it completely occludes it
  45107. * 0 mean it has no impact
  45108. */
  45109. protected _ambientTextureImpactOnAnalyticalLights: number;
  45110. /**
  45111. * Stores the alpha values in a texture.
  45112. */
  45113. protected _opacityTexture: BaseTexture;
  45114. /**
  45115. * Stores the reflection values in a texture.
  45116. */
  45117. protected _reflectionTexture: BaseTexture;
  45118. /**
  45119. * Stores the refraction values in a texture.
  45120. */
  45121. protected _refractionTexture: BaseTexture;
  45122. /**
  45123. * Stores the emissive values in a texture.
  45124. */
  45125. protected _emissiveTexture: BaseTexture;
  45126. /**
  45127. * AKA Specular texture in other nomenclature.
  45128. */
  45129. protected _reflectivityTexture: BaseTexture;
  45130. /**
  45131. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45132. */
  45133. protected _metallicTexture: BaseTexture;
  45134. /**
  45135. * Specifies the metallic scalar of the metallic/roughness workflow.
  45136. * Can also be used to scale the metalness values of the metallic texture.
  45137. */
  45138. protected _metallic: Nullable<number>;
  45139. /**
  45140. * Specifies the roughness scalar of the metallic/roughness workflow.
  45141. * Can also be used to scale the roughness values of the metallic texture.
  45142. */
  45143. protected _roughness: Nullable<number>;
  45144. /**
  45145. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45146. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45147. */
  45148. protected _microSurfaceTexture: BaseTexture;
  45149. /**
  45150. * Stores surface normal data used to displace a mesh in a texture.
  45151. */
  45152. protected _bumpTexture: BaseTexture;
  45153. /**
  45154. * Stores the pre-calculated light information of a mesh in a texture.
  45155. */
  45156. protected _lightmapTexture: BaseTexture;
  45157. /**
  45158. * The color of a material in ambient lighting.
  45159. */
  45160. protected _ambientColor: Color3;
  45161. /**
  45162. * AKA Diffuse Color in other nomenclature.
  45163. */
  45164. protected _albedoColor: Color3;
  45165. /**
  45166. * AKA Specular Color in other nomenclature.
  45167. */
  45168. protected _reflectivityColor: Color3;
  45169. /**
  45170. * The color applied when light is reflected from a material.
  45171. */
  45172. protected _reflectionColor: Color3;
  45173. /**
  45174. * The color applied when light is emitted from a material.
  45175. */
  45176. protected _emissiveColor: Color3;
  45177. /**
  45178. * AKA Glossiness in other nomenclature.
  45179. */
  45180. protected _microSurface: number;
  45181. /**
  45182. * source material index of refraction (IOR)' / 'destination material IOR.
  45183. */
  45184. protected _indexOfRefraction: number;
  45185. /**
  45186. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45187. */
  45188. protected _invertRefractionY: boolean;
  45189. /**
  45190. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45191. * Materials half opaque for instance using refraction could benefit from this control.
  45192. */
  45193. protected _linkRefractionWithTransparency: boolean;
  45194. /**
  45195. * Specifies that the material will use the light map as a show map.
  45196. */
  45197. protected _useLightmapAsShadowmap: boolean;
  45198. /**
  45199. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45200. * makes the reflect vector face the model (under horizon).
  45201. */
  45202. protected _useHorizonOcclusion: boolean;
  45203. /**
  45204. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45205. * too much the area relying on ambient texture to define their ambient occlusion.
  45206. */
  45207. protected _useRadianceOcclusion: boolean;
  45208. /**
  45209. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45210. */
  45211. protected _useAlphaFromAlbedoTexture: boolean;
  45212. /**
  45213. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45214. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45215. */
  45216. protected _useSpecularOverAlpha: boolean;
  45217. /**
  45218. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45219. */
  45220. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45221. /**
  45222. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45223. */
  45224. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45225. /**
  45226. * Specifies if the metallic texture contains the roughness information in its green channel.
  45227. */
  45228. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45229. /**
  45230. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45231. */
  45232. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45233. /**
  45234. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45235. */
  45236. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45237. /**
  45238. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45239. */
  45240. protected _useAmbientInGrayScale: boolean;
  45241. /**
  45242. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45243. * The material will try to infer what glossiness each pixel should be.
  45244. */
  45245. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45246. /**
  45247. * Defines the falloff type used in this material.
  45248. * It by default is Physical.
  45249. */
  45250. protected _lightFalloff: number;
  45251. /**
  45252. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45253. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45254. */
  45255. protected _useRadianceOverAlpha: boolean;
  45256. /**
  45257. * Allows using an object space normal map (instead of tangent space).
  45258. */
  45259. protected _useObjectSpaceNormalMap: boolean;
  45260. /**
  45261. * Allows using the bump map in parallax mode.
  45262. */
  45263. protected _useParallax: boolean;
  45264. /**
  45265. * Allows using the bump map in parallax occlusion mode.
  45266. */
  45267. protected _useParallaxOcclusion: boolean;
  45268. /**
  45269. * Controls the scale bias of the parallax mode.
  45270. */
  45271. protected _parallaxScaleBias: number;
  45272. /**
  45273. * If sets to true, disables all the lights affecting the material.
  45274. */
  45275. protected _disableLighting: boolean;
  45276. /**
  45277. * Number of Simultaneous lights allowed on the material.
  45278. */
  45279. protected _maxSimultaneousLights: number;
  45280. /**
  45281. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45282. */
  45283. protected _invertNormalMapX: boolean;
  45284. /**
  45285. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45286. */
  45287. protected _invertNormalMapY: boolean;
  45288. /**
  45289. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45290. */
  45291. protected _twoSidedLighting: boolean;
  45292. /**
  45293. * Defines the alpha limits in alpha test mode.
  45294. */
  45295. protected _alphaCutOff: number;
  45296. /**
  45297. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45298. */
  45299. protected _forceAlphaTest: boolean;
  45300. /**
  45301. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45302. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45303. */
  45304. protected _useAlphaFresnel: boolean;
  45305. /**
  45306. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45307. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45308. */
  45309. protected _useLinearAlphaFresnel: boolean;
  45310. /**
  45311. * The transparency mode of the material.
  45312. */
  45313. protected _transparencyMode: Nullable<number>;
  45314. /**
  45315. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45316. * from cos thetav and roughness:
  45317. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45318. */
  45319. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45320. /**
  45321. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45322. */
  45323. protected _forceIrradianceInFragment: boolean;
  45324. /**
  45325. * Force normal to face away from face.
  45326. */
  45327. protected _forceNormalForward: boolean;
  45328. /**
  45329. * Enables specular anti aliasing in the PBR shader.
  45330. * It will both interacts on the Geometry for analytical and IBL lighting.
  45331. * It also prefilter the roughness map based on the bump values.
  45332. */
  45333. protected _enableSpecularAntiAliasing: boolean;
  45334. /**
  45335. * Default configuration related to image processing available in the PBR Material.
  45336. */
  45337. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45338. /**
  45339. * Keep track of the image processing observer to allow dispose and replace.
  45340. */
  45341. private _imageProcessingObserver;
  45342. /**
  45343. * Attaches a new image processing configuration to the PBR Material.
  45344. * @param configuration
  45345. */
  45346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45347. /**
  45348. * Stores the available render targets.
  45349. */
  45350. private _renderTargets;
  45351. /**
  45352. * Sets the global ambient color for the material used in lighting calculations.
  45353. */
  45354. private _globalAmbientColor;
  45355. /**
  45356. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  45357. */
  45358. private _useLogarithmicDepth;
  45359. /**
  45360. * If set to true, no lighting calculations will be applied.
  45361. */
  45362. private _unlit;
  45363. /**
  45364. * Instantiates a new PBRMaterial instance.
  45365. *
  45366. * @param name The material name
  45367. * @param scene The scene the material will be use in.
  45368. */
  45369. constructor(name: string, scene: Scene);
  45370. /**
  45371. * Gets a boolean indicating that current material needs to register RTT
  45372. */
  45373. readonly hasRenderTargetTextures: boolean;
  45374. /**
  45375. * Gets the name of the material class.
  45376. */
  45377. getClassName(): string;
  45378. /**
  45379. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45380. */
  45381. /**
  45382. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  45383. */
  45384. useLogarithmicDepth: boolean;
  45385. /**
  45386. * Gets the current transparency mode.
  45387. */
  45388. /**
  45389. * Sets the transparency mode of the material.
  45390. *
  45391. * | Value | Type | Description |
  45392. * | ----- | ----------------------------------- | ----------- |
  45393. * | 0 | OPAQUE | |
  45394. * | 1 | ALPHATEST | |
  45395. * | 2 | ALPHABLEND | |
  45396. * | 3 | ALPHATESTANDBLEND | |
  45397. *
  45398. */
  45399. transparencyMode: Nullable<number>;
  45400. /**
  45401. * Returns true if alpha blending should be disabled.
  45402. */
  45403. private readonly _disableAlphaBlending;
  45404. /**
  45405. * Specifies whether or not this material should be rendered in alpha blend mode.
  45406. */
  45407. needAlphaBlending(): boolean;
  45408. /**
  45409. * Specifies if the mesh will require alpha blending.
  45410. * @param mesh - BJS mesh.
  45411. */
  45412. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  45413. /**
  45414. * Specifies whether or not this material should be rendered in alpha test mode.
  45415. */
  45416. needAlphaTesting(): boolean;
  45417. /**
  45418. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  45419. */
  45420. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  45421. /**
  45422. * Gets the texture used for the alpha test.
  45423. */
  45424. getAlphaTestTexture(): BaseTexture;
  45425. /**
  45426. * Stores the reflectivity values based on metallic roughness workflow.
  45427. */
  45428. private static _scaledReflectivity;
  45429. /**
  45430. * Specifies that the submesh is ready to be used.
  45431. * @param mesh - BJS mesh.
  45432. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  45433. * @param useInstances - Specifies that instances should be used.
  45434. * @returns - boolean indicating that the submesh is ready or not.
  45435. */
  45436. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45437. /**
  45438. * Specifies if the material uses metallic roughness workflow.
  45439. * @returns boolean specifiying if the material uses metallic roughness workflow.
  45440. */
  45441. isMetallicWorkflow(): boolean;
  45442. private _prepareEffect;
  45443. private _prepareDefines;
  45444. /**
  45445. * Force shader compilation
  45446. */
  45447. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  45448. clipPlane: boolean;
  45449. }>): void;
  45450. /**
  45451. * Initializes the uniform buffer layout for the shader.
  45452. */
  45453. buildUniformLayout(): void;
  45454. /**
  45455. * Unbinds the textures.
  45456. */
  45457. unbind(): void;
  45458. /**
  45459. * Binds the submesh data.
  45460. * @param world - The world matrix.
  45461. * @param mesh - The BJS mesh.
  45462. * @param subMesh - A submesh of the BJS mesh.
  45463. */
  45464. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45465. /**
  45466. * Returns the animatable textures.
  45467. * @returns - Array of animatable textures.
  45468. */
  45469. getAnimatables(): IAnimatable[];
  45470. /**
  45471. * Returns the texture used for reflections.
  45472. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  45473. */
  45474. private _getReflectionTexture;
  45475. /**
  45476. * Returns the texture used for refraction or null if none is used.
  45477. * @returns - Refection texture if present. If no refraction texture and refraction
  45478. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45479. */
  45480. private _getRefractionTexture;
  45481. /**
  45482. * Disposes the resources of the material.
  45483. * @param forceDisposeEffect - Forces the disposal of effects.
  45484. * @param forceDisposeTextures - Forces the disposal of all textures.
  45485. */
  45486. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45487. }
  45488. }
  45489. declare module BABYLON {
  45490. /**
  45491. * The Physically based simple base material of BJS.
  45492. *
  45493. * This enables better naming and convention enforcements on top of the pbrMaterial.
  45494. * It is used as the base class for both the specGloss and metalRough conventions.
  45495. */
  45496. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  45497. /**
  45498. * Number of Simultaneous lights allowed on the material.
  45499. */
  45500. maxSimultaneousLights: number;
  45501. /**
  45502. * If sets to true, disables all the lights affecting the material.
  45503. */
  45504. disableLighting: boolean;
  45505. /**
  45506. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  45507. */
  45508. environmentTexture: BaseTexture;
  45509. /**
  45510. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45511. */
  45512. invertNormalMapX: boolean;
  45513. /**
  45514. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45515. */
  45516. invertNormalMapY: boolean;
  45517. /**
  45518. * Normal map used in the model.
  45519. */
  45520. normalTexture: BaseTexture;
  45521. /**
  45522. * Emissivie color used to self-illuminate the model.
  45523. */
  45524. emissiveColor: Color3;
  45525. /**
  45526. * Emissivie texture used to self-illuminate the model.
  45527. */
  45528. emissiveTexture: BaseTexture;
  45529. /**
  45530. * Occlusion Channel Strenght.
  45531. */
  45532. occlusionStrength: number;
  45533. /**
  45534. * Occlusion Texture of the material (adding extra occlusion effects).
  45535. */
  45536. occlusionTexture: BaseTexture;
  45537. /**
  45538. * Defines the alpha limits in alpha test mode.
  45539. */
  45540. alphaCutOff: number;
  45541. /**
  45542. * Gets the current double sided mode.
  45543. */
  45544. /**
  45545. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45546. */
  45547. doubleSided: boolean;
  45548. /**
  45549. * Stores the pre-calculated light information of a mesh in a texture.
  45550. */
  45551. lightmapTexture: BaseTexture;
  45552. /**
  45553. * If true, the light map contains occlusion information instead of lighting info.
  45554. */
  45555. useLightmapAsShadowmap: boolean;
  45556. /**
  45557. * Return the active textures of the material.
  45558. */
  45559. getActiveTextures(): BaseTexture[];
  45560. hasTexture(texture: BaseTexture): boolean;
  45561. /**
  45562. * Instantiates a new PBRMaterial instance.
  45563. *
  45564. * @param name The material name
  45565. * @param scene The scene the material will be use in.
  45566. */
  45567. constructor(name: string, scene: Scene);
  45568. getClassName(): string;
  45569. }
  45570. }
  45571. declare module BABYLON {
  45572. /**
  45573. * The Physically based material of BJS.
  45574. *
  45575. * This offers the main features of a standard PBR material.
  45576. * For more information, please refer to the documentation :
  45577. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  45578. */
  45579. class PBRMaterial extends PBRBaseMaterial {
  45580. /**
  45581. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45582. */
  45583. static readonly PBRMATERIAL_OPAQUE: number;
  45584. /**
  45585. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45586. */
  45587. static readonly PBRMATERIAL_ALPHATEST: number;
  45588. /**
  45589. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45590. */
  45591. static readonly PBRMATERIAL_ALPHABLEND: number;
  45592. /**
  45593. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45594. * They are also discarded below the alpha cutoff threshold to improve performances.
  45595. */
  45596. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45597. /**
  45598. * Defines the default value of how much AO map is occluding the analytical lights
  45599. * (point spot...).
  45600. */
  45601. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45602. /**
  45603. * Intensity of the direct lights e.g. the four lights available in your scene.
  45604. * This impacts both the direct diffuse and specular highlights.
  45605. */
  45606. directIntensity: number;
  45607. /**
  45608. * Intensity of the emissive part of the material.
  45609. * This helps controlling the emissive effect without modifying the emissive color.
  45610. */
  45611. emissiveIntensity: number;
  45612. /**
  45613. * Intensity of the environment e.g. how much the environment will light the object
  45614. * either through harmonics for rough material or through the refelction for shiny ones.
  45615. */
  45616. environmentIntensity: number;
  45617. /**
  45618. * This is a special control allowing the reduction of the specular highlights coming from the
  45619. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45620. */
  45621. specularIntensity: number;
  45622. /**
  45623. * Debug Control allowing disabling the bump map on this material.
  45624. */
  45625. disableBumpMap: boolean;
  45626. /**
  45627. * AKA Diffuse Texture in standard nomenclature.
  45628. */
  45629. albedoTexture: BaseTexture;
  45630. /**
  45631. * AKA Occlusion Texture in other nomenclature.
  45632. */
  45633. ambientTexture: BaseTexture;
  45634. /**
  45635. * AKA Occlusion Texture Intensity in other nomenclature.
  45636. */
  45637. ambientTextureStrength: number;
  45638. /**
  45639. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45640. * 1 means it completely occludes it
  45641. * 0 mean it has no impact
  45642. */
  45643. ambientTextureImpactOnAnalyticalLights: number;
  45644. /**
  45645. * Stores the alpha values in a texture.
  45646. */
  45647. opacityTexture: BaseTexture;
  45648. /**
  45649. * Stores the reflection values in a texture.
  45650. */
  45651. reflectionTexture: Nullable<BaseTexture>;
  45652. /**
  45653. * Stores the emissive values in a texture.
  45654. */
  45655. emissiveTexture: BaseTexture;
  45656. /**
  45657. * AKA Specular texture in other nomenclature.
  45658. */
  45659. reflectivityTexture: BaseTexture;
  45660. /**
  45661. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45662. */
  45663. metallicTexture: BaseTexture;
  45664. /**
  45665. * Specifies the metallic scalar of the metallic/roughness workflow.
  45666. * Can also be used to scale the metalness values of the metallic texture.
  45667. */
  45668. metallic: Nullable<number>;
  45669. /**
  45670. * Specifies the roughness scalar of the metallic/roughness workflow.
  45671. * Can also be used to scale the roughness values of the metallic texture.
  45672. */
  45673. roughness: Nullable<number>;
  45674. /**
  45675. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45676. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45677. */
  45678. microSurfaceTexture: BaseTexture;
  45679. /**
  45680. * Stores surface normal data used to displace a mesh in a texture.
  45681. */
  45682. bumpTexture: BaseTexture;
  45683. /**
  45684. * Stores the pre-calculated light information of a mesh in a texture.
  45685. */
  45686. lightmapTexture: BaseTexture;
  45687. /**
  45688. * Stores the refracted light information in a texture.
  45689. */
  45690. refractionTexture: BaseTexture;
  45691. /**
  45692. * The color of a material in ambient lighting.
  45693. */
  45694. ambientColor: Color3;
  45695. /**
  45696. * AKA Diffuse Color in other nomenclature.
  45697. */
  45698. albedoColor: Color3;
  45699. /**
  45700. * AKA Specular Color in other nomenclature.
  45701. */
  45702. reflectivityColor: Color3;
  45703. /**
  45704. * The color reflected from the material.
  45705. */
  45706. reflectionColor: Color3;
  45707. /**
  45708. * The color emitted from the material.
  45709. */
  45710. emissiveColor: Color3;
  45711. /**
  45712. * AKA Glossiness in other nomenclature.
  45713. */
  45714. microSurface: number;
  45715. /**
  45716. * source material index of refraction (IOR)' / 'destination material IOR.
  45717. */
  45718. indexOfRefraction: number;
  45719. /**
  45720. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  45721. */
  45722. invertRefractionY: boolean;
  45723. /**
  45724. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45725. * Materials half opaque for instance using refraction could benefit from this control.
  45726. */
  45727. linkRefractionWithTransparency: boolean;
  45728. /**
  45729. * If true, the light map contains occlusion information instead of lighting info.
  45730. */
  45731. useLightmapAsShadowmap: boolean;
  45732. /**
  45733. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45734. */
  45735. useAlphaFromAlbedoTexture: boolean;
  45736. /**
  45737. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45738. */
  45739. forceAlphaTest: boolean;
  45740. /**
  45741. * Defines the alpha limits in alpha test mode.
  45742. */
  45743. alphaCutOff: number;
  45744. /**
  45745. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45746. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45747. */
  45748. useSpecularOverAlpha: boolean;
  45749. /**
  45750. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45751. */
  45752. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45753. /**
  45754. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45755. */
  45756. useRoughnessFromMetallicTextureAlpha: boolean;
  45757. /**
  45758. * Specifies if the metallic texture contains the roughness information in its green channel.
  45759. */
  45760. useRoughnessFromMetallicTextureGreen: boolean;
  45761. /**
  45762. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45763. */
  45764. useMetallnessFromMetallicTextureBlue: boolean;
  45765. /**
  45766. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45767. */
  45768. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45769. /**
  45770. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45771. */
  45772. useAmbientInGrayScale: boolean;
  45773. /**
  45774. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45775. * The material will try to infer what glossiness each pixel should be.
  45776. */
  45777. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45778. /**
  45779. * BJS is using an harcoded light falloff based on a manually sets up range.
  45780. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45781. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45782. */
  45783. /**
  45784. * BJS is using an harcoded light falloff based on a manually sets up range.
  45785. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45786. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45787. */
  45788. usePhysicalLightFalloff: boolean;
  45789. /**
  45790. * In order to support the falloff compatibility with gltf, a special mode has been added
  45791. * to reproduce the gltf light falloff.
  45792. */
  45793. /**
  45794. * In order to support the falloff compatibility with gltf, a special mode has been added
  45795. * to reproduce the gltf light falloff.
  45796. */
  45797. useGLTFLightFalloff: boolean;
  45798. /**
  45799. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45800. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45801. */
  45802. useRadianceOverAlpha: boolean;
  45803. /**
  45804. * Allows using an object space normal map (instead of tangent space).
  45805. */
  45806. useObjectSpaceNormalMap: boolean;
  45807. /**
  45808. * Allows using the bump map in parallax mode.
  45809. */
  45810. useParallax: boolean;
  45811. /**
  45812. * Allows using the bump map in parallax occlusion mode.
  45813. */
  45814. useParallaxOcclusion: boolean;
  45815. /**
  45816. * Controls the scale bias of the parallax mode.
  45817. */
  45818. parallaxScaleBias: number;
  45819. /**
  45820. * If sets to true, disables all the lights affecting the material.
  45821. */
  45822. disableLighting: boolean;
  45823. /**
  45824. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45825. */
  45826. forceIrradianceInFragment: boolean;
  45827. /**
  45828. * Number of Simultaneous lights allowed on the material.
  45829. */
  45830. maxSimultaneousLights: number;
  45831. /**
  45832. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45833. */
  45834. invertNormalMapX: boolean;
  45835. /**
  45836. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45837. */
  45838. invertNormalMapY: boolean;
  45839. /**
  45840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45841. */
  45842. twoSidedLighting: boolean;
  45843. /**
  45844. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45845. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45846. */
  45847. useAlphaFresnel: boolean;
  45848. /**
  45849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45850. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45851. */
  45852. useLinearAlphaFresnel: boolean;
  45853. /**
  45854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45855. * And/Or occlude the blended part.
  45856. */
  45857. environmentBRDFTexture: Nullable<BaseTexture>;
  45858. /**
  45859. * Force normal to face away from face.
  45860. */
  45861. forceNormalForward: boolean;
  45862. /**
  45863. * Enables specular anti aliasing in the PBR shader.
  45864. * It will both interacts on the Geometry for analytical and IBL lighting.
  45865. * It also prefilter the roughness map based on the bump values.
  45866. */
  45867. enableSpecularAntiAliasing: boolean;
  45868. /**
  45869. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45870. * makes the reflect vector face the model (under horizon).
  45871. */
  45872. useHorizonOcclusion: boolean;
  45873. /**
  45874. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45875. * too much the area relying on ambient texture to define their ambient occlusion.
  45876. */
  45877. useRadianceOcclusion: boolean;
  45878. /**
  45879. * If set to true, no lighting calculations will be applied.
  45880. */
  45881. unlit: boolean;
  45882. /**
  45883. * Gets the image processing configuration used either in this material.
  45884. */
  45885. /**
  45886. * Sets the Default image processing configuration used either in the this material.
  45887. *
  45888. * If sets to null, the scene one is in use.
  45889. */
  45890. imageProcessingConfiguration: ImageProcessingConfiguration;
  45891. /**
  45892. * Gets wether the color curves effect is enabled.
  45893. */
  45894. /**
  45895. * Sets wether the color curves effect is enabled.
  45896. */
  45897. cameraColorCurvesEnabled: boolean;
  45898. /**
  45899. * Gets wether the color grading effect is enabled.
  45900. */
  45901. /**
  45902. * Gets wether the color grading effect is enabled.
  45903. */
  45904. cameraColorGradingEnabled: boolean;
  45905. /**
  45906. * Gets wether tonemapping is enabled or not.
  45907. */
  45908. /**
  45909. * Sets wether tonemapping is enabled or not
  45910. */
  45911. cameraToneMappingEnabled: boolean;
  45912. /**
  45913. * The camera exposure used on this material.
  45914. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45915. * This corresponds to a photographic exposure.
  45916. */
  45917. /**
  45918. * The camera exposure used on this material.
  45919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45920. * This corresponds to a photographic exposure.
  45921. */
  45922. cameraExposure: number;
  45923. /**
  45924. * Gets The camera contrast used on this material.
  45925. */
  45926. /**
  45927. * Sets The camera contrast used on this material.
  45928. */
  45929. cameraContrast: number;
  45930. /**
  45931. * Gets the Color Grading 2D Lookup Texture.
  45932. */
  45933. /**
  45934. * Sets the Color Grading 2D Lookup Texture.
  45935. */
  45936. cameraColorGradingTexture: Nullable<BaseTexture>;
  45937. /**
  45938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45940. * 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;
  45941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45942. */
  45943. /**
  45944. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45945. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45946. * 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;
  45947. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45948. */
  45949. cameraColorCurves: Nullable<ColorCurves>;
  45950. /**
  45951. * Instantiates a new PBRMaterial instance.
  45952. *
  45953. * @param name The material name
  45954. * @param scene The scene the material will be use in.
  45955. */
  45956. constructor(name: string, scene: Scene);
  45957. /**
  45958. * Returns the name of this material class.
  45959. */
  45960. getClassName(): string;
  45961. /**
  45962. * Returns an array of the actively used textures.
  45963. * @returns - Array of BaseTextures
  45964. */
  45965. getActiveTextures(): BaseTexture[];
  45966. /**
  45967. * Checks to see if a texture is used in the material.
  45968. * @param texture - Base texture to use.
  45969. * @returns - Boolean specifying if a texture is used in the material.
  45970. */
  45971. hasTexture(texture: BaseTexture): boolean;
  45972. /**
  45973. * Makes a duplicate of the current material.
  45974. * @param name - name to use for the new material.
  45975. */
  45976. clone(name: string): PBRMaterial;
  45977. /**
  45978. * Serializes this PBR Material.
  45979. * @returns - An object with the serialized material.
  45980. */
  45981. serialize(): any;
  45982. /**
  45983. * Parses a PBR Material from a serialized object.
  45984. * @param source - Serialized object.
  45985. * @param scene - BJS scene instance.
  45986. * @param rootUrl - url for the scene object
  45987. * @returns - PBRMaterial
  45988. */
  45989. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45990. }
  45991. }
  45992. declare module BABYLON {
  45993. /**
  45994. * The PBR material of BJS following the metal roughness convention.
  45995. *
  45996. * This fits to the PBR convention in the GLTF definition:
  45997. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  45998. */
  45999. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  46000. /**
  46001. * The base color has two different interpretations depending on the value of metalness.
  46002. * When the material is a metal, the base color is the specific measured reflectance value
  46003. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  46004. * of the material.
  46005. */
  46006. baseColor: Color3;
  46007. /**
  46008. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  46009. * well as opacity information in the alpha channel.
  46010. */
  46011. baseTexture: BaseTexture;
  46012. /**
  46013. * Specifies the metallic scalar value of the material.
  46014. * Can also be used to scale the metalness values of the metallic texture.
  46015. */
  46016. metallic: number;
  46017. /**
  46018. * Specifies the roughness scalar value of the material.
  46019. * Can also be used to scale the roughness values of the metallic texture.
  46020. */
  46021. roughness: number;
  46022. /**
  46023. * Texture containing both the metallic value in the B channel and the
  46024. * roughness value in the G channel to keep better precision.
  46025. */
  46026. metallicRoughnessTexture: BaseTexture;
  46027. /**
  46028. * Instantiates a new PBRMetalRoughnessMaterial instance.
  46029. *
  46030. * @param name The material name
  46031. * @param scene The scene the material will be use in.
  46032. */
  46033. constructor(name: string, scene: Scene);
  46034. /**
  46035. * Return the currrent class name of the material.
  46036. */
  46037. getClassName(): string;
  46038. /**
  46039. * Return the active textures of the material.
  46040. */
  46041. getActiveTextures(): BaseTexture[];
  46042. /**
  46043. * Checks to see if a texture is used in the material.
  46044. * @param texture - Base texture to use.
  46045. * @returns - Boolean specifying if a texture is used in the material.
  46046. */
  46047. hasTexture(texture: BaseTexture): boolean;
  46048. /**
  46049. * Makes a duplicate of the current material.
  46050. * @param name - name to use for the new material.
  46051. */
  46052. clone(name: string): PBRMetallicRoughnessMaterial;
  46053. /**
  46054. * Serialize the material to a parsable JSON object.
  46055. */
  46056. serialize(): any;
  46057. /**
  46058. * Parses a JSON object correponding to the serialize function.
  46059. */
  46060. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  46061. }
  46062. }
  46063. declare module BABYLON {
  46064. /**
  46065. * The PBR material of BJS following the specular glossiness convention.
  46066. *
  46067. * This fits to the PBR convention in the GLTF definition:
  46068. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  46069. */
  46070. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  46071. /**
  46072. * Specifies the diffuse color of the material.
  46073. */
  46074. diffuseColor: Color3;
  46075. /**
  46076. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  46077. * channel.
  46078. */
  46079. diffuseTexture: BaseTexture;
  46080. /**
  46081. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  46082. */
  46083. specularColor: Color3;
  46084. /**
  46085. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  46086. */
  46087. glossiness: number;
  46088. /**
  46089. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  46090. */
  46091. specularGlossinessTexture: BaseTexture;
  46092. /**
  46093. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  46094. *
  46095. * @param name The material name
  46096. * @param scene The scene the material will be use in.
  46097. */
  46098. constructor(name: string, scene: Scene);
  46099. /**
  46100. * Return the currrent class name of the material.
  46101. */
  46102. getClassName(): string;
  46103. /**
  46104. * Return the active textures of the material.
  46105. */
  46106. getActiveTextures(): BaseTexture[];
  46107. /**
  46108. * Checks to see if a texture is used in the material.
  46109. * @param texture - Base texture to use.
  46110. * @returns - Boolean specifying if a texture is used in the material.
  46111. */
  46112. hasTexture(texture: BaseTexture): boolean;
  46113. /**
  46114. * Makes a duplicate of the current material.
  46115. * @param name - name to use for the new material.
  46116. */
  46117. clone(name: string): PBRSpecularGlossinessMaterial;
  46118. /**
  46119. * Serialize the material to a parsable JSON object.
  46120. */
  46121. serialize(): any;
  46122. /**
  46123. * Parses a JSON object correponding to the serialize function.
  46124. */
  46125. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  46126. }
  46127. }
  46128. declare module BABYLON {
  46129. /**
  46130. * Base class of all the textures in babylon.
  46131. * It groups all the common properties the materials, post process, lights... might need
  46132. * in order to make a correct use of the texture.
  46133. */
  46134. class BaseTexture {
  46135. /**
  46136. * Default anisotropic filtering level for the application.
  46137. * It is set to 4 as a good tradeoff between perf and quality.
  46138. */
  46139. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  46140. /**
  46141. * Gets or sets the unique id of the texture
  46142. */
  46143. uniqueId: number;
  46144. /**
  46145. * Define the name of the texture.
  46146. */
  46147. name: string;
  46148. /**
  46149. * Gets or sets an object used to store user defined information.
  46150. */
  46151. metadata: any;
  46152. private _hasAlpha;
  46153. /**
  46154. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  46155. */
  46156. hasAlpha: boolean;
  46157. /**
  46158. * Defines if the alpha value should be determined via the rgb values.
  46159. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  46160. */
  46161. getAlphaFromRGB: boolean;
  46162. /**
  46163. * Intensity or strength of the texture.
  46164. * It is commonly used by materials to fine tune the intensity of the texture
  46165. */
  46166. level: number;
  46167. /**
  46168. * Define the UV chanel to use starting from 0 and defaulting to 0.
  46169. * This is part of the texture as textures usually maps to one uv set.
  46170. */
  46171. coordinatesIndex: number;
  46172. private _coordinatesMode;
  46173. /**
  46174. * How a texture is mapped.
  46175. *
  46176. * | Value | Type | Description |
  46177. * | ----- | ----------------------------------- | ----------- |
  46178. * | 0 | EXPLICIT_MODE | |
  46179. * | 1 | SPHERICAL_MODE | |
  46180. * | 2 | PLANAR_MODE | |
  46181. * | 3 | CUBIC_MODE | |
  46182. * | 4 | PROJECTION_MODE | |
  46183. * | 5 | SKYBOX_MODE | |
  46184. * | 6 | INVCUBIC_MODE | |
  46185. * | 7 | EQUIRECTANGULAR_MODE | |
  46186. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  46187. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  46188. */
  46189. coordinatesMode: number;
  46190. /**
  46191. * | Value | Type | Description |
  46192. * | ----- | ------------------ | ----------- |
  46193. * | 0 | CLAMP_ADDRESSMODE | |
  46194. * | 1 | WRAP_ADDRESSMODE | |
  46195. * | 2 | MIRROR_ADDRESSMODE | |
  46196. */
  46197. wrapU: number;
  46198. /**
  46199. * | Value | Type | Description |
  46200. * | ----- | ------------------ | ----------- |
  46201. * | 0 | CLAMP_ADDRESSMODE | |
  46202. * | 1 | WRAP_ADDRESSMODE | |
  46203. * | 2 | MIRROR_ADDRESSMODE | |
  46204. */
  46205. wrapV: number;
  46206. /**
  46207. * | Value | Type | Description |
  46208. * | ----- | ------------------ | ----------- |
  46209. * | 0 | CLAMP_ADDRESSMODE | |
  46210. * | 1 | WRAP_ADDRESSMODE | |
  46211. * | 2 | MIRROR_ADDRESSMODE | |
  46212. */
  46213. wrapR: number;
  46214. /**
  46215. * With compliant hardware and browser (supporting anisotropic filtering)
  46216. * this defines the level of anisotropic filtering in the texture.
  46217. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  46218. */
  46219. anisotropicFilteringLevel: number;
  46220. /**
  46221. * Define if the texture is a cube texture or if false a 2d texture.
  46222. */
  46223. isCube: boolean;
  46224. /**
  46225. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  46226. */
  46227. is3D: boolean;
  46228. /**
  46229. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  46230. * HDR texture are usually stored in linear space.
  46231. * This only impacts the PBR and Background materials
  46232. */
  46233. gammaSpace: boolean;
  46234. /**
  46235. * Gets whether or not the texture contains RGBD data.
  46236. */
  46237. readonly isRGBD: boolean;
  46238. /**
  46239. * Is Z inverted in the texture (useful in a cube texture).
  46240. */
  46241. invertZ: boolean;
  46242. /**
  46243. * @hidden
  46244. */
  46245. lodLevelInAlpha: boolean;
  46246. /**
  46247. * With prefiltered texture, defined the offset used during the prefiltering steps.
  46248. */
  46249. lodGenerationOffset: number;
  46250. /**
  46251. * With prefiltered texture, defined the scale used during the prefiltering steps.
  46252. */
  46253. lodGenerationScale: number;
  46254. /**
  46255. * Define if the texture is a render target.
  46256. */
  46257. isRenderTarget: boolean;
  46258. /**
  46259. * Define the unique id of the texture in the scene.
  46260. */
  46261. readonly uid: string;
  46262. /**
  46263. * Return a string representation of the texture.
  46264. * @returns the texture as a string
  46265. */
  46266. toString(): string;
  46267. /**
  46268. * Get the class name of the texture.
  46269. * @returns "BaseTexture"
  46270. */
  46271. getClassName(): string;
  46272. /**
  46273. * Define the list of animation attached to the texture.
  46274. */
  46275. animations: Animation[];
  46276. /**
  46277. * An event triggered when the texture is disposed.
  46278. */
  46279. onDisposeObservable: Observable<BaseTexture>;
  46280. private _onDisposeObserver;
  46281. /**
  46282. * Callback triggered when the texture has been disposed.
  46283. * Kept for back compatibility, you can use the onDisposeObservable instead.
  46284. */
  46285. onDispose: () => void;
  46286. /**
  46287. * Define the current state of the loading sequence when in delayed load mode.
  46288. */
  46289. delayLoadState: number;
  46290. private _scene;
  46291. /** @hidden */
  46292. _texture: Nullable<InternalTexture>;
  46293. private _uid;
  46294. /**
  46295. * Define if the texture is preventinga material to render or not.
  46296. * If not and the texture is not ready, the engine will use a default black texture instead.
  46297. */
  46298. readonly isBlocking: boolean;
  46299. /**
  46300. * Instantiates a new BaseTexture.
  46301. * Base class of all the textures in babylon.
  46302. * It groups all the common properties the materials, post process, lights... might need
  46303. * in order to make a correct use of the texture.
  46304. * @param scene Define the scene the texture blongs to
  46305. */
  46306. constructor(scene: Nullable<Scene>);
  46307. /**
  46308. * Get the scene the texture belongs to.
  46309. * @returns the scene or null if undefined
  46310. */
  46311. getScene(): Nullable<Scene>;
  46312. /**
  46313. * Get the texture transform matrix used to offset tile the texture for istance.
  46314. * @returns the transformation matrix
  46315. */
  46316. getTextureMatrix(): Matrix;
  46317. /**
  46318. * Get the texture reflection matrix used to rotate/transform the reflection.
  46319. * @returns the reflection matrix
  46320. */
  46321. getReflectionTextureMatrix(): Matrix;
  46322. /**
  46323. * Get the underlying lower level texture from Babylon.
  46324. * @returns the insternal texture
  46325. */
  46326. getInternalTexture(): Nullable<InternalTexture>;
  46327. /**
  46328. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  46329. * @returns true if ready or not blocking
  46330. */
  46331. isReadyOrNotBlocking(): boolean;
  46332. /**
  46333. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  46334. * @returns true if fully ready
  46335. */
  46336. isReady(): boolean;
  46337. private _cachedSize;
  46338. /**
  46339. * Get the size of the texture.
  46340. * @returns the texture size.
  46341. */
  46342. getSize(): ISize;
  46343. /**
  46344. * Get the base size of the texture.
  46345. * It can be different from the size if the texture has been resized for POT for instance
  46346. * @returns the base size
  46347. */
  46348. getBaseSize(): ISize;
  46349. /**
  46350. * Scales the texture if is `canRescale()`
  46351. * @param ratio the resize factor we want to use to rescale
  46352. */
  46353. scale(ratio: number): void;
  46354. /**
  46355. * Get if the texture can rescale.
  46356. */
  46357. readonly canRescale: boolean;
  46358. /** @hidden */
  46359. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  46360. /** @hidden */
  46361. _rebuild(): void;
  46362. /**
  46363. * Triggers the load sequence in delayed load mode.
  46364. */
  46365. delayLoad(): void;
  46366. /**
  46367. * Clones the texture.
  46368. * @returns the cloned texture
  46369. */
  46370. clone(): Nullable<BaseTexture>;
  46371. /**
  46372. * Get the texture underlying type (INT, FLOAT...)
  46373. */
  46374. readonly textureType: number;
  46375. /**
  46376. * Get the texture underlying format (RGB, RGBA...)
  46377. */
  46378. readonly textureFormat: number;
  46379. /**
  46380. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  46381. * This will returns an RGBA array buffer containing either in values (0-255) or
  46382. * float values (0-1) depending of the underlying buffer type.
  46383. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  46384. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  46385. * @param buffer defines a user defined buffer to fill with data (can be null)
  46386. * @returns The Array buffer containing the pixels data.
  46387. */
  46388. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  46389. /**
  46390. * Release and destroy the underlying lower level texture aka internalTexture.
  46391. */
  46392. releaseInternalTexture(): void;
  46393. /**
  46394. * Get the polynomial representation of the texture data.
  46395. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46396. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46397. */
  46398. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46399. /** @hidden */
  46400. readonly _lodTextureHigh: Nullable<BaseTexture>;
  46401. /** @hidden */
  46402. readonly _lodTextureMid: Nullable<BaseTexture>;
  46403. /** @hidden */
  46404. readonly _lodTextureLow: Nullable<BaseTexture>;
  46405. /**
  46406. * Dispose the texture and release its associated resources.
  46407. */
  46408. dispose(): void;
  46409. /**
  46410. * Serialize the texture into a JSON representation that can be parsed later on.
  46411. * @returns the JSON representation of the texture
  46412. */
  46413. serialize(): any;
  46414. /**
  46415. * Helper function to be called back once a list of texture contains only ready textures.
  46416. * @param textures Define the list of textures to wait for
  46417. * @param callback Define the callback triggered once the entire list will be ready
  46418. */
  46419. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  46420. }
  46421. }
  46422. declare module BABYLON {
  46423. /**
  46424. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  46425. * It can help converting any input color in a desired output one. This can then be used to create effects
  46426. * from sepia, black and white to sixties or futuristic rendering...
  46427. *
  46428. * The only supported format is currently 3dl.
  46429. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  46430. */
  46431. class ColorGradingTexture extends BaseTexture {
  46432. /**
  46433. * The current texture matrix. (will always be identity in color grading texture)
  46434. */
  46435. private _textureMatrix;
  46436. /**
  46437. * The texture URL.
  46438. */
  46439. url: string;
  46440. /**
  46441. * Empty line regex stored for GC.
  46442. */
  46443. private static _noneEmptyLineRegex;
  46444. private _engine;
  46445. /**
  46446. * Instantiates a ColorGradingTexture from the following parameters.
  46447. *
  46448. * @param url The location of the color gradind data (currently only supporting 3dl)
  46449. * @param scene The scene the texture will be used in
  46450. */
  46451. constructor(url: string, scene: Scene);
  46452. /**
  46453. * Returns the texture matrix used in most of the material.
  46454. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  46455. */
  46456. getTextureMatrix(): Matrix;
  46457. /**
  46458. * Occurs when the file being loaded is a .3dl LUT file.
  46459. */
  46460. private load3dlTexture;
  46461. /**
  46462. * Starts the loading process of the texture.
  46463. */
  46464. private loadTexture;
  46465. /**
  46466. * Clones the color gradind texture.
  46467. */
  46468. clone(): ColorGradingTexture;
  46469. /**
  46470. * Called during delayed load for textures.
  46471. */
  46472. delayLoad(): void;
  46473. /**
  46474. * Parses a color grading texture serialized by Babylon.
  46475. * @param parsedTexture The texture information being parsedTexture
  46476. * @param scene The scene to load the texture in
  46477. * @param rootUrl The root url of the data assets to load
  46478. * @return A color gradind texture
  46479. */
  46480. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  46481. /**
  46482. * Serializes the LUT texture to json format.
  46483. */
  46484. serialize(): any;
  46485. }
  46486. }
  46487. declare module BABYLON {
  46488. /**
  46489. * Class for creating a cube texture
  46490. */
  46491. class CubeTexture extends BaseTexture {
  46492. /**
  46493. * The url of the texture
  46494. */
  46495. url: string;
  46496. /**
  46497. * Gets or sets the center of the bounding box associated with the cube texture.
  46498. * It must define where the camera used to render the texture was set
  46499. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46500. */
  46501. boundingBoxPosition: Vector3;
  46502. private _boundingBoxSize;
  46503. /**
  46504. * Gets or sets the size of the bounding box associated with the cube texture
  46505. * When defined, the cubemap will switch to local mode
  46506. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46507. * @example https://www.babylonjs-playground.com/#RNASML
  46508. */
  46509. /**
  46510. * Returns the bounding box size
  46511. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  46512. */
  46513. boundingBoxSize: Vector3;
  46514. protected _rotationY: number;
  46515. /**
  46516. * Sets texture matrix rotation angle around Y axis in radians.
  46517. */
  46518. /**
  46519. * Gets texture matrix rotation angle around Y axis radians.
  46520. */
  46521. rotationY: number;
  46522. private _noMipmap;
  46523. private _files;
  46524. private _extensions;
  46525. private _textureMatrix;
  46526. private _format;
  46527. private _createPolynomials;
  46528. /** @hidden */
  46529. readonly _prefiltered: boolean;
  46530. /**
  46531. * Creates a cube texture from an array of image urls
  46532. * @param files defines an array of image urls
  46533. * @param scene defines the hosting scene
  46534. * @param noMipmap specifies if mip maps are not used
  46535. * @returns a cube texture
  46536. */
  46537. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  46538. /**
  46539. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  46540. * @param url defines the url of the prefiltered texture
  46541. * @param scene defines the scene the texture is attached to
  46542. * @param forcedExtension defines the extension of the file if different from the url
  46543. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46544. * @return the prefiltered texture
  46545. */
  46546. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  46547. /**
  46548. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  46549. * as prefiltered data.
  46550. * @param rootUrl defines the url of the texture or the root name of the six images
  46551. * @param scene defines the scene the texture is attached to
  46552. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  46553. * @param noMipmap defines if mipmaps should be created or not
  46554. * @param files defines the six files to load for the different faces
  46555. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  46556. * @param onError defines a callback triggered in case of error during load
  46557. * @param format defines the internal format to use for the texture once loaded
  46558. * @param prefiltered defines whether or not the texture is created from prefiltered data
  46559. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  46560. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  46561. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46562. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46563. * @return the cube texture
  46564. */
  46565. 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);
  46566. /**
  46567. * Delays loading of the cube texture
  46568. */
  46569. delayLoad(): void;
  46570. /**
  46571. * Returns the reflection texture matrix
  46572. * @returns the reflection texture matrix
  46573. */
  46574. getReflectionTextureMatrix(): Matrix;
  46575. /**
  46576. * Sets the reflection texture matrix
  46577. * @param value Reflection texture matrix
  46578. */
  46579. setReflectionTextureMatrix(value: Matrix): void;
  46580. /**
  46581. * Parses text to create a cube texture
  46582. * @param parsedTexture define the serialized text to read from
  46583. * @param scene defines the hosting scene
  46584. * @param rootUrl defines the root url of the cube texture
  46585. * @returns a cube texture
  46586. */
  46587. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  46588. /**
  46589. * Makes a clone, or deep copy, of the cube texture
  46590. * @returns a new cube texture
  46591. */
  46592. clone(): CubeTexture;
  46593. }
  46594. }
  46595. declare module BABYLON {
  46596. /**
  46597. * A class extending Texture allowing drawing on a texture
  46598. * @see http://doc.babylonjs.com/how_to/dynamictexture
  46599. */
  46600. class DynamicTexture extends Texture {
  46601. private _generateMipMaps;
  46602. private _canvas;
  46603. private _context;
  46604. private _engine;
  46605. /**
  46606. * Creates a DynamicTexture
  46607. * @param name defines the name of the texture
  46608. * @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
  46609. * @param scene defines the scene where you want the texture
  46610. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46611. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46612. * @param format defines the texture format to use (default is BABYLON.Engine.TEXTUREFORMAT_RGBA)
  46613. */
  46614. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46615. /**
  46616. * Gets the current state of canRescale
  46617. */
  46618. readonly canRescale: boolean;
  46619. private _recreate;
  46620. /**
  46621. * Scales the texture
  46622. * @param ratio the scale factor to apply to both width and height
  46623. */
  46624. scale(ratio: number): void;
  46625. /**
  46626. * Resizes the texture
  46627. * @param width the new width
  46628. * @param height the new height
  46629. */
  46630. scaleTo(width: number, height: number): void;
  46631. /**
  46632. * Gets the context of the canvas used by the texture
  46633. * @returns the canvas context of the dynamic texture
  46634. */
  46635. getContext(): CanvasRenderingContext2D;
  46636. /**
  46637. * Clears the texture
  46638. */
  46639. clear(): void;
  46640. /**
  46641. * Updates the texture
  46642. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46643. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46644. */
  46645. update(invertY?: boolean, premulAlpha?: boolean): void;
  46646. /**
  46647. * Draws text onto the texture
  46648. * @param text defines the text to be drawn
  46649. * @param x defines the placement of the text from the left
  46650. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46651. * @param font defines the font to be used with font-style, font-size, font-name
  46652. * @param color defines the color used for the text
  46653. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46654. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46655. * @param update defines whether texture is immediately update (default is true)
  46656. */
  46657. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  46658. /**
  46659. * Clones the texture
  46660. * @returns the clone of the texture.
  46661. */
  46662. clone(): DynamicTexture;
  46663. /**
  46664. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46665. * @returns a serialized dynamic texture object
  46666. */
  46667. serialize(): any;
  46668. /** @hidden */
  46669. _rebuild(): void;
  46670. }
  46671. }
  46672. declare module BABYLON {
  46673. /**
  46674. * This represents a texture coming from an HDR input.
  46675. *
  46676. * The only supported format is currently panorama picture stored in RGBE format.
  46677. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46678. */
  46679. class HDRCubeTexture extends BaseTexture {
  46680. private static _facesMapping;
  46681. private _generateHarmonics;
  46682. private _noMipmap;
  46683. private _textureMatrix;
  46684. private _size;
  46685. private _onLoad;
  46686. private _onError;
  46687. /**
  46688. * The texture URL.
  46689. */
  46690. url: string;
  46691. /**
  46692. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46693. */
  46694. coordinatesMode: number;
  46695. protected _isBlocking: boolean;
  46696. /**
  46697. * Sets wether or not the texture is blocking during loading.
  46698. */
  46699. /**
  46700. * Gets wether or not the texture is blocking during loading.
  46701. */
  46702. isBlocking: boolean;
  46703. protected _rotationY: number;
  46704. /**
  46705. * Sets texture matrix rotation angle around Y axis in radians.
  46706. */
  46707. /**
  46708. * Gets texture matrix rotation angle around Y axis radians.
  46709. */
  46710. rotationY: number;
  46711. /**
  46712. * Gets or sets the center of the bounding box associated with the cube texture
  46713. * It must define where the camera used to render the texture was set
  46714. */
  46715. boundingBoxPosition: Vector3;
  46716. private _boundingBoxSize;
  46717. /**
  46718. * Gets or sets the size of the bounding box associated with the cube texture
  46719. * When defined, the cubemap will switch to local mode
  46720. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46721. * @example https://www.babylonjs-playground.com/#RNASML
  46722. */
  46723. boundingBoxSize: Vector3;
  46724. /**
  46725. * Instantiates an HDRTexture from the following parameters.
  46726. *
  46727. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46728. * @param scene The scene the texture will be used in
  46729. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46730. * @param noMipmap Forces to not generate the mipmap if true
  46731. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46732. * @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)
  46733. * @param reserved Reserved flag for internal use.
  46734. */
  46735. 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>);
  46736. /**
  46737. * Occurs when the file is raw .hdr file.
  46738. */
  46739. private loadTexture;
  46740. clone(): HDRCubeTexture;
  46741. delayLoad(): void;
  46742. /**
  46743. * Get the texture reflection matrix used to rotate/transform the reflection.
  46744. * @returns the reflection matrix
  46745. */
  46746. getReflectionTextureMatrix(): Matrix;
  46747. /**
  46748. * Set the texture reflection matrix used to rotate/transform the reflection.
  46749. * @param value Define the reflection matrix to set
  46750. */
  46751. setReflectionTextureMatrix(value: Matrix): void;
  46752. /**
  46753. * Parses a JSON representation of an HDR Texture in order to create the texture
  46754. * @param parsedTexture Define the JSON representation
  46755. * @param scene Define the scene the texture should be created in
  46756. * @param rootUrl Define the root url in case we need to load relative dependencies
  46757. * @returns the newly created texture after parsing
  46758. */
  46759. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46760. serialize(): any;
  46761. }
  46762. }
  46763. declare module BABYLON {
  46764. /**
  46765. * Class used to store data associated with WebGL texture data for the engine
  46766. * This class should not be used directly
  46767. */
  46768. class InternalTexture implements IInternalTextureTracker {
  46769. /**
  46770. * The source of the texture data is unknown
  46771. */
  46772. static DATASOURCE_UNKNOWN: number;
  46773. /**
  46774. * Texture data comes from an URL
  46775. */
  46776. static DATASOURCE_URL: number;
  46777. /**
  46778. * Texture data is only used for temporary storage
  46779. */
  46780. static DATASOURCE_TEMP: number;
  46781. /**
  46782. * Texture data comes from raw data (ArrayBuffer)
  46783. */
  46784. static DATASOURCE_RAW: number;
  46785. /**
  46786. * Texture content is dynamic (video or dynamic texture)
  46787. */
  46788. static DATASOURCE_DYNAMIC: number;
  46789. /**
  46790. * Texture content is generated by rendering to it
  46791. */
  46792. static DATASOURCE_RENDERTARGET: number;
  46793. /**
  46794. * Texture content is part of a multi render target process
  46795. */
  46796. static DATASOURCE_MULTIRENDERTARGET: number;
  46797. /**
  46798. * Texture data comes from a cube data file
  46799. */
  46800. static DATASOURCE_CUBE: number;
  46801. /**
  46802. * Texture data comes from a raw cube data
  46803. */
  46804. static DATASOURCE_CUBERAW: number;
  46805. /**
  46806. * Texture data come from a prefiltered cube data file
  46807. */
  46808. static DATASOURCE_CUBEPREFILTERED: number;
  46809. /**
  46810. * Texture content is raw 3D data
  46811. */
  46812. static DATASOURCE_RAW3D: number;
  46813. /**
  46814. * Texture content is a depth texture
  46815. */
  46816. static DATASOURCE_DEPTHTEXTURE: number;
  46817. /**
  46818. * Texture data comes from a raw cube data encoded with RGBD
  46819. */
  46820. static DATASOURCE_CUBERAW_RGBD: number;
  46821. /**
  46822. * Defines if the texture is ready
  46823. */
  46824. isReady: boolean;
  46825. /**
  46826. * Defines if the texture is a cube texture
  46827. */
  46828. isCube: boolean;
  46829. /**
  46830. * Defines if the texture contains 3D data
  46831. */
  46832. is3D: boolean;
  46833. /**
  46834. * Gets the URL used to load this texture
  46835. */
  46836. url: string;
  46837. /**
  46838. * Gets the sampling mode of the texture
  46839. */
  46840. samplingMode: number;
  46841. /**
  46842. * Gets a boolean indicating if the texture needs mipmaps generation
  46843. */
  46844. generateMipMaps: boolean;
  46845. /**
  46846. * Gets the number of samples used by the texture (WebGL2+ only)
  46847. */
  46848. samples: number;
  46849. /**
  46850. * Gets the type of the texture (int, float...)
  46851. */
  46852. type: number;
  46853. /**
  46854. * Gets the format of the texture (RGB, RGBA...)
  46855. */
  46856. format: number;
  46857. /**
  46858. * Observable called when the texture is loaded
  46859. */
  46860. onLoadedObservable: Observable<InternalTexture>;
  46861. /**
  46862. * Gets the width of the texture
  46863. */
  46864. width: number;
  46865. /**
  46866. * Gets the height of the texture
  46867. */
  46868. height: number;
  46869. /**
  46870. * Gets the depth of the texture
  46871. */
  46872. depth: number;
  46873. /**
  46874. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  46875. */
  46876. baseWidth: number;
  46877. /**
  46878. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  46879. */
  46880. baseHeight: number;
  46881. /**
  46882. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  46883. */
  46884. baseDepth: number;
  46885. /**
  46886. * Gets a boolean indicating if the texture is inverted on Y axis
  46887. */
  46888. invertY: boolean;
  46889. /**
  46890. * Gets or set the previous tracker in the list
  46891. */
  46892. previous: Nullable<IInternalTextureTracker>;
  46893. /**
  46894. * Gets or set the next tracker in the list
  46895. */
  46896. next: Nullable<IInternalTextureTracker>;
  46897. /** @hidden */
  46898. _initialSlot: number;
  46899. /** @hidden */
  46900. _designatedSlot: number;
  46901. /** @hidden */
  46902. _dataSource: number;
  46903. /** @hidden */
  46904. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  46905. /** @hidden */
  46906. _bufferView: Nullable<ArrayBufferView>;
  46907. /** @hidden */
  46908. _bufferViewArray: Nullable<ArrayBufferView[]>;
  46909. /** @hidden */
  46910. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  46911. /** @hidden */
  46912. _size: number;
  46913. /** @hidden */
  46914. _extension: string;
  46915. /** @hidden */
  46916. _files: Nullable<string[]>;
  46917. /** @hidden */
  46918. _workingCanvas: HTMLCanvasElement;
  46919. /** @hidden */
  46920. _workingContext: CanvasRenderingContext2D;
  46921. /** @hidden */
  46922. _framebuffer: Nullable<WebGLFramebuffer>;
  46923. /** @hidden */
  46924. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  46925. /** @hidden */
  46926. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  46927. /** @hidden */
  46928. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  46929. /** @hidden */
  46930. _attachments: Nullable<number[]>;
  46931. /** @hidden */
  46932. _cachedCoordinatesMode: Nullable<number>;
  46933. /** @hidden */
  46934. _cachedWrapU: Nullable<number>;
  46935. /** @hidden */
  46936. _cachedWrapV: Nullable<number>;
  46937. /** @hidden */
  46938. _cachedWrapR: Nullable<number>;
  46939. /** @hidden */
  46940. _cachedAnisotropicFilteringLevel: Nullable<number>;
  46941. /** @hidden */
  46942. _isDisabled: boolean;
  46943. /** @hidden */
  46944. _compression: Nullable<string>;
  46945. /** @hidden */
  46946. _generateStencilBuffer: boolean;
  46947. /** @hidden */
  46948. _generateDepthBuffer: boolean;
  46949. /** @hidden */
  46950. _comparisonFunction: number;
  46951. /** @hidden */
  46952. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  46953. /** @hidden */
  46954. _lodGenerationScale: number;
  46955. /** @hidden */
  46956. _lodGenerationOffset: number;
  46957. /** @hidden */
  46958. _lodTextureHigh: BaseTexture;
  46959. /** @hidden */
  46960. _lodTextureMid: BaseTexture;
  46961. /** @hidden */
  46962. _lodTextureLow: BaseTexture;
  46963. /** @hidden */
  46964. _isRGBD: boolean;
  46965. /** @hidden */
  46966. _webGLTexture: Nullable<WebGLTexture>;
  46967. /** @hidden */
  46968. _references: number;
  46969. private _engine;
  46970. /**
  46971. * Gets the Engine the texture belongs to.
  46972. * @returns The babylon engine
  46973. */
  46974. getEngine(): Engine;
  46975. /**
  46976. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  46977. */
  46978. readonly dataSource: number;
  46979. /**
  46980. * Creates a new InternalTexture
  46981. * @param engine defines the engine to use
  46982. * @param dataSource defines the type of data that will be used
  46983. * @param delayAllocation if the texture allocation should be delayed (default: false)
  46984. */
  46985. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  46986. /**
  46987. * Increments the number of references (ie. the number of Texture that point to it)
  46988. */
  46989. incrementReferences(): void;
  46990. /**
  46991. * Change the size of the texture (not the size of the content)
  46992. * @param width defines the new width
  46993. * @param height defines the new height
  46994. * @param depth defines the new depth (1 by default)
  46995. */
  46996. updateSize(width: int, height: int, depth?: int): void;
  46997. /** @hidden */
  46998. _rebuild(): void;
  46999. /** @hidden */
  47000. _swapAndDie(target: InternalTexture): void;
  47001. /**
  47002. * Dispose the current allocated resources
  47003. */
  47004. dispose(): void;
  47005. }
  47006. }
  47007. declare module BABYLON {
  47008. /**
  47009. * This represents the required contract to create a new type of texture loader.
  47010. */
  47011. interface IInternalTextureLoader {
  47012. /**
  47013. * Defines wether the loader supports cascade loading the different faces.
  47014. */
  47015. supportCascades: boolean;
  47016. /**
  47017. * This returns if the loader support the current file information.
  47018. * @param extension defines the file extension of the file being loaded
  47019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47020. * @param fallback defines the fallback internal texture if any
  47021. * @param isBase64 defines whether the texture is encoded as a base64
  47022. * @param isBuffer defines whether the texture data are stored as a buffer
  47023. * @returns true if the loader can load the specified file
  47024. */
  47025. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47026. /**
  47027. * Transform the url before loading if required.
  47028. * @param rootUrl the url of the texture
  47029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47030. * @returns the transformed texture
  47031. */
  47032. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47033. /**
  47034. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47035. * @param rootUrl the url of the texture
  47036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47037. * @returns the fallback texture
  47038. */
  47039. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47040. /**
  47041. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47042. * @param data contains the texture data
  47043. * @param texture defines the BabylonJS internal texture
  47044. * @param createPolynomials will be true if polynomials have been requested
  47045. * @param onLoad defines the callback to trigger once the texture is ready
  47046. * @param onError defines the callback to trigger in case of error
  47047. */
  47048. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47049. /**
  47050. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47051. * @param data contains the texture data
  47052. * @param texture defines the BabylonJS internal texture
  47053. * @param callback defines the method to call once ready to upload
  47054. */
  47055. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47056. }
  47057. }
  47058. declare module BABYLON {
  47059. /**
  47060. * Internal interface used to track InternalTexture already bound to the GL context
  47061. */
  47062. interface IInternalTextureTracker {
  47063. /**
  47064. * Gets or set the previous tracker in the list
  47065. */
  47066. previous: Nullable<IInternalTextureTracker>;
  47067. /**
  47068. * Gets or set the next tracker in the list
  47069. */
  47070. next: Nullable<IInternalTextureTracker>;
  47071. }
  47072. /**
  47073. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  47074. */
  47075. class DummyInternalTextureTracker {
  47076. /**
  47077. * Gets or set the previous tracker in the list
  47078. */
  47079. previous: Nullable<IInternalTextureTracker>;
  47080. /**
  47081. * Gets or set the next tracker in the list
  47082. */
  47083. next: Nullable<IInternalTextureTracker>;
  47084. }
  47085. }
  47086. declare module BABYLON {
  47087. /**
  47088. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47089. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47090. * You can then easily use it as a reflectionTexture on a flat surface.
  47091. * In case the surface is not a plane, please consider relying on reflection probes.
  47092. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47093. */
  47094. class MirrorTexture extends RenderTargetTexture {
  47095. private scene;
  47096. /**
  47097. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  47098. * It is possible to directly set the mirrorPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  47099. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47100. */
  47101. mirrorPlane: Plane;
  47102. /**
  47103. * Define the blur ratio used to blur the reflection if needed.
  47104. */
  47105. blurRatio: number;
  47106. /**
  47107. * Define the adaptive blur kernel used to blur the reflection if needed.
  47108. * This will autocompute the closest best match for the `blurKernel`
  47109. */
  47110. adaptiveBlurKernel: number;
  47111. /**
  47112. * Define the blur kernel used to blur the reflection if needed.
  47113. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47114. */
  47115. blurKernel: number;
  47116. /**
  47117. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  47118. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47119. */
  47120. blurKernelX: number;
  47121. /**
  47122. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  47123. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  47124. */
  47125. blurKernelY: number;
  47126. private _autoComputeBlurKernel;
  47127. protected _onRatioRescale(): void;
  47128. private _updateGammaSpace;
  47129. private _imageProcessingConfigChangeObserver;
  47130. private _transformMatrix;
  47131. private _mirrorMatrix;
  47132. private _savedViewMatrix;
  47133. private _blurX;
  47134. private _blurY;
  47135. private _adaptiveBlurKernel;
  47136. private _blurKernelX;
  47137. private _blurKernelY;
  47138. private _blurRatio;
  47139. /**
  47140. * Instantiates a Mirror Texture.
  47141. * Mirror texture can be used to simulate the view from a mirror in a scene.
  47142. * It will dynamically be rendered every frame to adapt to the camera point of view.
  47143. * You can then easily use it as a reflectionTexture on a flat surface.
  47144. * In case the surface is not a plane, please consider relying on reflection probes.
  47145. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  47146. * @param name
  47147. * @param size
  47148. * @param scene
  47149. * @param generateMipMaps
  47150. * @param type
  47151. * @param samplingMode
  47152. * @param generateDepthBuffer
  47153. */
  47154. constructor(name: string, size: number | {
  47155. width: number;
  47156. height: number;
  47157. } | {
  47158. ratio: number;
  47159. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  47160. private _preparePostProcesses;
  47161. /**
  47162. * Clone the mirror texture.
  47163. * @returns the cloned texture
  47164. */
  47165. clone(): MirrorTexture;
  47166. /**
  47167. * Serialize the texture to a JSON representation you could use in Parse later on
  47168. * @returns the serialized JSON representation
  47169. */
  47170. serialize(): any;
  47171. /**
  47172. * Dispose the texture and release its associated resources.
  47173. */
  47174. dispose(): void;
  47175. }
  47176. }
  47177. declare module BABYLON {
  47178. /**
  47179. * Creation options of the multi render target texture.
  47180. */
  47181. interface IMultiRenderTargetOptions {
  47182. /**
  47183. * Define if the texture needs to create mip maps after render.
  47184. */
  47185. generateMipMaps?: boolean;
  47186. /**
  47187. * Define the types of all the draw buffers we want to create
  47188. */
  47189. types?: number[];
  47190. /**
  47191. * Define the sampling modes of all the draw buffers we want to create
  47192. */
  47193. samplingModes?: number[];
  47194. /**
  47195. * Define if a depth buffer is required
  47196. */
  47197. generateDepthBuffer?: boolean;
  47198. /**
  47199. * Define if a stencil buffer is required
  47200. */
  47201. generateStencilBuffer?: boolean;
  47202. /**
  47203. * Define if a depth texture is required instead of a depth buffer
  47204. */
  47205. generateDepthTexture?: boolean;
  47206. /**
  47207. * Define the number of desired draw buffers
  47208. */
  47209. textureCount?: number;
  47210. /**
  47211. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47212. */
  47213. doNotChangeAspectRatio?: boolean;
  47214. /**
  47215. * Define the default type of the buffers we are creating
  47216. */
  47217. defaultType?: number;
  47218. }
  47219. /**
  47220. * A multi render target, like a render target provides the ability to render to a texture.
  47221. * Unlike the render target, it can render to several draw buffers in one draw.
  47222. * This is specially interesting in deferred rendering or for any effects requiring more than
  47223. * just one color from a single pass.
  47224. */
  47225. class MultiRenderTarget extends RenderTargetTexture {
  47226. private _internalTextures;
  47227. private _textures;
  47228. private _multiRenderTargetOptions;
  47229. /**
  47230. * Get if draw buffers are currently supported by the used hardware and browser.
  47231. */
  47232. readonly isSupported: boolean;
  47233. /**
  47234. * Get the list of textures generated by the multi render target.
  47235. */
  47236. readonly textures: Texture[];
  47237. /**
  47238. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47239. */
  47240. readonly depthTexture: Texture;
  47241. /**
  47242. * Set the wrapping mode on U of all the textures we are rendering to.
  47243. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47244. */
  47245. wrapU: number;
  47246. /**
  47247. * Set the wrapping mode on V of all the textures we are rendering to.
  47248. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47249. */
  47250. wrapV: number;
  47251. /**
  47252. * Instantiate a new multi render target texture.
  47253. * A multi render target, like a render target provides the ability to render to a texture.
  47254. * Unlike the render target, it can render to several draw buffers in one draw.
  47255. * This is specially interesting in deferred rendering or for any effects requiring more than
  47256. * just one color from a single pass.
  47257. * @param name Define the name of the texture
  47258. * @param size Define the size of the buffers to render to
  47259. * @param count Define the number of target we are rendering into
  47260. * @param scene Define the scene the texture belongs to
  47261. * @param options Define the options used to create the multi render target
  47262. */
  47263. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47264. /** @hidden */
  47265. _rebuild(): void;
  47266. private _createInternalTextures;
  47267. private _createTextures;
  47268. /**
  47269. * Define the number of samples used if MSAA is enabled.
  47270. */
  47271. samples: number;
  47272. /**
  47273. * Resize all the textures in the multi render target.
  47274. * Be carrefull as it will recreate all the data in the new texture.
  47275. * @param size Define the new size
  47276. */
  47277. resize(size: any): void;
  47278. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47279. /**
  47280. * Dispose the render targets and their associated resources
  47281. */
  47282. dispose(): void;
  47283. /**
  47284. * Release all the underlying texture used as draw buffers.
  47285. */
  47286. releaseInternalTextures(): void;
  47287. }
  47288. }
  47289. declare module BABYLON {
  47290. /**
  47291. * Raw cube texture where the raw buffers are passed in
  47292. */
  47293. class RawCubeTexture extends CubeTexture {
  47294. /**
  47295. * Creates a cube texture where the raw buffers are passed in.
  47296. * @param scene defines the scene the texture is attached to
  47297. * @param data defines the array of data to use to create each face
  47298. * @param size defines the size of the textures
  47299. * @param format defines the format of the data
  47300. * @param type defines the type of the data (like BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT)
  47301. * @param generateMipMaps defines if the engine should generate the mip levels
  47302. * @param invertY defines if data must be stored with Y axis inverted
  47303. * @param samplingMode defines the required sampling mode (like BABYLON.Texture.NEAREST_SAMPLINGMODE)
  47304. * @param compression defines the compression used (null by default)
  47305. */
  47306. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  47307. /**
  47308. * Updates the raw cube texture.
  47309. * @param data defines the data to store
  47310. * @param format defines the data format
  47311. * @param type defines the type fo the data (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  47312. * @param invertY defines if data must be stored with Y axis inverted
  47313. * @param compression defines the compression used (null by default)
  47314. * @param level defines which level of the texture to update
  47315. */
  47316. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  47317. /**
  47318. * Updates a raw cube texture with RGBD encoded data.
  47319. * @param data defines the array of data [mipmap][face] to use to create each face
  47320. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  47321. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47322. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47323. * @returns a promsie that resolves when the operation is complete
  47324. */
  47325. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  47326. /**
  47327. * Clones the raw cube texture.
  47328. * @return a new cube texture
  47329. */
  47330. clone(): CubeTexture;
  47331. /** @hidden */
  47332. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47333. }
  47334. }
  47335. declare module BABYLON {
  47336. /**
  47337. * Raw texture can help creating a texture directly from an array of data.
  47338. * This can be super useful if you either get the data from an uncompressed source or
  47339. * if you wish to create your texture pixel by pixel.
  47340. */
  47341. class RawTexture extends Texture {
  47342. /**
  47343. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47344. */
  47345. format: number;
  47346. private _engine;
  47347. /**
  47348. * Instantiates a new RawTexture.
  47349. * Raw texture can help creating a texture directly from an array of data.
  47350. * This can be super useful if you either get the data from an uncompressed source or
  47351. * if you wish to create your texture pixel by pixel.
  47352. * @param data define the array of data to use to create the texture
  47353. * @param width define the width of the texture
  47354. * @param height define the height of the texture
  47355. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47356. * @param scene define the scene the texture belongs to
  47357. * @param generateMipMaps define whether mip maps should be generated or not
  47358. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47359. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47360. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47361. */
  47362. constructor(data: ArrayBufferView, width: number, height: number,
  47363. /**
  47364. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  47365. */
  47366. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  47367. /**
  47368. * Updates the texture underlying data.
  47369. * @param data Define the new data of the texture
  47370. */
  47371. update(data: ArrayBufferView): void;
  47372. /**
  47373. * Creates a luminance texture from some data.
  47374. * @param data Define the texture data
  47375. * @param width Define the width of the texture
  47376. * @param height Define the height of the texture
  47377. * @param scene Define the scene the texture belongs to
  47378. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47379. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47380. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47381. * @returns the luminance texture
  47382. */
  47383. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47384. /**
  47385. * Creates a luminance alpha texture from some data.
  47386. * @param data Define the texture data
  47387. * @param width Define the width of the texture
  47388. * @param height Define the height of the texture
  47389. * @param scene Define the scene the texture belongs to
  47390. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47391. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47392. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47393. * @returns the luminance alpha texture
  47394. */
  47395. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47396. /**
  47397. * Creates an alpha texture from some data.
  47398. * @param data Define the texture data
  47399. * @param width Define the width of the texture
  47400. * @param height Define the height of the texture
  47401. * @param scene Define the scene the texture belongs to
  47402. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47403. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47404. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47405. * @returns the alpha texture
  47406. */
  47407. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  47408. /**
  47409. * Creates a RGB texture from some data.
  47410. * @param data Define the texture data
  47411. * @param width Define the width of the texture
  47412. * @param height Define the height of the texture
  47413. * @param scene Define the scene the texture belongs to
  47414. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47415. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47416. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47417. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47418. * @returns the RGB alpha texture
  47419. */
  47420. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47421. /**
  47422. * Creates a RGBA texture from some data.
  47423. * @param data Define the texture data
  47424. * @param width Define the width of the texture
  47425. * @param height Define the height of the texture
  47426. * @param scene Define the scene the texture belongs to
  47427. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47428. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47429. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47430. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47431. * @returns the RGBA texture
  47432. */
  47433. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47434. /**
  47435. * Creates a R texture from some data.
  47436. * @param data Define the texture data
  47437. * @param width Define the width of the texture
  47438. * @param height Define the height of the texture
  47439. * @param scene Define the scene the texture belongs to
  47440. * @param generateMipMaps Define whether or not to create mip maps for the texture
  47441. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  47442. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  47443. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  47444. * @returns the R texture
  47445. */
  47446. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  47447. }
  47448. }
  47449. declare module BABYLON {
  47450. /**
  47451. * Class used to store 3D textures containing user data
  47452. */
  47453. class RawTexture3D extends Texture {
  47454. /** Gets or sets the texture format to use */
  47455. format: number;
  47456. private _engine;
  47457. /**
  47458. * Create a new RawTexture3D
  47459. * @param data defines the data of the texture
  47460. * @param width defines the width of the texture
  47461. * @param height defines the height of the texture
  47462. * @param depth defines the depth of the texture
  47463. * @param format defines the texture format to use
  47464. * @param scene defines the hosting scene
  47465. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  47466. * @param invertY defines if texture must be stored with Y axis inverted
  47467. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  47468. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  47469. */
  47470. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  47471. /** Gets or sets the texture format to use */
  47472. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  47473. /**
  47474. * Update the texture with new data
  47475. * @param data defines the data to store in the texture
  47476. */
  47477. update(data: ArrayBufferView): void;
  47478. }
  47479. }
  47480. declare module BABYLON {
  47481. /**
  47482. * Creates a refraction texture used by refraction channel of the standard material.
  47483. * It is like a mirror but to see through a material.
  47484. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47485. */
  47486. class RefractionTexture extends RenderTargetTexture {
  47487. /**
  47488. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  47489. * It is possible to directly set the refractionPlane by directly using a BABYLON.Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the refractionPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the refractor as stated in the doc.
  47490. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47491. */
  47492. refractionPlane: Plane;
  47493. /**
  47494. * Define how deep under the surface we should see.
  47495. */
  47496. depth: number;
  47497. /**
  47498. * Creates a refraction texture used by refraction channel of the standard material.
  47499. * It is like a mirror but to see through a material.
  47500. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  47501. * @param name Define the texture name
  47502. * @param size Define the size of the underlying texture
  47503. * @param scene Define the scene the refraction belongs to
  47504. * @param generateMipMaps Define if we need to generate mips level for the refraction
  47505. */
  47506. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  47507. /**
  47508. * Clone the refraction texture.
  47509. * @returns the cloned texture
  47510. */
  47511. clone(): RefractionTexture;
  47512. /**
  47513. * Serialize the texture to a JSON representation you could use in Parse later on
  47514. * @returns the serialized JSON representation
  47515. */
  47516. serialize(): any;
  47517. }
  47518. }
  47519. declare module BABYLON {
  47520. /**
  47521. * This Helps creating a texture that will be created from a camera in your scene.
  47522. * It is basically a dynamic texture that could be used to create special effects for instance.
  47523. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  47524. */
  47525. class RenderTargetTexture extends Texture {
  47526. isCube: boolean;
  47527. /**
  47528. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  47529. */
  47530. static readonly REFRESHRATE_RENDER_ONCE: number;
  47531. /**
  47532. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  47533. */
  47534. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  47535. /**
  47536. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  47537. * the central point of your effect and can save a lot of performances.
  47538. */
  47539. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  47540. /**
  47541. * Use this predicate to dynamically define the list of mesh you want to render.
  47542. * If set, the renderList property will be overwritten.
  47543. */
  47544. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  47545. private _renderList;
  47546. /**
  47547. * Use this list to define the list of mesh you want to render.
  47548. */
  47549. renderList: Nullable<Array<AbstractMesh>>;
  47550. private _hookArray;
  47551. /**
  47552. * Define if particles should be rendered in your texture.
  47553. */
  47554. renderParticles: boolean;
  47555. /**
  47556. * Define if sprites should be rendered in your texture.
  47557. */
  47558. renderSprites: boolean;
  47559. /**
  47560. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  47561. */
  47562. coordinatesMode: number;
  47563. /**
  47564. * Define the camera used to render the texture.
  47565. */
  47566. activeCamera: Nullable<Camera>;
  47567. /**
  47568. * Override the render function of the texture with your own one.
  47569. */
  47570. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  47571. /**
  47572. * Define if camera post processes should be use while rendering the texture.
  47573. */
  47574. useCameraPostProcesses: boolean;
  47575. /**
  47576. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  47577. */
  47578. ignoreCameraViewport: boolean;
  47579. private _postProcessManager;
  47580. private _postProcesses;
  47581. private _resizeObserver;
  47582. /**
  47583. * An event triggered when the texture is unbind.
  47584. */
  47585. onBeforeBindObservable: Observable<RenderTargetTexture>;
  47586. /**
  47587. * An event triggered when the texture is unbind.
  47588. */
  47589. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  47590. private _onAfterUnbindObserver;
  47591. /**
  47592. * Set a after unbind callback in the texture.
  47593. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  47594. */
  47595. onAfterUnbind: () => void;
  47596. /**
  47597. * An event triggered before rendering the texture
  47598. */
  47599. onBeforeRenderObservable: Observable<number>;
  47600. private _onBeforeRenderObserver;
  47601. /**
  47602. * Set a before render callback in the texture.
  47603. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  47604. */
  47605. onBeforeRender: (faceIndex: number) => void;
  47606. /**
  47607. * An event triggered after rendering the texture
  47608. */
  47609. onAfterRenderObservable: Observable<number>;
  47610. private _onAfterRenderObserver;
  47611. /**
  47612. * Set a after render callback in the texture.
  47613. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  47614. */
  47615. onAfterRender: (faceIndex: number) => void;
  47616. /**
  47617. * An event triggered after the texture clear
  47618. */
  47619. onClearObservable: Observable<Engine>;
  47620. private _onClearObserver;
  47621. /**
  47622. * Set a clear callback in the texture.
  47623. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  47624. */
  47625. onClear: (Engine: Engine) => void;
  47626. /**
  47627. * Define the clear color of the Render Target if it should be different from the scene.
  47628. */
  47629. clearColor: Color4;
  47630. protected _size: number | {
  47631. width: number;
  47632. height: number;
  47633. };
  47634. protected _initialSizeParameter: number | {
  47635. width: number;
  47636. height: number;
  47637. } | {
  47638. ratio: number;
  47639. };
  47640. protected _sizeRatio: Nullable<number>;
  47641. /** @hidden */
  47642. _generateMipMaps: boolean;
  47643. protected _renderingManager: RenderingManager;
  47644. /** @hidden */
  47645. _waitingRenderList: string[];
  47646. protected _doNotChangeAspectRatio: boolean;
  47647. protected _currentRefreshId: number;
  47648. protected _refreshRate: number;
  47649. protected _textureMatrix: Matrix;
  47650. protected _samples: number;
  47651. protected _renderTargetOptions: RenderTargetCreationOptions;
  47652. /**
  47653. * Gets render target creation options that were used.
  47654. */
  47655. readonly renderTargetOptions: RenderTargetCreationOptions;
  47656. protected _engine: Engine;
  47657. protected _onRatioRescale(): void;
  47658. /**
  47659. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  47660. * It must define where the camera used to render the texture is set
  47661. */
  47662. boundingBoxPosition: Vector3;
  47663. private _boundingBoxSize;
  47664. /**
  47665. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  47666. * When defined, the cubemap will switch to local mode
  47667. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47668. * @example https://www.babylonjs-playground.com/#RNASML
  47669. */
  47670. boundingBoxSize: Vector3;
  47671. /**
  47672. * In case the RTT has been created with a depth texture, get the associated
  47673. * depth texture.
  47674. * Otherwise, return null.
  47675. */
  47676. depthStencilTexture: Nullable<InternalTexture>;
  47677. /**
  47678. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  47679. * or used a shadow, depth texture...
  47680. * @param name The friendly name of the texture
  47681. * @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)
  47682. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  47683. * @param generateMipMaps True if mip maps need to be generated after render.
  47684. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  47685. * @param type The type of the buffer in the RTT (int, half float, float...)
  47686. * @param isCube True if a cube texture needs to be created
  47687. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  47688. * @param generateDepthBuffer True to generate a depth buffer
  47689. * @param generateStencilBuffer True to generate a stencil buffer
  47690. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  47691. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  47692. * @param delayAllocation if the texture allocation should be delayed (default: false)
  47693. */
  47694. constructor(name: string, size: number | {
  47695. width: number;
  47696. height: number;
  47697. } | {
  47698. ratio: number;
  47699. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  47700. /**
  47701. * Creates a depth stencil texture.
  47702. * This is only available in WebGL 2 or with the depth texture extension available.
  47703. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  47704. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  47705. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  47706. */
  47707. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  47708. private _processSizeParameter;
  47709. /**
  47710. * Define the number of samples to use in case of MSAA.
  47711. * It defaults to one meaning no MSAA has been enabled.
  47712. */
  47713. samples: number;
  47714. /**
  47715. * Resets the refresh counter of the texture and start bak from scratch.
  47716. * Could be usefull to regenerate the texture if it is setup to render only once.
  47717. */
  47718. resetRefreshCounter(): void;
  47719. /**
  47720. * Define the refresh rate of the texture or the rendering frequency.
  47721. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  47722. */
  47723. refreshRate: number;
  47724. /**
  47725. * Adds a post process to the render target rendering passes.
  47726. * @param postProcess define the post process to add
  47727. */
  47728. addPostProcess(postProcess: PostProcess): void;
  47729. /**
  47730. * Clear all the post processes attached to the render target
  47731. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  47732. */
  47733. clearPostProcesses(dispose?: boolean): void;
  47734. /**
  47735. * Remove one of the post process from the list of attached post processes to the texture
  47736. * @param postProcess define the post process to remove from the list
  47737. */
  47738. removePostProcess(postProcess: PostProcess): void;
  47739. /** @hidden */
  47740. _shouldRender(): boolean;
  47741. /**
  47742. * Gets the actual render size of the texture.
  47743. * @returns the width of the render size
  47744. */
  47745. getRenderSize(): number;
  47746. /**
  47747. * Gets the actual render width of the texture.
  47748. * @returns the width of the render size
  47749. */
  47750. getRenderWidth(): number;
  47751. /**
  47752. * Gets the actual render height of the texture.
  47753. * @returns the height of the render size
  47754. */
  47755. getRenderHeight(): number;
  47756. /**
  47757. * Get if the texture can be rescaled or not.
  47758. */
  47759. readonly canRescale: boolean;
  47760. /**
  47761. * Resize the texture using a ratio.
  47762. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  47763. */
  47764. scale(ratio: number): void;
  47765. /**
  47766. * Get the texture reflection matrix used to rotate/transform the reflection.
  47767. * @returns the reflection matrix
  47768. */
  47769. getReflectionTextureMatrix(): Matrix;
  47770. /**
  47771. * Resize the texture to a new desired size.
  47772. * Be carrefull as it will recreate all the data in the new texture.
  47773. * @param size Define the new size. It can be:
  47774. * - a number for squared texture,
  47775. * - an object containing { width: number, height: number }
  47776. * - or an object containing a ratio { ratio: number }
  47777. */
  47778. resize(size: number | {
  47779. width: number;
  47780. height: number;
  47781. } | {
  47782. ratio: number;
  47783. }): void;
  47784. /**
  47785. * Renders all the objects from the render list into the texture.
  47786. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  47787. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  47788. */
  47789. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  47790. private _bestReflectionRenderTargetDimension;
  47791. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47792. private renderToTarget;
  47793. /**
  47794. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47795. * This allowed control for front to back rendering or reversly depending of the special needs.
  47796. *
  47797. * @param renderingGroupId The rendering group id corresponding to its index
  47798. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47799. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47800. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47801. */
  47802. 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;
  47803. /**
  47804. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47805. *
  47806. * @param renderingGroupId The rendering group id corresponding to its index
  47807. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47808. */
  47809. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47810. /**
  47811. * Clones the texture.
  47812. * @returns the cloned texture
  47813. */
  47814. clone(): RenderTargetTexture;
  47815. /**
  47816. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  47817. * @returns The JSON representation of the texture
  47818. */
  47819. serialize(): any;
  47820. /**
  47821. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  47822. */
  47823. disposeFramebufferObjects(): void;
  47824. /**
  47825. * Dispose the texture and release its associated resources.
  47826. */
  47827. dispose(): void;
  47828. /** @hidden */
  47829. _rebuild(): void;
  47830. /**
  47831. * Clear the info related to rendering groups preventing retention point in material dispose.
  47832. */
  47833. freeRenderingGroups(): void;
  47834. }
  47835. }
  47836. declare module BABYLON {
  47837. /**
  47838. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  47839. * @see http://doc.babylonjs.com/babylon101/materials#texture
  47840. */
  47841. class Texture extends BaseTexture {
  47842. /** nearest is mag = nearest and min = nearest and mip = linear */
  47843. static readonly NEAREST_SAMPLINGMODE: number;
  47844. /** nearest is mag = nearest and min = nearest and mip = linear */
  47845. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  47846. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47847. static readonly BILINEAR_SAMPLINGMODE: number;
  47848. /** Bilinear is mag = linear and min = linear and mip = nearest */
  47849. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  47850. /** Trilinear is mag = linear and min = linear and mip = linear */
  47851. static readonly TRILINEAR_SAMPLINGMODE: number;
  47852. /** Trilinear is mag = linear and min = linear and mip = linear */
  47853. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  47854. /** mag = nearest and min = nearest and mip = nearest */
  47855. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  47856. /** mag = nearest and min = linear and mip = nearest */
  47857. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  47858. /** mag = nearest and min = linear and mip = linear */
  47859. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  47860. /** mag = nearest and min = linear and mip = none */
  47861. static readonly NEAREST_LINEAR: number;
  47862. /** mag = nearest and min = nearest and mip = none */
  47863. static readonly NEAREST_NEAREST: number;
  47864. /** mag = linear and min = nearest and mip = nearest */
  47865. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  47866. /** mag = linear and min = nearest and mip = linear */
  47867. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  47868. /** mag = linear and min = linear and mip = none */
  47869. static readonly LINEAR_LINEAR: number;
  47870. /** mag = linear and min = nearest and mip = none */
  47871. static readonly LINEAR_NEAREST: number;
  47872. /** Explicit coordinates mode */
  47873. static readonly EXPLICIT_MODE: number;
  47874. /** Spherical coordinates mode */
  47875. static readonly SPHERICAL_MODE: number;
  47876. /** Planar coordinates mode */
  47877. static readonly PLANAR_MODE: number;
  47878. /** Cubic coordinates mode */
  47879. static readonly CUBIC_MODE: number;
  47880. /** Projection coordinates mode */
  47881. static readonly PROJECTION_MODE: number;
  47882. /** Inverse Cubic coordinates mode */
  47883. static readonly SKYBOX_MODE: number;
  47884. /** Inverse Cubic coordinates mode */
  47885. static readonly INVCUBIC_MODE: number;
  47886. /** Equirectangular coordinates mode */
  47887. static readonly EQUIRECTANGULAR_MODE: number;
  47888. /** Equirectangular Fixed coordinates mode */
  47889. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  47890. /** Equirectangular Fixed Mirrored coordinates mode */
  47891. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  47892. /** Texture is not repeating outside of 0..1 UVs */
  47893. static readonly CLAMP_ADDRESSMODE: number;
  47894. /** Texture is repeating outside of 0..1 UVs */
  47895. static readonly WRAP_ADDRESSMODE: number;
  47896. /** Texture is repeating and mirrored */
  47897. static readonly MIRROR_ADDRESSMODE: number;
  47898. /**
  47899. * 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
  47900. */
  47901. static UseSerializedUrlIfAny: boolean;
  47902. /**
  47903. * Define the url of the texture.
  47904. */
  47905. url: Nullable<string>;
  47906. /**
  47907. * Define an offset on the texture to offset the u coordinates of the UVs
  47908. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47909. */
  47910. uOffset: number;
  47911. /**
  47912. * Define an offset on the texture to offset the v coordinates of the UVs
  47913. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  47914. */
  47915. vOffset: number;
  47916. /**
  47917. * Define an offset on the texture to scale the u coordinates of the UVs
  47918. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47919. */
  47920. uScale: number;
  47921. /**
  47922. * Define an offset on the texture to scale the v coordinates of the UVs
  47923. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  47924. */
  47925. vScale: number;
  47926. /**
  47927. * Define an offset on the texture to rotate around the u coordinates of the UVs
  47928. * @see http://doc.babylonjs.com/how_to/more_materials
  47929. */
  47930. uAng: number;
  47931. /**
  47932. * Define an offset on the texture to rotate around the v coordinates of the UVs
  47933. * @see http://doc.babylonjs.com/how_to/more_materials
  47934. */
  47935. vAng: number;
  47936. /**
  47937. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  47938. * @see http://doc.babylonjs.com/how_to/more_materials
  47939. */
  47940. wAng: number;
  47941. /**
  47942. * Defines the center of rotation (U)
  47943. */
  47944. uRotationCenter: number;
  47945. /**
  47946. * Defines the center of rotation (V)
  47947. */
  47948. vRotationCenter: number;
  47949. /**
  47950. * Defines the center of rotation (W)
  47951. */
  47952. wRotationCenter: number;
  47953. /**
  47954. * Are mip maps generated for this texture or not.
  47955. */
  47956. readonly noMipmap: boolean;
  47957. private _noMipmap;
  47958. /** @hidden */
  47959. _invertY: boolean;
  47960. private _rowGenerationMatrix;
  47961. private _cachedTextureMatrix;
  47962. private _projectionModeMatrix;
  47963. private _t0;
  47964. private _t1;
  47965. private _t2;
  47966. private _cachedUOffset;
  47967. private _cachedVOffset;
  47968. private _cachedUScale;
  47969. private _cachedVScale;
  47970. private _cachedUAng;
  47971. private _cachedVAng;
  47972. private _cachedWAng;
  47973. private _cachedProjectionMatrixId;
  47974. private _cachedCoordinatesMode;
  47975. /** @hidden */
  47976. _samplingMode: number;
  47977. /** @hidden */
  47978. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  47979. private _deleteBuffer;
  47980. protected _format: Nullable<number>;
  47981. private _delayedOnLoad;
  47982. private _delayedOnError;
  47983. /**
  47984. * Observable triggered once the texture has been loaded.
  47985. */
  47986. onLoadObservable: Observable<Texture>;
  47987. protected _isBlocking: boolean;
  47988. /**
  47989. * Is the texture preventing material to render while loading.
  47990. * If false, a default texture will be used instead of the loading one during the preparation step.
  47991. */
  47992. isBlocking: boolean;
  47993. /**
  47994. * Get the current sampling mode associated with the texture.
  47995. */
  47996. readonly samplingMode: number;
  47997. /**
  47998. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  47999. */
  48000. readonly invertY: boolean;
  48001. /**
  48002. * Instantiates a new texture.
  48003. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  48004. * @see http://doc.babylonjs.com/babylon101/materials#texture
  48005. * @param url define the url of the picture to load as a texture
  48006. * @param scene define the scene the texture will belong to
  48007. * @param noMipmap define if the texture will require mip maps or not
  48008. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48009. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48010. * @param onLoad define a callback triggered when the texture has been loaded
  48011. * @param onError define a callback triggered when an error occurred during the loading session
  48012. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48013. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48014. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48015. */
  48016. 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);
  48017. /**
  48018. * Update the url (and optional buffer) of this texture if url was null during construction.
  48019. * @param url the url of the texture
  48020. * @param buffer the buffer of the texture (defaults to null)
  48021. */
  48022. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>): void;
  48023. /**
  48024. * Finish the loading sequence of a texture flagged as delayed load.
  48025. * @hidden
  48026. */
  48027. delayLoad(): void;
  48028. /**
  48029. * Update the sampling mode of the texture.
  48030. * Default is Trilinear mode.
  48031. *
  48032. * | Value | Type | Description |
  48033. * | ----- | ------------------ | ----------- |
  48034. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  48035. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  48036. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  48037. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  48038. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  48039. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  48040. * | 7 | NEAREST_LINEAR | |
  48041. * | 8 | NEAREST_NEAREST | |
  48042. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  48043. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  48044. * | 11 | LINEAR_LINEAR | |
  48045. * | 12 | LINEAR_NEAREST | |
  48046. *
  48047. * > _mag_: magnification filter (close to the viewer)
  48048. * > _min_: minification filter (far from the viewer)
  48049. * > _mip_: filter used between mip map levels
  48050. *@param samplingMode Define the new sampling mode of the texture
  48051. */
  48052. updateSamplingMode(samplingMode: number): void;
  48053. private _prepareRowForTextureGeneration;
  48054. /**
  48055. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  48056. * @returns the transform matrix of the texture.
  48057. */
  48058. getTextureMatrix(): Matrix;
  48059. /**
  48060. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  48061. * @returns The reflection texture transform
  48062. */
  48063. getReflectionTextureMatrix(): Matrix;
  48064. /**
  48065. * Clones the texture.
  48066. * @returns the cloned texture
  48067. */
  48068. clone(): Texture;
  48069. /**
  48070. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  48071. * @returns The JSON representation of the texture
  48072. */
  48073. serialize(): any;
  48074. /**
  48075. * Get the current class name of the texture usefull for serialization or dynamic coding.
  48076. * @returns "Texture"
  48077. */
  48078. getClassName(): string;
  48079. /**
  48080. * Dispose the texture and release its associated resources.
  48081. */
  48082. dispose(): void;
  48083. /**
  48084. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  48085. * @param parsedTexture Define the JSON representation of the texture
  48086. * @param scene Define the scene the parsed texture should be instantiated in
  48087. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48088. * @returns The parsed texture if successful
  48089. */
  48090. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  48091. /**
  48092. * Creates a texture from its base 64 representation.
  48093. * @param data Define the base64 payload without the data: prefix
  48094. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48095. * @param scene Define the scene the texture should belong to
  48096. * @param noMipmap Forces the texture to not create mip map information if true
  48097. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48098. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48099. * @param onLoad define a callback triggered when the texture has been loaded
  48100. * @param onError define a callback triggered when an error occurred during the loading session
  48101. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48102. * @returns the created texture
  48103. */
  48104. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  48105. /**
  48106. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  48107. * @param data Define the base64 payload without the data: prefix
  48108. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  48109. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  48110. * @param scene Define the scene the texture should belong to
  48111. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  48112. * @param noMipmap Forces the texture to not create mip map information if true
  48113. * @param invertY define if the texture needs to be inverted on the y axis during loading
  48114. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  48115. * @param onLoad define a callback triggered when the texture has been loaded
  48116. * @param onError define a callback triggered when an error occurred during the loading session
  48117. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  48118. * @returns the created texture
  48119. */
  48120. 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;
  48121. }
  48122. }
  48123. declare module BABYLON {
  48124. /**
  48125. * Settings for finer control over video usage
  48126. */
  48127. interface VideoTextureSettings {
  48128. /**
  48129. * Applies `autoplay` to video, if specified
  48130. */
  48131. autoPlay?: boolean;
  48132. /**
  48133. * Applies `loop` to video, if specified
  48134. */
  48135. loop?: boolean;
  48136. /**
  48137. * Automatically updates internal texture from video at every frame in the render loop
  48138. */
  48139. autoUpdateTexture: boolean;
  48140. /**
  48141. * Image src displayed during the video loading or until the user interacts with the video.
  48142. */
  48143. poster?: string;
  48144. }
  48145. /**
  48146. * If you want to display a video in your scene, this is the special texture for that.
  48147. * This special texture works similar to other textures, with the exception of a few parameters.
  48148. * @see https://doc.babylonjs.com/how_to/video_texture
  48149. */
  48150. class VideoTexture extends Texture {
  48151. /**
  48152. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  48153. */
  48154. readonly autoUpdateTexture: boolean;
  48155. /**
  48156. * The video instance used by the texture internally
  48157. */
  48158. readonly video: HTMLVideoElement;
  48159. private _onUserActionRequestedObservable;
  48160. /**
  48161. * Event triggerd when a dom action is required by the user to play the video.
  48162. * This happens due to recent changes in browser policies preventing video to auto start.
  48163. */
  48164. readonly onUserActionRequestedObservable: Observable<Texture>;
  48165. private _generateMipMaps;
  48166. private _engine;
  48167. private _stillImageCaptured;
  48168. private _poster;
  48169. /**
  48170. * Creates a video texture.
  48171. * If you want to display a video in your scene, this is the special texture for that.
  48172. * This special texture works similar to other textures, with the exception of a few parameters.
  48173. * @see https://doc.babylonjs.com/how_to/video_texture
  48174. * @param name optional name, will detect from video source, if not defined
  48175. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  48176. * @param scene is obviously the current scene.
  48177. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  48178. * @param invertY is false by default but can be used to invert video on Y axis
  48179. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  48180. * @param settings allows finer control over video usage
  48181. */
  48182. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  48183. private _getName;
  48184. private _getVideo;
  48185. private _createInternalTexture;
  48186. private reset;
  48187. /**
  48188. * @hidden Internal method to initiate `update`.
  48189. */
  48190. _rebuild(): void;
  48191. /**
  48192. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  48193. */
  48194. update(): void;
  48195. /**
  48196. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  48197. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  48198. */
  48199. updateTexture(isVisible: boolean): void;
  48200. protected _updateInternalTexture: (e?: Event | undefined) => void;
  48201. /**
  48202. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  48203. * @param url New url.
  48204. */
  48205. updateURL(url: string): void;
  48206. /**
  48207. * Dispose the texture and release its associated resources.
  48208. */
  48209. dispose(): void;
  48210. /**
  48211. * Creates a video texture straight from your WebCam video feed.
  48212. * @param scene Define the scene the texture should be created in
  48213. * @param onReady Define a callback to triggered once the texture will be ready
  48214. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  48215. */
  48216. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  48217. minWidth: number;
  48218. maxWidth: number;
  48219. minHeight: number;
  48220. maxHeight: number;
  48221. deviceId: string;
  48222. }): void;
  48223. }
  48224. }
  48225. declare var DracoDecoderModule: any;
  48226. declare var WebAssembly: any;
  48227. declare module BABYLON {
  48228. /**
  48229. * Configuration for Draco compression
  48230. */
  48231. interface IDracoCompressionConfiguration {
  48232. /**
  48233. * Configuration for the decoder.
  48234. */
  48235. decoder?: {
  48236. /**
  48237. * The url to the WebAssembly module.
  48238. */
  48239. wasmUrl?: string;
  48240. /**
  48241. * The url to the WebAssembly binary.
  48242. */
  48243. wasmBinaryUrl?: string;
  48244. /**
  48245. * The url to the fallback JavaScript module.
  48246. */
  48247. fallbackUrl?: string;
  48248. };
  48249. }
  48250. /**
  48251. * Draco compression (https://google.github.io/draco/)
  48252. *
  48253. * This class wraps the Draco module.
  48254. *
  48255. * **Encoder**
  48256. *
  48257. * The encoder is not currently implemented.
  48258. *
  48259. * **Decoder**
  48260. *
  48261. * 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.
  48262. *
  48263. * To update the configuration, use the following code:
  48264. * ```javascript
  48265. * BABYLON.DracoCompression.Configuration = {
  48266. * decoder: {
  48267. * wasmUrl: "<url to the WebAssembly library>",
  48268. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48269. * fallbackUrl: "<url to the fallback JavaScript library>",
  48270. * }
  48271. * };
  48272. * ```
  48273. *
  48274. * 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.
  48275. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48276. * Use `BABYLON.DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48277. *
  48278. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48279. * ```javascript
  48280. * var dracoCompression = new BABYLON.DracoCompression();
  48281. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48282. * [BABYLON.VertexBuffer.PositionKind]: 0
  48283. * });
  48284. * ```
  48285. *
  48286. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48287. */
  48288. class DracoCompression implements IDisposable {
  48289. private static _DecoderModulePromise;
  48290. /**
  48291. * The configuration. Defaults to the following urls:
  48292. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48293. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48294. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48295. */
  48296. static Configuration: IDracoCompressionConfiguration;
  48297. /**
  48298. * Returns true if the decoder is available.
  48299. */
  48300. static readonly DecoderAvailable: boolean;
  48301. /**
  48302. * Constructor
  48303. */
  48304. constructor();
  48305. /**
  48306. * Stop all async operations and release resources.
  48307. */
  48308. dispose(): void;
  48309. /**
  48310. * Decode Draco compressed mesh data to vertex data.
  48311. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48312. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48313. * @returns A promise that resolves with the decoded vertex data
  48314. */
  48315. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48316. [kind: string]: number;
  48317. }): Promise<VertexData>;
  48318. private static _GetDecoderModule;
  48319. private static _LoadScriptAsync;
  48320. private static _LoadFileAsync;
  48321. }
  48322. }
  48323. declare module BABYLON {
  48324. /**
  48325. * Particle emitter emitting particles from the inside of a box.
  48326. * It emits the particles randomly between 2 given directions.
  48327. */
  48328. class BoxParticleEmitter implements IParticleEmitterType {
  48329. /**
  48330. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48331. */
  48332. direction1: Vector3;
  48333. /**
  48334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48335. */
  48336. direction2: Vector3;
  48337. /**
  48338. * 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.
  48339. */
  48340. minEmitBox: Vector3;
  48341. /**
  48342. * 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.
  48343. */
  48344. maxEmitBox: Vector3;
  48345. /**
  48346. * Creates a new instance BoxParticleEmitter
  48347. */
  48348. constructor();
  48349. /**
  48350. * Called by the particle System when the direction is computed for the created particle.
  48351. * @param worldMatrix is the world matrix of the particle system
  48352. * @param directionToUpdate is the direction vector to update with the result
  48353. * @param particle is the particle we are computed the direction for
  48354. */
  48355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48356. /**
  48357. * Called by the particle System when the position is computed for the created particle.
  48358. * @param worldMatrix is the world matrix of the particle system
  48359. * @param positionToUpdate is the position vector to update with the result
  48360. * @param particle is the particle we are computed the position for
  48361. */
  48362. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48363. /**
  48364. * Clones the current emitter and returns a copy of it
  48365. * @returns the new emitter
  48366. */
  48367. clone(): BoxParticleEmitter;
  48368. /**
  48369. * Called by the GPUParticleSystem to setup the update shader
  48370. * @param effect defines the update shader
  48371. */
  48372. applyToShader(effect: Effect): void;
  48373. /**
  48374. * Returns a string to use to update the GPU particles update shader
  48375. * @returns a string containng the defines string
  48376. */
  48377. getEffectDefines(): string;
  48378. /**
  48379. * Returns the string "BoxParticleEmitter"
  48380. * @returns a string containing the class name
  48381. */
  48382. getClassName(): string;
  48383. /**
  48384. * Serializes the particle system to a JSON object.
  48385. * @returns the JSON object
  48386. */
  48387. serialize(): any;
  48388. /**
  48389. * Parse properties from a JSON object
  48390. * @param serializationObject defines the JSON object
  48391. */
  48392. parse(serializationObject: any): void;
  48393. }
  48394. }
  48395. declare module BABYLON {
  48396. /**
  48397. * Particle emitter emitting particles from the inside of a cone.
  48398. * It emits the particles alongside the cone volume from the base to the particle.
  48399. * The emission direction might be randomized.
  48400. */
  48401. class ConeParticleEmitter implements IParticleEmitterType {
  48402. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48403. directionRandomizer: number;
  48404. private _radius;
  48405. private _angle;
  48406. private _height;
  48407. /**
  48408. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  48409. */
  48410. radiusRange: number;
  48411. /**
  48412. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  48413. */
  48414. heightRange: number;
  48415. /**
  48416. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  48417. */
  48418. emitFromSpawnPointOnly: boolean;
  48419. /**
  48420. * Gets or sets the radius of the emission cone
  48421. */
  48422. radius: number;
  48423. /**
  48424. * Gets or sets the angle of the emission cone
  48425. */
  48426. angle: number;
  48427. private _buildHeight;
  48428. /**
  48429. * Creates a new instance ConeParticleEmitter
  48430. * @param radius the radius of the emission cone (1 by default)
  48431. * @param angles the cone base angle (PI by default)
  48432. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  48433. */
  48434. constructor(radius?: number, angle?: number,
  48435. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  48436. directionRandomizer?: number);
  48437. /**
  48438. * Called by the particle System when the direction is computed for the created particle.
  48439. * @param worldMatrix is the world matrix of the particle system
  48440. * @param directionToUpdate is the direction vector to update with the result
  48441. * @param particle is the particle we are computed the direction for
  48442. */
  48443. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48444. /**
  48445. * Called by the particle System when the position is computed for the created particle.
  48446. * @param worldMatrix is the world matrix of the particle system
  48447. * @param positionToUpdate is the position vector to update with the result
  48448. * @param particle is the particle we are computed the position for
  48449. */
  48450. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48451. /**
  48452. * Clones the current emitter and returns a copy of it
  48453. * @returns the new emitter
  48454. */
  48455. clone(): ConeParticleEmitter;
  48456. /**
  48457. * Called by the GPUParticleSystem to setup the update shader
  48458. * @param effect defines the update shader
  48459. */
  48460. applyToShader(effect: Effect): void;
  48461. /**
  48462. * Returns a string to use to update the GPU particles update shader
  48463. * @returns a string containng the defines string
  48464. */
  48465. getEffectDefines(): string;
  48466. /**
  48467. * Returns the string "ConeParticleEmitter"
  48468. * @returns a string containing the class name
  48469. */
  48470. getClassName(): string;
  48471. /**
  48472. * Serializes the particle system to a JSON object.
  48473. * @returns the JSON object
  48474. */
  48475. serialize(): any;
  48476. /**
  48477. * Parse properties from a JSON object
  48478. * @param serializationObject defines the JSON object
  48479. */
  48480. parse(serializationObject: any): void;
  48481. }
  48482. }
  48483. declare module BABYLON {
  48484. /**
  48485. * Particle emitter emitting particles from the inside of a cylinder.
  48486. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  48487. */
  48488. class CylinderParticleEmitter implements IParticleEmitterType {
  48489. /**
  48490. * The radius of the emission cylinder.
  48491. */
  48492. radius: number;
  48493. /**
  48494. * The height of the emission cylinder.
  48495. */
  48496. height: number;
  48497. /**
  48498. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48499. */
  48500. radiusRange: number;
  48501. /**
  48502. * How much to randomize the particle direction [0-1].
  48503. */
  48504. directionRandomizer: number;
  48505. /**
  48506. * Creates a new instance CylinderParticleEmitter
  48507. * @param radius the radius of the emission cylinder (1 by default)
  48508. * @param height the height of the emission cylinder (1 by default)
  48509. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48510. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48511. */
  48512. constructor(
  48513. /**
  48514. * The radius of the emission cylinder.
  48515. */
  48516. radius?: number,
  48517. /**
  48518. * The height of the emission cylinder.
  48519. */
  48520. height?: number,
  48521. /**
  48522. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48523. */
  48524. radiusRange?: number,
  48525. /**
  48526. * How much to randomize the particle direction [0-1].
  48527. */
  48528. directionRandomizer?: number);
  48529. /**
  48530. * Called by the particle System when the direction is computed for the created particle.
  48531. * @param worldMatrix is the world matrix of the particle system
  48532. * @param directionToUpdate is the direction vector to update with the result
  48533. * @param particle is the particle we are computed the direction for
  48534. */
  48535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48536. /**
  48537. * Called by the particle System when the position is computed for the created particle.
  48538. * @param worldMatrix is the world matrix of the particle system
  48539. * @param positionToUpdate is the position vector to update with the result
  48540. * @param particle is the particle we are computed the position for
  48541. */
  48542. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48543. /**
  48544. * Clones the current emitter and returns a copy of it
  48545. * @returns the new emitter
  48546. */
  48547. clone(): CylinderParticleEmitter;
  48548. /**
  48549. * Called by the GPUParticleSystem to setup the update shader
  48550. * @param effect defines the update shader
  48551. */
  48552. applyToShader(effect: Effect): void;
  48553. /**
  48554. * Returns a string to use to update the GPU particles update shader
  48555. * @returns a string containng the defines string
  48556. */
  48557. getEffectDefines(): string;
  48558. /**
  48559. * Returns the string "CylinderParticleEmitter"
  48560. * @returns a string containing the class name
  48561. */
  48562. getClassName(): string;
  48563. /**
  48564. * Serializes the particle system to a JSON object.
  48565. * @returns the JSON object
  48566. */
  48567. serialize(): any;
  48568. /**
  48569. * Parse properties from a JSON object
  48570. * @param serializationObject defines the JSON object
  48571. */
  48572. parse(serializationObject: any): void;
  48573. }
  48574. /**
  48575. * Particle emitter emitting particles from the inside of a cylinder.
  48576. * It emits the particles randomly between two vectors.
  48577. */
  48578. class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  48579. /**
  48580. * The min limit of the emission direction.
  48581. */
  48582. direction1: Vector3;
  48583. /**
  48584. * The max limit of the emission direction.
  48585. */
  48586. direction2: Vector3;
  48587. /**
  48588. * Creates a new instance CylinderDirectedParticleEmitter
  48589. * @param radius the radius of the emission cylinder (1 by default)
  48590. * @param height the height of the emission cylinder (1 by default)
  48591. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48592. * @param direction1 the min limit of the emission direction (up vector by default)
  48593. * @param direction2 the max limit of the emission direction (up vector by default)
  48594. */
  48595. constructor(radius?: number, height?: number, radiusRange?: number,
  48596. /**
  48597. * The min limit of the emission direction.
  48598. */
  48599. direction1?: Vector3,
  48600. /**
  48601. * The max limit of the emission direction.
  48602. */
  48603. direction2?: Vector3);
  48604. /**
  48605. * Called by the particle System when the direction is computed for the created particle.
  48606. * @param worldMatrix is the world matrix of the particle system
  48607. * @param directionToUpdate is the direction vector to update with the result
  48608. * @param particle is the particle we are computed the direction for
  48609. */
  48610. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48611. /**
  48612. * Clones the current emitter and returns a copy of it
  48613. * @returns the new emitter
  48614. */
  48615. clone(): CylinderDirectedParticleEmitter;
  48616. /**
  48617. * Called by the GPUParticleSystem to setup the update shader
  48618. * @param effect defines the update shader
  48619. */
  48620. applyToShader(effect: Effect): void;
  48621. /**
  48622. * Returns a string to use to update the GPU particles update shader
  48623. * @returns a string containng the defines string
  48624. */
  48625. getEffectDefines(): string;
  48626. /**
  48627. * Returns the string "CylinderDirectedParticleEmitter"
  48628. * @returns a string containing the class name
  48629. */
  48630. getClassName(): string;
  48631. /**
  48632. * Serializes the particle system to a JSON object.
  48633. * @returns the JSON object
  48634. */
  48635. serialize(): any;
  48636. /**
  48637. * Parse properties from a JSON object
  48638. * @param serializationObject defines the JSON object
  48639. */
  48640. parse(serializationObject: any): void;
  48641. }
  48642. }
  48643. declare module BABYLON {
  48644. /**
  48645. * Particle emitter emitting particles from the inside of a hemisphere.
  48646. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  48647. */
  48648. class HemisphericParticleEmitter implements IParticleEmitterType {
  48649. /**
  48650. * The radius of the emission hemisphere.
  48651. */
  48652. radius: number;
  48653. /**
  48654. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48655. */
  48656. radiusRange: number;
  48657. /**
  48658. * How much to randomize the particle direction [0-1].
  48659. */
  48660. directionRandomizer: number;
  48661. /**
  48662. * Creates a new instance HemisphericParticleEmitter
  48663. * @param radius the radius of the emission hemisphere (1 by default)
  48664. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48665. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48666. */
  48667. constructor(
  48668. /**
  48669. * The radius of the emission hemisphere.
  48670. */
  48671. radius?: number,
  48672. /**
  48673. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48674. */
  48675. radiusRange?: number,
  48676. /**
  48677. * How much to randomize the particle direction [0-1].
  48678. */
  48679. directionRandomizer?: number);
  48680. /**
  48681. * Called by the particle System when the direction is computed for the created particle.
  48682. * @param worldMatrix is the world matrix of the particle system
  48683. * @param directionToUpdate is the direction vector to update with the result
  48684. * @param particle is the particle we are computed the direction for
  48685. */
  48686. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48687. /**
  48688. * Called by the particle System when the position is computed for the created particle.
  48689. * @param worldMatrix is the world matrix of the particle system
  48690. * @param positionToUpdate is the position vector to update with the result
  48691. * @param particle is the particle we are computed the position for
  48692. */
  48693. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48694. /**
  48695. * Clones the current emitter and returns a copy of it
  48696. * @returns the new emitter
  48697. */
  48698. clone(): HemisphericParticleEmitter;
  48699. /**
  48700. * Called by the GPUParticleSystem to setup the update shader
  48701. * @param effect defines the update shader
  48702. */
  48703. applyToShader(effect: Effect): void;
  48704. /**
  48705. * Returns a string to use to update the GPU particles update shader
  48706. * @returns a string containng the defines string
  48707. */
  48708. getEffectDefines(): string;
  48709. /**
  48710. * Returns the string "HemisphericParticleEmitter"
  48711. * @returns a string containing the class name
  48712. */
  48713. getClassName(): string;
  48714. /**
  48715. * Serializes the particle system to a JSON object.
  48716. * @returns the JSON object
  48717. */
  48718. serialize(): any;
  48719. /**
  48720. * Parse properties from a JSON object
  48721. * @param serializationObject defines the JSON object
  48722. */
  48723. parse(serializationObject: any): void;
  48724. }
  48725. }
  48726. declare module BABYLON {
  48727. /**
  48728. * Particle emitter represents a volume emitting particles.
  48729. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  48730. */
  48731. interface IParticleEmitterType {
  48732. /**
  48733. * Called by the particle System when the direction is computed for the created particle.
  48734. * @param worldMatrix is the world matrix of the particle system
  48735. * @param directionToUpdate is the direction vector to update with the result
  48736. * @param particle is the particle we are computed the direction for
  48737. */
  48738. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48739. /**
  48740. * Called by the particle System when the position is computed for the created particle.
  48741. * @param worldMatrix is the world matrix of the particle system
  48742. * @param positionToUpdate is the position vector to update with the result
  48743. * @param particle is the particle we are computed the position for
  48744. */
  48745. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48746. /**
  48747. * Clones the current emitter and returns a copy of it
  48748. * @returns the new emitter
  48749. */
  48750. clone(): IParticleEmitterType;
  48751. /**
  48752. * Called by the GPUParticleSystem to setup the update shader
  48753. * @param effect defines the update shader
  48754. */
  48755. applyToShader(effect: Effect): void;
  48756. /**
  48757. * Returns a string to use to update the GPU particles update shader
  48758. * @returns the effect defines string
  48759. */
  48760. getEffectDefines(): string;
  48761. /**
  48762. * Returns a string representing the class name
  48763. * @returns a string containing the class name
  48764. */
  48765. getClassName(): string;
  48766. /**
  48767. * Serializes the particle system to a JSON object.
  48768. * @returns the JSON object
  48769. */
  48770. serialize(): any;
  48771. /**
  48772. * Parse properties from a JSON object
  48773. * @param serializationObject defines the JSON object
  48774. */
  48775. parse(serializationObject: any): void;
  48776. }
  48777. }
  48778. declare module BABYLON {
  48779. /**
  48780. * Particle emitter emitting particles from a point.
  48781. * It emits the particles randomly between 2 given directions.
  48782. */
  48783. class PointParticleEmitter implements IParticleEmitterType {
  48784. /**
  48785. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48786. */
  48787. direction1: Vector3;
  48788. /**
  48789. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  48790. */
  48791. direction2: Vector3;
  48792. /**
  48793. * Creates a new instance PointParticleEmitter
  48794. */
  48795. constructor();
  48796. /**
  48797. * Called by the particle System when the direction is computed for the created particle.
  48798. * @param worldMatrix is the world matrix of the particle system
  48799. * @param directionToUpdate is the direction vector to update with the result
  48800. * @param particle is the particle we are computed the direction for
  48801. */
  48802. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48803. /**
  48804. * Called by the particle System when the position is computed for the created particle.
  48805. * @param worldMatrix is the world matrix of the particle system
  48806. * @param positionToUpdate is the position vector to update with the result
  48807. * @param particle is the particle we are computed the position for
  48808. */
  48809. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48810. /**
  48811. * Clones the current emitter and returns a copy of it
  48812. * @returns the new emitter
  48813. */
  48814. clone(): PointParticleEmitter;
  48815. /**
  48816. * Called by the GPUParticleSystem to setup the update shader
  48817. * @param effect defines the update shader
  48818. */
  48819. applyToShader(effect: Effect): void;
  48820. /**
  48821. * Returns a string to use to update the GPU particles update shader
  48822. * @returns a string containng the defines string
  48823. */
  48824. getEffectDefines(): string;
  48825. /**
  48826. * Returns the string "PointParticleEmitter"
  48827. * @returns a string containing the class name
  48828. */
  48829. getClassName(): string;
  48830. /**
  48831. * Serializes the particle system to a JSON object.
  48832. * @returns the JSON object
  48833. */
  48834. serialize(): any;
  48835. /**
  48836. * Parse properties from a JSON object
  48837. * @param serializationObject defines the JSON object
  48838. */
  48839. parse(serializationObject: any): void;
  48840. }
  48841. }
  48842. declare module BABYLON {
  48843. /**
  48844. * Particle emitter emitting particles from the inside of a sphere.
  48845. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  48846. */
  48847. class SphereParticleEmitter implements IParticleEmitterType {
  48848. /**
  48849. * The radius of the emission sphere.
  48850. */
  48851. radius: number;
  48852. /**
  48853. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48854. */
  48855. radiusRange: number;
  48856. /**
  48857. * How much to randomize the particle direction [0-1].
  48858. */
  48859. directionRandomizer: number;
  48860. /**
  48861. * Creates a new instance SphereParticleEmitter
  48862. * @param radius the radius of the emission sphere (1 by default)
  48863. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  48864. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  48865. */
  48866. constructor(
  48867. /**
  48868. * The radius of the emission sphere.
  48869. */
  48870. radius?: number,
  48871. /**
  48872. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  48873. */
  48874. radiusRange?: number,
  48875. /**
  48876. * How much to randomize the particle direction [0-1].
  48877. */
  48878. directionRandomizer?: number);
  48879. /**
  48880. * Called by the particle System when the direction is computed for the created particle.
  48881. * @param worldMatrix is the world matrix of the particle system
  48882. * @param directionToUpdate is the direction vector to update with the result
  48883. * @param particle is the particle we are computed the direction for
  48884. */
  48885. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48886. /**
  48887. * Called by the particle System when the position is computed for the created particle.
  48888. * @param worldMatrix is the world matrix of the particle system
  48889. * @param positionToUpdate is the position vector to update with the result
  48890. * @param particle is the particle we are computed the position for
  48891. */
  48892. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  48893. /**
  48894. * Clones the current emitter and returns a copy of it
  48895. * @returns the new emitter
  48896. */
  48897. clone(): SphereParticleEmitter;
  48898. /**
  48899. * Called by the GPUParticleSystem to setup the update shader
  48900. * @param effect defines the update shader
  48901. */
  48902. applyToShader(effect: Effect): void;
  48903. /**
  48904. * Returns a string to use to update the GPU particles update shader
  48905. * @returns a string containng the defines string
  48906. */
  48907. getEffectDefines(): string;
  48908. /**
  48909. * Returns the string "SphereParticleEmitter"
  48910. * @returns a string containing the class name
  48911. */
  48912. getClassName(): string;
  48913. /**
  48914. * Serializes the particle system to a JSON object.
  48915. * @returns the JSON object
  48916. */
  48917. serialize(): any;
  48918. /**
  48919. * Parse properties from a JSON object
  48920. * @param serializationObject defines the JSON object
  48921. */
  48922. parse(serializationObject: any): void;
  48923. }
  48924. /**
  48925. * Particle emitter emitting particles from the inside of a sphere.
  48926. * It emits the particles randomly between two vectors.
  48927. */
  48928. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  48929. /**
  48930. * The min limit of the emission direction.
  48931. */
  48932. direction1: Vector3;
  48933. /**
  48934. * The max limit of the emission direction.
  48935. */
  48936. direction2: Vector3;
  48937. /**
  48938. * Creates a new instance SphereDirectedParticleEmitter
  48939. * @param radius the radius of the emission sphere (1 by default)
  48940. * @param direction1 the min limit of the emission direction (up vector by default)
  48941. * @param direction2 the max limit of the emission direction (up vector by default)
  48942. */
  48943. constructor(radius?: number,
  48944. /**
  48945. * The min limit of the emission direction.
  48946. */
  48947. direction1?: Vector3,
  48948. /**
  48949. * The max limit of the emission direction.
  48950. */
  48951. direction2?: Vector3);
  48952. /**
  48953. * Called by the particle System when the direction is computed for the created particle.
  48954. * @param worldMatrix is the world matrix of the particle system
  48955. * @param directionToUpdate is the direction vector to update with the result
  48956. * @param particle is the particle we are computed the direction for
  48957. */
  48958. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  48959. /**
  48960. * Clones the current emitter and returns a copy of it
  48961. * @returns the new emitter
  48962. */
  48963. clone(): SphereDirectedParticleEmitter;
  48964. /**
  48965. * Called by the GPUParticleSystem to setup the update shader
  48966. * @param effect defines the update shader
  48967. */
  48968. applyToShader(effect: Effect): void;
  48969. /**
  48970. * Returns a string to use to update the GPU particles update shader
  48971. * @returns a string containng the defines string
  48972. */
  48973. getEffectDefines(): string;
  48974. /**
  48975. * Returns the string "SphereDirectedParticleEmitter"
  48976. * @returns a string containing the class name
  48977. */
  48978. getClassName(): string;
  48979. /**
  48980. * Serializes the particle system to a JSON object.
  48981. * @returns the JSON object
  48982. */
  48983. serialize(): any;
  48984. /**
  48985. * Parse properties from a JSON object
  48986. * @param serializationObject defines the JSON object
  48987. */
  48988. parse(serializationObject: any): void;
  48989. }
  48990. }
  48991. declare module BABYLON {
  48992. /** @hidden */
  48993. class CannonJSPlugin implements IPhysicsEnginePlugin {
  48994. private _useDeltaForWorldStep;
  48995. world: any;
  48996. name: string;
  48997. private _physicsMaterials;
  48998. private _fixedTimeStep;
  48999. BJSCANNON: any;
  49000. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  49001. setGravity(gravity: Vector3): void;
  49002. setTimeStep(timeStep: number): void;
  49003. getTimeStep(): number;
  49004. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49005. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49006. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49007. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49008. private _processChildMeshes;
  49009. removePhysicsBody(impostor: PhysicsImpostor): void;
  49010. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49011. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49012. private _addMaterial;
  49013. private _checkWithEpsilon;
  49014. private _createShape;
  49015. private _createHeightmap;
  49016. private _minus90X;
  49017. private _plus90X;
  49018. private _tmpPosition;
  49019. private _tmpDeltaPosition;
  49020. private _tmpUnityRotation;
  49021. private _updatePhysicsBodyTransformation;
  49022. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49023. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49024. isSupported(): boolean;
  49025. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49026. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49027. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49028. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49029. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49030. getBodyMass(impostor: PhysicsImpostor): number;
  49031. getBodyFriction(impostor: PhysicsImpostor): number;
  49032. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49033. getBodyRestitution(impostor: PhysicsImpostor): number;
  49034. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49035. sleepBody(impostor: PhysicsImpostor): void;
  49036. wakeUpBody(impostor: PhysicsImpostor): void;
  49037. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49038. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49039. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49040. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49041. getRadius(impostor: PhysicsImpostor): number;
  49042. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49043. dispose(): void;
  49044. private _extendNamespace;
  49045. }
  49046. }
  49047. declare module BABYLON {
  49048. /** @hidden */
  49049. class OimoJSPlugin implements IPhysicsEnginePlugin {
  49050. world: any;
  49051. name: string;
  49052. BJSOIMO: any;
  49053. constructor(iterations?: number);
  49054. setGravity(gravity: Vector3): void;
  49055. setTimeStep(timeStep: number): void;
  49056. getTimeStep(): number;
  49057. private _tmpImpostorsArray;
  49058. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49059. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49060. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49061. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49062. private _tmpPositionVector;
  49063. removePhysicsBody(impostor: PhysicsImpostor): void;
  49064. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49065. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49066. isSupported(): boolean;
  49067. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49068. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49069. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49070. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49071. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49072. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49073. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49074. getBodyMass(impostor: PhysicsImpostor): number;
  49075. getBodyFriction(impostor: PhysicsImpostor): number;
  49076. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49077. getBodyRestitution(impostor: PhysicsImpostor): number;
  49078. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49079. sleepBody(impostor: PhysicsImpostor): void;
  49080. wakeUpBody(impostor: PhysicsImpostor): void;
  49081. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49082. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  49083. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49084. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49085. getRadius(impostor: PhysicsImpostor): number;
  49086. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49087. dispose(): void;
  49088. }
  49089. }
  49090. declare module BABYLON {
  49091. /**
  49092. * This represents a set of one or more post processes in Babylon.
  49093. * A post process can be used to apply a shader to a texture after it is rendered.
  49094. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49095. */
  49096. class PostProcessRenderEffect {
  49097. private _postProcesses;
  49098. private _getPostProcesses;
  49099. private _singleInstance;
  49100. private _cameras;
  49101. private _indicesForCamera;
  49102. /**
  49103. * Name of the effect
  49104. * @hidden
  49105. */
  49106. _name: string;
  49107. /**
  49108. * Instantiates a post process render effect.
  49109. * A post process can be used to apply a shader to a texture after it is rendered.
  49110. * @param engine The engine the effect is tied to
  49111. * @param name The name of the effect
  49112. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  49113. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  49114. */
  49115. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  49116. /**
  49117. * Checks if all the post processes in the effect are supported.
  49118. */
  49119. readonly isSupported: boolean;
  49120. /**
  49121. * Updates the current state of the effect
  49122. * @hidden
  49123. */
  49124. _update(): void;
  49125. /**
  49126. * Attaches the effect on cameras
  49127. * @param cameras The camera to attach to.
  49128. * @hidden
  49129. */
  49130. _attachCameras(cameras: Camera): void;
  49131. /**
  49132. * Attaches the effect on cameras
  49133. * @param cameras The camera to attach to.
  49134. * @hidden
  49135. */
  49136. _attachCameras(cameras: Camera[]): void;
  49137. /**
  49138. * Detatches the effect on cameras
  49139. * @param cameras The camera to detatch from.
  49140. * @hidden
  49141. */
  49142. _detachCameras(cameras: Camera): void;
  49143. /**
  49144. * Detatches the effect on cameras
  49145. * @param cameras The camera to detatch from.
  49146. * @hidden
  49147. */
  49148. _detachCameras(cameras: Camera[]): void;
  49149. /**
  49150. * Enables the effect on given cameras
  49151. * @param cameras The camera to enable.
  49152. * @hidden
  49153. */
  49154. _enable(cameras: Camera): void;
  49155. /**
  49156. * Enables the effect on given cameras
  49157. * @param cameras The camera to enable.
  49158. * @hidden
  49159. */
  49160. _enable(cameras: Nullable<Camera[]>): void;
  49161. /**
  49162. * Disables the effect on the given cameras
  49163. * @param cameras The camera to disable.
  49164. * @hidden
  49165. */
  49166. _disable(cameras: Camera): void;
  49167. /**
  49168. * Disables the effect on the given cameras
  49169. * @param cameras The camera to disable.
  49170. * @hidden
  49171. */
  49172. _disable(cameras: Nullable<Camera[]>): void;
  49173. /**
  49174. * Gets a list of the post processes contained in the effect.
  49175. * @param camera The camera to get the post processes on.
  49176. * @returns The list of the post processes in the effect.
  49177. */
  49178. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  49179. }
  49180. }
  49181. declare module BABYLON {
  49182. /**
  49183. * PostProcessRenderPipeline
  49184. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49185. */
  49186. class PostProcessRenderPipeline {
  49187. private engine;
  49188. private _renderEffects;
  49189. private _renderEffectsForIsolatedPass;
  49190. /**
  49191. * @hidden
  49192. */
  49193. protected _cameras: Camera[];
  49194. /** @hidden */
  49195. _name: string;
  49196. /**
  49197. * Initializes a PostProcessRenderPipeline
  49198. * @param engine engine to add the pipeline to
  49199. * @param name name of the pipeline
  49200. */
  49201. constructor(engine: Engine, name: string);
  49202. /**
  49203. * "PostProcessRenderPipeline"
  49204. * @returns "PostProcessRenderPipeline"
  49205. */
  49206. getClassName(): string;
  49207. /**
  49208. * If all the render effects in the pipeline are support
  49209. */
  49210. readonly isSupported: boolean;
  49211. /**
  49212. * Adds an effect to the pipeline
  49213. * @param renderEffect the effect to add
  49214. */
  49215. addEffect(renderEffect: PostProcessRenderEffect): void;
  49216. /** @hidden */
  49217. _rebuild(): void;
  49218. /** @hidden */
  49219. _enableEffect(renderEffectName: string, cameras: Camera): void;
  49220. /** @hidden */
  49221. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  49222. /** @hidden */
  49223. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49224. /** @hidden */
  49225. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  49226. /** @hidden */
  49227. _attachCameras(cameras: Camera, unique: boolean): void;
  49228. /** @hidden */
  49229. _attachCameras(cameras: Camera[], unique: boolean): void;
  49230. /** @hidden */
  49231. _detachCameras(cameras: Camera): void;
  49232. /** @hidden */
  49233. _detachCameras(cameras: Nullable<Camera[]>): void;
  49234. /** @hidden */
  49235. _update(): void;
  49236. /** @hidden */
  49237. _reset(): void;
  49238. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  49239. /**
  49240. * Disposes of the pipeline
  49241. */
  49242. dispose(): void;
  49243. }
  49244. }
  49245. declare module BABYLON {
  49246. /**
  49247. * PostProcessRenderPipelineManager class
  49248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49249. */
  49250. class PostProcessRenderPipelineManager {
  49251. private _renderPipelines;
  49252. /**
  49253. * Initializes a PostProcessRenderPipelineManager
  49254. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49255. */
  49256. constructor();
  49257. /**
  49258. * Adds a pipeline to the manager
  49259. * @param renderPipeline The pipeline to add
  49260. */
  49261. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  49262. /**
  49263. * Attaches a camera to the pipeline
  49264. * @param renderPipelineName The name of the pipeline to attach to
  49265. * @param cameras the camera to attach
  49266. * @param unique if the camera can be attached multiple times to the pipeline
  49267. */
  49268. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  49269. /**
  49270. * Detaches a camera from the pipeline
  49271. * @param renderPipelineName The name of the pipeline to detach from
  49272. * @param cameras the camera to detach
  49273. */
  49274. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  49275. /**
  49276. * Enables an effect by name on a pipeline
  49277. * @param renderPipelineName the name of the pipeline to enable the effect in
  49278. * @param renderEffectName the name of the effect to enable
  49279. * @param cameras the cameras that the effect should be enabled on
  49280. */
  49281. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49282. /**
  49283. * Disables an effect by name on a pipeline
  49284. * @param renderPipelineName the name of the pipeline to disable the effect in
  49285. * @param renderEffectName the name of the effect to disable
  49286. * @param cameras the cameras that the effect should be disabled on
  49287. */
  49288. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  49289. /**
  49290. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  49291. */
  49292. update(): void;
  49293. /** @hidden */
  49294. _rebuild(): void;
  49295. /**
  49296. * Disposes of the manager and pipelines
  49297. */
  49298. dispose(): void;
  49299. }
  49300. }
  49301. declare module BABYLON {
  49302. interface Scene {
  49303. /** @hidden (Backing field) */
  49304. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49305. /**
  49306. * Gets the postprocess render pipeline manager
  49307. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  49308. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49309. */
  49310. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  49311. }
  49312. /**
  49313. * Defines the Render Pipeline scene component responsible to rendering pipelines
  49314. */
  49315. class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  49316. /**
  49317. * The component name helpfull to identify the component in the list of scene components.
  49318. */
  49319. readonly name: string;
  49320. /**
  49321. * The scene the component belongs to.
  49322. */
  49323. scene: Scene;
  49324. /**
  49325. * Creates a new instance of the component for the given scene
  49326. * @param scene Defines the scene to register the component in
  49327. */
  49328. constructor(scene: Scene);
  49329. /**
  49330. * Registers the component in a given scene
  49331. */
  49332. register(): void;
  49333. /**
  49334. * Rebuilds the elements related to this component in case of
  49335. * context lost for instance.
  49336. */
  49337. rebuild(): void;
  49338. /**
  49339. * Disposes the component and the associated ressources
  49340. */
  49341. dispose(): void;
  49342. private _gatherRenderTargets;
  49343. }
  49344. }
  49345. declare module BABYLON {
  49346. /**
  49347. * Helper class dealing with the extraction of spherical polynomial dataArray
  49348. * from a cube map.
  49349. */
  49350. class CubeMapToSphericalPolynomialTools {
  49351. private static FileFaces;
  49352. /**
  49353. * Converts a texture to the according Spherical Polynomial data.
  49354. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49355. *
  49356. * @param texture The texture to extract the information from.
  49357. * @return The Spherical Polynomial data.
  49358. */
  49359. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49360. /**
  49361. * Converts a cubemap to the according Spherical Polynomial data.
  49362. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49363. *
  49364. * @param cubeInfo The Cube map to extract the information from.
  49365. * @return The Spherical Polynomial data.
  49366. */
  49367. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49368. }
  49369. }
  49370. declare module BABYLON {
  49371. /**
  49372. * Header information of HDR texture files.
  49373. */
  49374. interface HDRInfo {
  49375. /**
  49376. * The height of the texture in pixels.
  49377. */
  49378. height: number;
  49379. /**
  49380. * The width of the texture in pixels.
  49381. */
  49382. width: number;
  49383. /**
  49384. * The index of the beginning of the data in the binary file.
  49385. */
  49386. dataPosition: number;
  49387. }
  49388. /**
  49389. * This groups tools to convert HDR texture to native colors array.
  49390. */
  49391. class HDRTools {
  49392. private static Ldexp;
  49393. private static Rgbe2float;
  49394. private static readStringLine;
  49395. /**
  49396. * Reads header information from an RGBE texture stored in a native array.
  49397. * More information on this format are available here:
  49398. * https://en.wikipedia.org/wiki/RGBE_image_format
  49399. *
  49400. * @param uint8array The binary file stored in native array.
  49401. * @return The header information.
  49402. */
  49403. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49404. /**
  49405. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49406. * This RGBE texture needs to store the information as a panorama.
  49407. *
  49408. * More information on this format are available here:
  49409. * https://en.wikipedia.org/wiki/RGBE_image_format
  49410. *
  49411. * @param buffer The binary file stored in an array buffer.
  49412. * @param size The expected size of the extracted cubemap.
  49413. * @return The Cube Map information.
  49414. */
  49415. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49416. /**
  49417. * Returns the pixels data extracted from an RGBE texture.
  49418. * This pixels will be stored left to right up to down in the R G B order in one array.
  49419. *
  49420. * More information on this format are available here:
  49421. * https://en.wikipedia.org/wiki/RGBE_image_format
  49422. *
  49423. * @param uint8array The binary file stored in an array buffer.
  49424. * @param hdrInfo The header information of the file.
  49425. * @return The pixels data in RGB right to left up to down order.
  49426. */
  49427. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49428. private static RGBE_ReadPixels_RLE;
  49429. }
  49430. }
  49431. declare module BABYLON {
  49432. /**
  49433. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49434. */
  49435. interface CubeMapInfo {
  49436. /**
  49437. * The pixel array for the front face.
  49438. * This is stored in format, left to right, up to down format.
  49439. */
  49440. front: Nullable<ArrayBufferView>;
  49441. /**
  49442. * The pixel array for the back face.
  49443. * This is stored in format, left to right, up to down format.
  49444. */
  49445. back: Nullable<ArrayBufferView>;
  49446. /**
  49447. * The pixel array for the left face.
  49448. * This is stored in format, left to right, up to down format.
  49449. */
  49450. left: Nullable<ArrayBufferView>;
  49451. /**
  49452. * The pixel array for the right face.
  49453. * This is stored in format, left to right, up to down format.
  49454. */
  49455. right: Nullable<ArrayBufferView>;
  49456. /**
  49457. * The pixel array for the up face.
  49458. * This is stored in format, left to right, up to down format.
  49459. */
  49460. up: Nullable<ArrayBufferView>;
  49461. /**
  49462. * The pixel array for the down face.
  49463. * This is stored in format, left to right, up to down format.
  49464. */
  49465. down: Nullable<ArrayBufferView>;
  49466. /**
  49467. * The size of the cubemap stored.
  49468. *
  49469. * Each faces will be size * size pixels.
  49470. */
  49471. size: number;
  49472. /**
  49473. * The format of the texture.
  49474. *
  49475. * RGBA, RGB.
  49476. */
  49477. format: number;
  49478. /**
  49479. * The type of the texture data.
  49480. *
  49481. * UNSIGNED_INT, FLOAT.
  49482. */
  49483. type: number;
  49484. /**
  49485. * Specifies whether the texture is in gamma space.
  49486. */
  49487. gammaSpace: boolean;
  49488. }
  49489. /**
  49490. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  49491. */
  49492. class PanoramaToCubeMapTools {
  49493. private static FACE_FRONT;
  49494. private static FACE_BACK;
  49495. private static FACE_RIGHT;
  49496. private static FACE_LEFT;
  49497. private static FACE_DOWN;
  49498. private static FACE_UP;
  49499. /**
  49500. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49501. *
  49502. * @param float32Array The source data.
  49503. * @param inputWidth The width of the input panorama.
  49504. * @param inputHeight The height of the input panorama.
  49505. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49506. * @return The cubemap data
  49507. */
  49508. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49509. private static CreateCubemapTexture;
  49510. private static CalcProjectionSpherical;
  49511. }
  49512. }
  49513. declare module BABYLON {
  49514. }
  49515. declare module BABYLON {
  49516. }
  49517. declare module BABYLON {
  49518. }
  49519. declare module BABYLON {
  49520. }
  49521. declare module BABYLON {
  49522. /**
  49523. * 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.
  49524. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49525. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49526. */
  49527. class CustomProceduralTexture extends ProceduralTexture {
  49528. private _animate;
  49529. private _time;
  49530. private _config;
  49531. private _texturePath;
  49532. /**
  49533. * Instantiates a new Custom Procedural Texture.
  49534. * 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.
  49535. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  49536. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  49537. * @param name Define the name of the texture
  49538. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  49539. * @param size Define the size of the texture to create
  49540. * @param scene Define the scene the texture belongs to
  49541. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49542. * @param generateMipMaps Define if the texture should creates mip maps or not
  49543. */
  49544. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49545. private _loadJson;
  49546. /**
  49547. * Is the texture ready to be used ? (rendered at least once)
  49548. * @returns true if ready, otherwise, false.
  49549. */
  49550. isReady(): boolean;
  49551. /**
  49552. * Render the texture to its associated render target.
  49553. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49554. */
  49555. render(useCameraPostProcess?: boolean): void;
  49556. /**
  49557. * Update the list of dependant textures samplers in the shader.
  49558. */
  49559. updateTextures(): void;
  49560. /**
  49561. * Update the uniform values of the procedural texture in the shader.
  49562. */
  49563. updateShaderUniforms(): void;
  49564. /**
  49565. * Define if the texture animates or not.
  49566. */
  49567. animate: boolean;
  49568. }
  49569. }
  49570. declare module BABYLON {
  49571. /**
  49572. * Class used to generate noise procedural textures
  49573. */
  49574. class NoiseProceduralTexture extends ProceduralTexture {
  49575. private _time;
  49576. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  49577. brightness: number;
  49578. /** Defines the number of octaves to process */
  49579. octaves: number;
  49580. /** Defines the level of persistence (0.8 by default) */
  49581. persistence: number;
  49582. /** Gets or sets animation speed factor (default is 1) */
  49583. animationSpeedFactor: number;
  49584. /**
  49585. * Creates a new NoiseProceduralTexture
  49586. * @param name defines the name fo the texture
  49587. * @param size defines the size of the texture (default is 256)
  49588. * @param scene defines the hosting scene
  49589. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  49590. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  49591. */
  49592. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  49593. private _updateShaderUniforms;
  49594. protected _getDefines(): string;
  49595. /** Generate the current state of the procedural texture */
  49596. render(useCameraPostProcess?: boolean): void;
  49597. /**
  49598. * Serializes this noise procedural texture
  49599. * @returns a serialized noise procedural texture object
  49600. */
  49601. serialize(): any;
  49602. /**
  49603. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49604. * @param parsedTexture defines parsed texture data
  49605. * @param scene defines the current scene
  49606. * @param rootUrl defines the root URL containing noise procedural texture information
  49607. * @returns a parsed NoiseProceduralTexture
  49608. */
  49609. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): NoiseProceduralTexture;
  49610. }
  49611. }
  49612. declare module BABYLON {
  49613. /**
  49614. * 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.
  49615. * This is the base class of any Procedural texture and contains most of the shareable code.
  49616. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49617. */
  49618. class ProceduralTexture extends Texture {
  49619. isCube: boolean;
  49620. /**
  49621. * Define if the texture is enabled or not (disabled texture will not render)
  49622. */
  49623. isEnabled: boolean;
  49624. /**
  49625. * Define if the texture must be cleared before rendering (default is true)
  49626. */
  49627. autoClear: boolean;
  49628. /**
  49629. * Callback called when the texture is generated
  49630. */
  49631. onGenerated: () => void;
  49632. /**
  49633. * Event raised when the texture is generated
  49634. */
  49635. onGeneratedObservable: Observable<ProceduralTexture>;
  49636. /** @hidden */
  49637. _generateMipMaps: boolean;
  49638. /** @hidden **/
  49639. _effect: Effect;
  49640. /** @hidden */
  49641. _textures: {
  49642. [key: string]: Texture;
  49643. };
  49644. private _size;
  49645. private _currentRefreshId;
  49646. private _refreshRate;
  49647. private _vertexBuffers;
  49648. private _indexBuffer;
  49649. private _uniforms;
  49650. private _samplers;
  49651. private _fragment;
  49652. private _floats;
  49653. private _ints;
  49654. private _floatsArrays;
  49655. private _colors3;
  49656. private _colors4;
  49657. private _vectors2;
  49658. private _vectors3;
  49659. private _matrices;
  49660. private _fallbackTexture;
  49661. private _fallbackTextureUsed;
  49662. private _engine;
  49663. private _cachedDefines;
  49664. private _contentUpdateId;
  49665. private _contentData;
  49666. /**
  49667. * Instantiates a new procedural texture.
  49668. * 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.
  49669. * This is the base class of any Procedural texture and contains most of the shareable code.
  49670. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49671. * @param name Define the name of the texture
  49672. * @param size Define the size of the texture to create
  49673. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  49674. * @param scene Define the scene the texture belongs to
  49675. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  49676. * @param generateMipMaps Define if the texture should creates mip maps or not
  49677. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  49678. */
  49679. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  49680. /**
  49681. * The effect that is created when initializing the post process.
  49682. * @returns The created effect corrisponding the the postprocess.
  49683. */
  49684. getEffect(): Effect;
  49685. /**
  49686. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  49687. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  49688. */
  49689. getContent(): Nullable<ArrayBufferView>;
  49690. private _createIndexBuffer;
  49691. /** @hidden */
  49692. _rebuild(): void;
  49693. /**
  49694. * Resets the texture in order to recreate its associated resources.
  49695. * This can be called in case of context loss
  49696. */
  49697. reset(): void;
  49698. protected _getDefines(): string;
  49699. /**
  49700. * Is the texture ready to be used ? (rendered at least once)
  49701. * @returns true if ready, otherwise, false.
  49702. */
  49703. isReady(): boolean;
  49704. /**
  49705. * Resets the refresh counter of the texture and start bak from scratch.
  49706. * Could be usefull to regenerate the texture if it is setup to render only once.
  49707. */
  49708. resetRefreshCounter(): void;
  49709. /**
  49710. * Set the fragment shader to use in order to render the texture.
  49711. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  49712. */
  49713. setFragment(fragment: any): void;
  49714. /**
  49715. * Define the refresh rate of the texture or the rendering frequency.
  49716. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  49717. */
  49718. refreshRate: number;
  49719. /** @hidden */
  49720. _shouldRender(): boolean;
  49721. /**
  49722. * Get the size the texture is rendering at.
  49723. * @returns the size (texture is always squared)
  49724. */
  49725. getRenderSize(): number;
  49726. /**
  49727. * Resize the texture to new value.
  49728. * @param size Define the new size the texture should have
  49729. * @param generateMipMaps Define whether the new texture should create mip maps
  49730. */
  49731. resize(size: number, generateMipMaps: boolean): void;
  49732. private _checkUniform;
  49733. /**
  49734. * Set a texture in the shader program used to render.
  49735. * @param name Define the name of the uniform samplers as defined in the shader
  49736. * @param texture Define the texture to bind to this sampler
  49737. * @return the texture itself allowing "fluent" like uniform updates
  49738. */
  49739. setTexture(name: string, texture: Texture): ProceduralTexture;
  49740. /**
  49741. * Set a float in the shader.
  49742. * @param name Define the name of the uniform as defined in the shader
  49743. * @param value Define the value to give to the uniform
  49744. * @return the texture itself allowing "fluent" like uniform updates
  49745. */
  49746. setFloat(name: string, value: number): ProceduralTexture;
  49747. /**
  49748. * Set a int in the shader.
  49749. * @param name Define the name of the uniform as defined in the shader
  49750. * @param value Define the value to give to the uniform
  49751. * @return the texture itself allowing "fluent" like uniform updates
  49752. */
  49753. setInt(name: string, value: number): ProceduralTexture;
  49754. /**
  49755. * Set an array of floats in the shader.
  49756. * @param name Define the name of the uniform as defined in the shader
  49757. * @param value Define the value to give to the uniform
  49758. * @return the texture itself allowing "fluent" like uniform updates
  49759. */
  49760. setFloats(name: string, value: number[]): ProceduralTexture;
  49761. /**
  49762. * Set a vec3 in the shader from a Color3.
  49763. * @param name Define the name of the uniform as defined in the shader
  49764. * @param value Define the value to give to the uniform
  49765. * @return the texture itself allowing "fluent" like uniform updates
  49766. */
  49767. setColor3(name: string, value: Color3): ProceduralTexture;
  49768. /**
  49769. * Set a vec4 in the shader from a Color4.
  49770. * @param name Define the name of the uniform as defined in the shader
  49771. * @param value Define the value to give to the uniform
  49772. * @return the texture itself allowing "fluent" like uniform updates
  49773. */
  49774. setColor4(name: string, value: Color4): ProceduralTexture;
  49775. /**
  49776. * Set a vec2 in the shader from a Vector2.
  49777. * @param name Define the name of the uniform as defined in the shader
  49778. * @param value Define the value to give to the uniform
  49779. * @return the texture itself allowing "fluent" like uniform updates
  49780. */
  49781. setVector2(name: string, value: Vector2): ProceduralTexture;
  49782. /**
  49783. * Set a vec3 in the shader from a Vector3.
  49784. * @param name Define the name of the uniform as defined in the shader
  49785. * @param value Define the value to give to the uniform
  49786. * @return the texture itself allowing "fluent" like uniform updates
  49787. */
  49788. setVector3(name: string, value: Vector3): ProceduralTexture;
  49789. /**
  49790. * Set a mat4 in the shader from a MAtrix.
  49791. * @param name Define the name of the uniform as defined in the shader
  49792. * @param value Define the value to give to the uniform
  49793. * @return the texture itself allowing "fluent" like uniform updates
  49794. */
  49795. setMatrix(name: string, value: Matrix): ProceduralTexture;
  49796. /**
  49797. * Render the texture to its associated render target.
  49798. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  49799. */
  49800. render(useCameraPostProcess?: boolean): void;
  49801. /**
  49802. * Clone the texture.
  49803. * @returns the cloned texture
  49804. */
  49805. clone(): ProceduralTexture;
  49806. /**
  49807. * Dispose the texture and release its asoociated resources.
  49808. */
  49809. dispose(): void;
  49810. }
  49811. }
  49812. declare module BABYLON {
  49813. interface AbstractScene {
  49814. /**
  49815. * The list of procedural textures added to the scene
  49816. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  49817. */
  49818. proceduralTextures: Array<ProceduralTexture>;
  49819. }
  49820. /**
  49821. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  49822. * in a given scene.
  49823. */
  49824. class ProceduralTextureSceneComponent implements ISceneComponent {
  49825. /**
  49826. * The component name helpfull to identify the component in the list of scene components.
  49827. */
  49828. readonly name: string;
  49829. /**
  49830. * The scene the component belongs to.
  49831. */
  49832. scene: Scene;
  49833. /**
  49834. * Creates a new instance of the component for the given scene
  49835. * @param scene Defines the scene to register the component in
  49836. */
  49837. constructor(scene: Scene);
  49838. /**
  49839. * Registers the component in a given scene
  49840. */
  49841. register(): void;
  49842. /**
  49843. * Rebuilds the elements related to this component in case of
  49844. * context lost for instance.
  49845. */
  49846. rebuild(): void;
  49847. /**
  49848. * Disposes the component and the associated ressources.
  49849. */
  49850. dispose(): void;
  49851. private _beforeClear;
  49852. }
  49853. }
  49854. declare module BABYLON {
  49855. /**
  49856. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  49857. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  49858. */
  49859. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  49860. private _scene;
  49861. private _camerasToBeAttached;
  49862. /**
  49863. * ID of the sharpen post process,
  49864. */
  49865. private readonly SharpenPostProcessId;
  49866. /**
  49867. * @ignore
  49868. * ID of the image processing post process;
  49869. */
  49870. readonly ImageProcessingPostProcessId: string;
  49871. /**
  49872. * @ignore
  49873. * ID of the Fast Approximate Anti-Aliasing post process;
  49874. */
  49875. readonly FxaaPostProcessId: string;
  49876. /**
  49877. * ID of the chromatic aberration post process,
  49878. */
  49879. private readonly ChromaticAberrationPostProcessId;
  49880. /**
  49881. * ID of the grain post process
  49882. */
  49883. private readonly GrainPostProcessId;
  49884. /**
  49885. * Sharpen post process which will apply a sharpen convolution to enhance edges
  49886. */
  49887. sharpen: SharpenPostProcess;
  49888. private _sharpenEffect;
  49889. private bloom;
  49890. /**
  49891. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  49892. */
  49893. depthOfField: DepthOfFieldEffect;
  49894. /**
  49895. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  49896. */
  49897. fxaa: FxaaPostProcess;
  49898. /**
  49899. * Image post processing pass used to perform operations such as tone mapping or color grading.
  49900. */
  49901. imageProcessing: ImageProcessingPostProcess;
  49902. /**
  49903. * Chromatic aberration post process which will shift rgb colors in the image
  49904. */
  49905. chromaticAberration: ChromaticAberrationPostProcess;
  49906. private _chromaticAberrationEffect;
  49907. /**
  49908. * Grain post process which add noise to the image
  49909. */
  49910. grain: GrainPostProcess;
  49911. private _grainEffect;
  49912. /**
  49913. * Glow post process which adds a glow to emmisive areas of the image
  49914. */
  49915. private _glowLayer;
  49916. /**
  49917. * Animations which can be used to tweak settings over a period of time
  49918. */
  49919. animations: Animation[];
  49920. private _imageProcessingConfigurationObserver;
  49921. private _sharpenEnabled;
  49922. private _bloomEnabled;
  49923. private _depthOfFieldEnabled;
  49924. private _depthOfFieldBlurLevel;
  49925. private _fxaaEnabled;
  49926. private _imageProcessingEnabled;
  49927. private _defaultPipelineTextureType;
  49928. private _bloomScale;
  49929. private _chromaticAberrationEnabled;
  49930. private _grainEnabled;
  49931. private _buildAllowed;
  49932. /**
  49933. * Enable or disable the sharpen process from the pipeline
  49934. */
  49935. sharpenEnabled: boolean;
  49936. private _resizeObserver;
  49937. private _hardwareScaleLevel;
  49938. private _bloomKernel;
  49939. /**
  49940. * Specifies the size of the bloom blur kernel, relative to the final output size
  49941. */
  49942. bloomKernel: number;
  49943. /**
  49944. * Specifies the weight of the bloom in the final rendering
  49945. */
  49946. private _bloomWeight;
  49947. /**
  49948. * Specifies the luma threshold for the area that will be blurred by the bloom
  49949. */
  49950. private _bloomThreshold;
  49951. private _hdr;
  49952. /**
  49953. * The strength of the bloom.
  49954. */
  49955. bloomWeight: number;
  49956. /**
  49957. * The strength of the bloom.
  49958. */
  49959. bloomThreshold: number;
  49960. /**
  49961. * The scale of the bloom, lower value will provide better performance.
  49962. */
  49963. bloomScale: number;
  49964. /**
  49965. * Enable or disable the bloom from the pipeline
  49966. */
  49967. bloomEnabled: boolean;
  49968. private _rebuildBloom;
  49969. /**
  49970. * If the depth of field is enabled.
  49971. */
  49972. depthOfFieldEnabled: boolean;
  49973. /**
  49974. * Blur level of the depth of field effect. (Higher blur will effect performance)
  49975. */
  49976. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  49977. /**
  49978. * If the anti aliasing is enabled.
  49979. */
  49980. fxaaEnabled: boolean;
  49981. private _samples;
  49982. /**
  49983. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  49984. */
  49985. samples: number;
  49986. /**
  49987. * If image processing is enabled.
  49988. */
  49989. imageProcessingEnabled: boolean;
  49990. /**
  49991. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  49992. */
  49993. glowLayerEnabled: boolean;
  49994. /**
  49995. * Enable or disable the chromaticAberration process from the pipeline
  49996. */
  49997. chromaticAberrationEnabled: boolean;
  49998. /**
  49999. * Enable or disable the grain process from the pipeline
  50000. */
  50001. grainEnabled: boolean;
  50002. /**
  50003. * @constructor
  50004. * @param name - The rendering pipeline name (default: "")
  50005. * @param hdr - If high dynamic range textures should be used (default: true)
  50006. * @param scene - The scene linked to this pipeline (default: the last created scene)
  50007. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  50008. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  50009. */
  50010. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  50011. /**
  50012. * Force the compilation of the entire pipeline.
  50013. */
  50014. prepare(): void;
  50015. private _hasCleared;
  50016. private _prevPostProcess;
  50017. private _prevPrevPostProcess;
  50018. private _setAutoClearAndTextureSharing;
  50019. private _depthOfFieldSceneObserver;
  50020. private _buildPipeline;
  50021. private _disposePostProcesses;
  50022. /**
  50023. * Adds a camera to the pipeline
  50024. * @param camera the camera to be added
  50025. */
  50026. addCamera(camera: Camera): void;
  50027. /**
  50028. * Removes a camera from the pipeline
  50029. * @param camera the camera to remove
  50030. */
  50031. removeCamera(camera: Camera): void;
  50032. /**
  50033. * Dispose of the pipeline and stop all post processes
  50034. */
  50035. dispose(): void;
  50036. /**
  50037. * Serialize the rendering pipeline (Used when exporting)
  50038. * @returns the serialized object
  50039. */
  50040. serialize(): any;
  50041. /**
  50042. * Parse the serialized pipeline
  50043. * @param source Source pipeline.
  50044. * @param scene The scene to load the pipeline to.
  50045. * @param rootUrl The URL of the serialized pipeline.
  50046. * @returns An instantiated pipeline from the serialized object.
  50047. */
  50048. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  50049. }
  50050. }
  50051. declare module BABYLON {
  50052. /**
  50053. * BABYLON.JS Chromatic Aberration GLSL Shader
  50054. * Author: Olivier Guyot
  50055. * Separates very slightly R, G and B colors on the edges of the screen
  50056. * Inspired by Francois Tarlier & Martins Upitis
  50057. */
  50058. class LensRenderingPipeline extends PostProcessRenderPipeline {
  50059. /**
  50060. * @ignore
  50061. * The chromatic aberration PostProcess id in the pipeline
  50062. */
  50063. LensChromaticAberrationEffect: string;
  50064. /**
  50065. * @ignore
  50066. * The highlights enhancing PostProcess id in the pipeline
  50067. */
  50068. HighlightsEnhancingEffect: string;
  50069. /**
  50070. * @ignore
  50071. * The depth-of-field PostProcess id in the pipeline
  50072. */
  50073. LensDepthOfFieldEffect: string;
  50074. private _scene;
  50075. private _depthTexture;
  50076. private _grainTexture;
  50077. private _chromaticAberrationPostProcess;
  50078. private _highlightsPostProcess;
  50079. private _depthOfFieldPostProcess;
  50080. private _edgeBlur;
  50081. private _grainAmount;
  50082. private _chromaticAberration;
  50083. private _distortion;
  50084. private _highlightsGain;
  50085. private _highlightsThreshold;
  50086. private _dofDistance;
  50087. private _dofAperture;
  50088. private _dofDarken;
  50089. private _dofPentagon;
  50090. private _blurNoise;
  50091. /**
  50092. * @constructor
  50093. *
  50094. * Effect parameters are as follow:
  50095. * {
  50096. * chromatic_aberration: number; // from 0 to x (1 for realism)
  50097. * edge_blur: number; // from 0 to x (1 for realism)
  50098. * distortion: number; // from 0 to x (1 for realism)
  50099. * grain_amount: number; // from 0 to 1
  50100. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  50101. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  50102. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  50103. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  50104. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  50105. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  50106. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  50107. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  50108. * }
  50109. * Note: if an effect parameter is unset, effect is disabled
  50110. *
  50111. * @param name The rendering pipeline name
  50112. * @param parameters - An object containing all parameters (see above)
  50113. * @param scene The scene linked to this pipeline
  50114. * @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)
  50115. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50116. */
  50117. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  50118. /**
  50119. * Sets the amount of blur at the edges
  50120. * @param amount blur amount
  50121. */
  50122. setEdgeBlur(amount: number): void;
  50123. /**
  50124. * Sets edge blur to 0
  50125. */
  50126. disableEdgeBlur(): void;
  50127. /**
  50128. * Sets the amout of grain
  50129. * @param amount Amount of grain
  50130. */
  50131. setGrainAmount(amount: number): void;
  50132. /**
  50133. * Set grain amount to 0
  50134. */
  50135. disableGrain(): void;
  50136. /**
  50137. * Sets the chromatic aberration amount
  50138. * @param amount amount of chromatic aberration
  50139. */
  50140. setChromaticAberration(amount: number): void;
  50141. /**
  50142. * Sets chromatic aberration amount to 0
  50143. */
  50144. disableChromaticAberration(): void;
  50145. /**
  50146. * Sets the EdgeDistortion amount
  50147. * @param amount amount of EdgeDistortion
  50148. */
  50149. setEdgeDistortion(amount: number): void;
  50150. /**
  50151. * Sets edge distortion to 0
  50152. */
  50153. disableEdgeDistortion(): void;
  50154. /**
  50155. * Sets the FocusDistance amount
  50156. * @param amount amount of FocusDistance
  50157. */
  50158. setFocusDistance(amount: number): void;
  50159. /**
  50160. * Disables depth of field
  50161. */
  50162. disableDepthOfField(): void;
  50163. /**
  50164. * Sets the Aperture amount
  50165. * @param amount amount of Aperture
  50166. */
  50167. setAperture(amount: number): void;
  50168. /**
  50169. * Sets the DarkenOutOfFocus amount
  50170. * @param amount amount of DarkenOutOfFocus
  50171. */
  50172. setDarkenOutOfFocus(amount: number): void;
  50173. /**
  50174. * Creates a pentagon bokeh effect
  50175. */
  50176. enablePentagonBokeh(): void;
  50177. /**
  50178. * Disables the pentagon bokeh effect
  50179. */
  50180. disablePentagonBokeh(): void;
  50181. /**
  50182. * Enables noise blur
  50183. */
  50184. enableNoiseBlur(): void;
  50185. /**
  50186. * Disables noise blur
  50187. */
  50188. disableNoiseBlur(): void;
  50189. /**
  50190. * Sets the HighlightsGain amount
  50191. * @param amount amount of HighlightsGain
  50192. */
  50193. setHighlightsGain(amount: number): void;
  50194. /**
  50195. * Sets the HighlightsThreshold amount
  50196. * @param amount amount of HighlightsThreshold
  50197. */
  50198. setHighlightsThreshold(amount: number): void;
  50199. /**
  50200. * Disables highlights
  50201. */
  50202. disableHighlights(): void;
  50203. /**
  50204. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  50205. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  50206. */
  50207. dispose(disableDepthRender?: boolean): void;
  50208. private _createChromaticAberrationPostProcess;
  50209. private _createHighlightsPostProcess;
  50210. private _createDepthOfFieldPostProcess;
  50211. private _createGrainTexture;
  50212. }
  50213. }
  50214. declare module BABYLON {
  50215. /**
  50216. * Render pipeline to produce ssao effect
  50217. */
  50218. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  50219. /**
  50220. * @ignore
  50221. * The PassPostProcess id in the pipeline that contains the original scene color
  50222. */
  50223. SSAOOriginalSceneColorEffect: string;
  50224. /**
  50225. * @ignore
  50226. * The SSAO PostProcess id in the pipeline
  50227. */
  50228. SSAORenderEffect: string;
  50229. /**
  50230. * @ignore
  50231. * The horizontal blur PostProcess id in the pipeline
  50232. */
  50233. SSAOBlurHRenderEffect: string;
  50234. /**
  50235. * @ignore
  50236. * The vertical blur PostProcess id in the pipeline
  50237. */
  50238. SSAOBlurVRenderEffect: string;
  50239. /**
  50240. * @ignore
  50241. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50242. */
  50243. SSAOCombineRenderEffect: string;
  50244. /**
  50245. * The output strength of the SSAO post-process. Default value is 1.0.
  50246. */
  50247. totalStrength: number;
  50248. /**
  50249. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  50250. */
  50251. maxZ: number;
  50252. /**
  50253. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  50254. */
  50255. minZAspect: number;
  50256. private _samples;
  50257. /**
  50258. * Number of samples used for the SSAO calculations. Default value is 8
  50259. */
  50260. samples: number;
  50261. private _textureSamples;
  50262. /**
  50263. * Number of samples to use for antialiasing
  50264. */
  50265. textureSamples: number;
  50266. /**
  50267. * Ratio object used for SSAO ratio and blur ratio
  50268. */
  50269. private _ratio;
  50270. /**
  50271. * Dynamically generated sphere sampler.
  50272. */
  50273. private _sampleSphere;
  50274. /**
  50275. * Blur filter offsets
  50276. */
  50277. private _samplerOffsets;
  50278. private _expensiveBlur;
  50279. /**
  50280. * If bilateral blur should be used
  50281. */
  50282. expensiveBlur: boolean;
  50283. /**
  50284. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  50285. */
  50286. radius: number;
  50287. /**
  50288. * The base color of the SSAO post-process
  50289. * The final result is "base + ssao" between [0, 1]
  50290. */
  50291. base: number;
  50292. /**
  50293. * Support test.
  50294. */
  50295. static readonly IsSupported: boolean;
  50296. private _scene;
  50297. private _depthTexture;
  50298. private _normalTexture;
  50299. private _randomTexture;
  50300. private _originalColorPostProcess;
  50301. private _ssaoPostProcess;
  50302. private _blurHPostProcess;
  50303. private _blurVPostProcess;
  50304. private _ssaoCombinePostProcess;
  50305. private _firstUpdate;
  50306. /**
  50307. * @constructor
  50308. * @param name The rendering pipeline name
  50309. * @param scene The scene linked to this pipeline
  50310. * @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 }
  50311. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50312. */
  50313. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50314. /**
  50315. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50316. */
  50317. dispose(disableGeometryBufferRenderer?: boolean): void;
  50318. private _createBlurPostProcess;
  50319. /** @hidden */
  50320. _rebuild(): void;
  50321. private _bits;
  50322. private _radicalInverse_VdC;
  50323. private _hammersley;
  50324. private _hemisphereSample_uniform;
  50325. private _generateHemisphere;
  50326. private _createSSAOPostProcess;
  50327. private _createSSAOCombinePostProcess;
  50328. private _createRandomTexture;
  50329. /**
  50330. * Serialize the rendering pipeline (Used when exporting)
  50331. * @returns the serialized object
  50332. */
  50333. serialize(): any;
  50334. /**
  50335. * Parse the serialized pipeline
  50336. * @param source Source pipeline.
  50337. * @param scene The scene to load the pipeline to.
  50338. * @param rootUrl The URL of the serialized pipeline.
  50339. * @returns An instantiated pipeline from the serialized object.
  50340. */
  50341. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  50342. }
  50343. }
  50344. declare module BABYLON {
  50345. /**
  50346. * Render pipeline to produce ssao effect
  50347. */
  50348. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  50349. /**
  50350. * @ignore
  50351. * The PassPostProcess id in the pipeline that contains the original scene color
  50352. */
  50353. SSAOOriginalSceneColorEffect: string;
  50354. /**
  50355. * @ignore
  50356. * The SSAO PostProcess id in the pipeline
  50357. */
  50358. SSAORenderEffect: string;
  50359. /**
  50360. * @ignore
  50361. * The horizontal blur PostProcess id in the pipeline
  50362. */
  50363. SSAOBlurHRenderEffect: string;
  50364. /**
  50365. * @ignore
  50366. * The vertical blur PostProcess id in the pipeline
  50367. */
  50368. SSAOBlurVRenderEffect: string;
  50369. /**
  50370. * @ignore
  50371. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  50372. */
  50373. SSAOCombineRenderEffect: string;
  50374. /**
  50375. * The output strength of the SSAO post-process. Default value is 1.0.
  50376. */
  50377. totalStrength: number;
  50378. /**
  50379. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  50380. */
  50381. radius: number;
  50382. /**
  50383. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  50384. * Must not be equal to fallOff and superior to fallOff.
  50385. * Default value is 0.975
  50386. */
  50387. area: number;
  50388. /**
  50389. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  50390. * Must not be equal to area and inferior to area.
  50391. * Default value is 0.0
  50392. */
  50393. fallOff: number;
  50394. /**
  50395. * The base color of the SSAO post-process
  50396. * The final result is "base + ssao" between [0, 1]
  50397. */
  50398. base: number;
  50399. private _scene;
  50400. private _depthTexture;
  50401. private _randomTexture;
  50402. private _originalColorPostProcess;
  50403. private _ssaoPostProcess;
  50404. private _blurHPostProcess;
  50405. private _blurVPostProcess;
  50406. private _ssaoCombinePostProcess;
  50407. private _firstUpdate;
  50408. /**
  50409. * @constructor
  50410. * @param name - The rendering pipeline name
  50411. * @param scene - The scene linked to this pipeline
  50412. * @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 }
  50413. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  50414. */
  50415. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  50416. /**
  50417. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  50418. */
  50419. dispose(disableDepthRender?: boolean): void;
  50420. private _createBlurPostProcess;
  50421. /** @hidden */
  50422. _rebuild(): void;
  50423. private _createSSAOPostProcess;
  50424. private _createSSAOCombinePostProcess;
  50425. private _createRandomTexture;
  50426. }
  50427. }
  50428. declare module BABYLON {
  50429. /**
  50430. * Standard rendering pipeline
  50431. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50432. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  50433. */
  50434. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  50435. /**
  50436. * Public members
  50437. */
  50438. /**
  50439. * Post-process which contains the original scene color before the pipeline applies all the effects
  50440. */
  50441. originalPostProcess: Nullable<PostProcess>;
  50442. /**
  50443. * Post-process used to down scale an image x4
  50444. */
  50445. downSampleX4PostProcess: Nullable<PostProcess>;
  50446. /**
  50447. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  50448. */
  50449. brightPassPostProcess: Nullable<PostProcess>;
  50450. /**
  50451. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  50452. */
  50453. blurHPostProcesses: PostProcess[];
  50454. /**
  50455. * Post-process array storing all the vertical blur post-processes used by the pipeline
  50456. */
  50457. blurVPostProcesses: PostProcess[];
  50458. /**
  50459. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  50460. */
  50461. textureAdderPostProcess: Nullable<PostProcess>;
  50462. /**
  50463. * Post-process used to create volumetric lighting effect
  50464. */
  50465. volumetricLightPostProcess: Nullable<PostProcess>;
  50466. /**
  50467. * Post-process used to smooth the previous volumetric light post-process on the X axis
  50468. */
  50469. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  50470. /**
  50471. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  50472. */
  50473. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  50474. /**
  50475. * Post-process used to merge the volumetric light effect and the real scene color
  50476. */
  50477. volumetricLightMergePostProces: Nullable<PostProcess>;
  50478. /**
  50479. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  50480. */
  50481. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  50482. /**
  50483. * Base post-process used to calculate the average luminance of the final image for HDR
  50484. */
  50485. luminancePostProcess: Nullable<PostProcess>;
  50486. /**
  50487. * Post-processes used to create down sample post-processes in order to get
  50488. * the average luminance of the final image for HDR
  50489. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  50490. */
  50491. luminanceDownSamplePostProcesses: PostProcess[];
  50492. /**
  50493. * Post-process used to create a HDR effect (light adaptation)
  50494. */
  50495. hdrPostProcess: Nullable<PostProcess>;
  50496. /**
  50497. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  50498. */
  50499. textureAdderFinalPostProcess: Nullable<PostProcess>;
  50500. /**
  50501. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  50502. */
  50503. lensFlareFinalPostProcess: Nullable<PostProcess>;
  50504. /**
  50505. * Post-process used to merge the final HDR post-process and the real scene color
  50506. */
  50507. hdrFinalPostProcess: Nullable<PostProcess>;
  50508. /**
  50509. * Post-process used to create a lens flare effect
  50510. */
  50511. lensFlarePostProcess: Nullable<PostProcess>;
  50512. /**
  50513. * Post-process that merges the result of the lens flare post-process and the real scene color
  50514. */
  50515. lensFlareComposePostProcess: Nullable<PostProcess>;
  50516. /**
  50517. * Post-process used to create a motion blur effect
  50518. */
  50519. motionBlurPostProcess: Nullable<PostProcess>;
  50520. /**
  50521. * Post-process used to create a depth of field effect
  50522. */
  50523. depthOfFieldPostProcess: Nullable<PostProcess>;
  50524. /**
  50525. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  50526. */
  50527. fxaaPostProcess: Nullable<FxaaPostProcess>;
  50528. /**
  50529. * Represents the brightness threshold in order to configure the illuminated surfaces
  50530. */
  50531. brightThreshold: number;
  50532. /**
  50533. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  50534. */
  50535. blurWidth: number;
  50536. /**
  50537. * Sets if the blur for highlighted surfaces must be only horizontal
  50538. */
  50539. horizontalBlur: boolean;
  50540. /**
  50541. * Sets the overall exposure used by the pipeline
  50542. */
  50543. exposure: number;
  50544. /**
  50545. * Texture used typically to simulate "dirty" on camera lens
  50546. */
  50547. lensTexture: Nullable<Texture>;
  50548. /**
  50549. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  50550. */
  50551. volumetricLightCoefficient: number;
  50552. /**
  50553. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  50554. */
  50555. volumetricLightPower: number;
  50556. /**
  50557. * Used the set the blur intensity to smooth the volumetric lights
  50558. */
  50559. volumetricLightBlurScale: number;
  50560. /**
  50561. * Light (spot or directional) used to generate the volumetric lights rays
  50562. * The source light must have a shadow generate so the pipeline can get its
  50563. * depth map
  50564. */
  50565. sourceLight: Nullable<SpotLight | DirectionalLight>;
  50566. /**
  50567. * For eye adaptation, represents the minimum luminance the eye can see
  50568. */
  50569. hdrMinimumLuminance: number;
  50570. /**
  50571. * For eye adaptation, represents the decrease luminance speed
  50572. */
  50573. hdrDecreaseRate: number;
  50574. /**
  50575. * For eye adaptation, represents the increase luminance speed
  50576. */
  50577. hdrIncreaseRate: number;
  50578. /**
  50579. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  50580. */
  50581. lensColorTexture: Nullable<Texture>;
  50582. /**
  50583. * The overall strengh for the lens flare effect
  50584. */
  50585. lensFlareStrength: number;
  50586. /**
  50587. * Dispersion coefficient for lens flare ghosts
  50588. */
  50589. lensFlareGhostDispersal: number;
  50590. /**
  50591. * Main lens flare halo width
  50592. */
  50593. lensFlareHaloWidth: number;
  50594. /**
  50595. * Based on the lens distortion effect, defines how much the lens flare result
  50596. * is distorted
  50597. */
  50598. lensFlareDistortionStrength: number;
  50599. /**
  50600. * Lens star texture must be used to simulate rays on the flares and is available
  50601. * in the documentation
  50602. */
  50603. lensStarTexture: Nullable<Texture>;
  50604. /**
  50605. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  50606. * flare effect by taking account of the dirt texture
  50607. */
  50608. lensFlareDirtTexture: Nullable<Texture>;
  50609. /**
  50610. * Represents the focal length for the depth of field effect
  50611. */
  50612. depthOfFieldDistance: number;
  50613. /**
  50614. * Represents the blur intensity for the blurred part of the depth of field effect
  50615. */
  50616. depthOfFieldBlurWidth: number;
  50617. /**
  50618. * For motion blur, defines how much the image is blurred by the movement
  50619. */
  50620. motionStrength: number;
  50621. /**
  50622. * List of animations for the pipeline (IAnimatable implementation)
  50623. */
  50624. animations: Animation[];
  50625. /**
  50626. * Private members
  50627. */
  50628. private _scene;
  50629. private _currentDepthOfFieldSource;
  50630. private _basePostProcess;
  50631. private _hdrCurrentLuminance;
  50632. private _floatTextureType;
  50633. private _ratio;
  50634. private _bloomEnabled;
  50635. private _depthOfFieldEnabled;
  50636. private _vlsEnabled;
  50637. private _lensFlareEnabled;
  50638. private _hdrEnabled;
  50639. private _motionBlurEnabled;
  50640. private _fxaaEnabled;
  50641. private _motionBlurSamples;
  50642. private _volumetricLightStepsCount;
  50643. private _samples;
  50644. /**
  50645. * @ignore
  50646. * Specifies if the bloom pipeline is enabled
  50647. */
  50648. BloomEnabled: boolean;
  50649. /**
  50650. * @ignore
  50651. * Specifies if the depth of field pipeline is enabed
  50652. */
  50653. DepthOfFieldEnabled: boolean;
  50654. /**
  50655. * @ignore
  50656. * Specifies if the lens flare pipeline is enabed
  50657. */
  50658. LensFlareEnabled: boolean;
  50659. /**
  50660. * @ignore
  50661. * Specifies if the HDR pipeline is enabled
  50662. */
  50663. HDREnabled: boolean;
  50664. /**
  50665. * @ignore
  50666. * Specifies if the volumetric lights scattering effect is enabled
  50667. */
  50668. VLSEnabled: boolean;
  50669. /**
  50670. * @ignore
  50671. * Specifies if the motion blur effect is enabled
  50672. */
  50673. MotionBlurEnabled: boolean;
  50674. /**
  50675. * Specifies if anti-aliasing is enabled
  50676. */
  50677. fxaaEnabled: boolean;
  50678. /**
  50679. * Specifies the number of steps used to calculate the volumetric lights
  50680. * Typically in interval [50, 200]
  50681. */
  50682. volumetricLightStepsCount: number;
  50683. /**
  50684. * Specifies the number of samples used for the motion blur effect
  50685. * Typically in interval [16, 64]
  50686. */
  50687. motionBlurSamples: number;
  50688. /**
  50689. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  50690. */
  50691. samples: number;
  50692. /**
  50693. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  50694. * @constructor
  50695. * @param name The rendering pipeline name
  50696. * @param scene The scene linked to this pipeline
  50697. * @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)
  50698. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  50699. * @param cameras The array of cameras that the rendering pipeline will be attached to
  50700. */
  50701. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  50702. private _buildPipeline;
  50703. private _createDownSampleX4PostProcess;
  50704. private _createBrightPassPostProcess;
  50705. private _createBlurPostProcesses;
  50706. private _createTextureAdderPostProcess;
  50707. private _createVolumetricLightPostProcess;
  50708. private _createLuminancePostProcesses;
  50709. private _createHdrPostProcess;
  50710. private _createLensFlarePostProcess;
  50711. private _createDepthOfFieldPostProcess;
  50712. private _createMotionBlurPostProcess;
  50713. private _getDepthTexture;
  50714. private _disposePostProcesses;
  50715. /**
  50716. * Dispose of the pipeline and stop all post processes
  50717. */
  50718. dispose(): void;
  50719. /**
  50720. * Serialize the rendering pipeline (Used when exporting)
  50721. * @returns the serialized object
  50722. */
  50723. serialize(): any;
  50724. /**
  50725. * Parse the serialized pipeline
  50726. * @param source Source pipeline.
  50727. * @param scene The scene to load the pipeline to.
  50728. * @param rootUrl The URL of the serialized pipeline.
  50729. * @returns An instantiated pipeline from the serialized object.
  50730. */
  50731. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  50732. /**
  50733. * Luminance steps
  50734. */
  50735. static LuminanceSteps: number;
  50736. }
  50737. }